You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(mobile): back from a session lands on its host's session list - #36956
On the phone, going back from a chat or terminal threw you out to the list of desktops instead of that desktop's session list. Now Back takes you one step back, to the session list. Going back again takes you to the desktop list.
What Changed
There were two separate causes.
Sessions opened from Home ("Jump back in") or a notification.navigateToHostStackRoute mounts the host's session list first, then opens the target. It used to REPLACE the list with the session, which left the host stack as h[session], so Back (iOS swipe or Android Back) went straight to Home. Sessions are now PUSHED over the list, giving h[list, session]. When that host's stack is already on screen, the session is pushed straight onto it instead of stacking a second list. Tasks, Automations and host edit still replace the list, as before.
Sessions opened from the host's session list on iOS. On phones the session list page opens a session inside its own document, so the native host stack holds a single screen. react-native-screens gives the edge swipe of a one-screen nested stack to the parent screen, so the swipe popped the whole host to Home. The page already claims Back while it has in-page history, but that claim only turned off the inner screen's swipe. Now:
A claim also turns off the parent screen's swipe. Claims are counted per parent, so the swipe only comes back when the last claim under that parent ends.
While the page claims Back, a left-edge pan on the shell's native view (MobileWebShellView.swift) sends Back to the page, the same frame Android's hardware Back sends. It is a gesture recognizer, not an overlay, so taps at the left edge still reach the page.
Android's in-page case already worked on main: hardware Back reaches the page through the existing claim. Only the Home/notification path was broken there, and the shared opener fixes it.
Why
The opener owns "open a host screen from outside the host", so fixing it covers Jump back in, notifications and every other caller at once. The alternative was repairing the stack from inside the session screen with a navigation RESET, which rewrites navigator state after mount. This change keeps the existing two-step mount and only changes the final action.
For the in-page case, the iOS swipe has to reach the page. I ruled out two alternatives:
usePreventRemove / preventNativeDismiss: react-native-screens lets the swipe finish, then rebuilds the stack, so the host visibly slides away and snaps back.
A JS touch strip over the left edge: it swallows taps on the page's top-left controls, including the back button.
A native pan recognizer that only arms while the page claims Back avoids both problems.
Before (main): open a session from the host's list, then swipe from the left edge. You land on Home.
After:
Jump back in, swipe: the session list.
Open a session from the list, swipe: the session list.
Swipe again: Home.
after-trim.mp4
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
iOS 27 simulator, dev build of this branch, OTA shell, paired to a scratch headless orca serve:
Main: an in-page session swipe goes to Home, and Jump back in leaves h[session], so its swipe also goes to Home.
This branch, with Expo Router's live state read over Hermes: Jump back in gives h[list, session] and the swipe lands on the list. An in-page session swipe goes back to the list. A second swipe goes to Home. A tap at x=14 still hits the page's back button.
Android emulator, 0.0.61 release APK (main's code): an in-page session plus hardware Back lands on the list (already fine). Resume plus Back lands on Home (the bug). The fix is the shared JS opener above. I didn't build an Android dev client.
Tests:
use-shell-page-back.test.tsx: a new test for the per-parent claim count. It fails if the parent swipe is restored unconditionally.
notification-route-coordination.test.ts and mobile-session-route.test.ts: updated to expect PUSH.
Shell screen mocks: now have a parent navigator.
Checks: mobile tsc (app and tests), oxlint and oxfmt on the changed files, the changed-code quality and React Doctor gates, and the 385 navigation, session, notification, shell and new-workspace test files.
AI Disclosure
Review
Needs blessing. This adds a native iOS edge gesture and changes what a swipe does while a sheet is open. To try it: a dev build from the worktree /Users/kelvinamoaba/orca/workspaces/orca/issue-36879-mobile-back on iPhone.
Open a host, tap a session, swipe from the left edge: you should land on that host's session list. Swipe again: the desktop list.
From Home, tap a "Jump back in" row, then swipe: the session list.
In a session, open a sheet (e.g. a tab's long-press menu), then swipe from the left edge: the sheet closes.
Two review rounds, with Codex and Claude reviewing in parallel; the last round was clean. Round 1 found two P2s, both fixed:
The "is this the stack root" check could leave the parent swipe on after a re-claim. It is now a per-parent claim count.
The edge gate used window coordinates, which a landscape safe-area inset breaks. It now uses the shell's own coordinates.
Left as P3: if the bridge can't deliver a frame for a moment, the iOS edge swipe does nothing, while Android falls through to the navigator.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Native change:MobileWebShellView.swift adds the backEdgeSwipe prop and the onBackEdgeSwipe event. Shell JS and native code ship together in the app binary, so there is no version skew. Android's Expo view ignores the undeclared prop.
Not changed:
A swipe that starts over the terminal does nothing, the same as on main: the terminal keeps the touch from every native recognizer.
Home's New Workspace overlay replaces at the root after Create and drops Home along with the host list. That is a separate defect and will get its own fix.
Behaviour change on iOS: while the page claims Back for any reason (an open sheet or drawer, as well as in-page history), a left-edge swipe now sends Back to the page, the same as Android's hardware Back. With a sheet open, the swipe now closes the sheet; before, it did nothing.
Cost: a session opened from Home or a notification now keeps the host list page mounted beneath it. That is the same shape as a native push from the list.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
Walkthrough
Session targets now open over the matching host list, using PUSH navigation when the host stack is mounted. The iOS web shell adds a configurable left-edge swipe that sends a back event to the bridge. Shell back claims also disable the parent screen’s swipe gesture until all claims end.
Severity of issue fixed: Medium
Merge Risk: Low · previous review 6c175
Back can return to another session or skip the host list. These bounded navigation gaps should be fixed or explicitly accepted before merge.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title clearly and concisely states the main user-facing fix: Back from a mobile session returns to its host's session list.
Linked Issues check
Issue [#36879] requires Back from mobile chat or terminal sessions to return to the host session list before Home. The navigation code identifies session targets with HOST_SESSION_ROUTE and dispatch…
Out of Scope Changes check
The changes stay within issue [#36879]. Host-stack changes implement session push behavior. Shell, native gesture, and claim-count changes implement iOS Back handling. Updated tests cover these paths.…
Docstring Coverage
Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Description check
The description is complete and follows the repository template. It explains the user-facing change, implementation, rationale, linked issue, visual proof, testing, review notes, scope boundaries, and…
Full details: Linked Issues check
Explanation
Issue [#36879] requires Back from mobile chat or terminal sessions to return to the host session list before Home. The navigation code identifies session targets with HOST_SESSION_ROUTE and dispatches PUSH when the host stack is mounted. It also pushes the session after the host list mounts, instead of replacing the list. useShellPageBack disables the parent iOS swipe while a page claims Back and restores it after the last claim. The native shell sends the edge swipe to the page. Updated route and claim-count tests cover the changed behavior.
Full details: Out of Scope Changes check
Explanation
The changes stay within issue [#36879]. Host-stack changes implement session push behavior. Shell, native gesture, and claim-count changes implement iOS Back handling. Updated tests cover these paths. No unrelated production feature or unrelated test change is shown.
Full details: Docstring Coverage
Explanation
Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 12 files.
Full details: Description check
Explanation
The description is complete and follows the repository template. It explains the user-facing change, implementation, rationale, linked issue, visual proof, testing, review notes, scope boundaries, and checklist status. The full repository command checklist is unchecked, but the author documents targeted checks and test coverage, so this is non-critical.
Finishing Touches
Generate docstrings
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Keep the host list directly below the new session.
If session A is open and a notification opens session B on the same host, this push leaves A below B. Back from B then returns to A, not the host list. Repeated notifications can add more sessions to the stack. (raw.githubusercontent.com)
Replace the current session when the host list is already below it, and ensure a host list exists otherwise. Update the different-workspace notification test to check the resulting Back destination.
When the h container exists but mountedHostStack is still null, the session branch disposes its state listener and pushes the nested session href. Because this push has no configured anchor, the nested stack can contain only the session. Back can then skip the host list. Keep the listener active for session targets and dispatch the existing PUSH after [hostId]/index commits.
A session opened from Home's "Jump back in" or a notification replaced the
host list it had just mounted, so Back went to Home. It is now pushed over
that list.
A session opened from the host list lives inside the list's own page, and
the stack holding it has one screen, so the iOS edge swipe belonged to the
parent screen and popped the whole host to Home. While the page claims Back
the parent's swipe is turned off too, and a left-edge pan on the shell view
sends Back to the page.
Count claims per parent screen instead of guessing whether a shell is its
stack's root, and measure the back edge from the shell's own left edge so
a landscape safe area does not hide it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
On the phone, going back from a chat or terminal threw you out to the list of desktops instead of that desktop's session list. Now Back takes you one step back, to the session list. Going back again takes you to the desktop list.
What Changed
There were two separate causes.
Sessions opened from Home ("Jump back in") or a notification.
navigateToHostStackRoutemounts the host's session list first, then opens the target. It used to REPLACE the list with the session, which left the host stack ash[session], so Back (iOS swipe or Android Back) went straight to Home. Sessions are now PUSHED over the list, givingh[list, session]. When that host's stack is already on screen, the session is pushed straight onto it instead of stacking a second list. Tasks, Automations and host edit still replace the list, as before.Sessions opened from the host's session list on iOS. On phones the session list page opens a session inside its own document, so the native host stack holds a single screen. react-native-screens gives the edge swipe of a one-screen nested stack to the parent screen, so the swipe popped the whole host to Home. The page already claims Back while it has in-page history, but that claim only turned off the inner screen's swipe. Now:
MobileWebShellView.swift) sends Back to the page, the same frame Android's hardware Back sends. It is a gesture recognizer, not an overlay, so taps at the left edge still reach the page.Android's in-page case already worked on main: hardware Back reaches the page through the existing claim. Only the Home/notification path was broken there, and the shared opener fixes it.
Why
usePreventRemove/preventNativeDismiss: react-native-screens lets the swipe finish, then rebuilds the stack, so the host visibly slides away and snaps back.A native pan recognizer that only arms while the page claims Back avoids both problems.
Linked Issue
Fixes #36879
Visual Proof
iOS 27 simulator, page served by Orca 1.4.246.
Before (main): open a session from the host's list, then swipe from the left edge. You land on Home.
After:
after-trim.mp4
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
iOS 27 simulator, dev build of this branch, OTA shell, paired to a scratch headless
orca serve:h[session], so its swipe also goes to Home.h[list, session]and the swipe lands on the list. An in-page session swipe goes back to the list. A second swipe goes to Home. A tap at x=14 still hits the page's back button.Android emulator, 0.0.61 release APK (main's code): an in-page session plus hardware Back lands on the list (already fine). Resume plus Back lands on Home (the bug). The fix is the shared JS opener above. I didn't build an Android dev client.
Tests:
use-shell-page-back.test.tsx: a new test for the per-parent claim count. It fails if the parent swipe is restored unconditionally.notification-route-coordination.test.tsandmobile-session-route.test.ts: updated to expect PUSH.Checks: mobile
tsc(app and tests), oxlint and oxfmt on the changed files, the changed-code quality and React Doctor gates, and the 385 navigation, session, notification, shell and new-workspace test files.AI Disclosure
Review
Needs blessing. This adds a native iOS edge gesture and changes what a swipe does while a sheet is open. To try it: a dev build from the worktree
/Users/kelvinamoaba/orca/workspaces/orca/issue-36879-mobile-backon iPhone.Two review rounds, with Codex and Claude reviewing in parallel; the last round was clean. Round 1 found two P2s, both fixed:
Left as P3: if the bridge can't deliver a frame for a moment, the iOS edge swipe does nothing, while Android falls through to the navigator.
Agent skill upstream boundary
Notes
MobileWebShellView.swiftadds thebackEdgeSwipeprop and theonBackEdgeSwipeevent. Shell JS and native code ship together in the app binary, so there is no version skew. Android's Expo view ignores the undeclared prop.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)