Skip to content

fix(mobile): open host editor reliably - #11635

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/mobile-fix-host-editor
Jul 31, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/mobile-fix-host-editor

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Before: Tap the host action menu → Edit host → see an empty Settings page with no form.
  • After: The populated Edit host form opens immediately with the saved name, address, and connection settings.

What changed

  • Enter the selected host's navigation stack before opening its nested edit screen.
  • Pass the host ID explicitly to both route levels.
  • Add a regression test for opening the editor before that host navigator has ever been mounted.

This does not change how host credentials are stored or how the app connects to a host.

Verification

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@brennanb2025, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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.

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 configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0889ff46-1320-4a07-8f0c-e8307d32fe04

📥 Commits

Reviewing files that changed from the base of the PR and between 7db0101 and b3e491b.

📒 Files selected for processing (3)
  • mobile/app/index.tsx
  • mobile/src/transport/host-edit-navigation.test.ts
  • mobile/src/transport/host-edit-navigation.ts

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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Simulator evidence

Fixed host editor:

orca-mobile-ios-edit-host-fixed.png

Comment on lines +16 to +18
requestAnimationFrame(() => {
router.replace(mobileHostEditRoute(hostId))
})

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 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-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a bug where tapping "Edit host" from a cold start opened a blank screen because Expo Router resolved a deep push to the host edit route into the nested host navigator's index route before that navigator had been mounted. The fix introduces a two-step navigation helper that first pushes to the host's index route (mounting the nested navigator), then defers a replace to the edit screen by one requestAnimationFrame, and covers the sequence with a regression test.

  • host-edit-navigation.ts encapsulates the push → RAF → replace logic and exposes typed helpers (mobileHostEditRoute, navigateToMobileHostEdit).
  • index.tsx replaces the raw router.push string call with the new helper.
  • The test stubs requestAnimationFrame to control timing and asserts push/replace ordering.

Confidence Score: 4/5

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

Important Files Changed

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
Loading

Reviews (1): Last reviewed commit: "fix(mobile): open host editor reliably" | Re-trigger Greptile

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Rendered QA evidence

Validated commit b3e491b96a from this PR worktree.

Electron mobile setup

The desktop Electron app rendered its Mobile settings surface from the PR worktree before device QA.

Electron Mobile settings

Mobile cold host editor flow

From a fresh mobile app launch, long-pressed a disconnected host to open the host action sheet:

Mobile host action sheet

Selected Edit host. The nested host navigator mounted and the populated editor rendered instead of the prior blank page:

Rendered mobile host editor

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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Attachments

iPad cold host editor QA

orca-pr11635-host-action-sheet.png orca-pr11635-host-editor.png
orca-pr11635-host-action-sheet.png orca-pr11635-host-editor.png

@brennanb2025
brennanb2025 merged commit 037f7a0 into main Jul 31, 2026
43 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.

1 participant