refactor(app): extract pawwork workspace lifecycle from layout.tsx#1062
Conversation
Slice 5 of the layout governance line (#1056). Pure extraction: moves the workspace lifecycle actions (createWorkspace / createCurrentWorkspace / deleteWorkspace / resetWorkspace / renameWorkspace / toggleCurrentWorkspace) out of pages/layout.tsx into the new controller pages/layout/pawwork-workspace-lifecycle.ts. layout.tsx 1530 -> 1358. No user-visible behavior change (DOM / copy / aria / command IDs / storage keys / styles untouched). Functions are verbatim copies with an input. prefix; the controller takes minimal Pick<> capability slices as input. Boundary notes: - setWorkspaceName and renameProject stay in layout.tsx: both are already injected into the slice-3 project-controls controller, so they remain shared primitives (injected here, not moved). - clearWorkspaceTerminals is injected rather than imported. Importing @/context/terminal pulls @solidjs/router, which evaluates a client-only solid template at module load and breaks the controller's unit test under the server build. The exact type is recovered via a type-only `typeof import("@/context/terminal").clearWorkspaceTerminals`, so no runtime module load enters the controller graph. - The dead closeProject / toggleProjectWorkspaces (zero references across packages) are left untouched; this slice is pure extraction, not cleanup. Verification: bun run typecheck 8/8; cd packages/app && bun test src/pages/layout = 178 pass (incl. 13 new focused lifecycle tests covering rename no-op guard, create dedup/child/navigate + failure abort, delete prune/reopen + navigate- before-remove ordering + failure no-mutate, reset clear-before-dispose-before- reset ordering + archive-only-unarchived + failure, toggle git/non-git, createCurrent dispatch). Refs #1056.
|
Warning Review limit reached
More reviews will be available in 34 minutes and 33 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Suggested priority: P2 (includes user-path files (packages/app/src/pages/layout.tsx, packages/app/src/pages/layout/pawwork-workspace-lifecycle.test.ts, packages/app/src/pages/layout/pawwork-workspace-lifecycle.ts)).
P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.
There was a problem hiding this comment.
Code Review
This pull request refactors the layout page by extracting workspace lifecycle methods—such as renaming, deleting, resetting, and creating workspaces—into a dedicated createPawworkWorkspaceLifecycle helper, accompanied by comprehensive unit tests. The feedback suggests centralizing active-session filtering and cleanup logic into shared helpers, and using optional chaining defensively when accessing session properties to prevent potential runtime crashes.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
… edges Addresses /codex review of the slice-5 extraction (#1062): - [P1] client-action-source.test.ts asserted the workspace.reset client-action header tagging lived in pages/layout.tsx, but resetWorkspace moved to pawwork-workspace-lifecycle.ts. Point the provenance guard at the new file so it keeps guarding the code that actually carries clientActionHeaders / kind: "workspace.reset" / actionClient.instance.dispose. - [P2] add a deleteWorkspace(leaveDeletedWorkspace=true) test (the real DialogDeleteWorkspace path): asserts the lifecycle never navigates while still removing + pruning + reopening the root (shouldLeave early return). - [P2] pin the resetWorkspace failure branch's toast dismiss: spy the module singleton toaster.dismiss so deleting the dismiss() call regresses the test (previously only setBusy(false) + no-archive were asserted). Verification: cd packages/app && bun test = 1667 pass; typecheck 8/8.
|
Re gemini on pawwork-workspace-lifecycle.ts:149 — out of scope for this slice. This PR is a pure, verbatim extraction: the predicate |
Summary
Slice 5 of the layout governance line (#1056). Pure extraction: moves the workspace lifecycle actions out of
pages/layout.tsxinto a new controllerpages/layout/pawwork-workspace-lifecycle.ts.Extracted (verbatim,
input.-prefixed):createWorkspace,createCurrentWorkspace,deleteWorkspace,resetWorkspace,renameWorkspace,toggleCurrentWorkspace.layout.tsx1530 → 1358.No user-visible behavior change (DOM / copy / aria / command IDs / storage keys / styles untouched).
Touched files
packages/app/src/pages/layout.tsx— remove the 6 functions + now-unused imports (clearWorkspaceTerminalsre-added and passed as input;clientActionHeaders,effectiveWorkspaceOrder,toasterdropped), wire up the controller destructure.packages/app/src/pages/layout/pawwork-workspace-lifecycle.ts— new controller (createPawworkWorkspaceLifecycle).packages/app/src/pages/layout/pawwork-workspace-lifecycle.test.ts— 13 new focused tests.Review focus
input.injection.setWorkspaceNameandrenameProjectstay inlayout.tsx(already injected into the slice-3 project-controls controller → shared primitives, injected here not moved).clearWorkspaceTerminalsinjected, not imported: importing@/context/terminalpulls@solidjs/router, which evals a client-only solid template at module load and breaks the unit test under the server build. Exact type recovered viatypeof import("@/context/terminal").clearWorkspaceTerminals(type-only, no runtime load).closeProject/toggleProjectWorkspaceshave zero references acrosspackages/— left in place (pure extraction, not cleanup).Verification
bun run typecheck8/8cd packages/app && bun test src/pages/layout→ 178 pass (165 prior + 13 new)eslintclean on changed filesRisk
Low. Mechanical extraction; behavior preserved and covered by the new tests. The only non-mechanical decision is injecting
clearWorkspaceTerminals(documented above). #1053 (automation) also touchespages/layout.tsxand will rebase on top.Refs #1056.