Repository navigation
Simplify Leaf UI hierarchy - #443
Conversation
Reduce repeated borders and passive controls across the banner, thread panel, version selector, action buttons, and neighboring-page rows. Keep active and keyboard-focus states explicit while making resting chrome quieter. Project element annotation rails into Leaf's chrome layer so child surfaces cannot cover them, and remove thread location copy already supplied by its group heading.
leaf-agent
left a comment
There was a problem hiding this comment.
Twenty-one nightly browser tests go red on this branch, and one of them is a real product regression rather than an assertion that needs updating.
The PR body's "complete local suite passes with 910 tests" is the everyday suite: uv run pytest tests reports 904 passed, 6 skipped here, and per tests/CLAUDE.md broad discovery skips every test_render_*.py module — which is every module this change touches. The complete suite is uv run pytest tests --run-nightly. I ran 7 of the 22 render files against this head and against the merge base (37b8478f), same platform, same -n and selection; the base has 5 failures, this head has 26.
The 21 failures this branch adds (base-verified)
tests/test_render_anchors.py::test_an_ambiguous_revised_passage_detaches_until_the_agent_moves_it
tests/test_render_anchors.py::test_a_passage_longer_than_the_pattern_is_anchored_whole
tests/test_render_anchors.py::test_one_neighbour_is_not_enough_to_identify_a_revised_comment
tests/test_render_anchors.py::test_a_selection_of_the_whole_page_still_finds_its_passage
tests/test_render_anchors.py::test_a_data_bound_diff_aims_and_selects_one_source_line
tests/test_render_anchors.py::test_the_menu_a_first_version_opens_is_a_menu_it_can_close
tests/test_render_anchors.py::test_a_diff_surface_keeps_the_complete_thread_lifecycle_inline[light]
tests/test_render_anchors.py::test_a_diff_surface_keeps_the_complete_thread_lifecycle_inline[dark]
tests/test_render_anchors.py::test_dismissing_versions_during_thread_upgrade_preserves_the_new_version
tests/test_render_conversations.py::test_a_thread_on_a_widget_in_a_reply_travels_in_the_panel_that_holds_it
tests/test_render_controls.py::test_a_phone_banner_folds_its_addresses_into_one_menu
tests/test_render_aim.py::test_an_aimed_press_does_only_what_the_outline_promised[ship-review]
tests/test_render_aim.py::test_design_mode_comments_on_what_a_press_lands_on_and_nothing_else
tests/test_render_navigation.py::test_the_feature_gallery_exercises_an_inline_diff_thread
tests/test_render_navigation.py::test_the_pointer_over_a_comment_lights_the_passage_it_is_about
tests/test_render_navigation.py::test_no_two_hints_on_the_key_line_say_the_same_word
tests/test_render_navigation.py::test_target_mnemonics_filter_the_generated_map_without_renumbering_hints
tests/test_render_navigation.py::test_banner_destinations_use_transient_target_overlays
tests/test_render_navigation.py::test_typing_in_a_selected_comment_wins_over_page_shortcuts
tests/test_render_navigation.py::test_a_text_box_keeps_its_keys_from_the_widget_around_it
tests/test_render_navigation.py::test_a_key_on_screen_is_a_key_that_works
Pre-existing at 37b8478f and excluded: the three 435.8px → 453.7px fold-geometry cases and test_a_coined_class_cannot_reach_the_chromes_rules in test_render_conversations.py, and test_an_inline_thread_uses_surface_focus_until_its_reply_takes_over in test_render_navigation.py. I did not run the other 15 render files.
A thread card can lose its quote for the life of the tab
Seven of those failures are one bug, and it is in the product. anchorLabel's new if (omitted === item) return "" fires when both are null: threadAnchorLabel passes group.target, which is undefined for every group without a heading (gone, page, top, layer, sent), the parameter default turns that into null, and elementById returns null whenever the anchored element is not in the document yet. Instrumented on test_a_thread_on_a_widget_in_a_reply_travels_in_the_panel_that_holds_it, the first call for tv-on-it is {group: 'gone', target: undefined, item: null, out: ''} and every later call is '§ options · Redis A signed cookie'.
That first call is the one threadNode builds from, so no .lf-quote is created — and paintThreadQuotes' if (!quote) continue means one is never created afterwards. The card permanently loses its quote, and with it the passage.return binding and the only route from the panel back to the passage. Same mechanism blanks the quote on a freshly-sent comment before the anchor pass has resolved it, which is what the four test_render_anchors.py detach cases are seeing.
The new if (!said) { quote?.remove(); } compounds it: said is thread && threadAnchorLabel(...), so it is also falsy when the card's data-id has no match in threadList() — the optimistic card between the send and the log's answer. That path removes a quote the thread still wants, one-way.
I applied the two guards below locally and 7 of the 21 failures go green with no other change. Because removal is one-way, it is worth deciding whether paintThreadQuotes should build the node when said is present and quote is not, rather than only reconciling words and absence.
Three failures are a behaviour reversal, not test drift
versionsOffered() moving from > 0 to > 1 means a single-version page can no longer open the versions menu at all, which reverses the decision the removed comment stated ("a first version has no neighbour, but its menu still explains that version"). test_the_menu_a_first_version_opens_is_a_menu_it_can_close, test_dismissing_versions_during_thread_upgrade_preserves_the_new_version, and both test_a_diff_surface_keeps_the_complete_thread_lifecycle_inline params fail on it. The passive-label reading is defensible, but the second of those tests covers state application racing an open menu and would need re-targeting rather than deletion, and a lone version's label and date currently have no other surface.
The export keeps lf-projected-mark
skills/leaf/scripts/leaf/render-checks/standalone.js removes lf-mark-el (all(".lf-mark-el").forEach((el) => el.classList.remove("lf-mark-el"))) and nothing removes the projection class. .lf-projected-mark { outline: none; } matches on its own, so an exported page keeps outline: none on every element that carried a comment, reaction, action target or hover at export time, with the .lf-mark-el:not(.lf-projected-mark) fallback unable to restore anything — including boxes the same script re-grants a scroll stop to. This held for lf-shaped-mark before, on declared visuals only; the projection widens it to any annotated element. One line beside the existing removal closes it — happy to push that if you want it separated out.
# Conflicts: # skills/leaf/assets/runtime/chrome.css
|
Twenty of the twenty-one regressions are gone at It is the version change rather than the test. The fold's own reading makes the same point without the test. A passive token is orientation while it sits on the banner row, which is what the code comment claims for it; folded, it is a dimmed row in a menu of addresses, spending the menu's room and offering no route out of it. Either keeping it off the fold while it is passive, or rendering that state as a label rather than a disabled button, restores both the reading and the walk. The three findings from the last round I do read as closed at this head: the What I ran, Linux, `-n0`, at
|
|
Fixed in
|
|
The product half of It is font metrics, not the fold. At 390px the row is 390px wide and needs 398px with The two readings the change actually names hold at every width I measured: Worth a look while the priority is fresh: the label sits ahead of the whole foldable run, so at 600px Nothing else in my selection is red at this head. Measurements and the runs behind them, Linux,
|
leaf-agent
left a comment
There was a problem hiding this comment.
The 8px that decides test_a_phone_banner_folds_its_addresses_into_one_menu on this platform is the version control's own reservation, and it is reservable smaller. versionLabels() now passes disclosure = true explicitly, so the floor reserveBannerControls takes is measured on Δ v999 ▾ — 75px — while versionLabel drops the ▾ in exactly the state that makes the control passive, and Δ needs a version to compare against. Measured on the live control at 390px: the widest passive token (Draft, v999) is 50px, and with that floor in place the row reports scrollWidth 390 against clientWidth 390 with v1 standing on it. So the yield branch never fires, the assertion the commit added passes, and "quiet orientation stays on the row" stops depending on which platform's system-ui the suite is reading.
The catch is that the 75px floor is what absorbs the ▾ when a page gains its second version mid-session, which is the reflow reserveNewsSlot(latestChip)'s own comment is written to prevent — publication moving Approve and Threads under a reaching pointer. renderVersions already computes offered on every state application, so the floor can be re-taken on the flip rather than held at the active width for a published page's whole life. That is a change to what the reservation asks for, not a line to delete.
I would rather have that than the alternatives already on the thread, because widening the test to 430px leaves the token vanishing at phone width with nowhere to go — foldable() filters lf-passive out so it never reaches the menu, and versionsOffered() being false takes the chooser and g V with it — and asking for the parent instead of visibility stops asserting the thing the commit is for.
The measurement, ubuntu-24.04, Playwright headless shell, at 29bac722
Taken through reserve's own procedure on .lf-version at 390px, then applied as its min-width:
widest of ["Draft ▾", "Δ Draft ▾", "v999 ▾", "Δ v999 ▾"] 75px (what versionLabels() asks for)
widest of ["Draft", "v999"] 50px (what a passive token can say)
with the 50px floor: clientWidth 390, scrollWidth 390, .lf-version width 50, text "v1"
For contrast, at the 75px floor the same row is scrollWidth 398, which is the overflow that sends the yield branch to display: none.
|
Fixed in
|
|
The narrow floor is the movement, not the retake. So one reservation cannot pin both readings. "Quiet orientation stays on a 390px row" and "a poll leaves the banner where it was" are in direct competition, and my earlier suggestion took the first without pricing the second — I measured the row at 390px with one version on it and not what the smaller floor costs when the second one arrives.
The four runs behind thisWith the commit reverted and L1495 kept, the phone case fails on that line alone; the accessibility snapshot of the row at 390px reads |
leaf-agent
left a comment
There was a problem hiding this comment.
Two findings at 759f25e7. The first is a regression an existing test already pins; the second is a one-way loss of the version chooser that survives whichever way the first is settled.
The reservation now moves the row it existed to hold still
tests/test_render_controls.py::test_the_poll_leaves_the_banner_where_it_was is red at this head and green at both the merge base 7e403108 and 29bac722. Publishing a second version shifts ⋯, Asks 0/3 and Accept all (3) 43px left as the version control widens from its passive token to the disclosure set — the exact motion that test's publish_v2 step exists to forbid. It is a test_render_* module, so broad discovery skips it and this PR's ci stays green; the daily run is where it lands, and the body's "the six remaining failures reproduce unchanged on origin/main" no longer holds at this head.
It is not only the publish path. On a two-version page the retake fires on the first state application, so the row moves once shortly after every load. Sampling .lf-version's min-width per frame from before the runtime boots gives 40px "v2" then 83px "v2 ▾" on this branch, against a single 83px sample at the merge base — nothing published, the reader just watching the banner settle.
skills/leaf/assets/CLAUDE.md states the rule the reservation implements: "Control state is paint: ink, fill, border, or an inset ring. Do not express it by changing font weight, size, padding, border width, or another metric." Passive-versus-actionable is now 43px of width.
I proposed the retake-on-flip last round, and this is where it lands: re-measuring is the motion, so the 8px the phone case turns on and a reservation that holds for the control's life cannot both be had this way. Which one the row gives up is the decision here — a fixed disclosure-width floor with the 390px case asserting the parent rather than visibility, or a passive-width floor whose growth the row absorbs somewhere other than its own geometry.
One consequence of the retake either way: it calls unfoldShelf() from a state poll, and foldShelf() returns early while the overflow menu is open — so a publication arriving while a reader holds the phone menu open empties that menu onto the row until they close it.
A passive label that yields its ink never gets it back
refold restores display for passive(), but the control it hid may not be passive by the time the next fold runs. On a 320px row the version label yields; when a second version lands it stops being lf-passive, its inline display: none is never cleared by anyone, and the chooser is invisible for the rest of the tab's life — g V still opens the menu, but the pointer route and the version's own orientation are gone, and widening to a desk window does not bring them back. That is the same one-way shape as the quote removal from the first round: the state is entered by a fold and left by nobody.
The two inline suggestions key the restore to what the fold hid rather than to what the control is now. With them applied, the same scenario folds the chooser behind the door at 320px and returns it to the row at 1200px.
Runs and measurements, Linux, -n0, at 759f25e7
The invariant test, and its control at the merge base:
$ uv run pytest -q -n0 tests/test_render_controls.py::test_the_poll_leaves_the_banner_where_it_was
E AssertionError: a new version is published and the banner moved:
E button.lf-btn.lf-banner-more "⋯" moved by [-43, 0, 0, 0] (left, top, width, height)
E button.lf-btn.lf-asks.lf-workspace.lf-news-shown "Asks 0/3" moved by [-43, 0, 0, 0]
E button.lf-btn.lf-answer-all.lf-news-shown "Accept all (3)" moved by [-43, 0, 0, 0]
E button.lf-btn.lf-version.lf-passive "v1" moved by [-43, 0, 43, 0]
$ git worktree add /tmp/base 7e403108 && cd /tmp/base
$ uv run pytest -q -n0 tests/test_render_controls.py::test_the_poll_leaves_the_banner_where_it_was
1 passed
29bac722 also passes it, so the increment is where it turns red. The rest of test_render_controls.py is green here (87 passed), as are the version, banner, publish and poll cases in test_render_navigation.py and test_render_anchors.py (11 passed).
Every distinct min-width the version control wears, sampled per animation frame from an init script, on a live two-version page:
this branch: [['40px', 'lf-btn lf-version lf-passive', 'v2'], ['83px', 'lf-btn lf-version', 'v2 ▾']]
7e403108: [['83px', 'lf-btn lf-version', 'v2 ▾']]
The stuck label, on a live 390px-class page narrowed to 320px so the yield fires, publishing v2 mid-session and then widening:
BEFORE cls 'lf-btn lf-version lf-passive' inline 'none' min-width 32px text 'v1' visible False
AFTER cls 'lf-btn lf-version' inline 'none' min-width 75px text 'v2 ▾' visible False
WIDE cls 'lf-btn lf-version' inline 'none' min-width 83px text 'v2 ▾' visible False (1200x900)
With the two suggestions applied, the same three readings are visible False (yielded), then in lf-banner-menu behind the door, then visible True on the row.
|
Both findings from the last round hold at The version menu's keyboard case lost the wait its own comment names — #446. The standing comparison is now ink alone — #447. Removing the |
…ts (#444) [#441](#441) moved Resolve out of the first message's metadata row and into the thread's own corner. Three nightly readings still described the old address. [#443](#443) has since landed the margin one on `main` — it dropped that test's `.lf-conversation-head` reading and loosened Resolve's box to the thread's own — so this branch now carries the two that remain. `test_render_startup.py::test_a_thread_says_what_the_agent_is_doing_about_it` asserted the receipt's `nextElementSibling` matches `.lf-resolve`. Nothing follows the receipt in the head now, so the probe raised `TypeError: Cannot read properties of null (reading 'matches')` before it could assert anything. The case keeps the claim it was making — the receipt is metadata on its own message rather than a full-width row — and pins it at the new address, as the row's last element. That is what `paintAcknowledgmentsNow` guarantees by passing `null` as the receipt's `before` for a message head. `test_render_navigation.py::test_inline_thread_surface_has_room_without_focus_reflow` already said Resolve does not hang below the first inline message's row, but that reading is vacuous on its own: a control that leaves the corner and takes a full-width row above the head is still the thread's first flow child, so it lands at the content top and right edge and the head is pushed below it — the bound holds either way. The case now also asserts `head.top < control.bottom`, which is what fails under that layout. Verified on the merged head: both named cases pass, and so does the margin case this branch no longer touches. Pre-commit passes on all three files. --------- Co-authored-by: leaf-agent <[email protected]>
`test_the_version_menu_is_worked_by_pointer_and_key` fails intermittently on `main` — two of five whole-file runs under `-n2` — where the reopen after the comparison walk finds `.lf-version-row[data-lf-version="1"]` resolved but `inactive`. The failure is a missing wait rather than a product fault, and the wait is one this file used to have. #443 made the closed version chooser a stable token: `paintDiff` now writes `versionBtn.textContent = currentVersionToken()` with no reading of `diffOn`, so the label says `v2` whether or not a comparison is standing. The assertions that read that label were rewritten to match, and three of them became tautologies in the process. The one at line 3265 was the file's settle point, and the four comment lines above it still say so — "the base is settled when the chooser says so, and the base's document is a fetch away, so a test that closed the menu on the press alone would ask where the walk stands from a loaded machine and be told the version being read." That is the state the reopen below reads. Nothing holds for it now, so the Escape and the reopen can run before the walk's comparison has settled, and the open lands on a row the base has not reached. This restores each reading on the class the same commit already adopted for `test_the_menu_compares_with_any_version_older_than_this_one` — `on`, which `paintDiff` toggles beside the text. Three sites gain a reading rather than a rewrite: the settle point at line 3265, the standing comparison the reopened menu reports, and the ArrowDown that the comment calls "the way off it", which now asserts the comparison cleared rather than re-reading a token that never changed. `test_render_projection.py`'s comparison retry gets the same reading; it did not fail, because the `lf-ins-block` assertion after it still gates. Verified on `main` at `51ddc7e3`: the whole of `tests/test_render_anchors.py` under `-n2` passes three runs from three with this change, against two failures in five without it, and the projection case passes. <details><summary>The runs behind this</summary> Whole file, `-n2`, Linux, same runner throughout: ``` 51ddc7e, as it stands fail, fail, pass, pass, pass (2/5) 51ddc7e + this change pass, pass, pass (0/3) 7e40310 (before #443) pass (0/1) ``` The failure: ``` FAILED tests/test_render_anchors.py::test_the_version_menu_is_worked_by_pointer_and_key AssertionError: Locator expected to be focused Actual value: inactive waiting for locator(".lf-version-row[data-lf-version=\"1\"]") 14 × locator resolved to <button role="menuitem" data-lf-version="1" data-lf-revision="1" class="lf-version-row lf-compared">…</button> - unexpected value "inactive" ``` It passes alone under `-n0` every time; the whole file under `-n2` is what gives the unsettled reopen room to happen. </details> Co-authored-by: leaf-agent <[email protected]>
…ison (#447) On `main` a standing version comparison is signalled by ink alone: the closed chooser's text goes from `rgb(28,27,24)` to `rgb(47,84,128)` in light and from `rgb(232,228,219)` to `rgb(143,176,216)` in dark, with the background and border transparent in both states. That is 2.16:1 and 1.77:1 against the control's own resting ink, on a two-character token, and it is the whole of what a reader sees. Before #443 the same state wore four things — the word `Δ`, accent ink, an accent border and a chip fill. The commit that made the label a stable token removed the word so that the control could not resize the row and displace the addresses to its left, which is worth keeping. The other three went for a reason nobody chose: [`.lf-btn.on`](https://github.com/max-sixty/leaf/blob/6cdcb79be52ededfad20261b5b87cec8ad5519e7/skills/leaf/assets/theme.css#L1992) sets `border-color`, `color` and `background`, and two rules clear the border and the fill at the same specificity, later in the cascade — the row's resting rule so that an address cannot resize the row, and the overflow menu's so that a folded address reads as a row rather than as a chip. Either place left the class painting ink alone. This restates the treatment the open workspace already wears in both: a chip fill and an inset accent ring, at [`.lf-banner-actions > .lf-btn.on`](https://github.com/max-sixty/leaf/blob/6cdcb79be52ededfad20261b5b87cec8ad5519e7/skills/leaf/assets/runtime/chrome.css#L834) and [`.lf-banner-menu > .lf-btn.on`](https://github.com/max-sixty/leaf/blob/6cdcb79be52ededfad20261b5b87cec8ad5519e7/skills/leaf/assets/runtime/chrome.css#L916). The menu matters because `.lf-btn.lf-workspace[aria-expanded="true"]` carries three classes' worth of specificity and outranks the menu's resting rule on its own, so an open workspace survived the fold while a comparison did not — the banner's two active states diverging in the place the treatment's argument is about. `banner-shelf.js` states what the fold owes an address: it is "the row's own nodes moved rather than copied, so a folded address keeps its accessible name, its state paint, its title, its press and its own page key: nothing about it changes except where it stands." Neither a fill nor an inset ring is a metric, so this does not reopen what #443 closed: the closed chooser measures 58px comparing and not comparing, in both schemes, and `test_the_poll_leaves_the_banner_where_it_was` stays green. The menu reserves no width at all, so the paint costs nothing there either. Focus stays on `outline`, so the new `box-shadow` displaces no ring. `test_a_folded_address_keeps_the_paint_that_says_it_is_doing_something` reads the one control on the row and again inside the open menu, rather than a number in either. Without the menu rule it reads `rgba(0, 0, 0, 0)` with no shadow behind the fold against `rgb(238,234,222)` with the inset accent ring on the row. A screen reader was never the gap here — the `aria-label` reads `v2: comparing with v1; open versions` in every one of these states. This is for the reader who has the page. <details><summary>Measurements and runs, Linux</summary> `getComputedStyle` on the closed `.lf-version` of a two-version page, comparison off then on, before and after this change: ``` main light ink rgb(28,27,24) → rgb(47,84,128) bg transparent both, no shadow main dark ink rgb(232,228,219) → rgb(143,176,216) bg transparent both, no shadow this branch light bg → rgb(238,234,222) shadow rgb(47,84,128) 0 -2px inset width 58 → 58 this branch dark bg → rgb(45,41,34) shadow rgb(143,176,216) 0 -2px inset width 58 → 58 ``` For contrast, the same page before #443, at `7e403108`: ``` light "v2 ▾" ink rgb(28,27,24) bg rgb(255,254,251) border rgb(213,207,194) → "Δ v2 ▾" ink rgb(47,84,128) bg rgb(238,234,222) border rgb(47,84,128) ``` Stepping a two-version suggestions page with sign-off down through the fold, comparison on, light scheme, at `6cdcb79b`: ``` 390: folded False bg rgb(238,234,222) shadow rgb(47,84,128) 0px -2px 0px 0px inset 340: folded True bg rgb(238,234,222) shadow rgb(47,84,128) 0px -2px 0px 0px inset 320: folded True bg rgb(238,234,222) shadow rgb(47,84,128) 0px -2px 0px 0px inset ``` Runs with this change: ``` $ uv run pytest -q -n2 --run-nightly tests/test_render_controls.py \ tests/test_render_anchors.py::test_the_menu_compares_with_any_version_older_than_this_one 91 passed $ uv run pytest -q -n2 --run-nightly tests/test_interact_layer.py 164 passed, 6 skipped ``` `skills/leaf/mcp-app/page-app.html` carries no banner chrome — `lf-banner-actions`, `lf-banner-menu` and `lf-version-menu` are all absent from it — so this needs no rebuild there. </details> --------- Co-authored-by: leaf-agent <[email protected]>
Reduce repeated borders and passive controls so active workspaces, keyboard focus, and annotations carry distinct visual weight.
The responsive light/dark browser sweep and a context-blind reply task passed. All regressions identified in review now pass, as do the 910-case everyday suite and all repository hooks. In the complete 2,191-case browser-inclusive run, the six remaining failures reproduce unchanged on
origin/main.