Repository navigation
Keep where the user was in each history entry, so Back, Forward and a reload return there - #6860
Conversation
… 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.
…ck returns there after a reload Back, Forward and a return after a revision's reload now read one record of where the user was, which history writes to the entry they leave as they leave it, in the entry's Navigation API state (`navigation.updateCurrentEntry`), and reads from the destination (`event.destination.getState()`). That state outlives a reload of the document, so Back after a revision that reloads the page, or after a plain reload, returns to the entry's place; before, the in-memory map of places was emptied by the reload and Back returned to whatever offset the browser had saved, with no focus. The record holds: - the page as a reading landmark (reading-place.js `capturePlace`: the line at the top and how far below the edge it stands), read where a glide is headed, in place of the pixel offset, so a revision that moved content above it still returns to the line; - the reply at the top of the open thread view and how far into it (thread/reply-landing.js `readingIn` / `showReading`), so a card or the panel's view reopens where the user had read it to rather than at its first unread reply; - focus, by what names its element or holds it: a thread's reply, with its caret; a message of a thread's view, a thread's drawing, or a page element by its id; and, for an element nothing names, its place among the elements like it there (focus.js `likeSelector`, now shared with `holdFocus`), which in the page counts only in the revision the record was read in; - the page's selection, as text offsets inside the nearest element with an id; - the floating panel's list (Threads, On, the menu) where one stood, so Back from a thread opened from a Threads row returns to Threads on that row, by the view's own way back; Escape still closes the panel from a thread view. It holds no copy of the thread `?thread=` names. Until the reader a thread opens in is the tab's setting (#6796), it keeps the reader the open view was, which the address's claim passes on. Behavior that changed: Back to a thread a link in it left now returns the user to that link in the thread's new drawing, where it returned them to the thread itself whenever the view had closed (the tests for the departure, the address and the new card test say so); and Back after the arrival opened a disclosure above the place left stands that place where it stood on screen rather than at the old pixel offset (`test_restore_selection_back_keeps_the_place_read_before_reveal`). Removed: history.js's `places` map of live nodes and pixel offsets by entry, the offset round trip `prepareEntry` made so native history saved the source offset, the `offset` and `reader` fields of the panel's held working place, the export of `THREAD_VIEW`, the `window.navigation?.` fallbacks in history.js and undo.js (every engine Leaf supports ships the Navigation API), and the test variant that removed the Navigation API. Measured: `history.replaceState` drops the entry's Navigation API state in Chromium and Playwright Firefox alike, so history writes the record only as the user leaves an entry, and `prepareEntry` writes it after renaming the entry back to its source. In Playwright's Firefox (build 1572) Forward now returns focus too, so the address test asserts it in both engines. Tests added: Back after a reload returns to the line and the link the entry left (Chromium, Firefox); Back reopens a card at the reply the user had read it to (Chromium, Firefox); Back from a thread opened from a Threads row returns to Threads on that row, and Forward reopens it (Chromium, Firefox). Max asked for this as the second half of Fable's review of the Back/Forward plan.
…assage, and keep Threads across a reload Codex's review of the entry record found four ways Back now lost the user's place, each because the record named focus and selection by rules of its own beside the ones Leaf already keeps. Each has a failing test first: - Words selected in prose no element names came back as nothing, since the record kept text offsets inside the nearest element with an id; and words a revision wrote before a saved offset made Back select others. The record now keeps the passage a comment on the selection would quote (`anchorForRange`, resolved by `resolveAnchor`), which needs no id and finds the same words in any revision; a caret is the passage from it to the end of its run of text. (`test_history_returns_a_selection_in_unnamed_prose_across_a_revision`) - After Threads, a row, and a reload, Back showed no list and left focus on the body: the record named `threads`, but the panel showed it only by going back from a thread view standing over it, which the reload had forgotten, and a thread about a passage came back beside it. The address's claim now hands the panel the list and the thread it puts away, and the panel opens the list, standing on that thread's row. (`test_back_from_a_thread_opened_from_threads_returns_to_its_row`, which now uses threads about passages and reloads) - A widget's generated control, as `lf-code`'s source, came back as the widget after a revision, since the record named it by its place among similar elements and refused that place after a revision, ignoring the `data-lf-carry` key carry.js crosses a revision by. (`test_history_returns_a_widgets_named_control_across_a_revision`) - Focus on a message, where `g u` and Undo's trip land, came back as the whole thread. (`test_back_returns_to_the_message_the_user_was_on`) Focus now has one identity: carry.js's `focusKey` / `focusedBy`, which a revision's handoff already used for page elements (owner id, tag, generated part key), extended to a thread's parts (its reply with the caret, a message, the drawing). An unnamed element is named by its place among similar elements in its holder only where that holder is drawn from the same words: a message, or the page in the key's revision; carry's revision restore never uses a place. History's `readFocus`/`focusOf` and `textPoint`/`pointEnd`/`selectionPoints` are deleted. Where a thread's view was read to now has one reading too: thread/reply-landing.js's `readingIn` / `showReading` (the message at the top and the offset into it) serve the entry record, the floating panel's hold of where the user stepped in from, and a revision's handoff of the panel's view, which kept raw `scrollTop` offsets. A card holding its transcript through one fit keeps its raw offset, since the drawing it measures doesn't change. Kept apart, with the reason in history.js's header: the revision handoff (each reading region's place, words being written and values typed, which history never restores, the comparison, the pointer), and the panel's live hold, which keeps the node the user left and its page place after the card that drew it closes. Max asked for the entry record as the second half of Fable's review; this follows Codex's review of it.
…and name what the record lost The user leaves an entry for another entry, by a reload, or for another document, and arrives at it the same three ways. History now writes the record at each departure, at `beforeunload` for the document's own (both engines keep that write through a reload; Firefox drops one made at `pagehide`), and returns to it on each arrival: a page loaded by a reload or by Back or Forward from another document reads `navigation.activation` and the current entry's state, and once presented runs the same return a traversal within the document does (the URL's claim opens the thread or the list, then the reading, focus and selection come back). A visit with no record travels to its `?thread=` as before, and a revision's reload keeps its own handoff. A sample's sandboxed frame, whose opaque origin the browser keeps no entries for, keeps no record. Fixed by that rule alone (failing tests first, Chromium and Firefox): - a reload on a thread about a passage the user opened in the panel shows it in the panel again, not in a card off screen with focus in it (`test_a_reload_keeps_a_thread_in_the_reader_it_showed`); - a reload keeps where a card was read to (`test_a_reload_keeps_where_a_card_was_read_to`); - a reload keeps the caret in a reply being written (`test_a_reload_keeps_the_caret_in_words_being_written[reply]`); - a reload on the Threads step keeps Threads open (`test_a_reload_keeps_the_list_the_panel_showed`); - Back from another document puts the user on the link they followed (`test_back_from_another_document_returns_to_the_link_followed`); - a reload no longer sends focus into a draft the user had put away, so the next key is a command (`test_a_reload_leaves_a_kept_draft_shut`): the saved composer opens on a reload only where the record says the user was in it, as it does on a return within the document, and Resume writing still reaches it. Each needed its own change: - Focus in a draft's own box is named by the draft (drafts.js `draftFocus`): its context, with the caret or as the box a walk stands on, since the arriving document draws that box only once its owner's Resume writing route opens it again (`resumeDraft`, `showDraft`, `travel: false`), its words coming from the drafts store. So the caret in a new comment and in a rewrite of the user's own message survives a reload (`test_a_reload_keeps_the_caret_in_words_being_written[comment]`, `[rewrite]`), and Back to a `t` stop at a kept draft reopens its box (`test_back_to_a_kept_draft_stop_reopens_its_editor`). `?thread=` can't name a draft, so the record does, as it does the panel's list. - Words selected in a message come back: the record keeps the message and each end as the characters before it in the message, which the page's reading doesn't hold (`test_back_returns_words_selected_in_a_message`). - carry.js's key names first everywhere, in a message as on the page: a generated control by its owner's id and `data-lf-carry` key, an element by its id (focus in its shadow tree counts as on it), and only then a place among similar elements (`test_back_returns_to_a_named_control_in_a_message_the_agent_rewrote`, which now focuses the option's own control, the one that takes focus). - A selection's ends are offsets in the page's reading from its quoted passage's start (passages.js `readingHolding`, `spanIn`, `pointAt`, which quote capture and snapping already use), and a caret quotes its block's words, so a caret before a space or at an element's edge comes back between the same characters (`test_history_returns_a_caret_between_the_same_characters`). - A thread's reading names a visible summary as a turn and skips messages a closed fold hides (`test_back_reopens_a_card_read_to_a_folded_summary`). - The panel's list record holds the row the user was on, so Back after Escape put the thread away still stands on it (an added step in `test_back_from_a_thread_opened_from_threads_returns_to_its_row`). - A revision's reload keeps the user on the message they were on: the panel's and the margin's handoff of a thread view now hold carry.js's focus key and restore it through `focusedBy` (`test_executable_revision_keeps_the_user_on_the_message_they_were_on`). Behavior other tests protected that changes with the rule: - A reload puts the user back at the caret they left in the page comment's box, so the tests that type on a reload's arrival no longer press `c` first (`_type_on_arrival` in test_shared_drafts.py, and `test_a_kept_draft_and_an_input_method_reach_the_editor_as_it_loads`), except where a send had taken the user out of the box. - An ordinary reload returns to the reply with its selection's ends (`test_live_executable_replacement_keeps_a_resolved_reply_session`). - A reload leaves a composer the user put away shut, and Resume writing opens it (`test_saved_widget_words_cannot_dismiss_an_unfinished_comment[reloaded-revision]`, `test_explicit_reopening_keeps_a_css_hidden_subject_draft_reachable[reload]`). The tests that open a saved draft again as the page loads, or find a kept rewrite under Resume writing, do it on a new visit (`test_the_comment_box_comes_back_to_where_its_passage_starts`, `test_the_user_rewrites_their_own_message_where_it_stands`, `test_a_package_feed_keeps_a_rewrite_where_a_card_would`), since a reload now returns the user to the rewrite itself. - A reload returns focus to the control the user last pressed (`test_reading_precedes_modules_and_widgets_restore_their_view`). Kept apart: a revision's reload still restores through its handoff, not the record. Swapping the handoff's chrome location for the record failed eight revision tests: the margin's revision rules (a card whose passage the revision hid opens in the panel) and the reply's editing continuity race the record's own opening of the thread. Max asked for the entry record as the second half of Fable's review; this follows Codex's second review and a fresh agent's use of the branch.
Close a margin card that shows a choice an agent's reply asks, press `m`, and the card opened again on that thread drew the reply without its choice, and `m` left focus on the body. A message's widgets stand in one drawing at a time (thread/messages.js, `authoredHolders`). Each opening draws the card's thread into a new body and a new seat, and the old seat stayed until the page's next draw pruned it, so its drawing, gone from the document, still held the widgets: instrumenting `settleAuthored` showed the holder disconnected and still among the message's drawings, which counts as held, and the new drawing, of the same rank, never outranked it. The card now prunes the old seat as it draws another (thread/inline.js, `pruneThreadSeat`), after the new one takes the reply being written, so the old drawings let go and the new one takes the widgets. main has the defect too. On the Back/Forward branch it also showed as Forward to an `m` stop focusing the message rather than its choice, since Back closes the card and Forward opens a new one. `test_forward_to_a_decision_in_a_message_returns_to_the_decision` covers both, failing first in Chromium and Firefox.
…d does A revision that needs a fresh document reloads it, and that reload now arrives at the entry's record like any other (history.js, `returnOnArrival`), so one path returns the page's place, the thread view and where the user was in it, focus and the selection. The handoff (version.js) keeps only what the record doesn't hold: each reading region's place, typed values, with an authored control's focus and caret so typing goes on before the page presents, the words being written with their native editing session, the comparison and the pointer. Composer recovery runs only on a visit with no record, so a revision no longer reopens a comment the user put away. Failing tests first, Chromium and Firefox: `test_executable_revision_leaves_a_put_away_comment_shut`, `test_executable_revision_keeps_the_page_selection`. What that took: - bootstrap.js renames away `_leaf-revision` with `replaceState`, which dropped the entry's navigation state, so the record never reached the arriving document; it writes the state back to the renamed entry. - The record's thread claim opens the thread where the user stands, moving no scroller (`scroll: false`), so a card whose passage a revision moved into a closed tab opens in the floating panel, as the margin's revision rule had it (`test_a_card_open_across_a_revision_opens_where_its_passage_stands`). - carry.js names a control a view draws in a thread, as a card's Close on its head line, by its place in the thread's drawing, so a user on Close comes back to it, and to the thread where it reopens elsewhere. - The eight revision tests the earlier attempt failed pass: the message the user was on, the scrolled-away reply, the resolved reply session and editor identity. Also: - Focus on a control inside a draft's box, as a drawing's Undo, names the draft and the control within its box (drafts.js `draftFocus`, input.js `boxOf`), so a reload reopens the box on that control (`test_a_reload_keeps_focus_on_a_control_in_a_comment_box`). - A message selection counts its ends within the message's body, which the age in its head no longer shifts (`test_back_returns_words_selected_in_a_message`, now with the age changed between leaving and returning). - The record is written as the page is hidden too, since a hidden tab can be discarded without `beforeunload` (`test_a_tab_discarded_while_hidden_comes_back_where_it_was_left`). - carry.js `focusByKey` focuses what a key names with its caret; history and the panel's and margin's in-place revision restorations call it, which gives those two the caret they dropped. - `test_history_returns_a_selection_with_its_trailing_space` covers a page selection's trailing space, which the exact ends already kept. - version.js's header and `installArrival` say how each arrival is placed now; the view saved at `pagehide` still places a new navigation in the same tab, whose new entry holds no record. Max asked for the entry record as the second half of Fable's review; this follows Codex's third review.
…message selections by what they are A document's arrival is now one operation bound to the entry it arrived at (history.js, `beginArrival`): the entry's record, one intent that every part of the arrival runs under, a revision's handoff included, and the handoff's extras, which the arrival holds until the record's return and the handoff's landing have both run. Failing tests first, Chromium and Firefox unless noted: - Back while a revision's reload still arrives ends that arrival: any navigation away ends it, and a traversal taken while the page still starts returns to its own record once the page has presented, rather than the delayed arrival putting the page back at the revision's entry (`test_back_during_a_revisions_arrival_ends_it`; it failed in Chromium, where the history listener was already up; in Firefox Back often came before it). - Until the arrival settles, a departure, the hidden page's checkpoint and a second revision's handoff write what the arrival owes, not a reading of the page it is still putting back (`readRecord`, version.js `reloadInto`): `test_a_revision_during_a_revisions_arrival_keeps_what_it_owes` (the comparison and the selection) and `test_hiding_the_page_while_it_arrives_keeps_what_the_arrival_owes`. - The handoff's early focus of an authored control runs under the arrival's intent, so it no longer ends the record's return of the user's place (`test_a_revision_keeps_a_field_being_typed_in_where_it_stood`: the field had moved 412px in Firefox, 40px in Chromium). - The arrival runs in order: the handoff readies the page for the record's claim, as by opening again the session of a reply being written; the record's return follows; the words being written go back after it, into the box it put the user in. So a reply written in the floating panel stays there rather than moving into a card, a passage a revision hid stays hidden, and a resolved thread's reply session still comes back in its card (`test_executable_revision_keeps_a_reply_where_it_was_written`, `test_live_executable_replacement_keeps_a_resolved_reply_session`). `thread-link-back` has the panel-reply defect too: its handoff opened the reply's thread itself, outside the record's claim. Also: - bootstrap.js renames the entry through one helper that keeps its state, which startup's recovery now uses too when it marks the address (`test_a_reload_recovery_asks_for_again_returns_to_the_record`). - Leaf's own thread controls declare `data-lf-carry` keys (Close, Resolve or Reopen, Show on page; the card's Dismiss, Previous, Next and Open in panel), which carry's key names in place of the position it named them by, found in the thread's drawing or the view the chrome declares beside it, as the floating panel's head (`test_a_reload_keeps_focus_on_a_control_of_a_thread_view`). The card's Close is `dismiss`, its own key, since it does what the panel's Close doesn't, so a return that opens the thread in the panel lands on the thread. The margin's own capture of the card's Close is gone. - A message selection keeps its words with its offsets, and comes back at the offsets where the words still stand there, else at their one place in the message, else not at all (`test_back_returns_words_selected_in_a_message[edit]`, `[gone]`). - A page selection's ends count from where its passage starts in the reading holding its first words. Asking that reading for a passage across data, which runs into other parts' readings, threw, and broke a reply's continuation on a diff since the record's exact ends landed (`test_tab_browsing_continues_a_displaced_reply_without_an_annotation_overlay`, which failed from 9cf59a5 on and passes on `thread-link-back`). Behavior another test protected that changes: Back to a thread the user left by Show on page returns to Show on page itself, not to the view as a whole (`test_back_reopens_the_thread_its_departure_put_away[Show on page]`). Max asked for the entry record as the second half of Fable's review; this follows Codex's fourth review.
…s again by the quote rules One restoration at a time now returns the user to an entry's record, whether the document arrives at its entry (a reload, or Back or Forward from another document) or a traversal moves within it (history.js, `beginRestoration`). Each is one ordered operation under one intent that every route it starts runs under: the fresh visit's thread arrival, the fragment landing, the thread claim, the draft routes, whose return is awaited, and the comparison, rechecked after its wait. A newer restoration, or any navigation but the document's own rename, aborts it: an `AbortController`, joined with the traversal's own `NavigateEvent.signal`. Until it settles, a departure, the hidden checkpoint and a revision's handoff write the record and extras it owes, while the user has given no input since. This replaces `beginArrival`'s latch and its three acknowledgements (`prepared`, `returned`, `landed`), the intents the fresh thread arrival, the fragment landing, the thread claim and the draft routes captured for themselves, and `threadControl`'s root-wide search. Failing tests first, Chromium and Firefox: - Two Backs while the page starts leave the entry the first reached its record (`test_two_backs_while_the_page_starts_leave_each_entry_its_record`; it failed in Firefox). - A visit whose address moves before it presents opens no stale thread and doesn't name it again (`test_a_visit_whose_address_moves_while_it_starts_opens_no_stale_thread`, push and replace). The thread arrival reads the address with the entry it arrives at, so a Back taken before history listened still returns to that entry's record. - A message selection is a passage of the message's body, captured with its words on each side and found again by the quote rules, a unique match in its context or the sole copy, never an offset among copies (passages.js `messageReading`, `passageIn`, `findQuote`). That deletes history.js's Range walk, TreeWalker and `indexOf` matching (`test_back_returns_words_selected_in_a_message[copy]`). A caret in a message, which holds no words, is no longer kept. - A page selection across lines of a diff is read and found again in the run of words across its data, the reading its anchor is captured in (passages.js `runReading`), so it comes back (`test_history_returns_a_selection_across_lines_of_a_diff`). - Thread controls are found through a declared part, `controls`, in place of a search of the root for sibling views (thread/selectors.js). Runtime code is 226 lines added and 230 removed against ebf2123. Max asked for the entry record as the second half of Fable's review; this follows Codex's fifth review.
…tion own its work to the end A restoration now settles only once every piece of work it runs has: its fresh thread arrival and the last fragment landing, which leaf.js scheduled beside it, join its lifetime (history.js, `run`), so a navigation finds it to abort until the last has run. Fragment travel a traversal starts runs under the traversal's intent rather than one it captured (anchor-travel.js, `returnToFragment`). And the context that tells a passage apart is one capture, widened until it finds the passage itself (passages.js, `passageContext`), which anchor capture and a selection in a message both ask, so `passageIn`'s fixed-width context goes. Failing tests first, Chromium and Firefox: - Words a message says twice, among neighbours alike for 24 characters, come back as the copy selected (`test_back_returns_one_of_two_like_passages_selected_in_a_message`; c513b1a stored no selection, ebf2123 kept it). - A visit to a fragment whose page leaves that address while deferred work still arrives doesn't land on the fragment when the work comes in (`test_a_visit_whose_address_drops_its_fragment_doesnt_land_on_it_later`, push and replace; it scrolled about 2,720px). - Back to a widget's part the widget has yet to draw, then a move to another address, takes the user nowhere once the part is drawn (`test_a_traversal_left_before_its_part_is_drawn_doesnt_travel_to_it`; it scrolled about 600px). Runtime code is 57 lines added and 53 removed against c513b1a. Max asked for the entry record as the second half of Fable's review; this follows Codex's sixth review.
leaf-agent
left a comment
There was a problem hiding this comment.
Two regressions in the arrival path are noted inline: a thread Back or a reload restores can still open after the user has moved on, and a revision's reload can skip the whole return to the entry's record.
#6778 overlaps this change in version.js, history.js, floating-panel.js and drafts.js, and it fixes the same reload loss a different way. It grows the revision handoff with the panel's list and row (captureCurrentLocation) and the reader a reply was written in (readerOf). This PR moves those facts into the entry's record and drops retainedCurrentLocation from the handoff. Whichever lands second has to choose one owner for them, or the handoff and the record will both restore the panel's list on a revision's reload.
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_
…return to the entry when a reply's words are gone Tend's two findings on #6860, each with a test that failed first in Chromium and Firefox: - A restoration's intent now stays available only until the user's own input, as well as until it is aborted (history.js, `beginRestoration`'s `stands`, which `owes` shares). Before, input ended the intent's focus-checking call but not `available`, which a route without focus asks (thread/destination.js, `openPageThread`), so the thread a traversal's or a reload's claim opened could still open after the user pressed a key or scrolled. With the bound in the one intent, `arrive` (thread/address.js) drops the re-restriction it made of its own arrival intent for the same reason, and `claim` needs none (`test_a_restoration_ends_at_the_users_own_input`, key and wheel). An exported page's `?thread=` arrival, which no restoration carries, now opens beside a fragment after input before presentation, where the re-restriction stopped it. - A revision's reload whose reply another tab sent or cleared meanwhile returns the user to the entry. `restoreReplyEditing` (thread/replies.js) returned without running `land` where the reply's session no longer stood, and so skipped the record's return that `keepReplySession` (version.js) runs inside it: no thread, place, focus or selection came back. It now runs `land` with no session kept (`test_executable_revision_whose_reply_another_tab_cleared_returns_to_the_entry`). The arrival's other early return, on an intent already ended, skips nothing the record's return would do, and an exception the continuity reports is the only other way past it. `write_draft_elsewhere` takes the record it writes over, so a test can write while the page's tab is mid-navigation and can't answer. Runtime code is 5 lines added and 6 removed against f85028d.
Conflicts resolved in browser/runtime/carry.js, composing/input.js, floating-panel.js, version.js and tests/browser/threads/test_navigation.py. > _This was written by Claude Code on behalf of max-sixty_
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_
> _This was written by Claude Code on behalf of max-sixty_
> _This was written by Claude Code on behalf of max-sixty_
…r a list The floating panel's header now records the call the user made: one Escape puts away a thread opened over Threads or On Me, as it does any other view, and Back returns to that list. Rejected was Escape stepping back to Threads at the thread's row, with a second Escape putting the list away. No behavior changes. > _This was written by Claude Code on behalf of max-sixty_
…old its keys until that return settles #6778 kept the user's place across the reload a restarted server forces by growing the reload's handoff (version.js, `handOff`). This branch's entry record (history.js) now returns the user to every reload, so the copies #6778 added for the same places go, and each behavior has one owner: - The reader a reply was written in, the floating panel's view or the thread's card: was the handoff's `replyReader`, read through `threadReader` and thread/destination.js's `readerOf`; now the record's thread view, whose `reader` the claim passes on (thread/address.js). This commit removes `readerOf`; the earlier merge of thread-link-back removed `threadReader` and `replyReader`. - The panel's open list, its row and its scroll: was the list branch of floating-panel.js's `captureCurrentLocation` and `restoreCurrentLocation`, carried in the handoff; now the record's list (history.js, `listShown`). The earlier merge removed that branch. - Keys typed while the reload loads: were released once the handoff's own restore finished (`landArrival`); now they wait for the arrival's restoration to settle (history.js, `settled`), which includes the record's return, so a key such as `r` acts in the thread view the record reopens rather than wherever focus stood when the handoff finished. A restoration now ends at the user's input within the entry (focus.js, `entryInputCount`): Back and Forward end it as navigations, and the entry they leave still gets the record the restoration owes it (`owes`), rather than a reading of a page half put back. `installArrival` takes the arrival it joins, which every caller has, so its fallback intent and the composition input it was built from go. `test_a_key_typed_through_the_reload_acts_where_the_user_is_put_back` (Chromium and Firefox) presses `r` as the tab reloads with a panel thread open, and checks that it resolves that thread. > _This was written by Claude Code on behalf of max-sixty_
…d from Threads Since #6796, a press on a row of Threads opens a thread about a passage beside its passage unless the user chose the panel, and main's own tests choose the panel first where they mean the panel's view. This branch's tests of Back to Threads' row and of a reload's return to a panel thread view do the same (`choose_threads_in_panel`). `test_a_reload_keeps_a_thread_in_the_reader_it_showed` then turns the choice back to cards before the reload, so it still checks that the entry's record, not the choice, keeps the view the user stood in. > _This was written by Claude Code on behalf of max-sixty_
…ndoff came to it Codex's AN: before install, prepaint handed on only a handoff it had been handed (`handoff &&`). A fresh visit whose module failed, where the user typed into an `autocomplete="off"` field, therefore lost the words when startup recovery reloaded it: `inputs.edited` knew the field had changed, but nothing carried its value. Now a document whose runtime hasn't installed its arrival hands on what it owes of the document on every departure: the handoff it was handed, if any, and the state of each control the user changed (the one-home predicates in document-inputs.js). A fresh one names no revision, since it carries only those controls. version.js accepts a handoff without a revision, and still requires that one which names a revision be no newer than the document. Test: `test_startup_recovery_s_reload_keeps_words_typed_before_leaf_started` makes a new visit whose rendering module fails once, has the user type Grace while recovery's probe waits, and lets recovery reload the page. At bb6fd18 the field came back empty; here it holds Grace. > _This was written by Claude Code on behalf of max-sixty_
Brings in main's six newer commits, through e7d5808 (#6998). One conflict, in the imports of browser/runtime/annotation-overlay/margin-projection.js. This branch imports `focusByKey` and `focusKey` from carry.js, so that Back returns the user to where they were in a card. #6998 moved `rove` out of focus.js into lib/roving.js and imports it from there. The resolution keeps both imports. The rest of the file merged cleanly, as main plus this branch's card changes. None of the incoming commits touches history.js, version.js, prepaint.js, bootstrap.js, carry.js, document-inputs.js or leaf.js. Their thread changes are these: - #6995 changes how a widget says its seats changed (`lf-layout`) and releases an outlet through the surface handle. - #6997 changes how a live sample's growth is held. - #6998 moves `el` and `rove` into the library. None of them changes thread destinations, the entry's record or the handoff. > _This was written by Claude Code on behalf of max-sixty_
Codex's AP: a document that starts hidden, as Leaf's reload of a background tab brings, read and removed the stored handoff at its first script. It never wrote the handoff back, since it never went from visible to hidden. A discard before install then lost what the handoff carried. prepaint's rule is that the tab holds what a document would hand on while it isn't standing in view. A document that starts hidden now writes what it hands on at its first script, as a hide does, and a page shown again still removes it. prepaint's header now also says what a same-page frame can do (AL): its first script, its return to view and its departure can remove the page's handoff, not only overwrite it. Test: `test_a_page_that_starts_hidden_keeps_its_handoff_in_the_tab` makes a Leaf reload's document start hidden, through an init script that sets `visibilityState`, and reads the tab before Leaf starts. At cd01db9 it held nothing; here it holds Ada. > _This was written by Claude Code on behalf of max-sixty_
Codex's AO: bootstrap's key hold took any handoff as a place handed back (`handedBack = handoff !== null`). A handoff of values alone therefore exempted held keys from the input clock, and version.js held them until the arrival settled. 0d78f47 made values-only handoffs common, as after a startup recovery, and an unplaced one after Back already did this. Codex's sequence: open `?thread=T`, startup fails, the user edits a field, and recovery reloads with values but no place. A key pressed while the page starts then no longer ended the arrival, which focused T and ran the key there. Whether a handoff puts the user back where they were now has one statement: prepaint's `placesUser()`. It is true only while the document stands at the entry the place was read at, by that entry's key. - bootstrap asks it for `handedBack`. The held-key run it restores and `typingBack` follow from that. - version.js asks it at install for `placed`, which also decides whether keys wait for the hand-back (`handingBackPlace`). `placesUser()` is a predicate rather than an `entry` field that prepaint trims at the first script, because the answer can change before install: Back taken before Leaf starts moves the document to another entry, and the arrival must see that. `placed` no longer checks `view.revision`, since every writer of `entry` writes a view with it. Test: `test_a_key_typed_while_a_page_handed_only_values_starts_ends_its_arrival` has two threads, opens the page at `?thread=one` with its module failing, has the user type Grace, and lets recovery reload. It then holds the first reading, presses `t`, and expects thread one focused, as on a fresh load. At cd01db9 the arrival focused one, and the held `t` walked on to two. > _This was written by Claude Code on behalf of max-sixty_
…er's step to it The arrival's clock counted the user's inputs from the document's start (`entryInputCount`, `count - away`), though `beginArrival` says it counts their inputs within the entry. So a key the hold doesn't keep, a press or a scroll at one entry, followed by Back to another before Leaf started handling steps, counted against the arrival at the entry Back reached, and that entry's record wasn't returned. document-inputs.js now keeps `within`: the inputs since the user's latest step Back or Forward, or since the document started, but for leaving the window. A step resets it. `entryInputCount` reads it, so the arrival and every return to an entry's record yield only to what the user did at that entry. After install a traversal already started its own count at the step, so nothing changes there. Test: `test_a_key_before_back_taken_before_leaf_starts_leaves_the_entry_its_record`. A Leaf reload at the second thread's entry is held before Leaf starts; the user presses ArrowDown there, which the hold doesn't keep, then goes Back to the first thread's entry. At 7987ffb the first thread's card never opened; here it opens and takes focus, as the entry's record says. A wheel wasn't a reliable trigger for this test. While the page held its rendering, Chromium delivered the DOM `wheel` event after the step, so it counted at the entry Back reached. A probe showed `count` at 1 with only the step counted, then 2 after Leaf started. A key is delivered at once. > _This was written by Claude Code on behalf of max-sixty_
The bootstrap's held-key run let its keys go on a counted input only where a reload handed back a place, because the hold API's `counted` callback was installed only then. Elsewhere, keys typed at one entry outlived a step Back or Forward taken before the runtime took them, and ran at the entry the step reached. - Without a handoff: keys pressed while a reloaded page started, then Back to another entry, ran there. - Codex's AR, which 7987ffb introduced: a reload at B handed on a place for A. bootstrap installed no callback there, so a key pressed at B rode Forward to A, ran at A and ended A's return. A run's lifetime is now separate from its clock exemption. bootstrap installs the hold on every load. `counted` now says whether the input was a step (document-inputs.js). A step lets the run go whatever the load; any other input lets it go only while a place is handed back. The clock exemption (`holds`) applies only while a place is handed back. bootstrap now asks `placesUser()` and `typingBack()` as each input comes, rather than once at its start, since a step can move the user onto or off the entry the handoff's place belongs to. Tests: - `test_keys_held_at_an_entry_go_when_back_leaves_it_before_leaf_starts`: the user reloads a started page, so nothing is handed on, presses `T` before Leaf starts, and goes Back. - `test_a_key_pressed_before_forward_to_the_reload_s_entry_goes_with_the_step` (AR): a Leaf reload at the second thread's entry, then Back, the user's reload of the first thread's entry and `t` there, then Forward, all before Leaf starts. At 7987ffb the held key still showed after the step in both. Here it goes, the first test's entry gets its record back, and AR's entry gets the reply being written there. > _This was written by Claude Code on behalf of max-sixty_
Brings in #6999 (0ff5679). In it, a package module looks up any address with `elementById(address, from)` and any registry entry with `layerFact`, and four lookups leave the package API. One conflict, in browser/runtime/check-api.js's exports from ui-marks.js: - #6999 added `inChrome` beside `uiInside`. - This branch added the line after it, `export { anchoringIsReady } from "./anchor-resolution.js";`, which the readiness tests ask the check API for. The resolution keeps both: `export { inChrome, uiInside } from "./ui-marks.js";` followed by the `anchoringIsReady` export. #6999 also changes the runtime's `elementById` in passages.js to look a root's id up through the root's tree first, under the same contract. This branch's callers, carry.js `restoreCarry` and version.js's arrival filter, pass `pageDocument()` and get the same answers. The merge touches nothing else this branch changed. > _This was written by Claude Code on behalf of max-sixty_
…er's latest step Codex's AS: 9539ab6 counted the user's inputs within an entry by resetting `within` at each step. A restoration compares counts for equality (`moved`, `owes`), so the reset made one the user's input had superseded current again. The route: a reload at A whose return is still pending, an act there, then Back to B. The reset came before history's `navigate` handler. That handler wrote A's departing state as the restoration's old record (`readRecord`, while the restoration seemed to owe it), so Forward to A returned the user to the reload's place rather than where they had moved to. The `popstate` path, in an opaque frame, could revive an arrival the same way. The clock no longer resets: `entryInputCount` is `count - away` again, which only grows. document-inputs.js records its value at each step (`entered`), and `beginArrival` counts from there (`enteredInputCount`) rather than from 0. What the user did at the entry they left still doesn't keep the arrival at the entry Back reached from its record, which was 9539ab6's aim, and a superseded return stays superseded. Test: `test_a_step_after_the_user_left_a_pending_return_keeps_their_newer_place`. A reload of the `#p20` entry is held on its first reading once the arrival is installed. The user presses End there, steps Back and then Forward. At d2dfdd7 Forward landed at scrollY 1446, the reload's place; here it lands at the page's end, where the user had moved to. Round 12's case (a) still passes. > _This was written by Claude Code on behalf of max-sixty_
Codex's AT, already true at 7987ffb: once the keyboard controller had taken the held run (`taken`), a step Back or Forward let nothing go. The controller presses one key per frame, so the keys still to be pressed ran at the entry the step reached: typed into a box there, or as commands during its return. A step now lets the run go whether or not the runtime has taken it. The controller's `keys` is the hold's own array, so the next frame finds it empty, and the controller releases the run and stops. Any other counted input still lets a run go only while it is waiting and a place is being handed back. Test: `test_held_keys_still_to_run_go_when_the_user_steps_back`. A page script makes each frame take 250 ms once Leaf takes the keys, so the user can act between replays. The user typed `chello` at `#said` while Leaf loaded, and steps Back once the runtime has taken the run. At d2dfdd7 the tab still held `ello` after the step; here it holds none, and no held key is shown. > _This was written by Claude Code on behalf of max-sixty_
…pt takes Codex's AU: 417ec99 let a held run go on every traversal, including one the page's own script takes, as an authored `history.back()` while the user's keys wait. That dropped words the user typed without their cancelling them. document-inputs.js now passes the Navigation API's `NavigateEvent.userInitiated` with each step, and the hold lets its run go only for the user's own step. A step the page's script takes leaves the run held, as before round 12, and its keys land at the entry the script took the page to. `popstate`, in an opaque frame, can't tell, so its step counts as the user's, as the clock already counts it. The clock counts every step, the script's included, so the arrival's baseline (`entered`) still moves with it. What `userInitiated` reads, measured with the suite's browsers: - Chromium 159: true for Playwright's `go_back` and `go_forward`, false for a page's `history.back()`. - Firefox 159: false for all four. Firefox therefore keeps a held run through the user's Back, at least as Playwright takes it. That is the reading that keeps the words. A real toolbar Back in Firefox wasn't measured. Tests: - `test_held_words_outlast_a_step_the_page_takes_itself`: `chi` held through a scripted `history.back()` ends as "hi" in the comment box. At d2dfdd7 the held keys were gone after the step. - Round 12's held-key tests now take the user's own steps (`page.go_back`, `page.go_forward`) rather than a script's, since a script's no longer lets the run go. > _This was written by Claude Code on behalf of max-sixty_
The comment on `step` now says what Firefox does and why. It reports no traversal as the user's, the browser's own Back included: both of Gecko's callers of `FireTraverseNavigateEvent` pass no user involvement (Gecko bug 1903552, "Track user navigation involvement"). So in Firefox a held run outlives the user's step, and its keys run at the entry the step reached. Before, the comment read as a measurement quirk. No code changes. > _This was written by Claude Code on behalf of max-sixty_
Brings in two main commits: - #7001 (9fc720c): a widget's walk is said through an `lf-walk` event, and `beginWalk`, `listWalkPosition`, `labelOf` and `saying` leave the package API. - #7002 (097bee4): the reading line is read inside `holdPlace`, which now takes a column; the old one-node hold is `holdPlaceOf`, and `readingAt` leaves the package API. One conflict, in the imports of browser/runtime/floating-panel.js: - This branch added `import { focusByKey, focusKey } from "./carry.js"` above the user-place import. - #7002 renamed that import's `holdPlace` to `holdPlaceOf`. The resolution keeps the carry.js import and main's `import { focusPlace, holdPlaceOf, standsAt } from "./user-place.js"`. main's other floating-panel changes merged cleanly: the press hold calls `holdPlaceOf(node)`, and a tab's preview reads `commandBindingsNow`. Nothing this branch adds or moves calls a name main took out of the package API or the old one-node `holdPlace`. check-api.js, runtime-globals.d.ts and module-scroll-and-motion.md merged cleanly, with both sides' additions: - check-api.js: main's `beginWalk` export and this branch's `anchoringIsReady`. - runtime-globals.d.ts: main's `lf-walk` event and announce words, and this branch's `DocumentInputs` and `lfStorage` members. - module-scroll-and-motion.md: main's `holdPlace(column, standIn)` and `{ words, rows }` text, and this branch's entry-state paragraph. > _This was written by Claude Code on behalf of max-sixty_
Codex's AV and AW: c125b6e still let a step the page's script takes drop the user's held words in two cases. - AV: during a reload Leaf asked for, with a place handed back, a scripted step's `counted(false)` met `!taken && placesUser()`, since the departing entry is still current at `navigate`, so the hold let the run go. This finished AU's fix rather than being a regression. - AW: in an opaque frame, where only `popstate` fires, every step counted as the user's (`step(true)`). That let a run go, and since 18a8cf1 a taken one too. A step now always moves the clock and the arrival's baseline (`entered`), but only one the browser says the user took notifies the hold (`if (user) hold?.counted(true)`). A scripted step no longer reaches the hold as an ordinary input. `popstate` can't say who stepped, so it counts as the page's step (`step(false)`) and lets nothing go, the same reading as Firefox, whose user steps also report false. There the keys stay and run where the user then stands. The comments in document-inputs.js (`step`, the hold), bootstrap.js and the `counted` type now state that one rule. Tests: `test_held_words_outlast_a_step_the_page_takes_itself` now runs three ways: - after the user's reload, as before; - after a reload Leaf asks for that hands back a place (AV); - in a page whose Navigation API holds no entries, so it hears of steps only through `popstate`, as a live sample's frame does (AW). An init script makes `navigation.currentEntry` read null. In each, `chi` is held and the page's own `history.back()` runs before Leaf starts. At 9026577 the second and third lost the held keys at the step; here all three keep them and end with "hi" in the comment box. > _This was written by Claude Code on behalf of max-sixty_
…wait (#7090) When Leaf reloads a page while the user is writing, as for a new revision or a restarted server, the letters typed before it puts them back were dropped if they scrolled, clicked, pressed a key that prints nothing or stepped Back first, or if the page failed to start. SOUL.md promises to drop typed words only when the user no longer wants them. Now each letter goes into its box as it is typed: - **In a reply or comment**, it goes into the draft. The panel shows the letters as "kept in the draft", and the box comes back holding them with the caret after them. If the box doesn't come back, the panel says "Draft kept" with Resume writing. Attached pictures stay attached. - **In a text field of the page's own**, it goes into the field's value, and the page hears it as input. A password never reaches the draft store. A date, time or number field, which has no caret to type at, takes the key once the user is back, as before. - **After the user moves on**, keys they press are page keys again. For the caret to land after the letters, focus on a control of the page's own and its caret now have one owner on arrival, the reload's handoff, rather than the handoff and then the entry's record. The record still returns the page's selection, and still lands at the reading place where the revision dropped the control (history.js header). Still open: no leave prompt before Leaf's modules load; a number field's digits are dropped if the user scrolls first, as before; a page field's letters when the page opens at a new history entry; editable areas and fields a widget generates. The maintainer asked for this as the follow-up to #6860; an independent agent reviewed it over four rounds. Tests: a case in `test_readiness.py` for each route, in Chromium and Firefox, each failing before the change, plus ones that hold main's behaviour for the page's selection, the landing at the reading place and fields with no caret; the focused selections, `pnpm run test:runtime` and `pnpm run check` pass. > _This was written by Claude Code on behalf of max-sixty_
…rneys (#7186) #6860 puts the user back where each history entry's record says on every reload. Three nightly-only journeys still expected the arrival from before it. They have failed since that commit. Each test now expects what #6860 says a reload does, and keeps checking the behavior it protected: - **`test_words_typed_on_a_reload_stand_over_the_send_it_cut_short`**: the send took the user out of the comment box, so after the second reload the record no longer puts them back in it. #6860 dropped the `c` from `_type_on_arrival` and added it to the browser-tier sibling (`…_over_a_resend_landing_after_a_rewrite`) for this case. This journey imports that helper but wasn't updated. It now presses `c` the same way. - **`test_executable_revision_does_not_restore_a_new_draft_generation`**: the `history.js` header says the record's return puts the user back in a draft's box without checking the draft. Only the handoff's restore stands down once another tab has rewritten it. So focus comes back to the reply. The test no longer expects no editing session. It checks that the box holds the other tab's generation (its attempt and words, from the drafts store), and still checks that the stored draft is the other tab's. - **`test_an_emptied_rewrite_keeps_nothing_and_saved_deletes_its_message`**: the reload now puts the user back in the rewrite, which holds the message's own words and nothing kept (the failing run's screenshot shows that box open). The old `dblclick` timed out on message text that the open editor replaced. The test now checks that the open box is focused and holds the message's words. None of these changes Leaf's behavior. They follow #6860's stated intent, so the repair gives none of it up. All three failed on `main` at `32dc564a8` with the errors in #7172. With this change, each passed in three runs in a row. Closes #7172 — automated triage Co-authored-by: leaf-agent <[email protected]>
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.
history.jsheader): as the user leaves the entry. A route's push writes it,beforeunloadwrites it for a reload or another document, and so does hiding the page.history.replaceStatedrops an entry's state, sobootstrap.jsrenames the URL through onerenamethat keeps it.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.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.jsalone 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 marksuserInitiated, 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 onlypopstate, and in Firefox, which reports no step as the user's, the toolbar's Back included (Gecko bug 1903552). The words are kept either way.data-lf-carryon Leaf's thread controls,data-lf-keyon 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 ofanchorForPassage.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.pyanddrafts/test_revisions.py, in Chromium and Firefox; the focused selections around them,test:runtimeandpnpm run checkpass. 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'schrome.tabs.discardshowed 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.