Skip to content

Give the page walks, the working place and focus readings one owner each - #2682

Merged
max-sixty merged 5 commits into
mainfrom
walks-and-place-one-owner
Oct 12, 2026
Merged

max-sixty merged 5 commits into
mainfrom
walks-and-place-one-owner

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Workstream #10 of the duplicate-logic sweep: the t and q walks and More's saved place each read the user's place their own way, so stepping from the caret and restoring a place behaved differently by entry point. This gives the walks, the working place, and every focus reading one owner each.

What changes for the user

  • t/T from the caret. With the caret in a paragraph a thread is on, t and T now open that thread, as q already arrives at an item holding the caret. Both directions used to skip it. Threads anchored inside a widget's shadow tree now order among the places beside them (the walk used to compare them through compareDocumentPosition, which calls cross-tree nodes disconnected), and a thread whose passage no longer resolves is sorted and stepped at the same place, its section, by both walks.
  • More's saved place. More reads and returns the working place through history.js readPlace/returnPlace, which check each selection end against its node's current length. More (and the floating panel's place-keeping rows, which had their own copy, readStanding) now also hold a collapsed caret, as Back does, so a live revision that shortens the caret's text node no longer makes a place-keeping command throw IndexSizeError. returnPlace no longer clears the document selection after restoring a field's caret, which had collapsed a textarea's selection on Back.
  • Keys before load. A printed key pressed on a checkbox or radio before the runtime loads is held and replayed, instead of being treated as typing and dropped.

Owners, and where to look

  • standing-target.js stepFrom: the one step rule for both walks. shadow-tree.js renderedOrder / byRenderedOrder: page order across shadow trees, now used by the thread list, the q walk, the page outline, the Questions panel's section words, the command reference, and annotation-inventory.js (whose copy it was). walkOrigin and placeOf take the node the user stands on, inside any shadow tree; the sides that answered only for light DOM climb across shadow roots.
  • thread/destination.js threadPlace: one reading of a thread's place for sorting and stepping.
  • focus.js focused(tree) replaces keyboard/scopes.js documentFocused; every raw document.activeElement read moved onto focused(), and every "is the user in this scope" read onto standingIn(scope). architecture/standing-reads in eslint.config.mjs refuses a raw activeElement read (save a frame's contentDocument and the editor's closed root) and contains(focused(...)).
  • Four more repeated questions: pointer.js pressIsKeyboardActivation (now exported to packages), control-selectors.js CARET_KEYS / selectsAll, keyboard/hints.js walkRows, and shadow-tree.js under / renderedUnder / composedParentNode. Ctrl/Cmd+Shift+A now keeps the writing caret in a draft, and the target picker's choose command id is target.picker.hint.choose.
  • skills/leaf/assets/AGENTS.md "One answer for each question" has a row for each new owner.

Tests

  • t/T from a caret on a thread's paragraph open that thread (both fail with the old rule).
  • More's Align after a revision shortens the caret's text node (throws IndexSizeError without the length check).
  • A t held from a checkbox before load (fails with the old typing test).
  • stepFrom, renderedOrder, the climbs, and the lint rule under Node.

Focused browser selections over the touched surfaces pass locally (about 550 tests), as do pnpm run test:runtime and eslint over every file.

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

max-sixty and others added 4 commits October 12, 2026 14:55
The t and q walks each stepped from the user's place by their own copy of
the same filter, and the copies disagreed. With the caret in a paragraph a
thread is on, `t` skipped that thread and `T` skipped it the other way,
while `q` arrived at an item holding the caret. The t walk also compared a
light-DOM place with a thread target inside a widget's shadow tree through
`compareDocumentPosition`, which calls them disconnected and orders them
arbitrarily, and it sorted a thread whose passage no longer resolves at its
section but stepped it as if it had no place.

`standing-target.js` now owns the step (`stepFrom`): an item whose place
holds the user's is the nearest either way, so `t` and `T` open the thread
on the caret's paragraph. Both walks read a thread's place as the list
sorts it (`threadPlace`, destination.js, from thread/placement.js). Page
order is read across shadow trees by `renderedOrder` in `shadow-tree.js`,
which annotation-inventory.js already computed for itself; the thread
list, the q walk, the page outline Threads labels sections from, the
Questions panel's section words and the command reference now sort by it.
`walkOrigin` no longer climbs to a shadow host, so places inside one widget
keep their order. `placeOf` takes the node the user stands on, inside any
shadow tree, and the sides that answered only for light DOM (the Threads
panel, the margin card, the details shelf, the Questions list) now climb
across shadow roots, so focus inside a widget in a reply still stands at
the reply's thread.

More held its own copy of the working place and restored raw offsets
checked only for `isConnected`. It now reads and returns the place through
history.js's `readPlace` and `returnPlace`, which already checked every end
against its node's current length. More now holds a collapsed caret too, as
Back does, so that check is what keeps a live revision that shortens the
caret's text node from making a place-keeping command throw IndexSizeError.
`returnPlace` no longer clears the document selection after restoring a
field's caret, which had collapsed a textarea's selection on Back.

Every reading of focus outside focus.js now asks `focused()`, or
`focused(tree)` for the node standing for it in one document or shadow
root, which replaces keyboard/scopes.js's `documentFocused`. The new
`architecture/standing-reads` lint refuses a raw `activeElement` read
elsewhere, save a frame's `contentDocument` and the editor's closed root.
Readers that compared `document.activeElement` now see a label press
holding the user, and those comparing with nodes in a shadow tree see
focus there.

A printed key pressed on a checkbox or radio before the runtime loads is
now held and replayed, as the presented page would take it: bootstrap.js's
typing test spells focus.js's `takesLetters` instead of counting every
input as a text field.

Four more repeated questions get one owner. Every click handler that read
`detail` to tell a keyboard click from a pointer one asks `pointer.js`
`pressIsKeyboardActivation`, which packages reach through `widget-api.js`.
`control-selectors.js` owns `CARET_KEYS` and `selectsAll`. The hint
session declares its Tab/Shift+Tab walk and Enter choose rows once, as
`walkRows`. `shadow-tree.js` owns `under`, `renderedUnder` and
`composedParentNode`; focus.js, keyboard/dispatch.js and passages.js drop
their own climbs. Ctrl/Cmd+Shift+A now keeps the writing caret in a draft,
the target picker's choose command is `target.picker.hint.choose`, and
`renderedUnder` answers true for a shadow root or document holding the node.

Tests: `t`/`T` from a caret on a thread's paragraph open that thread (fail
with the old rule); More's Align after a revision shortens the caret's
text node (throws without the length check); a `t` held from a checkbox
before load (fails with the old typing test); stepFrom, renderedOrder, the
climbs and the lint rule under Node.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	eslint.config.mjs
#	skills/leaf/assets/runtime/banner-toolbar.js
#	skills/leaf/assets/runtime/focus.js
#	skills/leaf/assets/runtime/history.js
#	skills/leaf/assets/runtime/queue-panel.js
#	skills/leaf/assets/runtime/shadow-tree.js
#	skills/leaf/assets/runtime/shadow.js
…ins copies

Review of the walk change found that once the Threads panel's side climbs
across shadow roots, focus deep inside a widget in a panel card passed the
margin's light-DOM `panel.contains(active)` guard and could scroll the card
under the user. Every `scope.contains(focused())` now asks focus.js
`standingIn(scope)`, which climbs as rendered, and the margin's guards read
`renderedUnder`. `architecture/standing-reads` refuses `contains(focused())`.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Closing the margin card with focus inside a widget's shadow tree in it
missed `preview.contains(at)`, so focus fell to the body instead of
returning to the card's button. That read and the ten spelled
`scope.contains(focused(document))` now ask `standingIn(scope)`, and
`architecture/standing-reads` refuses `contains(focused(...))` in either
reading.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
leaf-agent previously approved these changes Oct 12, 2026
The index row named `walkRows`, a method of the session `createHintSession`
returns, which the index test reads as a module export.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 92afd04 into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the walks-and-place-one-owner branch October 12, 2026 22:56
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