Repository navigation
Name every announced key as its press would resolve, and none on a touchscreen - #6702
Conversation
…uchscreen Leaf's screen-reader announcements wrote some keys into their words by hand: Draw mode's "z takes one back. Escape leaves.", Design mode's "Escape leaves.", Select mode's "press Tab to hear targets and Enter to choose. Press slash to search the page.", a chosen search match's "Press n for next, Shift+n for previous, or c to comment.", a heard hint's "Press Enter to choose." and Go-to's "type a hint or press Tab to hear them". Draw and Design also branched on a coarse pointer to say "Exit Draw mode leaves." Max chose on 2026-11-21, on the Leaf page for #6687, to read these keys from the register rather than keep them or drop them. `saying` moves from keyboard/scopes.js to keyboard/control-keys.js, beside the reading a control's key chips draw, and names a row's key only where resolving that key as a press (dispatch.js, `pressRuns`, which shares its synthetic press with `escapeInvocation`) would run the row. Its first form read row liveness alone, which a Codex review showed says `z` while the drawing's composer takes it; its second read `availableCommandRoutes`, which the second review showed counts an Escape that an earlier step, such as a grabbed card's cancel, takes first, and which evaluates every row on the page per hint heard (0.6 ms at 32 links, 10 ms at 1,024). Behavior changes: - Draw and Design say "w or Escape exit Draw mode": rows under one title are said once, and the page's Escape row is exported as `BACK_OUT` for a mode to name. "z takes one back" goes, since after the first stroke the composer has focus. - Select mode, the chosen search match, a heard hint and Go-to read their keys off their rows; Go-to's `hearThem` and the hint session's `words.take` go. - The repeat-search row's title is "next / previous match", as Go-to's edge row says "top / bottom", so its two keys' directions are said. - A touchscreen hears no keys, as `advertisesKeys` shows it none, which replaces the modes' own branches and reaches Go-to, reactions and the board's grab too. - `announce` takes a function for words read off the page and reads it as it speaks, 30 ms on, so resolving keys lays out nothing in the gesture's task: right after Draw mode's attributes change, reading them in the keydown cost 5 ms of forced layout on docs/how-it-works.html. Keydown plus frame now measures w 10.5 → 11.1 ms and g 19.9 → 19.6 ms there, base to head. It also trims what it says. Tests: the saying runtime test now registers its rows and checks a nearer scope's key goes unsaid; hint-session registers its walk rows; the browser and journey tests take the new words.
announce() now passes a function for words read off the page, such as the board's grab with its keys; the event's declared detail said string, so a listener typed against it would call wordsText on a function. Found by Codex's third review.
leaf-agent
left a comment
There was a problem hiding this comment.
After this PR, the dispatcher has two ways to answer whether a key would make a command now, and saying takes the second. pressRuns builds a synthetic keydown and runs resolveKey. The existing commandMatching walk, behind activeCommandLabel, already answers that question for the composer's placeholder: surface.js reads commentKey = activeCommandLabel(["comment.create"]). The new commentRows() in target-picker.js finds comment.create in pageScopes() again so saying can ask about it. #6687, which this PR answers, turns that walk into activeCommandBinding and commandKeysNow(id), described as "the keys that would make a command's press now … or none, as on … a touchscreen's". Once both land, a notice's press and an announcement read their keys through different code. Those readings can disagree: commandMatching approximates Escape with unclaimedScopes and reports one binding, while resolveKey orders the stack for Escape and returns INPUT_PENDING. A later fix to one reading then misses the other (AGENTS.md, "Fix the underlying issue": one canonical API per capability).
resolveKey on a synthetic press is the more faithful of the two, because it is the press, and escapeInvocation already reads it that way. One fix is to make that the dispatcher's single reading: activeCommandBinding/commandKeysNow would filter a command's bindings through pressRuns, and commentRows would go away. Settling which reading stays across this PR and #6687 is cheaper than reconciling them after both merge.
Four panel notices wrote their keys into their words: "2 changes since v1 — v shows them", "Annotations hidden — o shows them", "Edit discarded; g D restores it" and "Draft kept — g i resumes writing". Nothing checked those keys, so a phone showed `v`, and the discard notice named `g` while the caret sat in the reply box, where `g` types a letter. Now a notice names an action only through `press`, which the panel field's end shows with the keys that would make it now (`keyboard/control-keys.js`, `commandKeysNow`). This PR also takes the best of #6685, which converted the same four notices; Max asked for the merge and for the rules on how long words stay to be easy to change. What a reviewer should weigh: - **How long a notice stands is one rule** (`notifications.js`, `showNotice`), from #6685: every notice stands 4 s; one answering the user's own gesture with a press, or an undo's, then stays until the next input, and inputs within the 4 s don't end it; news passes with its press. Callers no longer pass `holds` for Next thread or Resume writing. So "Annotations hidden" now stays until the next input after its 4 s, and the Escape that leaves the reply box after a discard shows Restore edit. - **A touchscreen is shown no press at the field's end**, reversing #6483's word-alone press for a finger: Max judged a word alone there reads as status, and the panel's menu and lists reach each press's result. - **The live region hears a notice's words alone**, as on main; a screen reader meets the press as a button with its key chip inside. - **The pointer hold is main's**, for the page's own press only. - **An error may carry the press that recovers from it** (`errors.js`, `press`), from #6685: a refused send whose words went out of view offers Resume writing at the field's end and beside Dismiss in the Errors list. A field reading whose words come with a press names it (`field-readings.js`, `press`), so notices and errors share one path to the end. - **`architecture/spelled-keys`** (`eslint.config.mjs`), from #6685, refuses a string that spells a key after a dash or semicolon, the form the four notices used, including in what a screen reader hears from `announce`; #6702 has those announcements read their keys from the register. It reads that form, not every way of writing a key. - Left out from #6685: the spoken shortcut after a notice's words. Max asked for this in a Claude Code session; a separate Claude Code reviewer read the earlier rounds. Tests: `test:runtime`, `check:browser` and the affected browser tests pass; the new retention tests fail with the rule reverted. > _This was written by Claude Code on behalf of max-sixty_
…e-register # Conflicts: # browser/runtime/keyboard/control-keys.js
Tend's review of #6702 found two answers to whether a key would make a command now: `pressRuns`, which resolves a synthetic press through `resolveKey` for an announcement, and `activeCommandBinding`, which walked the stack through `commandMatching` for a notice's press and the composer's placeholder (via `commandKeysNow`, from #6687). The walk approximated Escape's order with `unclaimedScopes`, so the two could disagree and a fix to one would miss the other. `activeCommandBinding` now takes each binding of a row in the user's scopes that declares a wanted id, and keeps it where `pressRuns` holds. `invocationNow` is the one reading under both and under `escapeInvocation`. `commandMatching` keeps only its use by the reference (`commandFor`, behind `executeCommand`), which asks a different question: whether the command runs from the reference, where a disabled shortcut still leaves it executable. `commentRows` in target-picker.js stays: `saying` names rows, with their titles, and the page's `c` row is declared inside surface.js's setup, so a chosen search match finds it by id. Tests: the saying runtime test also checks `activeCommandBinding` drops `g` where a nearer scope takes it; test:runtime, check:browser, and 15 browser tests covering notice presses, the composer placeholder, Go-to, Draw mode and page search pass.
|
On the review of 3d33801, that the dispatcher has two readings of whether a key would make a command now: 9dc18e2 makes the press the one reading.
|
|
That resolves it. At 9dc18e2, |
…ey tests (#6806) #6702 rewrote Leaf's screen-reader announcements in `saying`'s "key title" form. A heard hint now ends "Enter choose target" where it said "Press Enter to choose", and Go to names "letters visible target" where it said "type a hint". Two journey tests in `tests/journeys/test_render_navigation.py` still expected the old sentences. Pull request CI doesn't run journey tests, so they first failed on `main` in the full-tier dispatch [run 45073646401](https://github.com/max-sixty/leaf/actions/runs/45073646401) on `3c9424f48`. They now assert the new words, which still check that each announcement tells a listener how to choose a target. No behavior changes. - `test_quick_shortcuts_can_be_disabled_without_withdrawing_commands` - `test_the_g_chord_reaches_named_surfaces_and_visible_targets` Run locally by node id, both fail on `main` (`017ddeccf`) with the same messages as on CI and pass on this branch. Refs #6804 — automated triage Co-authored-by: leaf-agent <[email protected]>
…indow (#6688) The page keeps no room for the floating panel: it lays out in the whole window, the panel stands over it, and the user folds the panel with `.` where it covers something. Until now the page kept a 72px band (`--lf-foot-room`) across the window's whole width at the end of every scroller and below every window-sized box, through about eleven rules (body and part padding, `--lf-end-room` threaded through workspace regions, tabs, panes and the file editor, sticky tracks, the trace stage, a landing trim, the `under-panel` render refusal), and it kept needing patches (#3394, #3619, #5969, #6555, #6671). Max asked whether the page could know nothing about the panel; this is that change, which he picked over keeping the band, on the decision page in his session. What still counts the panel is Leaf's own placement: the root's landing band still ends above the panel's band, and an inner scroller the page can't carry, held in a full-window workspace or stuck, now ends its band there too wherever the panel stands across the destination's columns (`landingBand(scroller, across)`), in place of the band each pane kept in its padding. The panel no longer writes the root's `scroll-padding-bottom`, since a band across the whole window made a Tab onto a stuck sidebar link beside the panel scroll the page 340px. A Layout's end padding adds the safe area at the window's foot. Landings also stop scrolling the page past how far it can still carry a scroller (`pageCarry`, geometry.js), so a stuck tab side list's open item stays in the window. Four faults the missing band exposed are fixed where they live: an empty visual-review discussion now lays out where its comment box would stand, so the box takes that seat only where the panel leaves it in sight, rather than opening under the panel's row and jumping between its two seats every 70ms; a comment box the user sees no longer moves to a seat outside the window, which took the draft out of sight when a review's window widened from a phone's width; and a file tree no longer reveals a row the user pressed, which moved the row from under the pointer before mouseup so the click opened nothing (main does this too with a real mouse); and a Tab's landing above the panel, which waits for the next frame, now runs first when a key comes before that frame, so Enter on a link Tab left under the panel follows the link rather than letting go of focus (`landing-scroll.js`). To weigh: where content ends flush with the window's foot under the panel's 540px, the row covers its last 44px until folded (4 of 27 examples at 1728×999, 1 on a phone; 1 on main), and Tab onto a control there, as at the end of a long tab side list, leaves focus out of sight; the browser's own reveals (find, a page field's caret) no longer stop above the panel; and in a visual review that fills the window, the comment box opens over the case's head, covering its help button, rather than in its discussion. Tests: the runs of every tier before last, on this branch (https://github.com/max-sixty/leaf/actions/runs/45015279476) and on main (https://github.com/max-sixty/leaf/actions/runs/45015281683), failed four tests on the branch alone, each only some of the time, and each now has a fix here: the Tab landing above; the aim sweep lets the page's scroll carry a margin marker Leaf anchors to the page (`carriersOf`, now on the check API); the stale-keys sweep shows a sample frame below the window before reading, as a check does; and the file-pick test waits for the page's scroll to start, which fails on main too. All four passed in the last runs (https://github.com/max-sixty/leaf/actions/runs/45044731101, branch; https://github.com/max-sixty/leaf/actions/runs/45044712114, main). Those failed two others on the branch alone on Linux: the drawing test, which #6718 fixes and this branch now holds, and the trace journey, whose `hover` scrolled the page 9px now that the root keeps no scroll padding, which the shift watch misread (#6763, now on main, fixes the watch); the journey now points without scrolling and passes 8 of 8 copies at 4× CPU throttle. Seven more failed once each on the branch's macOS job alone, as eight did on main's; rerun locally at 4× throttle, four fail on main as well and three on neither. The latest runs, with #6718 in (https://github.com/max-sixty/leaf/actions/runs/45073644131, branch; https://github.com/max-sixty/leaf/actions/runs/45073646401, main), failed nothing on Linux that main didn't. Six tests failed on the branch's macOS job alone: - two journeys whose announcements #6702 reworded on main, which fail on main's Linux job too; - a shift-watch teardown of the kind #6763 fixes; - the removal test, which fails on main too at 4× CPU throttle; - the pane pin and comment-box return tests, which passed all 12 local copies, 6 on each tree, both plain and at 4× throttle. Since those runs started, main gained #6720, #6739, #6756 and #6763, which this branch now holds; in `seatFab` it keeps #6739's rule that a seat is judged only as the box moves in, judged by this branch's rules. Their new tests, with this branch's visual-review, card-growth and trace tests, pass on that merge here. Locally the changed tests, the drawing tests, `pnpm run test:runtime` and `pnpm run check:browser` pass on the merge of today's main; the focus-ring sweep fails on `review-a-fix` on main and here alike. > _This was written by Claude Code on behalf of max-sixty_
Leaf's screen-reader announcements wrote some keys into their words by hand, where nothing checked them against the bindings or against where focus was, and Draw and Design branched on a touchscreen to say "Exit Draw mode leaves." instead. Each now reads its keys through
saying, the reading Go-to and reactions already used, which this PR moves beside the key chips' reading incontrol-keys.js: it names a key only where resolving that key as a press now would run the row (pressRunsindispatch.js), and a touchscreen hears none, as it is shown none.To weigh:
activeCommandBinding, behind Name a notice's keys only through its press #6687'scommandKeysNow) now come from the same reading: each key is resolved as its press (invocationNow, whichescapeInvocationreads too) in place of a second walk of the stack that approximated Escape's order, which Tend's review found could disagree with an announcement. That walk remains only for running a command from the command reference.saying's "key title" form. A mode's two ways out are said once, under their shared title ("w or Escape").z, so no announcement can truthfully offer it.announcenow also takes a function, read as it speaks 30 ms later. Resolving keys in the keydown itself forced a 5 ms layout right after Draw mode changed the page; read later, keydown plus frame measures w 10.5 → 11.1 ms and g 19.9 → 19.6 ms ondocs/how-it-works.html, base to head. A page listening forlf-announcecan now receive a function indetail; the module reference says so.Max chose this on the Leaf page for #6687, over keeping the words or dropping the keys. Tests:
test:runtime(saying follows the dispatcher and says nothing on a touchscreen),check:browser, the 11 browser and journey tests whose words changed; the table is fromleaf-dev probe --baseonincident-report, desktop and--touch. Codex reviewed it three times; the fixes for its findings are in.