Repository navigation
fix(android): Back goes to the page first, and leaves the app only with nothing open (shell side) - #3763
Conversation
…th nothing open In the Android app every Back left the app, whatever was open: the activity had no Back handling, so the system's default finished it, and the page, which keeps a history entry for each open sheet, dialog, menu and pane, was never asked. MainActivity now keeps an OnBackPressedCallback that is on only while the WebView's history has an entry of the same place behind the page shown (the PC's pages, or the app's own before a PC is chosen: PCStore.pageTakesBack, told again on every doUpdateVisitedHistory). Its Back is goBack(): the page closes what is open or shows the pane before, and the demo returns to the connect screen. With no such entry (the first page with nothing open, a sign-in in front of the PC, the error page) the callback is off and Back is the system's, so the app leaves at once with Android's own predictive-back animation and no second press. iOS is unchanged: the app has no Back, and WKWebView's back-forward swipe stays off. Co-authored-by: sisyphus-dev-ai <[email protected]>
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
|
Review at
CodeRabbit reviewed this head and had no comment. |
Merge passMerged head
Two reviewers at this head: Claude (Opus) CLEAR, Codex Terra CLEAR. It touches The Android app's Back left the app from anywhere. The shell now gives Back to the page while the WebView's history has an entry of the same place behind the page shown ( What the Opus reviewer tried and could not break, by reading: Back never returns to a sign-in page, another port on the PC's host, the hosted app's root outside a relay scope or Left, none HIGH, all traced and not run, sent to the author's lane:
Reports: |
…l peek keeps Back after Settings (#3786) ## Change **Web side**, a follow-up to #3761 (merged at `a91d33ff6`). It reaches phones when the PC updates Ovis. It takes up what the merge pass's reviews of #3761 and #3763 left for this lane: each item, and how it stands, is listed under "Review items" below. No issue: the items come from the merge pass's review reports and its comment on #3761. ### What was wrong Seen in a phone-sized browser (390x844, by touch, Back as one step back in the tab's history), in #3761's code: - **A request to join with no history entry let Back through.** A sheet that opens with no tap since the user's last Back has no entry until the next tap: Chromium's Back would skip one made then. A device's request to join shows by itself and answers nothing on Back. Up so, Back went to the pane before behind the request, and closed a file, Settings or a web page under it. - **A terminal peek lost Back after Settings.** Settings opened over a command's terminal peek takes the peek's entry. Back closed Settings and left the peek with no entry, so the next Back went to the pane before with the peek gone. With a page of Settings open, the Back off Settings' list closed Settings and the peek together. A web page opened over the peek left it without an entry the same way. - **No Navigation API** (Chromium before 102; the build targets 87): the module could tell neither which entry the history was on nor how to go onto one. A Back that closed a menu over the drawer left the drawer with no entry, and the next Back closed it and moved the pane. Reproduced on the unit tests' Chromium-like history. - **Settings showed again** when a sheet took the entry Back had left for it: only the file and diff viewers asked whether an entry was being taken. Seen on a desktop window with Files open as a dialog, Settings opened over it by its shortcut and closed by Back, then narrowed to a phone's width: Settings came back over Files, and one Back closed both. - No test pressed Back on a touch screen of 980px and wider, where the app is laid out as on a desktop. ### What changes - **A Back or a Forward that a sheet with no entry refuses moves nothing.** The sheets are asked from the top down, the one opened last first, and one that refuses keeps the Back from those under it. The history then goes again onto the entry the app is on (`traverseTo`). A way back that another traversal overtakes is taken again when that one lands. - **Whoever keeps state by the history's entry stays still for those two steps.** Settings, the file viewer, the diff viewer and the web panel ask `sheetStep.holds(event)` and leave their state alone: no file closed and opened again, no page framed anew. The sheets answer whichever listener hears the event first. - **A sheet that stays under a navigation keeps its place, and gets its entry back.** While the history is on the entry the navigation took, or above it, the sheet is left as it is. The user's Back below that entry sends the sheet onto it again, and the sheet takes it back, as Files takes the entry Back left for a file. Settings and the web panel now ask `sheetStep.taking(event)`, as the file and diff viewers do, so the entry is not shown again as theirs. - **Where the browser has no Navigation API**, the module keeps what it needs of one in each entry's state (`ovis:place`): a key of the entry's own and its count in the tab's history. A push writes the place one above the entry it is made from, a replace keeps the entry's, and going onto an entry is `history.go` by the difference of two counts. Everything above then works there as it does by the browser's own keys. Nothing is written where the browser has the API, or where it keeps every entry. - **Tests that press Back there.** `scripts/phone-back-demo-regression.ts` has a third screen, 1180x820 by touch: a row's menu, a tab's close confirmation (the tab stays), Files with a document and then a change opened over it, and a menu over a web page docked beside the pane. `scripts/terminal-autoswitch-demo-regression.ts` presses Back with Settings over a peek. A last section of the first suite runs with the browser's Navigation API taken away: a menu over the drawer, and Files after Back closed a file opened from it. Kept as it was: Back sends nothing to a pane, closes no pane and no tab, and discards no draft. No entry is added with no tap behind it. Design source (`src/AGENTS.md`): as in #3761. Android's own rule for a sheet, a menu and the drawer, and what the Android apps of Paseo and T3 Code do with the system's Back: the surface opened last answers it, and what is under it stays. The DESIGN.md entry says that what is under a request to join stays where it is. ### Review items, and how each stands From the review of #3761 at `b147d6908`: 1. Codex MEDIUM, a refusing sheet with no entry lets Back navigate the pane behind it: **fixed**. 2. Codex MEDIUM, nested sheets lose Back without the Navigation API: **fixed**, by the places kept in the entries' states, with a case of two Backs in a row. 3. Opus LOW, the one-second wait after `sheetStep.goingBack`: **fixed in #3761** (`1b1885870`). `backUnderCurrentEntry` tells the sheets when its traversal is refused. A `history.go()` that lands nowhere says nothing, so the bound stays for the two callers that use it. 4. Opus LOW, no test on touch screens of 980px and wider: **added** (the third screen). From the review of #3761 at `a91d33ff6`: 5. Codex MEDIUM, a terminal peek without an entry after Back closes Settings: **fixed**. 6. Opus LOW, Files taking an entry Back left for Settings or a web page: **fixed in its effect**, by the second of the two fixes the review names. Settings and the web panel ask `sheetStep.taking`, so neither shows again, and Files keeps Back: on the narrowed desktop window above, Settings now stays closed, Files holds the entry and Back closes Files alone. Files still takes whatever entry Back left, which costs what a new entry would: the entries ahead. Going there only for a file's or a diff's entry would leave Files with no entry until the next tap. The rotation the review names closes Files beside the pane, in this build and in #3761's: run on a 1180x820 touch screen turned to 820x1180, Settings did not show again in either. 7. Opus LOW, the file viewer's X tapped in the ~2 ms its More menu's own step back takes: **not changed**. The X does nothing then, and a second tap closes the file. A fix has to count the X's step from where the menu's step lands, which the Navigation API path and the `history.go` fallback count differently, and then tell the two landings apart. From the review of #3763: 8. Codex MEDIUM, Back leaving the app or changing panes behind Files or a confirmation on a wide Android screen: **fixed by #3761**, which made every surface take part on any screen worked by touch alone (`BACK_QUERY`), and covered here by the third screen. Not run in the Android app at that size. 9. Codex MEDIUM, Back stepping through an embedded page's own history before it closes the preview: **not changed**; see Limits. 10. Opus LOW, `PCStoreTest` covering only `pageTakesBack`: **not in this PR**. It is the shell side, for a follow-up there. From the reviews of this PR at `9e1cf1355`, all about a Chromium with no Navigation API: 11. CodeRabbit Major (the review thread), a request to join with no entry letting Back through there: **fixed**, with that case in the unit tests and run in Chrome with the API taken away. 12. Codex MEDIUM, Settings' Back still closing a terminal peek there: **fixed**, the same way. 13. Opus LOW, the one step forward landing short after a jump back past more than one entry: **fixed**. The step forward is gone; the way back goes by the counts of both entries, as it does by the browser's own keys. ### Behaviour a reviewer may not expect - `sheetStep.holds(event)` makes the sheets hear the event at once when their own listener has not run yet, so the answer is the same whichever of Settings' and the sheets' listeners was added first. In the app the sheets' listener is the first. - A sheet that stays under a navigation is left as it is by every traversal that lands on the navigation's entry or above it, a step Settings takes between its own entries included. - In a Chromium with no Navigation API, every entry's state carries `ovis:place`, and a `replaceState(null)` there writes a state that holds only that place. No other browser's entries change. - The sheets are asked newest first. With several sheets up that hold no entry, the order they close in on one Back is the reverse of before; all of them still close unless one refuses. ### Limits, not fixed here - Back from the first entry leaves the app with a request to join still up: no popstate comes for the page to refuse. Holding it there needs the app's shell to ask the page first, which is shell side and a store build. - Where the places are the app's own (no Navigation API): a way over more than one entry counts the steps a framed page took, and can land short where such a page is open; and an entry the browser makes by itself (a #fragment) has no place until the next push from it. On such an entry the app behaves as it did before this PR. - Read from the code, not run: a browser that keeps every entry and has no Navigation API (an older Safari or Firefox) is as before this PR. There every sheet has an entry, so a request to join always refuses on its own. But with a page of Settings open over a terminal peek, Back from the page to Settings' list gives the peek an entry above the list, since nothing tells the app where the peek's old entry lies: the next Back ends the peek under Settings and seems to do nothing, and a third closes Settings. The places are not kept there: no such browser was at hand to run them in. - A page framed in a preview adds history entries of its own when the reader moves inside it, and Back steps through them before it reaches the preview's entry, as in any browser and as on main. The page can neither see nor drop those entries. The preview's own Close already skips them (`historyNavigation.ts`). Closing the preview at once on the system's Back needs the shell to ask the page, and is a choice to make: in-app browsers step back through the page first. - With a terminal peek under Files, after Back closes a file opened from Files, the next Back closes Files and the peek together, as in #3761. Files is in front again with no tap behind it, the peek has taken its entry back, and Files has none of its own until the next tap, so both are asked. Found while checking the peek; it needs the sheets that wait for a tap to count as a stack, which is more than this PR should change. - On a tablet-sized touch screen, a web page docked beside the pane holds no history entry, as on a desktop and as before #3761. With only that page open, Back goes to the pane before or leaves the app. A file docked there holds one. Found while writing the third screen. Left for a follow-up: it changes what the panel's history rows in `file-viewer-regression` expect. - The other limits named in #3761 stand: a scroll's end read as a tap within five seconds of one, iOS Safari not run, the lists that close on a press outside and the Back swipe, the two dead presses. ## Validation On the VM pool (the merge gate's runner image, through `vm-check`): - At `2442e0b08`, the branch as pushed: integration, 1432 pass and 0 fail; every browser script, 209 of 209 (one on its second run); and the static steps of `bun run check fast` (release guards, workflow syntax, generated types and themes, typecheck, build). - Its unit tests did not get a result there. In two runs the first unit shard came back with no output, on two different VMs, so the pool could not count the files and marked the group failed. The other shards ran: 8875 pass, and the one failure is the pool's known kernel-only test in `server/copilot.test.ts`. - At the branch merged with main `3ade453cb` (a local merge, not pushed), which is the tree GitHub's checks run: `bun run check fast` passes with every unit shard, 16825 pass, and the two failures are the pool's known kernel-only tests (`server/copilot.test.ts`, `server/session-history.test.ts`; neither is touched here). The nine suites nearest the change pass on their first run: `phone-back-demo-regression`, `terminal-autoswitch-demo-regression`, `file-viewer-regression`, `file-viewer-mobile-regression`, `deep-link-demo-regression`, `palette-local-page-demo-regression`, `settings-pages-demo-regression`, `key-bar-customization-demo-regression`, `phone-inbox-demo-regression`. - At `9e1cf1355`, before the last two commits, every browser suite had passed in the lane's local queue (209 of 209, first run) with `bun run check fast` (16699 pass, 0 fail). Unit cases. Each new one fails with the change it covers taken out (run once each way): - `src/lib/sheetHistory.skips.test.ts` (26): a refused Back and Forward with no entry, a listener that asks before the sheets' own, the refusal keeping Back from the sheet under it, a second Back overtaking the way back, and a staying sheet under one and under two entries of a navigation. Seven more with no Navigation API, on the places kept in the entries' states: a menu over the drawer, a refusing sheet, a jump back past more than one entry, a request with no entry (Back and Forward), a staying sheet under two entries of a navigation, a way that another traversal overtakes, and an entry the browser made by itself. - `src/lib/settingsHistory.test.ts` (40) and `src/lib/useFilePanels.reopen.hook.test.ts` (13): Settings, a file, a diff and a web page through the two held steps, and Settings and a web page on an entry a sheet takes. In a real browser (headless Chrome through Playwright, the demo build, Back as one step back in the tab's history), #3761's code against this branch. The scripts are scratch and not in the repository: - **The request to join.** The app's real prompt, mounted in a scratch build on a test event, shown with no tap since the user's Back: over a pane at 390x844 and 1180x820, and over a file, Settings and a web page at 390x844. In #3761's code Back moved to the pane before behind it, and closed the file, Settings and the page under it. Here the pane stays for Back and for Forward, and the file, Settings and the page stay as the same DOM nodes. After a tap the request holds an entry and refuses on it; after Deny, Back is the app's again. On the first screen Back leaves the app in both. - **A terminal peek.** Settings over it from its list and from a page of Settings, and a web page over it: the results under "What was wrong" in #3761's code, and one thing per Back here. - **With the Navigation API taken away** (deleted from the window before the app loads, which puts the app where a Chromium before 102 puts it): the request to join and the peek, the same scenes, with the same results as with the API. - **Files on a narrowed desktop window**, after Back closed Settings: the result under "What was wrong" in #3761's code. Here Settings stays closed and Back closes Files alone. - **The suites against builds without the change.** `phone-back-demo-regression` fails at the first tablet case against a scratch build that keeps touch screens of 980px and wider out of Back, and at the Files case of its section with no Navigation API against `9e1cf1355` with that section added (on the pool: twice, at the wait for Files' entry). `terminal-autoswitch-demo-regression` fails at "Back closes Settings and leaves the peek" against #3761's build. GitHub's run at `9e1cf1355`: 12 checks passed; "Native macOS session identity" was cancelled after 15 minutes with no runner assigned, and never ran. Not run: an Android device or emulator, a Chromium that really is older than 102, a browser that keeps every entry and has no Navigation API, iOS. The shell is unchanged. The way back is the `traverseTo` that #3761's emulator runs exercised in Android Chrome for a menu over the drawer. --------- Co-authored-by: sisyphus-dev-ai <[email protected]>
## Summary Android 1.0 (7) went public in production on 2026-11-13. Two merged fixes reach phones only with a new store build: #3735 (the connect screen says why a connect fails within 20 s) and #3763 (Back goes to the page first, and leaves the app only with nothing open). This raises the build for that first update: - `app/android/app/build.gradle`: `versionCode` 7 -> 8, `versionName` 1.0 -> 1.0.1 (`app/store/android.md`: raise `versionName` for each public release). - `app/store/android.md`: the version rows say 8 / 1.0.1 and name the last upload. iOS is untouched (1.0 build 8 is in App Review). Nothing here builds or uploads. ## Validation - `bun run check fast` on the VM pool (vm-check fast, commit d1dc72e on main 0522c7f): release guards, workflow syntax, generated types and themes, typecheck, build: ok; unit shard 1/2 ok; unit shard 2/2 failed only on the known VM-only red `server/copilot.test.ts` "keeps a logged binding when only the log's timestamps change" (VM kernel's coarse file clock, listed in known-red). - No test reads `versionCode` or `versionName` (`git grep` over test files).
Change
Shell side of the phone Back fix: it changes the Android app, so it reaches users only with a new Play build. The web side is #3761, which reaches phones as soon as the PC updates Ovis. Each is useful alone, and the app needs both to be right everywhere.
No issue: the maintainer reported it ("on a phone, Back does not close what is open, the whole app goes away").
What was wrong
In the Android app every Back left the app, whatever was open. Measured on the app as released in v0.5.3: on Android 17, 29 of 29 surfaces by the Back key, and the 7 tried by the back gesture and in three-button navigation; on Android 15, the 3 tried. The page keeps a history entry for each open sheet, dialog, menu, Settings step and pane, but
MainActivityhad no Back handling at all (noOnBackPressedCallback, no Capacitor App plugin), so the system's default finished the activity and the page was never asked.What changes
MainActivitykeeps anOnBackPressedCallbackthat is on only while the WebView's history has an entry of the same place behind the page shown: the PC's pages, or the app's own pages before a PC is chosen (PCStore.pageTakesBack, told again on everydoUpdateVisitedHistory, which also sees the entries a page adds withpushState). Its Back iswebView.goBack(): the page closes what is open or shows the pane before, and the app's demo goes back to the connect screen.Kept as it was: Back sends nothing to a pane, closes no pane and no tab, discards no draft and no unanswered prompt. The page decides all of that (see #3761); the shell only chooses between the page and the system.
Built on #3735, now in main: its error page and its cover while a PC opens are both places where Back leaves the app, as that PR wants for a server that is not Ovis.
Validation
Local only: CI has no Android job.
bun run check fastin the CI runner image (herdr-ci-runner:local) at77832ca49merged with maina72178b70: ok (workflow syntax, generated types and themes, typecheck, build, unit tests: 16415 pass, 0 fail, 57 skip in 915 files)../gradlew testDebugUnitTestinapp/android: 45 tests in 4 suites, 0 failures;PCStoreTest28, one new (backIsThePagesOnlyOverAnotherPageOfTheSamePlace)../gradlew assembleDebug: ok. The debug APK was installed on two emulators, with an own AVD each, the demo's fixtures served on loopback throughadb reverse, and Back sent as the system gets it (adb shell input keyevent 4, or a swipe in from the left edge). Surfaces were opened by touch over the WebView's DevTools socket.Android 17 (API 37, WebView 145), with the web side (fix(phone): Back closes what is open, one surface at a time (web side) #3761)
/list, the expanded key row, the terminal lens): Back left from them as from the first screen. 1 the matrix could not open (a draft; see the sequence below)Predictive back, same device, read from a screenshot taken while the finger was still down in a 6 s swipe: on the first screen the system shrinks the app's window over the launcher, exactly as for the v0.5.3 app; with the drawer or the header's More sheet open the window stays whole, and lifting the finger closes the drawer or the sheet.
Android 17 with main's web (the shell alone): 6 of 8 surfaces closed alone, those main already gives a history entry. The drawer and New workspace opened from it still leave the app: they have no entry before fix(phone): Back closes what is open, one surface at a time (web side) #3761.
Android 15 (API 35), whose WebView cannot be driven over DevTools, so through the page's accessibility names: the drawer, the header's More sheet and Settings each closed on Back and the app stayed. The next Back left the app from the sheet's and Settings' screen; after the drawer, the first case after a fresh install, it did nothing once (below).
The app's own pages, before a PC is chosen (Android 17): from the bundled demo Back went through the demo's own entries, then to the connect screen, and from the connect screen it left the app. The demo is bundled from this checkout, which is without fix(phone): Back closes what is open, one surface at a time (web side) #3761: its drawer has no entry yet and stayed open on the first Back.
Before (the app as released in v0.5.3, same emulators): 29 of 29 left the app.
Not run: a physical phone; iOS (unchanged).
One thing the shell makes visible: right after a first connect, with no pane chosen before, the page adds an entry for the pane it picks (web side, as on main). The first Back on the first screen then goes to that entry and shows no change, and the second leaves. Seen on the Android 15 run, whose first case followed a fresh install. v0.5.3 left at once there, as everywhere.