Skip to content

Refactor management UI to list view and edit dialog pattern#180

Merged
mikkisguy merged 4 commits into
mainfrom
restructuring-character-management-and-handling-in-sidebars
May 31, 2026
Merged

Refactor management UI to list view and edit dialog pattern#180
mikkisguy merged 4 commits into
mainfrom
restructuring-character-management-and-handling-in-sidebars

Conversation

@mikkisguy

@mikkisguy mikkisguy commented May 30, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Read-only list views and dedicated create/edit dialogs for routes, variables, and stats (per-item edit/delete flows with confirmations)
    • New focused edit dialogs and list components for managing single items
  • Changes

    • Route and variable keys are now immutable — edit flows update metadata only (name, prefix, description, category, etc.)
    • Updated empty-state and helper messaging across editors and prose editor
  • Documentation

    • Added design spec for the list+edit dialogs refactor and UX patterns

@mikkisguy mikkisguy self-assigned this May 30, 2026
@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ad472229-c10c-4bf9-b1c7-18462663f428

📥 Commits

Reviewing files that changed from the base of the PR and between 0ac9f82 and 0a545cc.

📒 Files selected for processing (4)
  • apps/frontend/src/components/StatList.tsx
  • apps/frontend/src/components/StatProgression.tsx
  • apps/frontend/src/components/script-mode/StatManagementDialog.tsx
  • apps/frontend/src/components/script-mode/VariablesDialog.tsx
💤 Files with no reviewable changes (1)
  • apps/frontend/src/components/script-mode/VariablesDialog.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/frontend/src/components/StatList.tsx
  • apps/frontend/src/components/script-mode/StatManagementDialog.tsx

📝 Walkthrough

Walkthrough

This PR refactors routes, variables, and stats from inline management UIs into list views with dedicated edit dialogs, locks route/variable keys by removing them from update schemas and service inputs, updates frontend types/hooks, adds list/edit components, rewires parent dialogs, adjusts tests, and adds a design spec.

Changes

Routes, Variables, and Stats: List + Edit Dialog Refactor

Layer / File(s) Summary
Backend schema contracts: lock keys after creation
apps/backend/src/lib/validation.ts
updateRouteConfigSchema removes routeKey and adds routeName/jumpPrefix; updateVariableSchema removes key, making those fields immutable on update.
Backend service interfaces and implementations
apps/backend/src/services/route-configs.service.ts, apps/backend/src/services/variables.service.ts
UpdateRouteConfigBody and UpdateVariableBody types no longer accept key fields; update payload construction and assignment logic were restricted to allowed fields.
Backend test updates for immutable keys
apps/backend/src/services/__tests__/variables.service.integration.test.ts
Tests that previously updated or asserted uniqueness of variable key were removed or adapted; a new test verifies key updates are ignored.
Frontend types and hooks: align with backend
apps/frontend/src/hooks/useRouteConfigs.ts, apps/frontend/src/hooks/useVariables.ts, apps/frontend/src/lib/api/route-configs.ts, apps/frontend/src/lib/api/variables.ts
Hook and API input types were narrowed to remove routeKey/key from update payloads to match backend validation.
Route management: EditDialog and List components
apps/frontend/src/components/RouteEditDialog.tsx, apps/frontend/src/components/RouteList.tsx
New RouteEditDialog (create/edit form, key editable only on create) and RouteList (read-only rows with edit/delete and confirm) replace the monolithic settings content.
Variable management: EditDialog and List components
apps/frontend/src/components/VariableEditDialog.tsx, apps/frontend/src/components/VariablesList.tsx
New VariableEditDialog (create/edit modal, key locked in edit mode, updates send only description/category) and VariablesList (grouped by category, edit/delete with confirm).
Stat management: EditDialog and List components
apps/frontend/src/components/StatEditDialog.tsx, apps/frontend/src/components/StatList.tsx, apps/frontend/src/components/StatProgression.tsx
New StatEditDialog and StatList provide stat create/edit flows and a selectable list with inline edit/delete and confirmation; StatProgression empty-state rendering updated.
Parent dialog refactoring
apps/frontend/src/components/ide-shared/RouteSettingsDialog.tsx, apps/frontend/src/components/script-mode/StatManagementDialog.tsx, apps/frontend/src/components/script-mode/VariablesDialog.tsx
Parent dialogs were refactored to own loading/error/empty state rendering, manage edit-mode sentinel state, and mount the new list and edit dialog components as controlled children.
Minor UI adjustments and design documentation
apps/frontend/src/components/CharacterDialog.tsx, apps/frontend/src/components/write-mode/ProseEditor.tsx, docs/superpowers/specs/2026-05-30-list-edit-dialogs-refactor-design.md
Small button styling/text tweaks and a new spec describing the refactor, state model, and backend/frontend contract changes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • mikkisguy/branchforge#179: Introduced initial CRUD dialog restructuring and DialogShell wiring that this PR further refactors into list + edit dialogs and aligns backend/frontend contracts.

Suggested labels

priority:medium

Poem

"🐰 I hopped through lists and dialogs bright,

Locked the keys to keep things right.
Routes and vars and stats in tune,
One-small-refactor, one big boom. ✨"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title Check ✅ Passed Title check skipped as CodeRabbit has written the PR title.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch restructuring-character-management-and-handling-in-sidebars

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot changed the title @coderabbitai Refactor management UI to list view and edit dialog pattern May 30, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/backend/src/services/__tests__/variables.service.integration.test.ts`:
- Around line 422-425: Add an explicit test in this integration suite that
verifies key immutability by calling updateVariable with a payload containing a
new key (e.g., updateVariable(id, userId, { key: "new_key" })) and asserting the
contract: either the call rejects with the appropriate error or the variable's
key remains unchanged after the call; place the test near the existing "should
throw NotFoundError when variable does not exist" case and reference
updateVariable and the variables service so CI enforces that key updates are
rejected/ignored.

In `@apps/frontend/src/components/script-mode/VariablesDialog.tsx`:
- Around line 100-111: The VariableEditDialog's visibility is currently driven
only by editingVariableId and ignores the parent dialog's open state, causing
the edit dialog to remain or reopen when the parent closes; update the logic so
the edit dialog only opens when both the parent `open` prop/state and
`editingVariableId` indicate edit mode (e.g., pass open={open &&
editingVariableId !== null} to VariableEditDialog) or add an effect that clears
`editingVariableId` when the parent `open` becomes false (useEffect(() => { if
(!open) setEditingVariableId(null); }, [open])); reference variables:
VariableEditDialog, editingVariableId, MODE_NEW, and the parent `open`
prop/state.

In `@apps/frontend/src/components/StatEditDialog.tsx`:
- Around line 7-20: The TSX file's local imports must include .js extensions for
ESM compliance: update the imports that reference local modules (Dialog
components from "`@/components/ui/dialog`", Button from "`@/components/ui/button`",
Input from "`@/components/ui/input`", Label from "`@/components/ui/label`", and
useStats from "`@/hooks/useStats`") to include the .js extension (e.g.
"`@/components/ui/dialog.js`", "`@/components/ui/button.js`", etc.), leaving
external package imports (like "lucide-react" and "`@branchforge/shared`")
unchanged.
- Around line 140-145: The numeric conversion in handleChange (which updates
StatFormState via setForm for fields minValue/maxValue) can produce NaN; change
the conversion to parse the value, check isNaN, and if NaN either retain the
previous numeric value or set a safe fallback (e.g., null/undefined) instead of
storing NaN, and add an explicit guard in the save handler
(handleSave/handleSubmit or whatever submits create/update payloads) to validate
that minValue and maxValue are real numbers (not NaN) and fail validation if
they are not before sending the payload.

In `@apps/frontend/src/components/StatList.tsx`:
- Around line 56-70: The row currently uses a non-semantic div with
role="button" and contains focusable edit/delete Button controls which violates
ARIA; change the markup so the selectable action is a real interactive element
and not a parent of other buttons: remove role="button" from the outer container
in StatList.tsx and either (a) replace the row click handler with a dedicated
<button> element that covers the selection area and keeps onClick={() =>
onSelect(stat.key)} / onKeyDown logic attached to that button (leaving the
edit/delete Buttons as siblings inside the row), or (b) keep the outer div
purely presentational (no role or tabIndex) and add a child <button> (or
focusable element) that invokes onSelect(stat.key); ensure you update references
around onSelect, stat.key, stat.id, and isSelected so the edit/delete Buttons
(the Buttons previously at ~lines 91-117) are no longer descendants of a
role="button" element and stopPropagation handling is not required.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 37cc612f-c4b9-4e55-9490-693cf3b290c3

📥 Commits

Reviewing files that changed from the base of the PR and between b655534 and c54666d.

📒 Files selected for processing (25)
  • apps/backend/src/lib/validation.ts
  • apps/backend/src/services/__tests__/variables.service.integration.test.ts
  • apps/backend/src/services/route-configs.service.ts
  • apps/backend/src/services/variables.service.ts
  • apps/frontend/src/components/CharacterDialog.tsx
  • apps/frontend/src/components/RouteEditDialog.tsx
  • apps/frontend/src/components/RouteList.tsx
  • apps/frontend/src/components/RouteSettingsContent.tsx
  • apps/frontend/src/components/StatEditDialog.tsx
  • apps/frontend/src/components/StatList.tsx
  • apps/frontend/src/components/StatManagementContent.tsx
  • apps/frontend/src/components/StatsContent.tsx
  • apps/frontend/src/components/VariableEditDialog.tsx
  • apps/frontend/src/components/VariablesContent.tsx
  • apps/frontend/src/components/VariablesList.tsx
  • apps/frontend/src/components/VariablesManagementContent.tsx
  • apps/frontend/src/components/ide-shared/RouteSettingsDialog.tsx
  • apps/frontend/src/components/script-mode/StatManagementDialog.tsx
  • apps/frontend/src/components/script-mode/VariablesDialog.tsx
  • apps/frontend/src/components/write-mode/ProseEditor.tsx
  • apps/frontend/src/hooks/useRouteConfigs.ts
  • apps/frontend/src/hooks/useVariables.ts
  • apps/frontend/src/lib/api/route-configs.ts
  • apps/frontend/src/lib/api/variables.ts
  • docs/superpowers/specs/2026-05-30-list-edit-dialogs-refactor-design.md
💤 Files with no reviewable changes (13)
  • apps/frontend/src/components/VariablesContent.tsx
  • apps/frontend/src/components/StatManagementContent.tsx
  • apps/frontend/src/hooks/useRouteConfigs.ts
  • apps/frontend/src/components/StatsContent.tsx
  • apps/frontend/src/lib/api/variables.ts
  • apps/frontend/src/lib/api/route-configs.ts
  • apps/frontend/src/components/RouteSettingsContent.tsx
  • apps/backend/src/services/route-configs.service.ts
  • apps/backend/src/services/variables.service.ts
  • apps/frontend/src/components/CharacterDialog.tsx
  • apps/frontend/src/components/VariablesManagementContent.tsx
  • apps/frontend/src/hooks/useVariables.ts
  • apps/backend/src/lib/validation.ts

Comment thread apps/frontend/src/components/script-mode/VariablesDialog.tsx
Comment thread apps/frontend/src/components/StatEditDialog.tsx
Comment thread apps/frontend/src/components/StatEditDialog.tsx Outdated
Comment thread apps/frontend/src/components/StatList.tsx
@mikkisguy mikkisguy merged commit 122b9bf into main May 31, 2026
5 checks passed
@mikkisguy mikkisguy deleted the restructuring-character-management-and-handling-in-sidebars branch May 31, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant