Repository navigation
fix(mobile): open host editor reliably - #11635
Conversation
|
Warning Review limit reached
Next review available in: 8 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
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 |
| requestAnimationFrame(() => { | ||
| router.replace(mobileHostEditRoute(hostId)) | ||
| }) |
There was a problem hiding this comment.
Deferred replace has no cancellation path
If the user navigates away (or the action sheet is dismissed a second time) in the ~16 ms between the push and the RAF callback, replace will still fire and land on whatever screen happens to be on top at that moment. Storing the handle returned by requestAnimationFrame and cancelling it when appropriate (e.g. in a cleanup effect at the call site, or by checking a cancelled flag inside the callback) would make this race benign.
Greptile SummaryThis PR fixes a bug where tapping "Edit host" from a cold start opened a blank screen because Expo Router resolved a deep
Confidence Score: 4/5Safe to merge; the core navigation fix is well-reasoned and manually verified, with only a minor uncancelled-RAF edge case under rapid user input. The two-step push-then-replace approach correctly addresses the cold-navigator mount ordering problem, and the regression test gives good coverage of the deferred replace sequence. The uncancelled RAF handle is a minor edge case unlikely to manifest in practice given the 16ms window and the action sheet closing before the press handler fires. Files Needing Attention: mobile/src/transport/host-edit-navigation.ts — the uncancelled RAF callback is worth a second look if this helper is ever reused in contexts with longer-lived components.
|
| Filename | Overview |
|---|---|
| mobile/src/transport/host-edit-navigation.ts | New module encapsulating the two-step push-then-replace navigation to reliably open the host edit screen; relies on requestAnimationFrame timing to give the nested navigator one JS frame to mount before the replace fires, with no cancellation path if navigation changes in that window. |
| mobile/src/transport/host-edit-navigation.test.ts | Regression test verifying the cold-navigator sequence: confirms push fires immediately and replace is deferred to the RAF callback with the correct typed route object. |
| mobile/app/index.tsx | Replaces the direct router.push string with the new navigateToMobileHostEdit helper; minimal, surgical change. |
Sequence Diagram
sequenceDiagram
participant User
participant HomeScreen
participant navigateToMobileHostEdit
participant Router
participant HostNavigator
User->>HomeScreen: Tap "Edit host"
HomeScreen->>navigateToMobileHostEdit: navigateToMobileHostEdit(router, hostId)
navigateToMobileHostEdit->>Router: router.push("/h/host-1")
Router->>HostNavigator: Mount nested host navigator at index route
Note over Router,HostNavigator: Nested navigator now mounted in JS state
navigateToMobileHostEdit->>navigateToMobileHostEdit: requestAnimationFrame(callback)
Note over navigateToMobileHostEdit: Defers replace until next JS frame (~16ms)
HostNavigator-->>navigateToMobileHostEdit: RAF fires (navigator mounted)
navigateToMobileHostEdit->>Router: "router.replace({pathname: "/h/[hostId]/edit", params: {hostId}})"
Router->>HostNavigator: Replace index with edit screen
HostNavigator-->>User: Edit host screen shown
Reviews (1): Last reviewed commit: "fix(mobile): open host editor reliably" | Re-trigger Greptile
Rendered QA evidenceValidated commit Electron mobile setupThe desktop Electron app rendered its Mobile settings surface from the PR worktree before device QA. Mobile cold host editor flowFrom a fresh mobile app launch, long-pressed a disconnected host to open the host action sheet: Selected Edit host. The nested host navigator mounted and the populated editor rendered instead of the prior blank page: The host is intentionally offline in this proof, so the workspace sidebar remains in its disconnected loading state; the affected edit form is fully rendered with the stored name and address. |
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]>
…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]>






What this fixes
On mobile, choosing Edit host from a saved desktop could open a completely blank Settings page. This happened most often the first time the host editor was opened after launching the app.
Before / after
What changed
This does not change how host credentials are stored or how the app connects to a host.
Verification