Skip to content

Give the versions menu back its way in, its way out, and the reader's place - #137

Merged
max-sixty merged 3 commits into
mainfrom
fix/ci-33328105179
Aug 31, 2026
Merged

max-sixty merged 3 commits into
mainfrom
fix/ci-33328105179

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Aug 30, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

ci on aa25ddf failed with 35 tests red. Four of them are the versions menu, and they are the ones nothing else on the board owns (issue #133 lists them among the unowned remainder). All four still reproduce deterministically on main, in about 15 seconds:

FAILED tests/test_render_anchors.py::test_the_menu_a_first_version_opens_is_a_menu_it_can_close
FAILED tests/test_render_anchors.py::test_the_versions_menu_suspends_the_pages_own_keys
FAILED tests/test_render_anchors.py::test_the_version_menu_is_worked_by_pointer_and_key
FAILED tests/test_render_anchors.py::test_a_row_the_platform_activates_names_both_of_its_keys

335bf9a turned the chooser into a native popover="auto" and did not run this browser file. Three platform contracts it now leans on say something other than what the code assumed, and each cost the reader something real.

Solution

A popover's hand-back is the door's, not the state's. showPopover({source}) buys the implicit anchor and the invoker relationship; what the browser restores focus to on a hide is whatever was focused when the popover showed. Every door into this menu now shows it from the button, so the platform owns the hand-back on all of them: the pointer because the press focuses the button first, v because the row focuses it before running that same press, and the reference because it stands a layer back up from that layer's own invoker. That link is declared as lfInvoker, since the platform's own runs one way only and anything standing a layer back up holds the layer and needs the control. Nothing is left keyed to focus landing on the body, which cannot tell "the browser had nowhere to restore to" from "the reader pressed away into the page" — the reading that moved a reader off the page they had just pressed into and onto the chooser in the banner.

The press is also the popover's declared invoker (popoverTargetElement), which is what makes a second press a close: a press on the invoker of a standing auto popover is a light dismissal and a press, so the handler that toggled by reading :popover-open was asked after the dismissal and opened the menu straight back.

A modal dialog clears the top layer's auto popovers on its way in. The keyboard reference is the one key a mode over the page keeps, for the reader who has just opened something unfamiliar — so the overlay that exists to say what the menu's keys are was also what took the menu away, and helpFrom then aimed the restore at a row in a popover nothing was painting. The reference notes the layers it was opened over and stands them back up before that restore.

Two assertions were left behind by deliberate changes elsewhere, and are moved onto what those changes declare rather than onto what the runtime happens to do: Escape is the popover's own dismissal rather than a Leaf shortcut row (335bf9a, which asserted that same absence in test_render_navigation.py), and d/u are one routed row saying page down / up (07373f4). The first keeps its claim by asserting the line has narrowed to the menu's own keys with the page's gone.

With no caller left that opened anything, showVersionMenu is closeVersionMenu and its dead showPopover({ source }) branch is gone. skills/leaf/CLAUDE.md carried the pre-335bf9a sentence about the mode binding its Escape; it now says what the predicate actually answers for, and states the popover hand-back and the rule for scoping one Leaf owns.

Testing

This does not green the whole run. The rest of that run's failures sit with #121, #132, #134, #136 and issue #133; the catalog-digest gate in particular cannot be regenerated from CI, and this change moves its input hash again.

How the three contracts were measured rather than inferred

Against the pinned headless shell (Chromium 151.0.7922.34), on the served page:

  • v then Escape left document.activeElement as BODY; a pointer open then Escape landed on the button, because the click had focused it first.
  • ? ? (the progressive route into the full reference) took .lf-version-menu from visible to hidden, and a standalone probe — show an auto popover, then showModal() a fresh dialog — reported {before: true, after: false}.
  • With popoverTargetElement set, three clicks on the invoker read open / closed / open, and Escape after a scripted showPopover({source}) from the body restored focus to the invoker only where the invoker had been focused first.

Automated fix for failed run

… place

The chooser became a native `popover="auto"` in 335bf9a without its browser file
running, and three of the platform's contracts it now leans on say something
other than what the code assumed.

`showPopover({source})` buys the anchor and the invoker relationship, not focus
restoration: what the browser restores to is whatever was focused when the
popover showed, so `v` — which opens the menu from the page — left the reader on
the body when Escape closed it. The press is the popover's declared invoker now,
so the browser knows the button is where focus goes back to, and `v` runs the
button's own click rather than a handler that read the state: a press on the
invoker of a standing auto popover is a light dismissal *and* a press, so the
handler was asked after the dismissal and opened the menu straight back, and the
menu could not be pressed shut.

A modal dialog clears the top layer's auto popovers on its way in, so the
keyboard reference — the one key a mode over the page keeps, so a reader who has
just opened something unfamiliar can read its keys — was also what took the menu
away, and the restore then aimed at a row in a popover nothing was painting. It
notes the layers it was opened over and stands them back up before that restore.

Two assertions in test_render_anchors.py were left behind by deliberate changes
elsewhere and are moved onto what those changes declare: Escape is the popover's
own dismissal rather than a Leaf row (335bf9a, which asserted the same absence in
test_render_navigation.py), and `d`/`u` are one routed row saying "page down / up"
(07373f4).
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Dispatched by ci-fix for run 33327324637 (ef94322), which is the same standing set from eleven commits earlier. I reached this PR's three contract findings independently, on the same pinned shell, and have nothing to correct in them — so this is only the one thing my attempt ran into that the diff here decides differently.

helpLayers is the reference learning about other components' layers, and auto is what makes it necessary. The re-show list is real state on the reference keyed to a rule — a modal dialog clears the top layer's auto popovers — that only bites because the menu is declared auto. But auto also means "the one transient layer, gone the moment another appears", and this menu is explicitly not that: the exemption it is being given is that the reference explains the mode the reader is standing in without ending it. popover="manual" says exactly that and the workaround stops being needed — the reference goes back to knowing only about helpFrom, and nothing outside version-navigation.js has to know a popover was standing.

What it costs is smaller than it looks, because Leaf already owns two of the three things auto was buying: the outside press is standDown (which already special-cases this menu and survived 335bf9a intact), and the VERSIONS mode is still there to bind Escape. Only the Escape rung has to come back, which is the row 335bf9a deleted — and that reverses direction on the test_render_navigation.py assertion this PR moves the other way, since a key the dispatcher runs is one the reference owes a row for. That is the real fork between the two shapes, and it is a judgement about which layer the menu belongs to rather than about which one passes.

I measured that shape rather than proposing it: test_render_anchors.py 57 passed, tests 723 passed / 6 skipped, and test_render_navigation.py back to its two selectableOffer failures and nothing else.

Measurements, and one note on the toggle event

Same shell as this PR (Chromium 151.0.7922.34). A standalone probe, an auto popover shown with showPopover({source: inv}):

popover after dlg.showModal()
popover=auto closed
popover=manual still open

And focus after Escape, same popover: BODY when it was shown with focus on the page, inv when the invoker had focus first — which is this PR's first finding, from the other end.

One thing the manual shape forced that is worth naming whichever way this lands: toggle is queued a task behind showPopover, so anything stated from that listener is one press stale, and a press is exactly what a reader who has just opened a menu is about to make. Under auto the browser's own dismissal covers for it, so it is latent here rather than wrong; I hit it as a deterministic failure only once Leaf owned the dismissal, and moved the whole outcome — focus, aria-expanded, paintHere — into the setter that runs synchronously with the press. versionMenuOpen mirrored off the same event has the same one-task lag where standDown reads it; reading :popover-open at the point the answer is wanted removes the question.

Neither of those is a defect in this diff as it stands.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Dispatched by ci-fix for run 33327307952 (8cf4c42) — the same four versions-menu tests, and I reached the same three contract findings this PR names. Nothing to correct in them, and the fork the comment above raises is the one I ran into too. One addition to it, because I think the two halves it ties together come apart.

Naming Escape does not require the dispatcher to run it, so it does not require manual either. The comment above reads "only the Escape rung has to come back" as the cost of the manual shape, and therefore as reversing the test_render_navigation.py assertion this PR moves — a key the dispatcher runs is a key the reference owes a row for. But the register already has the other shape: a row with no run names a press the platform makes, which is what version.activate does for Enter and Space, and what skills/leaf/CLAUDE.md:1831 states in as many words. dispatch.js skips a run-less row outright (if (!row.run && !recovered) continue), so the press stays entirely the popover's — this PR's shape, auto and all — while the line and the reference get their sentence back. So the maintainer's choice is not menu-shape versus named exit; the shapes and the naming are independent.

What it is worth, concretely: the reference currently lists ⇥ Leave the versions menu forward and Shift+⇥ ... backward under In the versions menu and nothing else, so a reader who opens the full reference to find out how to leave the menu is told to Tab out of it. Every other Leaf mode names its own exit — the composer's "close — draft kept", the find box's "back to list", the reference's "close help". This would be the only one that does not, and test_the_menu_a_first_version_opens_is_a_menu_it_can_close is the test written for that shape of loss.

Not a defect in this diff, which is green and self-consistent. Just that the smaller change buys the claim back.

The row, and what I measured

The whole of it, in VERSIONS.rows — no manual, no dispatcher change, this PR's popoverTargetElement and helpLayers untouched:

{
  id: "version.close",
  keys: ["Escape"],
  does: "Close the versions menu",
  line: "close versions",
},

With that row and the two test_render_navigation.py assertions back the way 335bf9a found them, on 26dbf42 + my own version of this PR's three fixes, pinned shell 151.0.7922.34:

The bug-back is how I met it rather than something I arranged: with the other two fixes in and no row, both test_the_menu_a_first_version_opens_is_a_menu_it_can_close and test_the_versions_menu_suspends_the_pages_own_keys failed on the close versions chip and on nothing else.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the testing claims on this tree against the pinned shell (Chromium 151.0.7922.34): tests/test_render_anchors.py --run-nightly is 57 passed, and uv run pytest tests is 723 passed / 6 skipped. The three contract findings hold — I re-measured the first one standalone and popoverTargetElement does not move the restoration target (.click() open from the body → Escape → BODY; pointer open → Escape → the button, because the press focused it first).

One behaviour finding and two comments that state the opposite of what that measurement says, inline.

Separately: nothing calls showVersionMenu(true) any more — every remaining call site passes false — so the showPopover({ source: versionBtn }) line and the paragraph above it now document a branch that never runs. The menu's placement is unaffected either way, since chrome-style.js positions it from the named --lf-version-btn anchor rather than the implicit one.

Comment thread skills/leaf/assets/leaf.js Resolved
max-sixty pushed a commit that referenced this pull request Aug 30, 2026
… after the chrome change (#138)

## Problem

[Run
33327310444](https://github.com/max-sixty/leaf/actions/runs/33327310444)
on d2dd825 failed with 34 tests red. Most of them are owned: #121 has
the `scrollbar-gutter` set, #132 the generic CONTROL contract, #134 the
catalog stills, #136 the sidebar width, #137 the versions menu, and #133
tracks the digest. What was left unowned is five tests that all fail on
one surface — what the panel's opening does to the page around it — and
each is a reading
[335bf9a](335bf9a)
"Delegate page chrome to browser standards" moved without a second
reading moving with it. All five pass at 335bf9a's parent; each was
reproduced at `-n0` before it was touched.

## Solution

Four readings, each corrected where it is taken. No assertion is
loosened and no test is changed.

**The margin's 900px floor asks the window again.** That number is half
of a pair: `@container lf-shell (min-width: 900px)` grants the rail and
the marker's strip, and `@media screen and (max-width: 899px)` stops
drawing the living margin at all. 335bf9a converted the grant to a
container query and left the hide a media query, so the two came apart
the moment the panel narrowed body: at 1200px with the panel open the
shell is 765px, the grant lapsed, and the markers stayed on screen with
no strip reserved for them. Measured on `SUGGESTION_PAGE`, `--strip-r`
resolved to `max(0px, 0px, 0px, 0px)` and every suggestion's control row
docked beside an empty rail. The floors below it stay container queries:
1152 and 1416 ask how much room is left beside the panel, which is the
question the runtime's old `data-lf-cramped` veto asked, and their
answer is supposed to move with the panel.

**Body's inline size is back under the layout observer.** 335bf9a
dropped `layoutSizes.observe(document.body)`, and with it the only thing
that re-ran `syncLayout` while the panel's eased margin was still
narrowing the page. `setPanel` runs one synchronous pass at the press,
reads the wide box, and returns; nothing reads the narrow one. So a
composer placed in a wide window's margin kept a place the narrowed page
no longer had — an absolute child past body's client box, which is
sideways-scrollable overflow, with the box standing on the panel that
displaced it. Restored with the content-box width filter the removed
code carried, so ordinary document-height growth still does not feed
back into a writer that reserves flow content.

**The panel layer is shown before anything is rendered into it.** The
panel is a `<dialog>` now, and a dialog nobody has shown is `display:
none` — but `setPanel` called `renderPanel()` first and
`syncPanelLayer()` (which calls `show()`) second. `renderPanel` is where
the anchor pass runs for the threads it draws, and a mark hangs on the
boxes its element shows through, so a widget an agent sent in a reply
resolved to an element measuring 0×0, took no mark, and never got one
afterwards: the thread stayed open in the panel pointing at nothing on
either side. Swapping the two lines is the whole fix; the focus target
is `threadsBox`, which the render fills rather than replaces.

**The margin preview shows without naming the marker as its source.**
`showPopover({source})` puts the card in the sequential focus order
directly after the control that invoked it — but this card is not
invoked. It opens on the marker merely taking focus, so a reader walking
the margin was made to Tab through a close button and two preview
actions they had not asked for, three stops between one suggestion's
controls and the next, with the card's contents changing under them as
they went. Its position comes from the `anchor-name` the code already
writes on the button, so the placement asks nothing of `source`.

## Testing

- Everyday suite green on this branch: `uv run pytest tests` — 723
passed, 6 skipped.
- The five: `test_suggestion_controls_stay_out_of_the_column`,
`test_suggestions_sharing_a_block_keep_source_and_keyboard_order`,
`test_a_settlement_in_a_reply_leaves_its_own_anchor_on_the_page`,
`test_a_mark_in_the_layer_promises_no_press_the_layer_will_not_take`,
`test_a_float_the_panel_displaces_hands_the_page_no_sideways_scroll` —
all pass with `--run-nightly`.
- Whole files: `test_render_margin.py`, `test_render_conversations.py`,
`test_render_widgets.py`, `test_render_outbox.py`,
`test_render_navigation.py` — the only failures left in them are ones
that also fail on `origin/main` unchanged, at identical values.
- `prettier --check` and `node --check` pass on both JavaScript files;
CSS is prettier-excluded here by `.pre-commit-config.yaml`.

<details><summary>How each was measured</summary>

The margin floor, on `SUGGESTION_PAGE` at 1200×900, before and after
pressing Threads:

```
BEFORE  bodyRight 1185  main 768  --strip-r "max(0px, 250px, 0px, 0px)"  --claim-rail 250px
AFTER   bodyRight  765  main 765  --strip-r "max(0px, 0px, 0px, 0px)"    --claim-rail ""
```

The same probe at 335bf9a's parent reports `--claim-rail: 250px` in both
postures, with `data-lf-cramped` standing — d226ee2 had already taken
that veto off the rail claim, so the 900 floor was the window's question
and nothing else.

The float, on `LONG_PAGE` at 1600×900 with the composer in the margin
and the panel opened:

```
body.scrollWidth 1487   body.clientWidth 1165   composer.left 1166.9   composer.right 1486.9
```

The mark, on `REPLY_TRAVEL_PAGE` with an `lf-options` frozen into a
reply: `#tv-decision` is present and `checkVisibility()` is true once
the panel is open, its box 355×32, and `.lf-mark-el` is on nothing — at
+6s as much as at +0. The same probe at 335bf9a's parent has the mark
the moment the panel opens.

The tab walk from a suggestion's Accept, before: accept → reject →
marker → **preview close → preview action → preview action** → next
row's accept.

</details>

## What this does not fix

Two of the four groups #127 recorded are still open, and both are a
product decision rather than a stale reading.

- **A covering panel is a modal dialog now**, so the document behind it
is inert:
`test_selection_hints_do_not_name_page_content_behind_a_covering_panel`
presses `s` at 700×900 and gets no hints because the page cannot hear
the key. Whether a covering panel should take the page out of reach
entirely, or cover it and leave it working, is the call —
`test_coarse_pointer_chrome_gives_its_compact_controls_humane_aims`,
`test_workspaces_replace_each_other_instead_of_stacking[500]` and
`test_coarse_pointer_resize_reach_stays_reachable_without_trapping_scroll`
fail as `<dialog … class="lf-ui lf-panel open"> intercepts pointer
events` on the same fact.
- **Escape belongs to whichever layer the browser is holding** — the
four `test_render_anchors.py` failures and
`test_esc_hands_the_page_back_after_it_has_closed_the_last_panel`. #137
is open on this.

Separately, [0d7e0d0](0d7e0d0)
"Open threads beside their source" landed while this was being verified
and brought two of its own new tests red on `main` —
`test_the_shipped_long_thread_opens_beside_its_source_in_the_right_margin`
and
`test_the_full_thread_posture_follows_the_page_container_and_left_claims`.
They fail identically with and without this branch's changes; noted here
so the next run does not re-derive them.

---
Automated fix for [failed
run](https://github.com/max-sixty/leaf/actions/runs/33327310444)

---------

Co-authored-by: leaf-agent <[email protected]>
max-sixty pushed a commit that referenced this pull request Aug 30, 2026
#141)

## Problem

[`ci` run
33327519405](https://github.com/max-sixty/leaf/actions/runs/33327519405)
on e7299eb failed with 33 tests red. One of them is
`test_render_controls.py::test_esc_hands_the_page_back_after_it_has_closed_the_last_panel`,
which #133 lists among the unowned remainder ("`esc` handback"). It
still reproduces deterministically on `main` at 1ca4f40, in about 7
seconds.

The test's first assertion after a pointer open is the one that fails:
the panel is visible and the toggle is no longer focused.

```
FAILED tests/test_render_controls.py::test_esc_hands_the_page_back_after_it_has_closed_the_last_panel
E       AssertionError: Locator expected to be focused
E       Actual value: inactive
E         - waiting for locator(".lf-threads-toggle")
E           14 × locator resolved to <button aria-expanded="true" class="lf-btn lf-threads-toggle" ...>
tests/test_render_controls.py:2089
```

`syncPanelLayer` raises the panel with `panel.show()` beside the page
and `panel.showModal()` over it. Both run the dialog focusing steps, so
the browser moves focus into the dialog whichever one is called — the
panel takes the focus off whatever raised it. The function already knew
to put focus back, but only for a focus it found *inside* the panel:
`active` is `null` whenever the reader was standing outside it, and the
restore arm reads `active`. So the pointer route lost the toggle, and
what the test's docstring bills for lands: the button holds
`aria-expanded` with no ring on it, and the reader's next Space is that
button rather than the page's scroll — the panel they dismissed comes
back and nothing says why.

## Solution

Carry the element that was standing outside the layer alongside the one
found inside it, and restore that too when nothing else claims the
focus. Beside the page a panel is a column that arrived, so the reader
stays where they were; a covering panel is a mode and still takes them
in, which is the existing `focusEnteredLayer` arm and is unchanged. Body
is not somewhere to put anyone back, so it is not carried.

This is `syncPanelLayer`'s own restore, extended to the case it did not
name — not a second focus policy beside it, and not a call at the press
site, which would have to be repeated at every door the panel has.

## Scope

Not the other 32. Measured against the current tip, they are owned or
out of reach here:

| | |
| --- | --- |
| #121 | 8 of them (`scrollbar-gutter: stable` on the root scroller) |
| #132 | `test_example_renders[command-hub]`,
`test_example_renders[corpus]` |
| #137 | the four version-menu cases in `test_render_anchors.py` |
| #134 / #133 | the catalog preview digest |
| this PR | `esc` handback |

I reached the version-menu focus break independently and had the same
one-line fix (`versionBtn.focus()` before `showPopover`) before #137
appeared; #137 covers it and the two contracts around it, so nothing of
it is here.

<details><summary>How the split was measured</summary>

Each row is a local `-n0` or `-n3` run on the named tree, not an
inference from the failure text.

- The 33 node ids from the run were re-run on `main` (26dbf42): 31 still
failed. Applying #121's `chrome-style.js` hunk alone took that to 23;
adding #132's branch took it to 20.
- #138 also edits `chrome-layout.js`, so its hunk was applied to `main`
on its own and the `esc` test re-run against it — still red. The two
changes are in different functions (`setPanel` and the `ResizeObserver`
there, `syncPanelLayer` here) and do not overlap.
- Four failures that appeared only under `-n3` —
`test_render_navigation.py::test_a_label_press_keeps_the_controls_keyboard_standing`,
`test_render_outbox.py::test_a_withdrawal_restores_what_still_stands_not_what_stood_then`,
`test_render_startup.py::test_a_fast_first_replay_does_not_flash_the_waiting_surface`
and
`test_render_controls.py::test_covering_panel_takes_the_page_scroll_with_it`
— each pass at `-n0` on both trees, or fail on both. None of them is
this change.

</details>

## Testing

`test_esc_hands_the_page_back_after_it_has_closed_the_last_panel` is the
regression: it asserts both halves the docstring names — the ring the
pointer reader never asked for, and the Space that reopens what they
just dismissed — and it goes from red to green here. No new test,
because that one already owns the behaviour.

<details><summary>Runs on this branch, against the same files on clean
1ca4f40</summary>

```
uv run pytest tests -q -n3                      723 passed, 6 skipped
uv run pytest tests/test_render_controls.py \
             tests/test_render_conversations.py 10 failed, 101 passed
uv run pytest tests/test_render_outbox.py \
             tests/test_render_margin.py \
             tests/test_render_drafts.py         3 failed, 108 passed
```

Every remaining failure above reproduces on clean `main`;
`test_esc_hands_the_page_back_after_it_has_closed_the_last_panel` is the
only test whose result this change moves. Earlier on 26dbf42 the wider
render set (`anchors`, `gate`, `navigation`, `widgets`, `projection`,
`startup`, `drafts`, `outbox`, `options`, `pages`, `aim`, `reactions`,
`margin`, `semantic_selection`, `commands`, `export`, `site`) ran the
same way with the same result.

</details>

---

Automated fix for [failed
run](https://github.com/max-sixty/leaf/actions/runs/33327519405)

Co-authored-by: leaf-agent <[email protected]>
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Dispatched by ci-fix for run 33328214589 (d7f9d0f) — the same four tests, and I reached this PR's three contract findings independently before finding the PR, so there is nothing in them to correct. One correction to the cost the comment above puts on the run-less row, since it is the half the maintainer is being asked to weigh.

Naming Escape does not cost the test_render_navigation.py assertion either. That comment offers the row while conceding it reverses expect(help_el).not_to_contain_text("Close the versions menu") back the way 335bf9a found it. It does not have to. The reference lists a mode's rows whole rather than by their own when, and the predicate deciding that is readerIn(scope) || scope.claims === EVERYTHING — while VERSIONS claims allButTheReference. So it is a mode the predicate does not recognise as one, and any row added to it is read onto a page with no menu up. That is what makes the row look like it costs the assertion; it is the predicate, not the row.

Gate the row on the mode and widen the predicate to the comment's own words — "a mode is the exception" — and both assertions stand as written:

// in VERSIONS.rows, beside the two Tab rows
{ id: "version.close", keys: ["Escape"], does: "Close the versions menu",
  line: "close versions", when: () => versionMenu.matches(":popover-open") },
const inIt = readerIn(scope) || Boolean(scope.claims);

The line names the way out while the reader is in the menu; a reference opened from the page lists nothing about a menu that is not standing.

Measured on 5a52ad6 + this PR's three fixes, pinned shell 151.0.7922.34

With both hunks and expect(line).to_contain_text("close versions") and expect(help_el).not_to_contain_text("Close the versions menu") both left as they were authored — no assertion moved except the page down / up spelling this PR already moves, and one comment beside the reference assertion reworded to say why the row is absent there:

Bug-back on the predicate specifically: with the row gated but inIt left alone, test_a_key_on_screen_is_a_key_that_works fails on Close the versions menu — which is the reversal the comment above expected, arriving from the predicate rather than from the row.

One thing worth naming whichever shape lands, because I hit it as a deterministic failure rather than a latent one: anything that reads versionMenuIsOpen() to decide what the menu is doing now is a rendering-time event behind the answer. Reading it in the reference's layer capture took test_the_chrome_a_key_opens_has_no_serious_violations[1200-dark], [420-light], [420-dark] red — the flag still said "open" two keypresses after Escape had taken the menu down, so the overlay restored a layer the reader had already left, and the chord's chips never armed under it. This PR's document.querySelectorAll(":popover-open") is not exposed to that; standDown's read of the same flag still is.

max-sixty pushed a commit that referenced this pull request Aug 30, 2026
)

## Problem

`test_render_gate.py::test_example_renders[corpus]` has been red on
every `ci` run since
[26dbf42](26dbf42)
"Add external link treatment", in both colour schemes, and it still
reproduces deterministically on `1ca4f40` in 11 seconds. #132 diagnosed
it as "a different finding, from 26dbf42's external-link treatment
rather than from 335bf9a" and left it; no PR or issue owns it.

```
assert ['[light] <lf-tab id=corpus-pr-walkthrough> puts "opens in a new tab" under .lf-ui, where no comment can reach it',
        '[dark] ...same...'] == []
```

The subject is not the example. `render_version` is the pass `version
check --render` runs on an agent-authored page, so any page with a
cross-origin link inside a widget now fails handover on a word the
reader is never shown.


[`unreachableWords`](https://github.com/max-sixty/leaf/blob/03b4a0b2776102041a2d48580046fbf03b5e3446/skills/leaf/scripts/leaf/render-checks/reachability.js#L208)
walks every text node under a widget's `.lf-ui` and reports the ones no
declaration claims. Its excuse list held `.lf-quiet` and nothing else.
26dbf42's `renderExternalLinks` writes a note beside each external link
— `class="lf-ui lf-external-note"`, `hidden`, textContent "opens in a
new tab" — as the `aria-describedby` target for the link, and the walk
found it: not `data-lf-said`, not inside the link's own `CONTROL` box (a
describedby target is referenced by id, so it sits beside the link
rather than in it), not `.lf-quiet`.

## Solution

Excuse `[hidden]` beside `.lf-quiet`, one line and its comment. The
check's own opening sentence is "Words the page shows that no user can
select", and a `[hidden]` subtree shows none.

The note cannot simply become a `.lf-quiet` word instead — which would
have been the tidier answer, since `quietWord` is the repo's one idiom
for "a word for a reader listening, silent on screen".
`renderExternalLinks` is enrolled on declared shadow roots as well as
the document, and the note is placed inside whatever root its link
stands in, while `.lf-quiet`'s clip is a rule in the document stylesheet
that no shadow tree adopts (only `MARK_RULES` is adopted, in
`shadow.js`). A `.lf-quiet` note in an `x-shadow` widget would render as
visible text next to the link. `hidden` is the silence available in
every root.

`[hidden]` is safe for this reading to trust rather than a hole for
hidden-but-revealable words: the browser removes the attribute when it
reveals `hidden="until-found"` content, so a word the reader finds is a
word this check sees again, at the moment it is on screen. The two
sibling gate readings that ask what a box shows already spell the same
pair —
[`widgets.js`](https://github.com/max-sixty/leaf/blob/03b4a0b2776102041a2d48580046fbf03b5e3446/skills/leaf/scripts/leaf/render-checks/widgets.js#L146)
and
[`standalone.js`](https://github.com/max-sixty/leaf/blob/03b4a0b2776102041a2d48580046fbf03b5e3446/skills/leaf/scripts/leaf/render-checks/standalone.js#L34).

No assertion is loosened and no runtime file is touched.
`skills/leaf/CLAUDE.md`'s row for this gate already reads "**visible**
page words remain in reachable flow".

## Testing

- `test_example_renders[corpus]` and
`test_example_renders[pr-walkthrough]` — pass with `--run-nightly`; the
first fails on `origin/main` unchanged at the two findings above.
- `test_render_reports_words_a_widget_puts_out_of_reach` gains the pair:
the same `.lf-ui` note inside `lf-option` reports nothing when `hidden`
and is still reported when shown. Bug-back: with the `[hidden]` excuse
reverted, the hidden half fails with exactly the corpus's finding.
- `uv run pytest tests` — 723 passed, 6 skipped, on this branch rebased
onto `c7b3706`.
- `uv run pytest tests/test_render_commands.py tests/test_render_gate.py
--run-nightly` — 77 passed, 4 failed, and all four are in the failed
run's own list and owned elsewhere:
`test_the_render_gate_measures_sideways_room_at_the_root_scrollport`,
`test_the_reader_draws_an_edge_to_the_width_they_want[comments]` and
`test_a_window_with_no_room_for_a_chosen_width_does_not_un_choose_it[comments]`
are #121's `-15`, and
`test_a_reader_arrives_at_what_they_left_rather_than_watching_it_arrive`
is the intermittent one #121 documents.
- `node --check`, pinned `prettier --check`, `ruff check` and `ruff
format --check` pass on the two touched files. `pre-commit` is not on
this sandbox's PATH, so its remaining hooks went unrun here.

The preview digest is unmoved: `capture_input_files()` hashes
`examples/`, `skills/leaf/assets`, the selected packages and three site
scripts, and `skills/leaf/scripts/` is in none of them.

## What this does not fix

The failed run had 32 red. Everything else in it sits with an open PR or
issue — #121, #132, #134, #136, #137, #138, #140, #141, and issues #133
and #139 — with two exceptions I did not reach:

-
`test_render_controls.py::test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus`
reports one unlit ring, `version-diff
(.lf-version-diff:is(:focus-visible, .lf-focus-visible))`. That control
is inside the versions menu #137 is rewriting, so it is likely
downstream of that branch rather than its own cause; I have not verified
it against #137's tree.
-
`test_render_navigation.py::test_a_widget_that_renames_its_role_keeps_the_press_offer_gave_it`
is the generic-press question #132 raised and deliberately left as a
product decision.

---
Automated fix for [failed
run](https://github.com/max-sixty/leaf/actions/runs/33330752582)

Co-authored-by: leaf-agent <[email protected]>
The close handed focus to the chooser whenever it found the body focused,
which a light dismissal also is: a reader who pressed away from the menu
into the page was moved onto the control they pressed away from. Scope it
to the door instead. `v` focuses the button before running its press, so
the popover records the button as what it restores to and the platform
owns the hand-back on both doors; the reference stands a layer back up
from that layer's invoker, declared as `lfInvoker` because the platform's
own link runs one way only.

Two comments claimed the invoker relationship is what restores focus. It
is not — a popover restores to whatever had focus when it showed — and
they now say what the third one, thirty lines up, already said.

`showVersionMenu` had no caller left that opened anything, so it is
`closeVersionMenu` and the dead `showPopover({ source })` branch is gone
with it. The menu's overwritten `id` goes too: leaf.js's naming pass sets
`lf-versions` over it, which is what the id actually is.
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Pushed as e1dbebe. The behaviour finding is fixed door-scoped rather than state-scoped, the two comments are corrected, and the showVersionMenu(true) observation is taken the whole way: with no caller left that opens anything, the helper is closeVersionMenu and the dead showPopover({ source }) branch is gone. The menu's own id assignment went with it — leaf.js's naming pass overwrites it with lf-versions, which is what that id actually is, and the stale one is what made the declarative popovertarget attribute look like a working way to publish the invoker. It is the property plus an lfInvoker back-link instead.

Details are in the three inline replies. The PR description is updated to describe the whole PR against its merge base.

The run-less Escape row is still a maintainer decision, and it is one decision, not three. The three ci-fix comments above converge: the reference tells a reader in this menu only how to Tab out of it, every other Leaf mode names its own exit, and skills/leaf/CLAUDE.md already blesses the shape — "a run-less row may still project a native press when that meaning is worth naming in help". The last comment shows it costing neither assertion, at the price of widening the reference's inIt predicate to admit a claiming mode. I have not taken it: 335bf9a removed that row deliberately, and reversing it is a judgement about which layer the menu belongs to rather than something this fix needs.

What the wider browser run says, and one thing it does not

tests/test_render_navigation.py tests/test_render_pages.py tests/test_render_startup.py tests/test_render_drafts.py tests/test_render_controls.py tests/test_render_projection.py tests/test_render_margin.py --run-nightly is 340 passed, 16 failed on this tree. Re-running those 16 node ids on this PR's own base commit reproduces 15 of them, so they are the board's, not this change's: the -15 sideways-scroll cases (#121, #136), the selectableOffer keyline pair (#132), and the covering-panel and margin-thread groups.

The sixteenth is test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus, which failed on version-diff (.lf-version-diff:is(:focus-visible, .lf-focus-visible)) — the ring the versions-menu walk is the sole home for, so worth being sure about. It passed on that base run and passes on this tree twice: alone (-n0), and in its own file alongside the nine known test_render_controls.py failures. It went red only in the seven-file run, which is the load class running-tend describes.

The versions menu is also the one place a Δ is reachable by keyboard, so if that ring ever goes unlit deterministically it is this walk to look at first.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-measured e1dbebe independently on the pinned shell (Chromium 151.0.7922.34). The three findings from the previous review are fixed and the fix holds where it is claimed to; nothing new from this pass, and I have left the run-less Escape row alone — four comments already put that decision in front of the maintainer.

What I checked beyond re-running what the description claims: test_the_menu_a_first_version_opens_is_a_menu_it_can_close and test_the_versions_menu_suspends_the_pages_own_keys both fail on the merge base (0d7e0d0) and pass here — the button is disabled on a first-version page there, so v opens nothing. This PR is what takes those two back to green rather than a change that happens to keep them there. The two test_render_navigation.py failures reproduce on that same base, so they are not this branch's.

Measurements

Against a worktree at e1dbebe, with the leaf package path repointed at it — the review checkout's editable install resolves the runtime assets to the checkout, so a naive run serves the previous head's version-navigation.js. Under that mistake the newly added light-dismissal step fails about two runs in three, which is a good demonstration of the bug it was written for: standDown's hidePopover() restores focus to the button, and whether Chromium's mousedown focus fix-up clears it afterwards is a race. On the actual tree it passes 4/4 at -n0.

  • tests/test_render_anchors.py --run-nightly — 57 passed.
  • uv run pytest tests — 723 passed, 6 skipped.
  • tests/test_render_navigation.py --run-nightly — 56 passed, 2 failed: test_a_widget_that_renames_its_role_keeps_the_press_offer_gave_it and test_the_arrows_say_which_way_the_section_under_the_reader_goes. Both reproduce on 0d7e0d0.

Traced rather than read, since the diff turns on platform behaviour:

  • The v door's hand-back is the platform's. With versionBtn.focus() before the press, the popover records the button, so Escape restores to it and a light dismissal restores nothing.
  • The reference round trip. layer.lfInvoker?.focus() before showPopover() gives the re-shown menu a way out; the restore && layer.contains(restore) gate keeps it off a reader whose focus is elsewhere.
  • The page-map preview is the tree's other popover=auto and goes through the same re-show without an lfInvoker. I probed it (g m 3, ? ?, Escape) expecting the round trip to cost it its exit: it does not. Its own Escape already lands on BODY with or without the trip, so the missing link buys nothing there — worth knowing before anyone adds it on the strength of the CLAUDE.md sentence.
  • The removed versionMenu.id and the removed showVersionMenu(true) branch have no remaining readers, and versionBtn.disabled stays in step with versionsOffered() through renderVersions and the snapshot restore, so run: () => { versionBtn.focus(); versionBtn.click(); } cannot meet a disabled button while its when is live.

360c40a's tip took `CHOOSER.run` from `versionBtn.onclick()` to
`versionBtn.click()` in #142, and this branch had taken the same line to a
focus-then-click for the popover's focus hand-back. Both route the key through
the visible control; the branch's is that plus the focus, so the merge keeps it.
max-sixty pushed a commit that referenced this pull request Aug 30, 2026
…p's own press (#140)

## Problem

Two leftovers from
[335bf9a](335bf9a)
"Delegate page chrome to browser standards", which moved control
activation off a page-wide `CONTROL` scope and into rows declared where
each control is. Both are on `ci`'s red list for [the run this was
dispatched
for](https://github.com/max-sixty/leaf/actions/runs/33328596524) or
reachable from the same change, and both still reproduce at `1ca4f40`.

**`lf-worktree`'s head names fewer keys than work it.** The commit gave
the head a row binding `PRESS` — Enter and Space — over a button wearing
`aria-expanded`, which is ARIA's disclosure pattern.
`skills/leaf/CLAUDE.md` states what that costs: "every row over a
disclosure reads [`DISCLOSE`] — this scope's, and a widget's own row
re-wording the same press. Two rows naming different sets is not two
promises but one: `lineRows` prints the nearer row and drops the other
whole, so a widget naming one key fewer takes the rest off the line".
The widget row is nearer, so the arrow that opens the evidence went on
working and stopped being named — on the key line and in
`aria-keyshortcuts`, which is written once when the scope is declared
and so froze at `Enter Space`. Nothing tested it; the identical bug in
`lf-options` is what [#132](#132)
is for, and that PR does not reach this package.

**`test_a_widget_that_renames_its_role_keeps_the_press_offer_gave_it`
still asks for the deleted scope's word.** It asserts the key line reads
`press it` over a focused tab. `press it` was `CONTROL`'s `line`, and
335bf9a removed the scope in the same commit that gave `lf-tabs` its own
`tab.activate` row reading `open the tab`. The commit updated several
tests in that file and dropped
`test_the_reference_names_the_space_that_works_a_control` outright; this
assertion was missed, so the test fails before reaching the two facts it
exists to hold.

## Solution

`lf-worktree`'s head takes its keys from `DISCLOSE(head)`, the way
`lf-diff` and `lf-draft` already do, and keeps its own `run`. `DISCLOSE`
hands over only the arrow that changes the state, so the press stays a
direction rather than a second toggle; it also answers for where the
head stands, and the runtime's disclosure scope stops at the chrome. The
head is a span from `selectableOffer`, so a copy frozen into thread
markup has no platform pair underneath it the way a `details > summary`
does — the row's own press is the only thing there, which is the shape
[#132](#132) keeps for the sibling
widget. Its `line` reads the way the tree is standing, and
`aria-expanded` is written at birth so the head is never briefly a
control the runtime cannot place — without that write `DISCLOSE` hands
back both arrows, and that is the value `aria-keyshortcuts` is written
with when the scope is declared. The repaint that keeps the line and
`aria-keyshortcuts` together is the document's disclosure watch, which
[#132](#132) moved from
`paintHere()` to `paintKeys()` while this branch was open; the widget
owes none of its own, which is what `skills/leaf/CLAUDE.md` now says in
as many words.

The tabs test asserts `open the tab` — the strip's own word for the same
press — and its docstring now describes where that press is declared
rather than the scope that used to supply it. Everything after the
assertion is unchanged: Enter still has to re-select the focused tab,
and Space still has to be consumed rather than scrolling the page out
from under it.

New coverage in `test_render_projection.py` for the worktree head, since
nothing exercised it. It holds the row rather than the repaint: on the
page, both surfaces naming the row's keys — the line and
`aria-keyshortcuts` — plus a second `→` on an open tree, so a scope
answering nothing at all could not pass it. In a message: the same head
in the threads panel, where `aria-keyshortcuts` reads `Enter Space`, the
arrow moves nothing, and Enter and Space fold it. The repaint behind
both surfaces is held by
`test_a_widgets_native_control_names_the_press_the_platform_makes`,
which #132 added.

## Testing

`uv run pytest tests` at `c292244` — 723 passed, 6 skipped. After
merging `main` (which brought #132 and #143) and taking the repaint out
at `890e7ff`, `test_render_projection.py`, `test_render_navigation.py`,
and `test_render_anchors.py` — 193 passed, 4 failed, all four the
version-menu group [#137](#137)
owns and all four failing identically on `origin/main` in a clean
worktree. With `--run-nightly`, `test_render_projection.py` and
`test_render_navigation.py` — 137 passed, 1 failed, that one being
`test_the_arrows_say_which_way_the_section_under_the_reader_goes`, which
is #132's settled ask and untouched here; it fails the same way at the
merge base `1ca4f40`.

Each half of the new test was run against the code it holds and fails
there: the page half at `assert 'Enter Space' == 'Enter Space
ArrowRight'` on `main`'s `lf-worktree.js`, and the thread-markup half at
`aria-expanded` staying `"false"` under Enter with the row's `run`
removed.

<details><summary>What this does not fix in that run</summary>

The run reported 34 failures. Most of the rest already have a PR open:
the `-15` root scrollbar-gutter family is
[#121](#121) (`assert -15 == 0`,
the drawn edge landing a bar's width off the hand, the covering panel's
blank strip), the version-menu group is
[#137](#137), the settled ask's
disclosure keys were [#132](#132),
now merged, the margin and float placements are
[#138](#138), the gallery stills
are [#134](#134), and the
sidebar's stated window is
[#136](#136).

No guard stops the third widget from declaring a fixed key pair over a
disclosure. `DISCLOSE` exists so the two surfaces cannot come apart, but
a widget has to remember to call it, and two of the four widgets over a
disclosure did not. A corpus-wide check — every focusable disclosure
names the keys `DISCLOSE` gives it — would catch the next one, and is
left out of this PR because it belongs beside the corpus checks rather
than in a fix for two widgets.

</details>

---
Automated fix for [failed
run](https://github.com/max-sixty/leaf/actions/runs/33328596524)

---------

Co-authored-by: leaf-agent <[email protected]>
@max-sixty
max-sixty merged commit ff8ce5c into main Aug 31, 2026
3 of 4 checks passed
@max-sixty
max-sixty deleted the fix/ci-33328105179 branch August 31, 2026 00:53
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