Skip to content

Add a Back step for every stop, and name the thread an entry shows in its URL - #6799

Merged
max-sixty merged 14 commits into
mainfrom
thread-link-back
Nov 23, 2026
Merged

max-sixty merged 14 commits into
mainfrom
thread-link-back

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Following a link from a thread in the floating panel and then pressing Back didn't reopen the thread. The cause was wider than that route: history recorded the open thread view only where a route scrolled the page, and the panel, thread cards, revisions and Undo each remembered a thread their own way. An independent review of the Back/Forward design proposed one place to return to; this is the first of its two pull requests.

  • A Back step for every stop. A route that travels adds an entry where it moves the page or puts focus somewhere the user wasn't (anchor-travel.js, prepareNavigationStep). So each t and m stop, a followed link, a Threads row and Resolve's move to the next thread are steps. Only a user's gesture adds one: a refusal's restoration, a traversal's claim and a reload's arrival don't.
  • ?thread=<id> names the thread an entry shows (thread/address.js). History writes it into every entry (history.js, nameThread), renames the current entry as a thread view opens or closes, and a traversal opens or puts away the named thread once the page is placed. Escape renames the entry and never traverses. A reload, or Forward into the page, reopens the thread with focus and without moving the page. The thread opens where Let the user choose whether threads open beside their passages or in the panel #6796's choice of where threads open puts it, except that history keeps which view the user stood in, so Back after Show on page returns to the panel's view they left.
  • notes/browser-support.md corrects Firefox's account: stock Firefox names Forward's destination, and drops focus as it applies a return, which this puts back.

To weigh: the address bar now changes as threads open and close; every t and m stop adds a step, even one already on screen ("one Back per stop", #5232), and so does a Threads row that opens a thread the page already shows, which #6796's test of that case now expects; Back from a thread opened from Threads closes the panel, as Escape does, and a Back to a place in the panel's Threads or On Me list, which #6778 reopens on main, leaves the panel shut, until the second pull request records the panel's view in entry state; a history write the browser refuses past its rate limit isn't retried.

Max asked for this. Codex reviewed it four times, the merge with #6796 included, and a fresh agent used it in Chromium and Firefox; their findings are fixed. Tests: new cases in test_threads, test_reading_place, test_obligation_walk, test_navigation and test_tabs; test:runtime and pnpm run check pass. test_render_floating_panel::test_an_open_view_covers_the_page_beneath_it fails on main too.

This was written by Claude Code on behalf of max-sixty

… entry shows

Max asked for what Fable's review of the Back/Forward plan recommends; this
takes its findings A, B, F, G and H.

Step rule (A). A route that travels now adds a Back step when it lands the
user on a stop they weren't on, as well as when it moves the page
(`prepareNavigationStep`). Before, only page movement counted:
- the first `t` to a thread already on screen added no entry, so Back from
  its card left the page; it now returns to the page with the card put away;
- `m` between two asks on screen, and `t` between threads seated in a diff,
  added none; each stop is now a step Back retraces;
- a `navigateToDatum` trip to a line the diff already showed is now a step,
  so `test_call_diff_projects_stable_commentable_rows` expects two entries.

The thread's address (B). `?thread=` is now the one record of which thread
view an entry shows (new `thread/address.js`):
- one writer renames the entry the user is on as the panel's thread view or
  a margin card opens, closes or turns to another thread, keeping the page
  key and the fragment, so the address bar names the open thread and a
  reload reopens it;
- a traversal opens the thread the entry names, puts any open one away where
  it names none, works beside a fragment, and leaves placing the page to the
  entry's record;
- a URL with both `?thread=` and `#id` lands on the element with the thread
  open beside it (before, the fragment won and no thread opened); threads.md
  says so.
The case Fable found failing now passes in Chromium, Playwright's Firefox and
stock Firefox 160: open by `?thread=q`, follow its link to `#s8p3`, Back
(page at the top, q open, focus in it), Forward (on `#s8p3`, q put away).
Before, Back left the page at `#s8p3` and Forward left q open.

Deleted: history's `chrome` capture/restore (`ChromeLocation`, `readPlace`'s
`chrome`, `returnPlace`'s reopen through the panel's and margin's
restore pairs) and its composition in leaf.js; the thread route in leaf.js
and its URL restoration after opening. The revision handoff keeps the
panel's and margin's capture, which also holds a margin entry's focus and
the panel's offset. In their place the record keeps the thread view focus
was in (`WorkingPlace.thread`: its id, the route's `reader` request for that
view, its scroll), which the traversal's claim passes to the route, so Back
still reopens a passage thread read in the panel there.

Behavior that changes with B:
- a card a press puts away (focus moving to a link or a tab) renames the
  entry first, so Back to it returns focus to what was pressed with the card
  away; the tab test now expects the tab set's `#second` beside the thread;
- a reload reopens the thread view that stood open; three draft tests that
  assumed none came back now put it away or check what they meant.

Escape and the back gesture (F) put a thread away by renaming the entry,
never traversing. Undo's trip (G) travels only to a place out of view and
keeps no history code of its own. history.js states rule H, and travel
enforces it: a route begun without the browser's user activation renames
instead of adding an entry. A rename waits for a navigation under way,
since a history write aborts it in Chromium and Firefox.

Firefox drops focus to `body` as it applies a same-document traversal; the
return now puts it back once the traversal has applied. notes/browser-support.md
records that, and corrects the Forward entry: stock Firefox 160 names
Forward's destination; only Playwright's build doesn't.

Tests: test_a_walk_to_a_stop_already_on_screen_is_a_back_step (3 cases) and
test_back_and_forward_show_the_thread_each_entry_names (Chromium and
Playwright Firefox) fail on main and pass here.
…page

A reload is a return, and a return never moves the page past where the
browser restored it; only a followed thread link travels. So a URL naming a
thread now opens that thread where the page stands, without taking focus,
when the browser restored the page's place (a reload, or Back or Forward
into the document), as a fragment's arrival already does (`aimArrival`).
Before, a reload travelled to the thread and took focus, which moved the
page to a passage thread's words.
The two tests that expected focus after a reload and after Forward into the
document now expect the thread shown.

Drop travel's user-activation check. Of `prepareNavigationStep`'s callers,
only one could run without a gesture: the panel handing its open thread to a
reader a package registers later, which opened the thread through the route
as travel. It now opens with `travel: false`, as every other route that
isn't the user's gesture does (arrival `history: false`; traversal,
revision, margin and panel restores, `returnToPage`, the comment box and
in-place opens `travel: false`). history.js states the rule and names that
convention; module-reading.md says navigateToDatum is a step Back returns
from where it moves focus or the page.
…even gaps

Codex reviewed the branch's Back/Forward change and found seven gaps; each
now has a test or probe that failed before this commit.

1. A rename asked for during a navigation replayed its URL after that
   navigation ended, onto whatever entry the user had moved to since, and
   a revision's reload could go out without its `_leaf-revision` mark.
   `replaceEntry` now renames only the entry it was asked on and drops
   itself once a newer navigation has moved the user. A rename that would
   change nothing writes nothing, and the revision reload waits for a
   navigation under way before marking the entry it reloads.
   (test_a_rename_waiting_on_a_navigation_names_only_its_own_entry)
2. A datum trip started with a thread open pushed the URL it captured
   before arrival put the thread away, so Forward or a reload reopened it.
   Every entry history writes now names the thread that stands open as it
   is written, through address.js's one composition (`name`, passed to
   `mountHistory`), whether a route, a widget such as the tab set or a
   waiting rename writes it. The address writer is a plain rename with no
   scheduling of its own. (test_a_trip_that_puts_a_thread_away_leaves_an_
   entry_naming_none)
3. `m` from a widget's question in one margin card to one in another read
   its departure after drawing the second thread, which had already renamed
   the entry it left, so Back named the wrong thread. The obligation
   arrival now reads its departure before drawing anything.
4. The thread view's traversal claim replaced the tab set's, so Back across
   root views with a thread changing lost the view's reading position (and
   travel then put the thread away again). The tab set's claim now reveals
   its view and places the page, and the thread opens or goes in it after.
   (test_back_to_another_view_with_a_thread_returns_to_both)
5. `m` between questions shown in the floating panel added no Back step,
   since their arrival never planned its departure. Every obligation
   arrival now plans it, so these are steps like any walk's.
   (3 and 5: test_an_m_walk_between_thread_asks_is_a_back_step_naming_the_
   thread_it_left, margin and panel)
6. The return after the log refuses a Resolve travelled as a step and
   pushed an entry, though no gesture began it. It now travels without a
   departure (`history: false`), through `returnToThread`'s route options;
   Undo's trip, its other caller, stays a step.
   (test_resolve_acknowledges_the_press_and_recovers_a_refusal now checks
   the entry count)
7. The address writer's bare catch swallowed every error. Only the rate
   limit's SecurityError is dropped now, in `replaceEntry`, since the next
   write names the entry again; anything else surfaces. (Probe:
   .tmp/back-steps/rename_throws.py, a TypeError thrown by replaceState
   now reaches pageerror.)

test_thread_url_reveals_a_tab_despite_its_generated_display_fragment now
accepts the thread named by its own id as well as by the reply the link
named: the tab set's rename can land before the thread stands open, and
the entry is named again once it does.
…ns off history

A cold review of the branch's preview found three faults; each has a test
that failed before this commit.

A. Back put a card on the wrong side of its words. The traversal opened the
   entry's thread view before history placed the page, so a card chose its
   side against the page being left: after a `t` walk, Back reopened a card
   that had stood above its passage below it, over the passage's first line,
   while Forward and reload placed it above. The thread view now opens or
   goes once the page stands where the entry left it.
   (test_back_reopens_a_card_on_the_side_it_opened_on)
B. A press on a margin marker whose thread holds an unsent reply added a
   Back step, which the next Back undid with no visible change; threads
   without a draft added none. The marker opens the draft through its
   draft entry, whose route travelled. A margin press now opens a draft
   where the user stands, as it opens a thread: `resumeDraft`,
   `openThreadDraft` and `arriveEditor` take the caller's `travel`. Their
   other callers are gestures that travel, as before: Resume writing, a row
   of Threads' Drafts or Page Map, Restore discarded edit, and the `t` walk
   onto a draft.
   (test_a_marker_opens_a_thread_holding_a_reply_where_the_user_stands)
C. After a reload, the first `t` landed on the card the reload had reopened
   and added a Back step that changed nothing on screen. An arrival onto the
   view of the thread that already stands open, with the page still, is now
   no step; a part inside that view, such as a question it asks, still is.
   Rejected: focusing the reopened thread on a reload, which would put the
   user's keys in the thread after every reload, though a reload keeps no
   record of whether they were in it, and in a card that may stand off
   screen. (test_t_onto_the_card_a_reload_reopened_adds_no_back_step)

A reload reopens the thread by its route's own reader, so a passage thread
read in the panel comes back as a card beside its passage.
…ule's exception

After a reload, the first `t` landed on the card the reload had reopened
without focus, which changed nothing on screen. The previous commit hid the
empty Back step that left with a case in the step rule. The team lead chose
the other route: a reload is a return, and a return puts the user back in
the thread view, as Back does and as main did on a reload. So an arrival
whose place the browser restored, a reload's or a traversal's into the
document, now opens the entry's thread with focus and without moving the
page (`scroll: false`; focus lands with `preventScroll`), and the next `t`
goes on to the next thread, a step. Checked in Chromium and Playwright's
Firefox: the restored offset stands through the focus.

Removed: the step rule's case for an arrival onto the thread view already
open, and travel's `openThread` input that read it.

Tests: test_t_after_a_reload_goes_on_from_the_thread_it_reopened replaces
the test of the removed case and asserts that the first `t` after a reload
goes to the next thread and adds one step; it fails on the previous commit.
test_thread_url_opens_its_canonical_surface_on_arrival and
test_following_a_thread_url_uses_native_history expect focus in the thread
again after a reload and after Forward into the document.
…d opens, await renames

Codex re-reviewed the branch; three of its findings are fixed here, each with a
test that failed before this commit.

#8. Back to an entry naming thread A and a fragment the page had hidden since
decided at the navigate event that A, open in the panel, needed nothing. Revealing
the fragment then put the panel's view away, A stayed closed, and the entry lost
`?thread=A`. The thread claim is now decided, not only run, after the claimant,
the fragment's return and the page's placement.
(test_back_to_a_hidden_fragment_opens_the_thread_its_entry_names)

#9. A press on a row of Threads, and Resolve moving the user on to the next
thread, opened through the panel's own `open`, which took no departure, so one
entry went from no thread to A to B and Back couldn't return to A. `open` now
reads a departure for a thread it opens and commits it once focus lands in the
arriving view, by travel's rule, so these are Back steps as every route's are;
so are On Me's Reply and Discuss and a menu row naming a thread. A send's new
thread and Open in panel open where the user stands (`travel: false`), and a
route that opens its thread through the reader keeps its own departure, since
`open` takes focus there for no one. Back from a thread opened from Threads
returns to the entry before it, which names no thread, so the panel closes
rather than returning to the list.
(test_a_threads_row_and_resolve_s_move_on_are_back_steps)

#1. A revision's reload waited on one navigation, so a navigation superseding
it let the reload run before its `_leaf-revision` mark was written.
`replaceEntry` now answers once its rename is written or dropped, and the
reload awaits that instead of waiting on its own.
(test_a_rename_waiting_on_a_navigation_answers_once_written)
# Conflicts:
#	browser/runtime/floating-panel.js
…vigation is under way

A revision whose code changed reloads the page with `_leaf-revision` in its URL.
Since ca2a8a4 the reload awaited replaceEntry, which defers a rename until a
navigation under way ends and drops it if that navigation moved the user to
another entry. So a reload asked during a slow navigation either waited for it
or, once a newer navigation superseded it, reloaded the new entry without the
mark, interrupting that navigation (Codex's final review of the branch).

history.js now owns `reloadAt`, which writes the mark and reloads at once. It
has nothing to wait for: the reload ends any navigation under way anyway, and an
intercepted navigation commits its URL immediately, so the address it marks is
the entry the user is on. reloadInto is synchronous again, and replaceEntry
returns nothing, as before ca2a8a4; widget-api.js still exports only
replaceEntry.

The test that a deferred rename answers once written gives way to one that a
reload asked during a navigation that never ends requests the marked URL. With
fb87a19's sequence (await replaceEntry, then reload) no reload comes.

Max asked for this branch via Fable's review.
leaf-agent
leaf-agent previously approved these changes Nov 23, 2026
Takes in #6778, which keeps the user's place across Leaf's own reloads.

- A revision's reload (`reloadAt`, history.js) now reloads through
  #6778's `reloadDocument`, so it skips the leave prompt and writes the
  handoff at `pagehide`, which #6778 writes only for Leaf's reloads.
- The chrome's location keeps #6778's panel list for a revision, and its
  capture keeps this branch's signature, since a return to a working
  place no longer reads the chrome: the URL names the thread view.
- `test_a_reload_into_another_runtime_keeps_the_user_where_they_were`
  no longer expects an ordinary reload after the handoff to close the
  thread card, since the entry's address names that thread and a reload
  reopens it; the closed disclosure still shows the handoff was spent.

> _This was written by Claude Code on behalf of max-sixty_
leaf-agent
leaf-agent previously approved these changes Nov 23, 2026
Two files conflicted with #6886, which removed per-record obligations
(`awaits.records`):

- browser/runtime/obligations/view.js: `arriveAtRecordNow` keeps this
  branch's `prepareNavigationStep()` before the thread's source is drawn,
  with main's comment on that drawing; main's removal of the record
  owner's reveal merged cleanly.
- tests/browser/navigation/test_obligation_walk.py: keeps this branch's
  `m`-walk Back-step test and its `IN_THREAD` reader, and drops the records
  tests and imports main removed with the feature.

> _This was written by Claude Code on behalf of max-sixty_
leaf-agent
leaf-agent previously approved these changes Nov 23, 2026
max-sixty added a commit that referenced this pull request Nov 23, 2026
…the panel (#6796)

A thread about a passage can now be read beside the passage, as before
and by default, or in the floating panel, and a card's Open in panel and
the panel's Show on page switch between them. Until now each route
picked a reader by the thread's kind, so a thread moved into the panel
came back as a card on the next `t`. One setting, kept for the tab, now
decides every route to a passage's thread: `t`, a press on the passage,
Threads, On Me, a `?thread=` link, Resolve's move to the next thread and
Undo. The panel's `reveal` takes the thread or declines it by the
setting, and the margin draws no card under the panel setting
(`thread/threads-in-panel.js`).

- Each switch raises a notice, "Threads open in the panel" or "Threads
open beside their passages", whose `p` switches back and moves that
thread back.
- Under the panel setting, a route scrolls the passage into view above
the panel, only as far as needed. `landing-scroll.js` judges what the
panel covers by where its opening animation ends, and history adds a
Back step only where the page moves.
- Placements Leaf forces, such as a thread about the whole page, a
resolved thread, a passage the page doesn't draw or a window too narrow
for cards, put the thread in the panel without changing the setting.
- Undo no longer records which reader a thread was settled in
(`settled.reader`), since it reopens the thread by the route.

To weigh: a switch lands on the thread so its notice shows, unless the
user was writing in the reply, where the caret stays. On a touchscreen
the notice shows no press, following the rule from #6483 and #6687; a
finger switches back with the thread's own button. The Back/Forward pull
request, #6799, also changes `anchor-travel.js` and `floating-panel.js`,
so whichever lands second will conflict there.

Max asked for this. A blind UX review shaped it: the page still scrolls
under the panel setting, the notice offers the way back, forced
placements leave the setting alone, and one setting decides every route.
A fresh agent used it in Chromium and Firefox, and Codex reviewed it
twice; their findings are fixed. Tests:
`tests/browser/threads/test_threads_in_panel.py` is new, tests that
opened a passage's thread in the panel from Threads now choose the panel
first, and `test:runtime` and `pnpm run check` pass.

> _This was written by Claude Code on behalf of max-sixty_
Main gained #6796, the user's choice of where threads about a passage open
(thread/threads-in-panel.js), which every route now follows. Three files
conflicted; the rest merged cleanly.

- browser/runtime/floating-panel.js: a Threads row, Resolve's move to the
  next thread and a card's Open in panel take main's route
  (`threadActions.open`), which follows the choice and takes the route's
  own departure. That left the panel's own departure (`departing`, `open`'s
  returned `landed`, `transition`'s and `focusView`'s `landed`) with no
  caller that committed it, so it goes, with the panel's
  `prepareNavigationStep` dependency. `open` keeps `travel` for a package's
  reader, so a send's thread still adds no Back step there.
- browser/runtime/undo.js: main's `returnToThread`, which opens the thread
  by the route and doesn't travel to one drawn in view, keeps this branch's
  `travel` and `history` options: a return the log's refusal began adds no
  Back step, and Undo travels only to a place out of view.
- browser/runtime/thread/folding.js: main dropped the settlement's reader;
  the refused settlement's return keeps `history: false`.

thread/destination.js merged cleanly but lost this branch's plan of the
route's departure on the primary's view: main plans it only through the
passage's landing (`scrollToThread`), so a thread about the whole page
opened from a Threads row or by Resolve's move on added no Back step
(`test_a_threads_row_and_resolve_s_move_on_are_back_steps` failed). A thread
with no passage now plans its departure on the view again.

#6796's `test_reopening_a_thread_on_the_element_read_adds_no_back_step`
asserted the step rule this branch replaced (a step only where the page
moves). Under this branch's rule a Threads row lands the user in a thread
they weren't in, a step, so the test, renamed
`..._moves_nothing`, still asserts the page doesn't move and now expects
the one step.

The history record keeps the `reader` of the view the user stood in, which
this branch had planned to drop once #6796 landed. The choice says where
routes open a thread from now on, not which view the user was in:
without the record, Back after Show on page no longer reopened the panel's
view the user had left, which main's
`test_back_reopens_the_thread_its_departure_put_away[Show on page]` asserts
and which failed. thread/address.js's header now says why.

> _This was written by Claude Code on behalf of max-sixty_
leaf-agent
leaf-agent previously approved these changes Nov 23, 2026
The merge of #6796 planned a thread route's departure on the floating
panel's view only for a thread about the whole page, and left a thread
with a passage to the passage's landing (`scrollToThread`) to plan and
commit it. A thread whose passage a revision removed has an anchor but no
passage to land on, so its route committed nothing: opened from a row of
Threads, or by Resolve's move to the next thread, it added no Back step
(Codex's review; history.length 2 where 3 is due).

The route now plans its departure on the view for every thread, the
passage's landing plans it again by whether the page moves, and the route
commits once the last landing it reached stands. A step commits once
(anchor-travel.js, `prepareNavigationStep`), so the landing's own commit
and the route's leave one entry.

`test_a_threads_row_and_resolve_s_move_on_are_back_steps` now also runs
on threads whose passage is gone.

> _This was written by Claude Code on behalf of max-sixty_
@max-sixty
max-sixty merged commit ba22bcc into main Nov 23, 2026
6 checks passed
@max-sixty
max-sixty deleted the thread-link-back branch November 23, 2026 20:50
max-sixty added a commit that referenced this pull request Nov 24, 2026
Main carries #6799 (thread-link-back) as the squash ba22bcc. This branch
already held #6799 up to d940bb9, so the merge is taken against that
commit rather than the older main the two histories share: each side
contributes only what it changed since #6799's d940, which leaves #6799's
later commits (df8a9c7, a step commits once) and main's newer work to
main's side. Six files conflicted on that base:

- drafts.js: main (#6907) dropped drafts.js's import of composing/input.js
  to break their cycle, and has a draft subscription carry what Resume
  writing asked the wiring (`closed`). The draft focus history keeps asks
  which box an editor's words are written in the same way: the subscription
  carries `box`, which mirrorDraft, the page's composer and the options
  addition supply, and composing/input.js no longer exports `boxOf`.
- floating-panel.js: main's Show on page button (it moves the thread, with
  its preview), with this branch's `data-lf-carry` key on it.
- thread/selectors.js: both `move` (main) and `controls` (this branch)
  parts.
- thread/address.js: the header keeps both the record's list return and
  main's account of the threads-in-panel choice.
- thread-preview.js: both the card's carry key and main's preview.
- test_navigation.py: Back to Show on page returns to the control, landing
  where main's Show on page now lands, on the card's thread.

It also drops two references the earlier merge left to code neither side
keeps: leaf.js's `threadReader` and floating-panel.js's `afterSettling`.

> _This was written by Claude Code on behalf of max-sixty_
leaf-agent added a commit that referenced this pull request Nov 24, 2026
…thread URL (#7023)

Since #6799, the sample frame's URL carries the open thread
(`?thread=<id>`), so `_read_by_the_sample` in
`tests/journeys/test_render_read_state.py` built
`…/?thread=<id>api/state` from `child.url`. That requested the page
document, and five journeys failed parsing it as JSON (`Unexpected UTF-8
BOM`). The helper now resolves `api/state` against the frame's
`document.baseURI`, as `tests/browser/test_render_controls.py` already
does, so a query on the page URL no longer changes the address. #6799
meant the address bar to name the thread. This change accepts that and
leaves the tests' assertions as they were.

Run locally with `-n0`, all five failed on `main` (`e80dd78be`) with the
BOM error and all five pass with this change:

-
`test_render_read_state.py::test_a_sample_in_a_native_modal_escapes_inherited_inertness`
-
`test_render_read_state.py::test_clipped_sample_cannot_acknowledge_child_viewport`
-
`test_render_read_state.py::test_offscreen_sample_cannot_acknowledge_child_viewport`
-
`test_render_sample_visibility.py::test_narrowing_a_partially_clipped_sample_does_not_acknowledge_hidden_words`
-
`test_render_sample_visibility.py::test_sample_exposure_preserves_parent_declared_occlusion`

Pull requests don't run `journeys/`, so this PR's CI won't exercise
them.

Closes #7018 — automated triage

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 24, 2026
… reload return there (#6860)

Each history entry now keeps where the user was in the entry's own
Navigation API state: the place on the page, the place read to in an
open thread and the view it was read in (the panel or its card), what
had focus and its caret, the selection, and the panel's list (which
list, On's tab, the row, how far it was read). Back, Forward, a reload,
the reload a new revision or a restarted server asks for, and a return
from another site put the user back there. It is the second of the two
pull requests the Back/Forward design review proposed, after #6799, and
replaces history's map of places, its pixel offsets and its fallbacks
for a missing Navigation API.

- **When the record is written** (`history.js` header): as the user
leaves the entry. A route's push writes it, `beforeunload` writes it for
a reload or another document, and so does hiding the page.
`history.replaceState` drops an entry's state, so `bootstrap.js` renames
the URL through one `rename` that keeps it.
- **One restoration at a time** (`beginRestoration`): a document's
arrival and each same-document traversal return to the destination's
record under one intent, aborted by a newer one or any navigation and
ended by the user's own input within the entry, counted from their
latest step to it (`document-inputs.js`, `entered`). Leaving the window
is no such input, any more than a step Back or Forward is
(`document-inputs.js`, `away`). A departure while one is pending writes
the record it still owes. A Back taken before Leaf starts returns to the
entry it reached.
- **One owner of the user's place across reloads:** #6778's copies (the
panel list's capture, the reply's reader, keys released at
`landArrival`) are gone. A reload Leaf asks for adds a handoff
(`version.js`) of what the record doesn't hold: values typed into the
page's inputs, the words being written, the comparison and the pointer.
Values stay out of the record, since Back to an older entry would put
older values back; the arrival puts them back on every control except
one the user has changed since the document started
(`document-inputs.js`, `edited`), so what the user types while the page
starts stays, and a value the page's own script sets as it loads gives
way to the carried one. The handoff names its entry and applies its
place only there. `prepaint.js` alone writes and reads it (its header):
each document's first script takes it from the tab and keeps it only
where the document stands at the history entry it was written at
(`navigation.currentEntry.id`), as after a reload, a discarded tab's
return or Back to a page the browser didn't keep, so the tab holds one
only while a document that would hand it on is going, hidden or starting
hidden, until the next document starts or the page shows again. What a
document going or hiding hands on is, before the runtime starts, the
handoff it came with, if any, plus the current state of each control the
user changed, with the place only until the user acts within the entry;
once the runtime starts, the handoff it came with while its arrival is
still owed, else, on a reload Leaf asked for, what the document then
holds, else nothing. The arrival puts back what the handoff carries of
the document, the values, the comparison and the pointer, whatever
becomes of its claim on the place. Where the handoff puts the user back
at this entry (`prepaint.js`, `placesUser`), keys typed meanwhile wait
in a queue of their own (`bootstrap.js`), kept in the tab until each is
pressed where the user is put back or let go, so a second reload before
then loses neither. The user's own step Back or Forward lets held keys
go on any load, those Leaf is still pressing included, so they don't run
at an entry they weren't typed at; the user's step is one the Navigation
API marks `userInitiated`, and any other step, such as one the page's
script takes, lets none go. Where the browser can't say who stepped,
held keys stay and run at the entry the step reached: in an opaque frame
such as a live sample, which hears only `popstate`, and in Firefox,
which reports no step as the user's, the toolbar's Back included ([Gecko
bug 1903552](https://bugzilla.mozilla.org/show_bug.cgi?id=1903552)). The
words are kept either way.
- **How each part is named:** focus by carry's keys (`data-lf-carry` on
Leaf's thread controls, `data-lf-key` on Versions rows); a page
selection as a passage; a selection in a message as a quote with the
context that tells it apart (`findQuote`), dropped rather than landing
on another copy. That context widens through one loop (`passages.js`,
`passageContext`) moved out of `anchorForPassage`.

To weigh: Back returns to the view the user read a thread in, whatever
#6796's threads-in-panel choice now says, so Back to an entry read in a
card draws a card under the panel choice (`reader: "card"`), and a
draft's restore goes to whichever view already shows its thread, a card,
the panel or a widget's seat, and follows the threads-in-panel choice
only where none does (`reader: "standing"`). Focus returns to the exact
control left, so Back to a thread put away by Show on page lands on Show
on page. A composer the user put away stays shut on a reload, a widget's
Feed view isn't kept, nor is a caret in a message. A handoff whose
arrival is still owed when the page goes passes whole to the next
reload, the browser's reload button included, so keys typed through the
first reload still land. Since leaving the window ends no return, a
find-in-page search made while one is still under way can be moved off
its match. The runtime grows by about 660 lines of code and 520 of
comments net, and the scripts inlined in every page (`bootstrap.js`,
`document-inputs.js`, `prepaint.js`) by 12.9 KB raw (4.2 KB gzipped);
most of it returns the user after a reload and from another site, which
the plan hadn't covered. In Firefox, CodeMirror's reply editor raises a
scroll-linked warning when the page goes while the travel to a thread
still glides; the test that met it now lets the glide land, so the
warning still fails every test.

Max asked for this on the Back/Forward review page, which lists the card
return as a call he may reverse. Codex reviewed it repeatedly, and each
finding it reproduced has a test that failed first. Tests: new cases in
`navigation/test_arrival_record.py`, `navigation/test_reading_place.py`,
`startup/test_readiness.py`, `threads/test_navigation.py`,
`threads/test_rewrites.py`, `threads/test_seated_threads.py`,
`threads/test_threads_in_panel.py` and `drafts/test_revisions.py`, in
Chromium and Firefox; the focused selections around them, `test:runtime`
and `pnpm run check` pass. A tab the browser discards while hidden has
no test, since the suite can't discard one: the hide tests check what
the tab holds after the hide, and Back to a page the browser didn't keep
stands in for the return. A probe with Chromium's `chrome.tabs.discard`
showed the returning page at the same entry, with the tab's storage
intact; Firefox's discard is unmeasured. A same-page frame, which no
page has, can still remove the page's handoff or write its own over it,
which the page's next document then drops. A page script that steps Back
after the runtime loads but before the first state arrives lets held
keys run in the box they were typed for, and that typing then supersedes
the return to the entry the script reached.

> _This was written by Claude Code on behalf of max-sixty_
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.

2 participants