Repository navigation
Seat the option binding badge on its Add action - #887
Conversation
leaf-agent
left a comment
There was a problem hiding this comment.
The card presentation loses the draft row's binding badge whenever the draft already holds text, and it takes an existing test with it: tests/test_render_widgets.py::test_ask_action_binding_badges_stay_aligned_when_focus_enters_a_card fails on this branch and passes on the merge base (4eaba8989937ca3494c1cd9fd457177220afcef7). It fills the add field, Tabs away, and expects the row's [data-lf-ask-binding-badge] beside the now-visible Add press. It is nightly-marked, and ci.yaml's nightly job carries github.event_name != 'pull_request', so neither uv run pytest tests nor this PR's gate selects it — main's own run would be the first to go red.
The two faces are not mutually exclusive. The text scope withholds the Ask bindings only while focus is in the field, but the press is revealed by content, which outlives focus. Write half an option, click away, then ask for bindings, and both are live at once. The press carries z-index: 1 (.lf-compose-submit { position: absolute; z-index: 1; … } in skills/leaf/assets/shadow.css), so it now paints over the badge this diff moved underneath it; exposedBindingBadge in skills/leaf/assets/runtime/asks/view.js hit-tests the badge's sample points, finds the press on top, and restores the badge to display: none in favour of a core chip. Measured on ASK_PAGE's #bracket card: base wears the inline badge at x≈862, just inside the press at x≈897; on this branch the inline badge is gone and the route's chip lands at x≈218 — the row's leading corner, some 680px from the Add press it is labelling. The second seat this diff removes as "an empty second action" is what kept the badge on its press in the one state where both faces are painted.
The new test does not reach that state: its only content-state reading is taken with focus still in the field, which is the single arrangement in which the mutual-exclusion claim holds.
Underneath it — the comment says "The draft has one trailing action seat", but nothing in the CSS states that seat; it is recomputed twice from parts. --lf-option-action-badge-inset restates --sp-1, which .lf-another .lf-compose-submit names independently as its own inset-inline-end/inset-block-end a few rules below, and restates max(28px, var(--aim-floor)) as a local --lf-icon-action-hit, a third copy of the value .lf-icon-action and .lf-compose-field each declare for themselves in shadow.css. Change either and the badge decenters with nothing to catch it. If one seat is the idea, name it once and place both occupants from it. That named seat is also where a rule about which face may occupy it would live, rather than being left as an assumption the runtime discovers at paint time and works around by relocating the badge to the other end of the row.
How the regression was measured
One probe, run twice with only skills/leaf/packages/default/theme.css swapped between the branch version and the base version: open ASK_PAGE, fill #bracket > .lf-another textarea, click #h to leave the field, press a twice, then read the row's .lf-key-badge, the .lf-compose-submit box, and any .lf-ask-binding-badges > .lf-ask-binding-badge.
- base: badge wears
data-lf-ask-binding-badge, box at x≈862.5 (width 19); press at x≈897.5; no core chip. - branch: badge has no attribute and computes
display: none; press unchanged at x≈897.5; one core chip "3" at x≈218. The row box starts at x≈211.5.
The shipped test reproduces the same state: uv run pytest tests/test_render_widgets.py -k binding_badges_stay_aligned_when_focus_enters_a_card passes on 4eaba89 and fails on the branch with element(s) not found for #live-question > .lf-another > .lf-key-badge[data-lf-ask-binding-badge]. It is the only failure among the 37 ask- and badge-related cases in that file; tests/test_render_options.py and tests/test_render_options_addition.py are green on the branch.
leaf-agent
left a comment
There was a problem hiding this comment.
The seat model is the fix the last round was asking for, and it holds: test_ask_action_binding_badges_use_the_available_card_action_seats passes on this head, a populated blurred card draft keeps its inline badge instead of dropping to a core chip, and --lf-option-add-seat-inset is now the one place the press and the badge are placed from. tests/test_render_options_addition.py, tests/test_render_options.py and tests/test_render_widgets.py -k "ask or badge or option" are green here (58 and 38 passed).
One thing the collapse took with it. --lf-option-action-room reserves the write-badge seat on every .lf-another, but only the card presentation seats a badge there. In the row presentation lf-options:not(:has(> lf-option > strong)) > :is(lf-option, .lf-another) puts the badge on the leading --lf-key-badge-col, so the trailing area holds the Add press alone — and the card-scoped padding-inline-end override this diff removed is what used to keep the two reservations apart. Measured on ASK_PAGE's #jobs group, the draft textarea's padding-inline-end goes 48px to 67px and typed text now stops 35px short of the Add press instead of 16px, with nothing standing in the 19px. The card group is unaffected: 75px to 67px, the same 8px past the badge.
That is the seat model stopping one level short. How much trailing room a row holds follows from which seats that presentation has, and .lf-another declares it as if both presentations had both — the same shape as the inset the last round was about, one rule further out. Declaring --lf-option-action-room at the Add seat in the base rule and re-declaring it with the write seat inside the card block puts it beside the two badge rules that decide the question. Happy to push that if you'd like it.
How the row-presentation reservation was measured
One probe, run on this head and on the merge base (588e0211c05e97c373edf7220d72560af8e6114c): open ASK_PAGE, fill #jobs > .lf-another textarea, then read the textarea's computed padding-inline-end, its right edge, and the .lf-compose-submit box.
- base:
padding-inline-end48px, text stops at x 881.5, press left at x 897.5 — 16px clear. - head:
padding-inline-end67px, text stops at x 862.5, press unchanged at x 897.5 — 35px clear.
#bracket, the card group, reads 75px on the base and 67px here; its badge occupies 40px to 59px from the row end either way, so the clearance past it is --sp-2 in both.
The “Another option” row always reserved separate trailing seats for its binding badge and hidden Add press, which left the empty-state badge floating inward from the action it describes.
This gives the form one declared action-seat model. While the draft is empty, its binding badge occupies the hidden Add seat. Content reveals Add in that same edge seat; in the card presentation, after focus leaves the field and both actions are available, the binding badge moves to the adjacent inner seat. Each presentation reserves only the seats it can use up front, so none of those transitions move the text or controls or leave an empty action-sized gap.
Browser coverage now checks the shared empty-state geometry, the direct click-to-input transition, the revealed Add press, the populated blurred state where both actions coexist, the absence of a fallback badge, and consistent end alignment across row and card presentations.
Validation:
uv run pytest tests,npm run test:runtime,uv run pre-commit run --all-files, and direct baseline/candidate browser comparison.