Repository navigation
fix(mobile): the shell returns to a screen already on its stack - #32110
Conversation
The page's own "back to hosts" chevron calls dismissTo('/') inside the page, which the page's
router hands to the shell as one navigate message. The shell pushed every such href, so leaving
a host from its page left [Home, Host, Home] with the old host page still mounted (WebView and
live subscriptions), and every round trip stacked another one. System Back then walked back
through stale host pages.
The shell now reads the navigation container's state first: an href that is already a screen
below this one (same path and query) is popped back to, and an href that is this screen is
dropped. Anything else is pushed as before. The pop names its navigator and source route
explicitly, because a screen's dispatch otherwise stamps its own key as the source and a parent
stack that cannot find it drops the pop.
The wide host-route dismissTo stays for the hrefs this rule does not cover: a host route whose
query differs from the one below (the missing-worktree bounce), and a cold deep link with no host
route below to return to. Overlay replace is unchanged, and so is the bridge message.
…reen on the stack
The session screen clears paneKey with setParams({ paneKey: '' }), which leaves ?paneKey= on the
stack entry, so a later navigate to the plain session href found no match and pushed a duplicate.
Empty query values are now dropped when canonicalising, and the fragment is stripped since
expo-router keeps it as a param no href spells the same way.
|
Review follow-up (4c4b5e0): a query param cleared to empty (the session screen's Known and accepted: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
Why
On a phone, leaving a host with the page's own "back to hosts" chevron didn't go back to Home. It opened a second Home on top. The old host page stayed mounted underneath, keeping its WebView and its live subscriptions to the desktop, and every round trip added another one. System Back from Home then landed on a stale host page.
Cause: inside the page, the chevron calls
dismissTo('/'), but the page's router hands every route it doesn't serve to the shell as onenavigate(href)message, and the shell always answered withpush.What changed
Before opening anything, the shell now checks its own navigation stack:
dismissToand the plain push work as before, and the overlayreplaceis untouched.Another worktree or tab under the same route pattern has a different path or query, so it still pushes.
native-stack-return.tsis a pure walk over the navigation state that finds the match. The pop names its navigator and source route explicitly, because a screen'sdispatchotherwise stamps its own key as the source, and the parent stack can't find that key and silently drops the pop. Only the device run caught that.Compatibility
Nothing on the wire changes: the bridge message and the page side are untouched, so every desktop version works. This ships with the next app release. Older apps keep today's behavior.
Verification
Android emulator (emulator-5710), real app, paired to a headless desktop:
[index]to[index, h, index]to[index, h, index, h, index]. System Back from Home landed on the stale host page.[index]each time, and Back from Home exits the app. This was re-run on the final commit with the temporary logging removed.Tests:
native-stack-return.test.tscovers matching, current-screen, a different worktree under the same pattern, and nested navigators.host-area-leave-session.test.tsx, the phone case that previously expected a push (the pile-up) now expects a return, and it fails on main.Checks: mobile
tsc, full mobile vitest,check:code-quality:changed, oxlint/oxfmt, and the reliability gates.Not verified on a device: tablet/wide layout (covered by harness tests), a cold deep link (verified by reading the source), and iOS.
Not in this PR
After a cold deep link, where the host page is the bottom screen, the page's chevron still pushes Home over the host page, the same as on main. Making that case replace instead is a possible follow-up.