Repository navigation
Previews show only where the user aims, and say only what the target doesn't - #5746
Conversation
…doesn't Two rules now decide whether a preview shows. A preview answers aiming, not arriving. A resting pointer, Tab and a held finger read one; a command's landing reads nothing: a walk such as `m`, an arrow key, a surface placing focus as it opens or handing it back. `m` used to preview the margin entry it landed on, over the words beside it. `K` (Shift+k, `preview.show`) reads the preview where focus stands on demand, as Neovim's K and VS Code's Show Hover do, so a landing's preview, such as a message's clock time, stays one key away. With walks no longer previewing, the record of each layer's opening input that told a surface's own placement apart from a walk (`layerOpened`, `openedThisInput`) goes. A preview says what its target doesn't. Every reading drops a line its target's face shows uncut, and shows nothing when only the face's own words are left (`beyondFace`); a face that cuts its words keeps every line. A control's face now counts the words of the labels beside it and a select's chosen option rather than every option, and says its name when either holds the other's words, so a select inside a <label> no longer previews "1× 0.5× 0.25×", and "Send reply" labelled "Send" previews nothing. A diagram names its drawing with `aria-label` instead of Pele's `<title>`, which the browser showed as a tooltip of the diagram's name over the whole drawing. Leaf's own titles on Next unread and Next On Me go, the page search count stops previewing its own words, and a screenshot's divider and open link no longer preview the image's alt. browser/AGENTS.md, keyboard/AGENTS.md, interface-goals.md, module-input.md and the glossary state both rules. Tests: a walk's landing previews nothing in a card it opens or one already open; a face shown whole previews nothing and a cut one does; the diagram smoke case checks the name moved.
…wser shows as a tooltip A drawing's <title> pops up as a native tooltip over every part of it, and in Leaf it only repeated the figcaption or the words beside it. The reading package now asks for an aria-label stating the drawing's point, and the docs, gallery and registry examples use it.
Tab shows a focus preview under the current rules and under #5746, which stops an arrow key's landing from previewing; the test is about the description a Tab-shown preview adds, so it no longer depends on the arrow landing.
… let K reach inside dialogs Codex's review and the audit's re-check of #5746 found four ways the face rule misjudged what the user sees. Words an ancestor clipped, such as a version note inside a label ending in an ellipsis, counted as shown, so their preview went. A hidden label counted as a control's face, so a slider named only by aria-label lost its name. In Firefox the root scroller reads as a window-tall box at the page's top, so once the page scrolled, every face counted as cut and controls previewed their own names. And the check read every descendant's size, 10,002 reads for a large titled section. `shownWhole` now reads a target's text run by run: a run counts if it renders and no box between it and the body clips it, and the read stops after a few lines (`FACE`). A press whose key chip the face draws is dropped like a line the face shows. A control's content name is read run by run less aria-hidden chips, so a menu row whose words and chip stand apart, such as the panel's Undo row, matches its face. `K` moves from a page command to a scope rooted at focus, so a modal dialog, which makes the page's own commands inert, keeps it.
Two more rounds of Codex review found the face rule's own clip walk wrong in ways
geometry.js already answers: transforms, positioned and fixed boxes and their containing
blocks, display: contents, and the root scroller. `faceOf` now asks `clippedContents`, the
walk previews already place by, whether each run is left whole, and `drawsText`, moved
from reading-place.js to geometry.js, whether the browser draws it.
A face is now a structured reading: its runs read apart and joined (so a word split by
its markup matches), whether any word or number it holds doesn't show (`partial`, so a
face showing only the start of a name doesn't stand for it), and the key chips it shows
in order. A select's options are its list, not hidden words. A control past the face
budget is content: only a name its markup gives previews over it, and its content name,
now its rendered text, is read only within the budget, as a label's text is.
lf-options' pick mark declares only the word its shape stands for ("choose one"), since
the option's words stand beside it and its position is a listener's.
leaf-agent
left a comment
There was a problem hiding this comment.
faceOf counts the text it's told to skip against FACE, so a label holding a long <select> drops out of the control's face. controlFace calls faceOf(label, control), which subtracts every option's characters from room before the skip check. Once the options pass ~300 characters, for example a country list, it returns null, and the ?? [] removes the label from the face entirely. markupName still returns the label's text through labelText, which skips the control before counting, so faceSays misses and the preview shows the label the user is looking at. That is the case the description says this PR fixes ("a <select> inside a <label>, which previewed all its options"), and it comes back for long selects. Checking skip before charging the budget brings it into line with labelText.
…e budget The review on dab9640 found that `faceOf` charged a label's select options against `FACE` before skipping them, so a label holding a list of more than about 300 characters, such as a country list, had no face. Its control then previewed the label the user was looking at, the case this branch fixes for a short select. Reading a face and a label's text now walks past the control and a select's or datalist's options without entering them (`faceWalker`), so they cost neither room nor time however long the list. The face-rule test gains a label over a 60-option select whose options don't repeat the label's word; it fails on the previous walk in both engines.
#5746 made a command's landing preview nothing: focus that code places, an arrow key's step and a surface handing focus back show no preview until the user presses K. Its pull request ran only the browser tests whose source it changed, so 13 browser and journey tests (16 cases) on `main` still expected the old landing preview and now fail there. I found them by running every later-tier test whose body reads a preview (125 of them) on merged `main`. Each of the 16 cases passes on the commit before #5746 and fails on it, and all of them pass with this change. - **Incidental Escape steps.** Most of these tests put a preview away before Escape (`put_preview_away`) only so the next Escape reached the step under test. With no preview standing, that step goes: three key-scope tests, an anchors test, three reaction tests, the rewrite test's four seats, the All pages keyboard journey and the diff outlet's attachment journey. - **The Undo row.** Two outbox tests read the row's words from its preview. The row shows its words whole, so under #5746's face rule it previews nothing, and the tests assert the row's label and age instead. - **Threads' notice.** This test checks that a landed row's preview stands clear of a notice arriving under it. It now asserts that the landing showed nothing, then reads that preview with K. `test_a_root_summary_keeps_thread_actions_outside_its_fold[1400-True-10]` and the outbox test's teardown write on `.lf-fp-quick` (#4745) also fail on the base, so they're inherited. > _This was written by Claude Code on behalf of max-sixty_
…e Escape (#5791) `test_the_keyboard_reference_is_a_modal_tab_loop_and_returns_to_its_door` has failed on every push run on `main` since #5746, starting with [42618688222](https://github.com/max-sixty/leaf/actions/runs/42618688222). It fails with `Locator expected to be hidden` after the Escape. The test pressed Tab a fixed number of times, the stop count plus two, then pressed Escape once. #5746 added `K` (`preview.show`), so the reference gained one row and one stop. That shifted where the fixed walk ends: on the commit before #5746 it ended on the page body, which has no preview, and now it ends on the Close button. Tab reads Close's preview, and under #5746's rule a standing preview takes the first Escape (`browser/runtime/keyboard/AGENTS.md`, "Escape"). So the reference stayed open. A probe confirmed that a second Escape closes it and returns focus to the door. The test now walks until Tab comes back to Close a second time. That still proves the loop wraps inside the dialog, and the walk ends at the same stop however many command rows there are. Before the Escape under test, it puts the preview away with `put_preview_away`, which fails unless a preview was showing. The product is unchanged, and both #5746's intent and the behavior the test protects still hold. The test fails on `main` at `d2fb80d4c` and passes with this change. Refs #3985 — automated triage Co-authored-by: leaf-agent <[email protected]>
On main, some previews told the user nothing: pressing
mcould land on a margin entry and open its preview over the words beside it, and every diagram showed the browser's tooltip of its own name. This states two rules for when a preview shows and what it may say, and makes the preview owner enforce both rather than fixing the two cases one by one.A preview answers aiming, not arriving. A resting pointer, Tab and a held finger read a preview. A command's landing reads nothing: a walk such as
m, an arrow key through a list, a surface placing focus as it opens or handing it back. The user asked the command for the place it lands on, which is already in front of them, so a preview there covers it and takes their next Escape.K(Shift+k,preview.show) reads the preview where focus stands on demand, as Neovim'sKand VS Code's Show Hover do. Its scope is rooted at focus, so it works inside a modal dialog, where the page's own commands don't reach, so a fact only a landing used to show, such as a message's clock time afterm, is one key away. The record of each layer's opening input (layerOpened,openedThisInput), which existed only to tell a surface's own placement apart from a walk, is deleted.A preview says what its target doesn't.
beyondFacedrops each line of a reading that the target's face shows whole, and each press whose key chips the face shows in order, and shows nothing when only the face's own words are left.faceOfreads the face run by run: a run of text counts only where the browser draws it (drawsText, moved from reading-place.js to geometry.js so both read text the same way) and the clips standing over it leave it whole (geometry.js'sclippedContents, the walk previews already place by), so words cut by an ellipsis, a line clamp, a narrow or scrolled parent, or a visually hidden label stay in the preview. A face with a word or number it doesn't show ispartial, so its first words no longer stand for a longer name it only begins. Lines match the face's runs read apart (a row's words and its key chip) or together (a word its markup splits). The read stops after a few lines (FACE); a control past that is content, and only a name its markup gives previews over it, so a preview over a long section reads no more than one over a button. A control's face counts the labels beside it and a select's chosen option; the name its content gives is the text the browser draws, as a screen reader reads it: each box apart, a word its markup splits whole, andaria-hiddentext left out. Reading a face or a label passes over the control and a select's options without entering them, so a long list costs nothing. Found by an audit of every preview source on main in Firefox, these now preview nothing:<select>inside a<label>, however long its list, which previewed all its options ("1× 0.5× 0.25×", the motion widget's Speed);aria-labelis shorter than its face ("Send reply" labelled "Send"), and command reference rows, whose key chip made the face longer than the name;titleon Next unread and Next On Me, and the trace's Pace select, whosearia-labelrepeated its label;lf-diagram, which now names its drawing witharia-labelrather than Pele's<title>. The docs, examples and the reading package's drawing advice do the same, since the browser shows any SVG<title>as a tooltip over the whole drawing.The rules are written in
browser/AGENTS.md("Pointing reads; pressing acts"),keyboard/AGENTS.md,skills/leaf/references/interface-goals.mdandmodule-input.md(each focus cause's preview behavior), and the glossary.Calls a reviewer may want to reverse:
Kis a new page key. It was free, and it matches Neovim's hover key.rchip), so the chip has something to label.Tests: a walk's landing previews nothing in a card it opens or one already open, and Tab still reads;
Kreads an arrow key's landing inside a modal dialog; a face shown whole previews nothing, on a scrolled page and where markup splits a word, while words cut by their own box or a box around them preview in full, as do a slider whose label is hidden or invisible, a button whose hidden notes run past a face, and a button showing only the start of its name; the diagram smoke case checks the name moved toaria-label. All 188 browser tests named for previews, tooltips or hover were run locally in both engines.