Skip to content

refactor(app): extract pawwork routing actions + deep-links from layout.tsx - #1061

Merged
Astro-Han merged 2 commits into
devfrom
claude/layout-routing-actions
Jun 2, 2026
Merged

refactor(app): extract pawwork routing actions + deep-links from layout.tsx#1061
Astro-Han merged 2 commits into
devfrom
claude/layout-routing-actions

Conversation

@Astro-Han

Copy link
Copy Markdown
Owner

Summary

Pure extraction (layout governance slice 4, refs #1056) of the pawwork routing actions and deep-link handling out of packages/app/src/pages/layout.tsx into packages/app/src/pages/layout/pawwork-routing-actions.ts. Design reviewed via /codex consult before implementation.

What moved (verbatim, no behavior change)

  • Routing actions: syncSessionRoute, navigateToProject, navigateToSession, openPawworkHome, openProject
  • Deep-link: handleDeepLinks + the onMount that drains pending deep-links and registers the window deepLinkEvent listener

Exposed as createPawworkRoutingActions(input). The 5 routing actions are destructured back into layout.tsx with identical names; every call site (startup autoselect createResource, keyboard-nav navigateSessionByOffset/navigateSessionByUnseen, chooseProject, active-route effect, command/sidebar config) is byte-unchanged.

Scope boundary (per /codex design consult)

  • projectRoot / activeProjectRoot / shellNavigation stay in layout.tsx and are injected as input. shellNavigation also serves settings (openSettings) and would form a cycle with projectRoot if moved; keeping them in layout is the cleanest boundary and matches "layout as composition root".
  • Composition layer (navigateSessionByOffset/navigateSessionByUnseen/navigateProjectByOffset) stays in layout — it coordinates slice 1/2/3 controllers.
  • onMount + deep-link listener live in the controller (precedent: layout-update-polling.ts, layout-sdk-event-effects.ts register lifecycle internally); makeEventListener cleanup stays under the Layout owner.
  • Three behaviors explicitly preserved (codex-flagged): deep-link new-session keeps openProject(dir,false) + navigate to the original slug (NOT openPawworkHome, which would resolve a different project root); syncSessionRoute keeps returning root (consumed by activeRoute.sessionProject dedupe); navigateToSession keeps unhide-then-openSession order. The inner requestAnimationFrame/untrack positions are preserved verbatim.

Touched files

  • packages/app/src/pages/layout.tsx (+22 / -90; 1598->1530 lines; removed 5 fn defs + deep-link block + 6 now-unused imports: openProjectRoute, the 4 deep-links helpers, pawworkSessionRouteUnhideKeys, setSessionHandoff)
  • packages/app/src/pages/layout/pawwork-routing-actions.ts (new, ~130 lines)
  • packages/app/src/pages/layout/pawwork-routing-actions.test.ts (new, 7 focused tests)

Verification

  • bun turbo typecheck: 8/8 pass
  • cd packages/app && bun test src/pages/layout: 165 pass / 0 fail (7 new routing tests: hidden-project unhide on navigateToSession/openPawworkHome, syncSessionRoute return/markViewed/expand, deep-link new-session uses openProject+slug-navigate not openPawworkHome, deep-link open-project routes through navigateToProject)
  • No DOM/copy/aria/command-id/storage-key/styling change. Relying on CI e2e-artifacts for rendered routing/deep-link paths.

Risk

Low. TDZ note: openProject is captured by the startup-autoselect createResource closure; the fetcher awaits ready/layout.ready before calling it, so the destructured const is initialized by the time it runs. layout.tsx is also touched by open PR #1053 (automation) in non-overlapping regions; #1053 rebases after this merges (per repo owner).

Refs #1056, follow-up to #875.

@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
@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 2 minutes and 20 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: 34c89b17-ebec-41ad-b76d-8b83407d7f77

📥 Commits

Reviewing files that changed from the base of the PR and between 1c786f3 and 5b58fba.

📒 Files selected for processing (3)
  • packages/app/src/pages/layout.tsx
  • packages/app/src/pages/layout/pawwork-routing-actions.test.ts
  • packages/app/src/pages/layout/pawwork-routing-actions.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/layout-routing-actions

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.

@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-routing-actions.test.ts, packages/app/src/pages/layout/pawwork-routing-actions.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 routing and deep-link handling logic from the main layout component into a new helper function createPawworkRoutingActions, accompanied by a new test suite. A review comment points out a missing dispose() call in one of the tests, which could lead to memory leaks.

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-routing-actions.test.ts
@Astro-Han

Copy link
Copy Markdown
Owner Author

Re gemini thread on pawwork-routing-actions.test.ts:161 — false positive. Every createRoot callback in this file calls dispose() as its last statement (the bot's own quoted snippet shows the dispose() call). The quoted expect(calls.touch).toEqual(["/repo"]) is also stale; the actual assertion is ["/resolved/repo"]. No change needed.

@Astro-Han
Astro-Han merged commit a20f49c into dev Jun 2, 2026
33 of 34 checks passed
@Astro-Han
Astro-Han deleted the claude/layout-routing-actions branch June 2, 2026 15:29
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