Skip to content

refactor(app): extract pawwork workspace lifecycle from layout.tsx#1062

Merged
Astro-Han merged 2 commits into
devfrom
claude/layout-workspace-lifecycle
Jun 2, 2026
Merged

refactor(app): extract pawwork workspace lifecycle from layout.tsx#1062
Astro-Han merged 2 commits into
devfrom
claude/layout-workspace-lifecycle

Conversation

@Astro-Han

Copy link
Copy Markdown
Owner

Summary

Slice 5 of the layout governance line (#1056). Pure extraction: moves the workspace lifecycle actions out of pages/layout.tsx into a new controller pages/layout/pawwork-workspace-lifecycle.ts.

Extracted (verbatim, input.-prefixed): createWorkspace, createCurrentWorkspace, deleteWorkspace, resetWorkspace, renameWorkspace, toggleCurrentWorkspace. layout.tsx 1530 → 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 (clearWorkspaceTerminals re-added and passed as input; clientActionHeaders, effectiveWorkspaceOrder, toaster dropped), 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

  • Verbatim equivalence of the 6 extracted functions under input. injection.
  • Boundary: setWorkspaceName and renameProject stay in layout.tsx (already injected into the slice-3 project-controls controller → shared primitives, injected here not moved).
  • clearWorkspaceTerminals injected, not imported: importing @/context/terminal pulls @solidjs/router, which evals a client-only solid template at module load and breaks the unit test under the server build. Exact type recovered via typeof import("@/context/terminal").clearWorkspaceTerminals (type-only, no runtime load).
  • Dead code left untouched: closeProject / toggleProjectWorkspaces have zero references across packages/ — left in place (pure extraction, not cleanup).
  • Reactivity / ordering: delete navigates-before-remove when deleting the active workspace; reset clears-terminals → dispose → reset → archive ordering.

Verification

  • bun run typecheck 8/8
  • cd packages/app && bun test src/pages/layout → 178 pass (165 prior + 13 new)
  • eslint clean on changed files

Risk

Low. Mechanical extraction; behavior preserved and covered by the new tests. The only non-mechanical decision is injecting clearWorkspaceTerminals (documented above). #1053 (automation) also touches pages/layout.tsx and will rebase on top.

Refs #1056.

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.
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Astro-Han, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d12edf08-5e3c-433b-9539-1ea18a53ae7a

📥 Commits

Reviewing files that changed from the base of the PR and between a20f49c and 68bdc31.

📒 Files selected for processing (4)
  • packages/app/src/context/global-sync/client-action-source.test.ts
  • 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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/layout-workspace-lifecycle

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.

@Astro-Han Astro-Han added P2 Medium priority app Application behavior and product flows ui Design system and user interface task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work tech-debt Supplemental cleanup, maintainability, architecture, test, or quality debt context labels Jun 2, 2026

@github-actions github-actions 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.

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.

@gemini-code-assist gemini-code-assist 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.

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.

Comment thread packages/app/src/pages/layout/pawwork-workspace-lifecycle.ts
… 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.
@Astro-Han

Copy link
Copy Markdown
Owner Author

Re gemini on pawwork-workspace-lifecycle.ts:149 — out of scope for this slice. This PR is a pure, verbatim extraction: the predicate session.time.archived === undefined is copied unchanged from layout.tsx (origin/dev L1003), and the same form appears elsewhere (L1108). Session.time is a non-optional SDK field (typecheck passes without ?.), so optional chaining would guard a state the type rules out. Centralizing the active-session filter into a shared helper is a cross-cutting refactor (it would also have to touch the other call site) and belongs in its own change, not a behavior-preserving extraction. No change here.

@Astro-Han Astro-Han merged commit 573c70a into dev Jun 2, 2026
34 of 35 checks passed
@Astro-Han Astro-Han deleted the claude/layout-workspace-lifecycle branch June 2, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app Application behavior and product flows P2 Medium priority task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work tech-debt Supplemental cleanup, maintainability, architecture, test, or quality debt context ui Design system and user interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant