Repository navigation
fix(mobile): open resume workspace route reliably - #11876
Conversation
📝 WalkthroughWalkthroughThe change adds typed mobile session route parameters and a 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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.
🧹 Nitpick comments (1)
mobile/src/session/mobile-session-route.test.ts (1)
25-34: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAssert every Resume route parameter.
The test proves only that the helper name appears. It can pass if the Resume card passes an incorrect host ID, worktree ID, or
name. Assert all three argument expressions to protect the navigation contract.Suggested assertions
expect(resumeCard).toContain('createMobileSessionHref({') + expect(resumeCard).toContain('hostId: resumeWorktree.hostId') + expect(resumeCard).toContain('worktreeId: resumeWorktree.worktree.worktreeId') + expect(resumeCard).toContain( + 'name: resumeWorktree.worktree.displayName || resumeWorktree.worktree.repo' + ) expect(resumeCard).not.toContain('encodeURIComponent(resumeWorktree.worktree.worktreeId)')
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b502913e-9204-4c6d-b226-a36179f1a6b4
📒 Files selected for processing (3)
mobile/app/index.tsxmobile/src/session/mobile-session-route.test.tsmobile/src/session/mobile-session-route.ts
Greptile SummaryThis PR fixes a mobile navigation regression where tapping the Resume card on the home screen would land on an empty Host screen instead of opening the session. The root cause was that the Resume card manually constructed a route string and passed it to
Confidence Score: 4/5The Resume-card fix is correct and well-tested; the remaining risk is that identical string-interpolation patterns in the host-stack screens are not yet migrated. The core change is clean: swapping a hand-built string route for an object href is exactly the right fix for cross-stack Expo navigation with special characters in IDs, and the session screen already expects the name param. The source-sniffing test is functional but ties the regression guard to JSX comment markers that could silently become stale. The more notable gap is that h/[hostId]/index.tsx and h/[hostId]/tasks.tsx still build session hrefs with encodeURIComponent inside string templates, leaving those paths open to the same class of issue on IDs containing path characters. Files Needing Attention: mobile/app/h/[hostId]/index.tsx and mobile/app/h/[hostId]/tasks.tsx retain the old encodeURIComponent-in-string-template pattern for session navigation and would benefit from the same migration.
|
| Filename | Overview |
|---|---|
| mobile/src/session/mobile-session-route.ts | New utility that wraps Expo Router's typed object-href form so IDs are never string-interpolated into a path; straightforward and correct. |
| mobile/src/session/mobile-session-route.test.ts | Adds two regression tests: one for the encoding contract, one source-sniffing test that reads index.tsx and asserts it uses the typed href; the source-scan test is functional but brittle if comment markers change. |
| mobile/app/index.tsx | Swaps the hand-crafted Resume-card string route for createMobileSessionHref; also now passes name as a query param, which is a small improvement over the previous path-only navigation. |
Sequence Diagram
sequenceDiagram
participant Home as Home Screen (index.tsx)
participant Helper as createMobileSessionHref
participant Router as Expo Router
participant Session as /h/[hostId]/session/[worktreeId]
note over Home: Resume card tapped
Home->>Helper: "createMobileSessionHref({ hostId, worktreeId, name })"
Helper-->>Home: "{ pathname, params }"
Home->>Router: router.push(href object)
note over Router: Expo encodes params exactly once
Router->>Session: Navigate with decoded hostId + worktreeId
Session->>Session: useLocalSearchParams
Reviews (1): Last reviewed commit: "fix(mobile): open resume workspace route..." | Re-trigger Greptile
| it('routes the home Resume card through the typed dynamic href', () => { | ||
| const start = homeSource.indexOf('{/* ─── Resume card ─── */}') | ||
| const end = homeSource.indexOf('{/* ─── Quick actions ─── */}', start) | ||
| const resumeCard = homeSource.slice(start, end) | ||
|
|
||
| expect(start).toBeGreaterThanOrEqual(0) | ||
| expect(end).toBeGreaterThan(start) | ||
| expect(resumeCard).toContain('createMobileSessionHref({') | ||
| expect(resumeCard).not.toContain('encodeURIComponent(resumeWorktree.worktree.worktreeId)') | ||
| }) |
There was a problem hiding this comment.
Source-sniffing test is fragile on comment-marker changes
The test locates the Resume card section using the JSX comments {/* ─── Resume card ─── */} and {/* ─── Quick actions ─── */} as delimiters. If either marker is removed or renamed, start or end becomes -1 and the guards fire — but the failure message won't explain why. More importantly, the not.toContain assertion only blacklists the exact identifier encodeURIComponent(resumeWorktree.worktree.worktreeId), so a minor rename or bracket-access variation would silently pass. The comment markers are now load-bearing for the regression guard.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Tapping Resume on Home landed on a blank host screen instead of the session. A cold push straight into the nested /h/[hostId] navigator resolves to the host index route without the dynamic id, so HostProtocolGate mounts with hostId undefined and never connects. Home already worked around this for the host editor (stablyai#11635) and Tasks (stablyai#11853) by mounting /h/[hostId] first and replacing it once the stack is committed. Extract that mechanism into host-stack-navigation so Resume uses the same transition instead of a direct push. The previous Resume fix (stablyai#11876) swapped the manual href for a typed dynamic href, but expo-router's encodeParam already applies encodeURIComponent to dynamic segments, so it resolved to the same URL the manual string produced and left the cold-navigator path unchanged. Claude-Session: https://claude.ai/code/session_01RMoaxp7MLg2ydP28KFLX7B
…12001) * fix(mobile): open the Resume workspace through a mounted host stack Tapping Resume on Home landed on a blank host screen instead of the session. A cold push straight into the nested /h/[hostId] navigator resolves to the host index route without the dynamic id, so HostProtocolGate mounts with hostId undefined and never connects. Home already worked around this for the host editor (#11635) and Tasks (#11853) by mounting /h/[hostId] first and replacing it once the stack is committed. Extract that mechanism into host-stack-navigation so Resume uses the same transition instead of a direct push. The previous Resume fix (#11876) swapped the manual href for a typed dynamic href, but expo-router's encodeParam already applies encodeURIComponent to dynamic segments, so it resolved to the same URL the manual string produced and left the cold-navigator path unchanged. Claude-Session: https://claude.ai/code/session_01RMoaxp7MLg2ydP28KFLX7B * fix(mobile): harden the host-stack transition after bot review - match a host route committed as the encoded segment it was pushed as, so an id containing `/`, `#`, or `%` still triggers the REPLACE - share one pending transition across the Home entry points; per-hook refs let a Tasks tap and a Resume tap arm two pushes that could not cancel each other - assert the source markers before slicing in the Resume wiring test Claude-Session: https://claude.ai/code/session_01RMoaxp7MLg2ydP28KFLX7B * test(mobile): lock the host-stack transition state machine Assert the replace waits for the host mount (zero dispatches before it, exactly one after), and cover cancel/retarget — the paths the shared pending transition relies on. * test(mobile): model listener removal in the navigation harness A no-op unsubscribe let setState keep calling a canceled listener, so the teardown assertions only exercised the active guard. Dropping the unsubscribe call from dispose now fails the suite. --------- Co-authored-by: kaynan <[email protected]>
Co-authored-by: OrcaWin <[email protected]>
…tablyai#12001) * fix(mobile): open the Resume workspace through a mounted host stack Tapping Resume on Home landed on a blank host screen instead of the session. A cold push straight into the nested /h/[hostId] navigator resolves to the host index route without the dynamic id, so HostProtocolGate mounts with hostId undefined and never connects. Home already worked around this for the host editor (stablyai#11635) and Tasks (stablyai#11853) by mounting /h/[hostId] first and replacing it once the stack is committed. Extract that mechanism into host-stack-navigation so Resume uses the same transition instead of a direct push. The previous Resume fix (stablyai#11876) swapped the manual href for a typed dynamic href, but expo-router's encodeParam already applies encodeURIComponent to dynamic segments, so it resolved to the same URL the manual string produced and left the cold-navigator path unchanged. Claude-Session: https://claude.ai/code/session_01RMoaxp7MLg2ydP28KFLX7B * fix(mobile): harden the host-stack transition after bot review - match a host route committed as the encoded segment it was pushed as, so an id containing `/`, `#`, or `%` still triggers the REPLACE - share one pending transition across the Home entry points; per-hook refs let a Tasks tap and a Resume tap arm two pushes that could not cancel each other - assert the source markers before slicing in the Resume wiring test Claude-Session: https://claude.ai/code/session_01RMoaxp7MLg2ydP28KFLX7B * test(mobile): lock the host-stack transition state machine Assert the replace waits for the host mount (zero dispatches before it, exactly one after), and cover cancel/retarget — the paths the shared pending transition relies on. * test(mobile): model listener removal in the navigation harness A no-op unsubscribe let setState keep calling a canceled listener, so the teardown assertions only exercised the active guard. Dropping the unsubscribe call from dispose now fails the suite. --------- Co-authored-by: kaynan <[email protected]>
Summary
Reproduction
On the attached iOS simulator, opening the Host card loaded Host 1 and its workspace. Returning home and tapping Resume instead landed on an empty Host screen and never opened the session.
The Resume card constructed a nested route string manually. Workspace IDs contain path characters such as
/, so Expo Router could interpret part of the ID as route structure during the direct cross-stack navigation.Validation
pnpm --dir mobile test— 380 files passed; 2,833 tests passed and 3 skippedpnpm --dir mobile typecheckpnpm run check:max-lines-ratchetpnpm run check:code-quality:changedLive baseline reproduction was completed. The attached simulator served another checkout, and the worktree-local candidate launcher stopped before Metro with
selector_ambiguous, so candidate validation is deterministic plus the full mobile suite.