Repository navigation
Description
Context
Part of #2576.
Every route write in ui-react replaces the current history entry, and nothing pushes one:
- (
useHashRoutes,packages/ui-react/src/hooks/use-hash-routes.ts:35-100) clears#/settings/storagewithhistory.replaceState.:158-161and:165-172write#/graphand#/activity, or clear them, the same way. - (
FilePanel,packages/ui-react/src/components/files/file-panel.tsx:37-105) replaces#/files/<path>on every file change and strips it on close. - (
showDetail,packages/ui-react/src/components/activity/activity-page.tsx:257-264) replaces#/activity/<runId>, deliberately: the comment at:243-246says "without history spam". - Sessions and Settings, other than the storage deep link, write no history at all.
So inside the installed app, history holds one entry. With no panel open, Android back from Graph, Activity, a file or a run detail closes the app. #2577 closes open panels on back through CloseWatcher without touching history, and does not change any of this.
No decision record covers back-navigation semantics. D52 N1 ("A panel is not a place") and N2 ("Esc, back, or Close files … returns focus") in sessions-and-drafts.md describe panels, not destinations or drill-ins. navigation.md D37 sets the five destinations and does not mention history.
Guide ui-components/stack-drill-down: "A pushState / popstate integration so every drill-down adds a history entry, the OS-level Back gesture works, and deep links open directly into the right view."
Recorded decisions — maintainer, 2026-10-22
Bounded C: Chat is the base. Actions or Graph occupies at most one replaceable view slot above Chat. Switching destinations collapses existing drill-ins rather than replaying destination taps. Deliberate drill-ins add entries; opening a panel alone adds none. Back from undrilled Actions or Graph returns to Chat, then leaves the app.
Drill-ins before panel dismissal: Back walks out of the innermost deliberate drill-in. At the panel root, Back closes the panel. One gesture performs one action, with focus restored per D52 N2. Coordinate with #2577; it is related work, not a declared blocker.
Session resume — option B: Resuming a session adds a deliberate drill-in. Back reopens Sessions focused on the resumed row; Back again closes the panel. At >=1280px, focus returns to that row in the persistent Sessions pane instead of opening a drawer. A destination switch clears the resume drill-in. This is a specific amendment to D52 N1; opening panels alone still adds no entry.
Cold run-detail launch — option B: #/activity/<runId> backs out to the Actions list, then Chat, then leaves. This supplies parent context even though it was not visited. Preserve the previously recorded runtime contingency: if real-browser proof shows the second unactivated step is grouped or skipped, record the evidence here before using the already ruled fallback Actions list → leave. No silent fallback or claim that a synthesized entry works.
Cold file deep link — option B: #/files/<path> backs out to the Files list, then closes Files to reveal Chat, then leaves. Do not close Files on the first Back. This supersedes both the original proposal and the earlier remaining-details comment for file deep links. It creates parent context for the linked file, not a history entry for opening the panel itself. Test this path without an unrelated user gesture. No reduced file-deep-link fallback has been approved.
Settings deep link: The existing ruling for #/settings/storage is unchanged: Back closes Settings and reveals Chat, then leaves. The latest option B selection concerns file deep links only.
Reconciled navigation behavior
This specification supersedes conflicting rows in the original design brief. The same Back policy applies at phone and desktop widths; inline tree expansion is not a drill-in. No new visible control is required; existing in-view Back controls must use the same navigation operation.
| Starting state / action | Back below 900px | Back at >=900px |
|---|---|---|
| Chat, nothing open | Leave app / previous browser page | Same |
| Open Actions from Chat | Chat | Same |
| Switch Actions to Graph | Chat; never replay Actions | Same |
| Open Files panel at root | Close Files; reveal underlying view | Close Files pane; reveal underlying view |
| Open file from Files list | Files list, focus file row | Files pane with no file, focus file row |
| Follow a link from one file to another | Previous file | Same |
| Open a folder as a stacked list | Previous list | Inline expansion adds no entry; root Back closes pane |
| Open run detail from Actions list | Actions list, focus run row | Same |
| Step from run detail A to sibling B | Actions list; sibling replaces detail entry | Same |
| Open Settings over Actions | Close Settings only; keep Actions | Same |
| Switch from Files with drill-ins to Actions | Chat; old drill-ins collapsed | Same |
| Resume a session from Sessions | Reopen Sessions, focus resumed row; next Back closes panel | Same below 1280px; at >=1280px return focus to persistent Sessions pane |
| Open subagent drill-in | Previous transcript view | Same |
Cold #/activity/<runId> |
Actions list → Chat → leave; runtime contingency above | Same |
Cold #/files/<path> |
Files list → close Files to Chat → leave | Same |
Cold #/settings/storage |
Close Settings to Chat → leave | Same |
Settings' existing dirty-state leave guard remains: declining a close keeps Settings open with no extra navigation.
Implementation and runtime conditions
One history helper owns writes and restoration. Panel dismissal and its close watcher belong to #2577, whose shared close-request helper exposes an arm/disarm control; this issue's history helper drives it (disarmed while a panel has drill-in entries above its root, re-armed at root). Escape keeps its D52 N2 meaning and closes the panel at any depth; when it closes a drilled-in panel, this helper collapses that panel's drill-in entries. The proposed watcher disarming at nonzero drill-in depth, re-arming at root, and asynchronous history.go collapse are implementation proposals requiring actual browser proof. A re-armed watcher must not group or skip a Back step; if it does, report it here before selecting an unruled fallback. The selected behavior is not evidence that these mechanisms work.
No maintainer choice remains open. The implementation must record these rulings in navigation.md, including the D52 N1 session-resume amendment. Runtime checks are implementation/merge conditions, not prerequisites for starting the work.
Scope
- Record the ruling as a new entry in navigation.md.
- Implement bounded C: one history helper in ui-react owns every write (
pushStateorreplaceStateby kind) and a singlepopstatehandler that restores store state from the URL. The sites above use it. File the implementation as its own task if it does not fit one sitting.
Out of scope
- General panel-dismissal implementation (ui-kit: Android back leaves the app instead of closing an open destination panel or pane #2577). Coordinating panel dismissal with drill-in history and applying the ruled drill-in-first precedence are in scope here.
- Swipe-back stack animations or scroll-snap view stacks from the guide.
- The host app's
index.html, manifeststart_urlor scope. - Navigation API (
navigation.navigate) adoption.
Acceptance criteria
- The maintainer selected bounded C on this issue: Chat base, at most one replaceable Actions/Graph slot, deliberate drill-ins, and no panel entries.
- Panel/drill-in precedence is recorded: Back walks out of deliberate drill-ins first and closes the panel only at its root.
- Cold run-detail launch is ruled:
#/activity/<runId>→ Back → Actions list → Back → Chat → Back → leave the app. - Session resume is ruled: resume a session → Back → Sessions focused on the resumed row → Back → panel closed; at >=1280px return focus to the persistent Sessions pane. Destination switches clear this drill-in.
- Cold file-deep-link option B is ruled: file → Files list → close Files to Chat → leave. Settings deep links close to Chat. The navigation table above reconciles the recorded rulings.
- Record the final history rulings in
navigation.mdduring implementation. - real-Chromium tests open each affected drill-in or destination and call
history.back(). They assert the restored view, focus per D52 N2, and that one Back gesture performs exactly one action: at nonzero drill-in depth it pops one drill-in without closing the containing panel; at panel root it closes the panel without also popping history. Cover Files root → file → linked file → Back → previous file → Back → list → Back → panel closed. Cover session resume → Back → Sessions with focus on the resumed row → Back → panel closed, persistent-pane focus at >=1280px, and clearing the resume drill-in on destination switch. They also check that a cold deep-link launch behaves as ruled, including#/activity/<runId>→ Actions list → Chat → leave,#/files/<path>→ Files list → close Files to Chat → leave, and#/settings/storage→ close Settings to Chat → leave, without requiring an unrelated user gesture to make Back work. Do not claim a synthesized entry works without real-browser evidence. Each test fails on the current tree. Record the failing-first runs in the PR. - every write site above goes through the one helper, and
grep -rn "replaceState\|pushState" packages/ui-react/srcshows no direct calls outside it apart fromuse-share-intake.ts.
Verification
bun run test packages/ui-react
node scripts/visual.mjs --project=rail-coarse --filter=phone-navigation
node scripts/visual.mjs --project=rail-fine --filter=desktop-navigation
bun run typecheck
bun run lintContract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT:commit prefix, and the doc updated in the same commit. - This changes a published package's behaviour, so it needs a changeset.
The hash formats stay as they are. Bounded C changes ui-react behaviour and needs a changeset. No supported machine shape or hash format changes are proposed.
2026-10-24: named #2577's arm/disarm control as the coordination boundary for the drill-in-first precedence (also folded into #2577) and stated that Escape keeps closing the panel; moved the stacked 2026-10-22 triage and correction notes to a comment.
Activity
schlessera commentedon Oct 22, 2026
Design needed: what Back means inside the installed app. Already decided: panels close on Esc or back and return focus (D52 N2), and #2577 implements that without touching history. Still open: whether destinations and drill-ins (a file, a run detail, a folder) become places that Back walks through. Nothing in code settles this, because every option works technically. The question is what a person expects when they swipe back from a file they opened three taps ago. A documented "no, Back leaves the app" is an acceptable answer.
schlessera commentedon Oct 22, 2026
Design brief: what Back means inside the installed app
Recommendation: C, bounded. Panels never push. History holds at most three layers:
CloseWatcher(ui-kit: Android back leaves the app instead of closing an open destination panel or pane #2577), and does nothing else.history.go(-n), then replaces that slot. Back never replays tab taps.Why the others lose:
cyclops-cave.mdcloses the app. That is the bug in the issue.Answers
pushSubagentView) pushes, and its in-view back callshistory.back().#/files/<path>and#/settings/storage: these open panels, so the panel's ownCloseWatchercloses it and Chat is beneath.#/activity/<runId>: a view. At boot the helper arms oneCloseWatcher, the one a page may create without activation, and on its close it switches to Chat.history.back(), so the on-screen and OS Back never disagree. No mocks needed.Panels and pushed entries: one gesture does one thing
CloseWatcheris armed and takes the Back.popstateand walks out of the drill-in. At depth 0 it re-arms the watcher, and the next Back closes the panel.Back table
voyages/ithaca-return.mdithaca-return.mdvoyages/cyclops-cave.mdithaca-return.mdithaca-return.mdvoyages/note-filer 06:40#/activity/<runId>#/files/<path>#/settings/storageDraft entry for
navigation.mdRisks to check in implementation
CloseWatcherafter apopstatehappens without user activation. Verify that Chrome Android does not group it with the previous one.history.go(-n)is asynchronous. The helper must apply the new destination only afterpopstatesettles, behind the existingafterLeavingSettingsguard.For the maintainer
CloseWatchertrick twice. I recommend Chat.schlessera commentedon Oct 22, 2026
2026-10-22 triage at main
aa8c8966b59f031f054f4876dbca84048b40ae4f: linked the newly supplied bounded-C proposal and named the unresolved acceptance, cold-launch/session choices and panel/drill-in precedence. Verified the existing replaceState paths against the D52 panel/focus rules. Preserve the concurrent needs: decision state, p2 and native #2576 parent. No history policy, watcher behavior or proposal is approved by this update.schlessera commentedon Oct 22, 2026
Decision (maintainer, 2026-10-22): Select option C, bounded destination history plus deliberate drill-ins. Chat is the base; Actions or Graph occupies at most one replaceable view slot above it. Switching destinations collapses the previous drill-in stack instead of replaying destination taps. Deliberate drill-ins push within the current view, while panels themselves add no entry. Back from an undrilled Actions or Graph view returns to Chat, then leaves the app.
This accepts the history model presented in the decision interview, not every detail of the existing design proposal. Panel/drill-in precedence, cold-launch behavior, session-resume behavior and the reconciled state table remain unresolved. The body and acceptance criteria now distinguish the ruling from those open choices. Keep
needs: decisionand noagent-ready; no browser mechanism or runtime proof is claimed.schlessera commentedon Oct 22, 2026
Decision (maintainer, 2026-10-22): Panel/drill-in precedence: option A, walk out of drill-ins first. Files root →
ithaca-return.md→ linkedcyclops-cave.mdunwinds one Back at a time to the previous file, then the Files list, then closes Files.This explicitly qualifies the existing panel-dismissal rule: Back closes the panel at its root; deliberate drill-ins take precedence while their depth is nonzero. One gesture performs one action and restores focus appropriately. The body and runtime acceptance criteria now reflect this policy. Coordinate with #2577; the proposal to disarm/re-arm CloseWatcher still requires actual browser verification. Cold-launch and session-resume choices remain unresolved; keep
needs: decisionand noagent-ready.schlessera commentedon Oct 22, 2026
Maintainer ruling: remaining details (bounded C)
CloseWatcheris disarmed while the drill-in depth is greater than 0 and re-armed at depth 0.CloseWatcherre-armed without user activation afterpopstate. If it does, raise it on this issue before choosing a fallback.#/activity/<runId>: Actions list, then Chat, then leave.CloseWatcher, then a second watcher armed on the first close).#/files/<path>and#/settings/storagestay as proposed: Back closes the panel and lands on Chat.Updated rows in the Back table (replace the matching rows in the brief)
ithaca-return.mdin Filesvoyages/cyclops-cave.mdithaca-return.md(watcher disarmed)ithaca-return.mdin Files#/activity/<runId>navigation.mdentry (final)All rulings for this issue are recorded.
needs: decisionis removed. The two runtime checks above are merge conditions, not open decisions.schlessera commentedon Oct 22, 2026
Decision (maintainer, 2026-10-22): Cold run-detail launch: option B. When the app launches directly at
#/activity/<runId>, successive Back actions go to the Actions list, then Chat, then leave the app. Preserve the run's parent context even though that list was not previously visited.This supersedes the existing design proposal's recommendation that the first Back return directly to Chat. Implementation must prove the actual cold-launch path in a real browser; synthetic-history or CloseWatcher mechanisms are not assumed to work. The body and runtime acceptance criteria reflect this ruling. Session-resume behavior and confirmation of panel deep-link behavior remain open; keep
needs: decisionand noagent-ready.schlessera commentedon Oct 22, 2026
Decision (maintainer, 2026-10-22): Session resume: option B, reconfirmed in the decision interview. Resuming a session adds a deliberate drill-in: Back reopens Sessions focused on the resumed session row; Back again closes the panel. At >=1280px, focus returns to the persistent Sessions pane. A destination switch clears this drill-in.
This confirms the session-resume branch of the earlier remaining-details ruling and supersedes later statements that session resume is unresolved. It is the specific exception to D52 N1; opening panels alone still adds no history entry. The issue body and runtime acceptance criteria now reflect it. Record the decision and D52 amendment in navigation.md during implementation. Browser mechanisms remain subject to real-browser proof. Panel deep-link confirmation and the reconciled state table remain open; retain
needs: decisionand noagent-ready.schlessera commentedon Oct 22, 2026
Decision (maintainer, 2026-10-22): Cold file deep links: option B. After launch at
#/files/<path>, Back shows the Files list first. The next Back closes Files and reveals Chat; the next leaves. Apply the same sequence at phone and desktop widths. This supersedes the direct-to-Chat file-deep-link rows in the original proposal and earlier remaining-details ruling. The existing Settings deep-link ruling is unchanged: close Settings to Chat.The body now consolidates the bounded-C, drill-in precedence, session-resume, cold run-detail and cold file-deep-link rulings and contains the reconciled navigation table. No maintainer decision remains open. Remove
needs: decisionand addagent-ready; implementation, the navigation.md record/D52 amendment and real-browser proof remain outstanding. Preserve the previously recorded run-detail fallback only under its evidence/reporting condition; no file-deep-link fallback is approved. Watcher grouping/re-arming and synthetic history still need runtime proof.schlessera commentedon Oct 24, 2026
History, moved from the body on 2026-10-24 (the active specification above reflects every ruling these notes record):
test(ui-react): arm and disarm under a page watcher that stays armed (#…
fix(ui-kit): only the topmost surface's Escape fallback acts (#2577)
fix(ui-kit): arm a close watcher only while its surface is topmost (#…
fix(ui-kit): only the topmost open surface holds a close watcher (#2577)
fix(ui-kit,ui-react): close non-modal panels on Android back (#2577) (#…