Skip to content

fix(mobile): open resume workspace route reliably - #11876

Merged
Jinwoo-H merged 1 commit into
mainfrom
mobile-connect-resume
Aug 1, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
mobile-connect-resume

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • route the home Resume card through a typed Expo dynamic href
  • pass raw host and workspace identities so Expo encodes them exactly once
  • add regression coverage for encoded-sensitive IDs and the Resume card wiring

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 skipped
  • pnpm --dir mobile typecheck
  • scoped mobile lint and formatting checks
  • pnpm run check:max-lines-ratchet
  • pnpm run check:code-quality:changed

Live 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.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds typed mobile session route parameters and a createMobileSessionHref helper. The Resume card now uses the helper with host, worktree, and display-name values instead of manually constructing and encoding the session path. Tests cover dynamic identifiers containing slashes, colons, spaces, and hash characters. Source inspection verifies the Resume card uses the helper.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, reproduction, cause, and validation, but omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections and document screenshots or no visual change, AI review findings, security checks, and platform-specific risks.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary change: making mobile Resume workspace navigation reliable.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@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)
mobile/src/session/mobile-session-route.test.ts (1)

25-34: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Assert 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

📥 Commits

Reviewing files that changed from the base of the PR and between 402e492 and 244ff1b.

📒 Files selected for processing (3)
  • mobile/app/index.tsx
  • mobile/src/session/mobile-session-route.test.ts
  • mobile/src/session/mobile-session-route.ts

@greptile-apps

greptile-apps Bot commented Aug 1, 2026

Copy link
Copy Markdown

Greptile Summary

This 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 router.push, so Expo Router would re-interpret percent-encoded path characters in worktreeId as route structure during cross-stack navigation.

  • Introduces createMobileSessionHref in mobile/src/session/mobile-session-route.ts, returning an Expo Router typed object-href ({ pathname, params }) so IDs are passed raw and the router encodes them exactly once.
  • Replaces the string-template call in the Resume card (mobile/app/index.tsx) and additionally starts forwarding the name query param.
  • Adds two regression tests: one asserting the encoding contract holds, and a second source-scanning test that reads index.tsx and verifies the Resume card uses the new helper rather than the old manual pattern.

Confidence Score: 4/5

The 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.

Important Files Changed

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
Loading

Reviews (1): Last reviewed commit: "fix(mobile): open resume workspace route..." | Re-trigger Greptile

Comment on lines +25 to +34
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)')
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 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!

@Jinwoo-H
Jinwoo-H merged commit c09a2ee into main Aug 1, 2026
44 checks passed
Jinwoo-H pushed a commit to kaynansc/orca that referenced this pull request Aug 4, 2026
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
Jinwoo-H pushed a commit that referenced this pull request Aug 4, 2026
…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]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants