Skip to content

refactor(app): extract pawwork workspace dialogs from layout.tsx - #1063

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

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

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

Slice 6 of the layout governance line (#1056). Pure extraction: moves the DialogDeleteWorkspace / DialogResetWorkspace confirm-dialog components out of pages/layout.tsx into pages/layout/pawwork-workspace-dialogs.tsx via a createWorkspaceDialogs(input) factory. layout.tsx 1358 → 1234.

No user-visible behavior change (DOM / copy / aria / i18n keys / styles untouched).

Touched files

  • packages/app/src/pages/layout.tsx — remove the two component definitions + now-unused Dialog / Button imports; add the factory destructure (placed after the slice-5 lifecycle controller so deleteWorkspace / resetWorkspace are in scope).
  • packages/app/src/pages/layout/pawwork-workspace-dialogs.tsx — new factory createWorkspaceDialogs.

Review focus

  • Verbatim equivalence of both components under input. injection (especially DialogDeleteWorkspace.handleDelete: leaveDeletedWorkspace computation → navigate → dialog.close()deleteWorkspace(root, dir, leave) ordering).
  • Factory pattern: the two components close over injected deps; props: { root, directory } and the dialog.show(() => <DialogX .../>) call sites are unchanged.
  • Import cleanup: Dialog / Button were only used by the extracted dialogs (confirmed zero other refs in layout.tsx).

Verification

  • bun run typecheck 8/8
  • cd packages/app && bun test → 1667 pass (no source-guard / shell-frame-contract breakage)
  • eslint clean

No new unit test: these are presentational components and the logic-bearing deleteWorkspace / resetWorkspace are already unit-tested in slice 5 (#1062). Solid render tests here need the @/testing/browser-subprocess harness (JSX needs a client solid-js/web build), which is disproportionate for two confirm dialogs.

Risk

Low. Mechanical extraction; behavior preserved. #1053 (automation) also touches pages/layout.tsx and will rebase on top.

Refs #1056.

Summary by CodeRabbit

  • Refactor
    • Reorganized workspace dialog management code for improved maintainability.

Slice 6 of the layout governance line (#1056). Pure extraction: moves the
DialogDeleteWorkspace / DialogResetWorkspace confirm-dialog components out of
pages/layout.tsx into pages/layout/pawwork-workspace-dialogs.tsx via a
createWorkspaceDialogs(input) factory. layout.tsx 1358 -> 1234.

No user-visible behavior change (DOM / copy / aria / i18n keys / styles
untouched). The two components are verbatim copies with an input. prefix; the
factory takes minimal Pick<> capability slices plus the slice-5 lifecycle
deleteWorkspace / resetWorkspace as input. The dialog.show(() => <DialogX .../>)
call sites in workspaceSidebarCtx are unchanged (the components are now
destructured from the factory).

Removed now-unused layout.tsx imports: Dialog, Button (only the extracted
dialogs used them).

These are presentational components; the logic-bearing deleteWorkspace /
resetWorkspace they call are already unit-tested in slice 5. Solid component
render tests in this repo require the browser-subprocess harness
(@/testing/browser-subprocess) because JSX templates need a client solid-js/web
build, which is disproportionate for two confirm dialogs — so this slice relies
on typecheck + the full app suite + codex equivalence review.

Verification: bun run typecheck 8/8; cd packages/app && bun test = 1667 pass;
eslint clean.

Refs #1056. #1053 (automation) also touches pages/layout.tsx and will rebase on top.
@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-dialogs.tsx)).

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.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR extracts workspace delete and reset dialog components from layout.tsx into a new createPawworkWorkspaceDialogs factory function. The factory encapsulates dialog state management, file status checking, session handling, and workspace action logic. Layout.tsx is refactored to import and instantiate the factory with required dependencies, removing 136 lines of inlined dialog code while adding 159 lines to the new module.

Changes

Workspace dialog extraction and refactoring

Layer / File(s) Summary
Dialog factory contract and setup
packages/app/src/pages/layout/pawwork-workspace-dialogs.tsx
Exports PawworkWorkspaceDialogsInput type defining the contract for SDK client, dialog controller, i18n function, navigation helpers, and workspace action callbacks.
Workspace dialog implementations
packages/app/src/pages/layout/pawwork-workspace-dialogs.tsx
DialogDeleteWorkspace loads directory status and navigates away if deleting the active workspace before confirming deletion. DialogResetWorkspace fetches unarchived sessions and displays an archived-count label before resetting. Both disable actions while loading and return from createPawworkWorkspaceDialogs factory.
Layout refactoring and factory wiring
packages/app/src/pages/layout.tsx
Updates imports, instantiates createPawworkWorkspaceDialogs with global SDK, dialog instance, language, route params, directory, and delete/reset callbacks. Removes the inlined 136-line dialog component implementations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰 Dialogs hop right out of the page,
Into their own cozy module—the stage,
With status checks, sessions, and navigation so keen,
The cleanest refactor you've ever seen!
A factory-made magic, now reusable and bright. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: extracting workspace dialogs from layout.tsx into a separate module.
Description check ✅ Passed The description is comprehensive and covers most required sections including Summary, Why (review focus, verification), related issue reference, and detailed explanation of changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ 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 claude/layout-workspace-dialogs

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.

@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 component in layout.tsx by extracting the DialogDeleteWorkspace and DialogResetWorkspace dialog components into a new file, pawwork-workspace-dialogs.tsx. The new file exports a createWorkspaceDialogs function that encapsulates the logic and state for these dialogs, improving code organization and readability. There are no review comments, so no feedback is provided.

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.

Align the factory + input type with the file name (pawwork-workspace-dialogs.tsx)
and the sibling controllers (createPawworkWorkspaceLifecycle / -RoutingActions /
-ProjectControls). The factory was inconsistently unprefixed while its file and
siblings carry the pawwork-* fork-marking convention.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/app/src/pages/layout/pawwork-workspace-dialogs.tsx (1)

53-58: ⚡ Quick win

Optional: de-duplicate the status-loading and description() logic.

Both dialogs contain an identical description() (Lines 53-58 and 120-125) and a near-identical onMount file.status loader (Lines 31-42 and 99-111). Since they now live side-by-side in this new module, a small shared helper (e.g. useWorkspaceDirtyStatus(directory) returning { status, dirty, description }) would remove the duplication without changing behavior. Safe to defer given this is a mechanical extraction.

Also applies to: 99-125

🤖 Prompt for 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.

In `@packages/app/src/pages/layout/pawwork-workspace-dialogs.tsx` around lines 53
- 58, Extract the duplicated status/description and the file.status onMount
loader into a small reusable hook (e.g., useWorkspaceDirtyStatus(directory)) and
replace both local description() functions and their onMount loaders with calls
to that hook; the hook should encapsulate returning { status, dirty, description
} (compute description using the same language.t keys used in description()) and
perform the file.status fetch/subscribe logic currently duplicated in the two
onMount blocks so callers (the dialogs) simply call
useWorkspaceDirtyStatus(directory) and use its returned values.
🤖 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.

Nitpick comments:
In `@packages/app/src/pages/layout/pawwork-workspace-dialogs.tsx`:
- Around line 53-58: Extract the duplicated status/description and the
file.status onMount loader into a small reusable hook (e.g.,
useWorkspaceDirtyStatus(directory)) and replace both local description()
functions and their onMount loaders with calls to that hook; the hook should
encapsulate returning { status, dirty, description } (compute description using
the same language.t keys used in description()) and perform the file.status
fetch/subscribe logic currently duplicated in the two onMount blocks so callers
(the dialogs) simply call useWorkspaceDirtyStatus(directory) and use its
returned values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2c4e2874-fe38-4002-bb53-d78c49df959e

📥 Commits

Reviewing files that changed from the base of the PR and between 573c70a and 61b9520.

📒 Files selected for processing (2)
  • packages/app/src/pages/layout.tsx
  • packages/app/src/pages/layout/pawwork-workspace-dialogs.tsx

@Astro-Han
Astro-Han merged commit e0e7f21 into dev Jun 2, 2026
36 checks passed
@Astro-Han
Astro-Han deleted the claude/layout-workspace-dialogs branch June 2, 2026 16:46
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