Skip to content

Canonicalize target border painting - #351

Merged
max-sixty merged 17 commits into
mainfrom
codex/canonical-border-paint
Sep 7, 2026
Merged

max-sixty merged 17 commits into
mainfrom
codex/canonical-border-paint

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

Leaf's structural borders, keyboard focus rings, and annotation traces could compete for the same edges, producing double borders or partly obscured outlines. This change gives each state one paint owner: draft fields keep a single host focus ring, whole-visual annotations paint in a runtime overlay above provider content, and margin correspondence uses one quiet target trace around the actual target with no second gutter leader. Adjacent reaction and Resolve actions reserve the focused action's complete ring instead of painting over it.

The registry now declares whole-visual paint semantics, and the browser regressions cover edge visibility, pointer ownership, shaped targets, live replacement, forced colors, draft focus ownership, and the complete focus-ring census. The dev dependency now requires Pillow 12.1, whose pixel iterator those edge regressions use.

Verification

  • uv run pre-commit run --all-files
  • uv run pytest tests (904 passed)
  • CI's touched-nightly browser slice (382 passed)
  • uv run pytest tests/test_render_pages.py tests/test_render_drawing.py tests/test_render_aim.py --run-nightly (123 passed)
  • Complete focus-ring census on the integrated head (1 passed)
  • Full control nightly module on the integrated head (82 passed)
  • Drawing-send timing check repeated on the integrated head (5 passed)
  • Message reaction and inline-thread keyboard regressions (3 passed)
  • Astra code and live-preview reviews (no actionable findings)

This was written by Codex on behalf of max-sixty

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two findings from running the nightly modules against this head; the everyday suite is green here (897 passed, 6 skipped), which is why neither shows up in the stated verification.

The interaction gallery loses its control styling. examples/developer/feature-gallery.html drops 46 lines of .interaction-controls / .interaction-control / .interaction-status CSS and nothing replaces them, while interaction-gallery.js still emits all three class names. tests/test_site.py is nightly-marked in full, so uv run pytest tests never reaches the test that pins them. Also worth noting against #353, which keeps that block and only drops its :focus-visible rule — the two branches will conflict here, and this deletion undoes what that one is building on.

The new focus state escapes the .lf-shaped-mark suppression. In anchors.js, rememberVisual(found) runs before the if (!t.root.drawing) guard, so a declared visual whose only thread is a drawing comment enters visualTargets with none of .lf-mark-el / .lf-react-el / .lf-action-target. That was inert before, because setTargets filters on states.size and the element had no state; focus is now a state on its own, so the element gets lf-shaped-mark and an overlay while its own ring is still outside the suppression selector. The open drawing-draft path (if (draft) rememberVisual(draft) with pendingDrawing set) reaches it the same way. Inline suggestion below.

Measurements and verification

Gallery CSS, at this head:

FAILED tests/test_site.py::test_the_interaction_gallery_drives_real_widgets
  AssertionError: assert ['14px', '14px', '14px'] == ['11.5px', '11.5px', '11.5px']

Restoring only examples/developer/feature-gallery.html from the merge base and re-running the same node id: 1 passed.

Double ring, on WIDE_DIAGRAM_PAGE with one drawing comment anchored at {"section": "flow"}, after #flow.focus():

element:  ['lf-rendered lf-shaped-mark', outline 'auto', '1px', 'rgb(16, 16, 16)']
overlays: ['lf-ui lf-visual-mark lf-target-paint lf-visual-mark-focus', border '2px', 'rgb(74, 59, 125)']

With the suggested chrome.css split, the same probe reads outline: 'none' on the element and the single 2px overlay ring. tests/test_render_pages.py tests/test_render_drawing.py tests/test_render_aim.py --run-nightly stay green with it applied (123 passed).

Nightly modules run against this head: test_render_margin (81), test_render_drafts + test_render_drawing (86), test_render_pages (52), test_render_widgets (105), test_render_controls + test_render_aim + test_render_anchors (206 passed, 1 failed), test_render_navigation + test_render_conversations (163 passed, 1 failed). Both of those failures — test_the_composed_corpus_declares_every_control_row_archetype and test_the_feature_gallery_exercises_the_injected_core_surfaces — reproduce unchanged on the merge base, so they are main's, not this branch's.

scripts/corpus.py reports no drift, and x-visual: whole on lf-shot raised nothing in the widget, aim, or anchor modules.

Comment thread skills/leaf/assets/runtime/chrome.css Resolved
Comment thread examples/developer/feature-gallery.html Resolved

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One finding, on a line the diff doesn't touch but newly falsifies.

pyproject.toml's dev group pins pillow>=11, and _edge_ink_changes in the two new screenshot tests calls Image.get_flattened_data(), which only exists in Pillow 12. I installed 11.0.0, 11.2.1 and 11.3.0 into throwaway targets and hasattr(PIL.Image.Image, "get_flattened_data") is False in all three, so test_a_screenshot_comment_mark_paints_above_its_edge_to_edge_frame and test_a_screenshot_margin_trace_paints_one_complete_quiet_contour raise AttributeError on any Pillow 11. uv.lock pins 12.3.0, so nothing in CI or a uv sync checkout hits it — the floor is simply no longer the lowest version the suite passes on, which is the one thing the pin is for. pillow>=12 restores that. The comment above it — # scripts/record-demo.py, which draws its frames. — is now half the story too, since tests/test_render_pages.py imports Pillow at module scope. Happy to push both as a commit if you'd rather not.

Both findings from the previous pass are fixed and verified here, so nothing else stands.

Verification against bbd024a

Nightly modules, all green on this head:

  • tests/test_render_margin.py — 81 passed (the lf-target-trace rename and the margin's dropped lf-margin-target class)
  • tests/test_render_drafts.py + tests/test_render_drawing.py — 86 passed (draft focus ownership, forced colors, the drawing-only visual)
  • tests/test_render_aim.py + tests/test_render_anchors.py + tests/test_render_widgets.py — 240 passed (blast radius of widening the outline suppression to .lf-shaped-mark)
  • tests/test_render_pages.py -k "marked_scrolling_visual or screenshot_comment_mark or screenshot_margin_trace or declaring_it_renders_a_picture" — 4 passed
  • tests/test_site.py -k interaction_gallery — 1 passed, which was the failing one before

The gallery restore leaves examples/developer/feature-gallery.html byte-identical to #353's version of that file (both 1112cca4..e4cff07f), so the two branches no longer collide there. Dropping the local :focus-visible rule is safe: interaction-gallery.js builds those buttons through offer("button", …), which writes data-lf-offer="button", and the shared pressable rule in theme.css gives exactly the same outline: var(--here-ring); outline-offset: var(--here-ring-gap).

On the widened suppression: lf-shaped-mark is written in target-paint.js only inside paintTargets where an overlay is actually placed, and removed on both the dropped-target and unplaced branches, so outline: none can't outlive the overlay that replaces it. x-visual: whole on lf-shot makes isItem refuse ids inside it, which is inert given the entry's x-content: none.

scripts/corpus.py and scripts/keydocs.py both report no drift.

max-sixty added a commit that referenced this pull request Sep 6, 2026
Three nightly tests have been red on `main` since #341, and nightly runs
after `main` moves, so PR CI and `wt merge` both stay green while nobody
sees them. All three are the same seam: the live interaction gallery
injects its playback row from the runtime and leaves the authored page
owning it.

**The ring census.** The page drew `outline: var(--here-ring)` on the
injected presses without naming the ring, so the floor below divided by
a population short of it. It was drawing the ring twice over: `offer`
marks those buttons `data-lf-offer="button"`, so the theme's pressable
floor already carries the hand, the hover tint, the disabled treatment,
and a ring that names itself. The page's copies are gone and the floor's
answer stands alone. No other authored page in the corpus draws the
layer's ring.

**The control-row sweep.** The row is a control row nothing had
declared. Declaring it means proving it holds still, and it did not: the
toggle rewrites its own word as a demo runs — Loading…, Play, Pause,
Played — so pressing Replay moved the button beside it, and the live
status line changed length on the same line as both presses. The toggle
now reserves the width of every word it can say, through `reserve`, the
layer's own helper, called where the runtime builds the row —
`scripts/corpus.py` copies each source's `<main>` and none of its
`<head>`, so a rule in the gallery's head would not reach the generated
corpus, which is the page this sweep actually walks. The status line
stands under the two presses at every width rather than only on a phone;
reserving its width instead would hold the row open at the width of its
longest sentence. `interaction-playback` is the new archetype; an
archetype may now name an `example`, because a demo is a scenario the
module names rather than markup the synthetic stability page can
compose, so its proof runs on the gallery itself. Replay is the press
for the same reason the diff's review press is: the button that has to
hold still is the toggle, and pressing Replay is what sends it through
every word it has.

**The injected-surfaces walk.** The gallery's own counts had moved on:
#341 added a live undecided suggestion and a second stored version, and
merging `main` brought the playground package's ask, so the walk now
sees thirteen asks and three version rows.

`tests/test_site.py` asserted the status line's `margin-left: 0` at
390px, which the layout change makes vacuous; it now reads the invariant
that replaced it.

## Checks

`uv run pre-commit run --all-files` is clean, and `uv run pytest tests
--run-nightly` passed whole — 2096 tests — on this branch before `main`
moved under it.

On the merged tree that full run reports 11 failures. A paired control,
a detached checkout of `ca4ac82d` with none of this branch on it, fails
10 of the same tests, so they arrived with the eight PRs that landed
while the first run was going. The eleventh,
`test_a_failed_preview_bootstrap_hears_the_replacement_server[theme.css]`,
passes on its own here and on the control: a flake in a 27-minute run.
The three tests this PR is about pass.

Nightly is red on `main` for two reasons this PR does not reach, both
worth someone's attention:

- the playground package's Reset, Copy instruction and Apply card share
rows and match no archetype, so
`test_the_composed_corpus_declares_every_control_row_archetype` fails on
`main` for that reason now instead;
- `.lf-resolve.lf-icon-action` (#347) has the left edge of its focus
ring under `.lf-react-trigger` (#349) in the ship-review thread, two
independent PRs whose rows now overlap by two pixels, which
`test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus`
reports as 2 faults over 714 stops.

Plus pre-existing reds in `test_render_anchors`, `test_render_export`,
`test_render_projection` and `test_render_widgets`, all present on the
control. **#340 is the standing
fix for the shape of this: nightly modules a PR touches never run before
it lands.

## Overlapping PRs

**#353 repairs the same three
readings, and opened while this branch's first suite was running. It
took the `reserve` route from the start, which is where this one has now
arrived; it also rehomes the scenarios' `#bg-motion-*` lookups onto the
stage, which this does not. One of the two should close, and which is
Max's call.

## Note for #351

**#351 deletes this same block
of gallery CSS and rehomes none of it, which would leave the injected
buttons without their pill shape or their `--aim-floor` aim target.
Whichever lands first, the other conflicts here.

> _This was written by Claude Code on behalf of max-sixty_

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01Q7ZBoNLYxFVhWgDsXH1RTx

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

pillow>=12 moves the floor but doesn't reach it: Image.get_flattened_data() arrived in 12.1, not 12.0, so the two screenshot tests still raise AttributeError on the lowest version the pin admits. pillow>=12.1 is the version the suite actually passes on. uv.lock records the specifier in [package.metadata.requires-dev], so it needs uv lock alongside the edit.

Everything else on this head checks out — the shaped-mark specificity fix is verified inline above, and the nightly modules the branch touches are green.

Measurements against 3f5e6c5

get_flattened_data by version, installed into throwaway targets:

12.0.0 -> False
12.1.0 -> True
12.2.0 -> True
12.3.0 -> True

The suite, with each shadowing the environment's 12.3.0 on PYTHONPATH:

PYTHONPATH=/tmp/pil-12.0.0 … -k "screenshot_comment_mark or screenshot_margin_trace"
  AttributeError: 'Image' object has no attribute 'get_flattened_data'
  tests/test_render_pages.py:831
  2 failed

PYTHONPATH=/tmp/pil-12.1.0 … same selection
  2 passed

Nightly modules on this head:

  • test_render_aim + test_render_anchors + test_render_widgets + test_render_margin + test_render_drawing + test_render_drafts — 399 passed
  • test_render_pages + test_render_controls — 131 passed, 1 failed
  • test_site.py -k interaction_gallery — 1 passed
  • test_render_pages.py -k "marked_scrolling_visual or screenshot_comment_mark or screenshot_margin_trace" — 3 passed

The one failure is test_the_composed_corpus_declares_every_control_row_archetype, which fails on origin/main too — on main naming Reset / Copy instruction / Apply card, here naming Play / Replay. Same assertion, different sampled rows across runs, so it is main's and not this branch's; the moving row set suggests the test reads before the gallery has settled rather than a corpus gap.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The three commits since 3f5e6c56 pull in work that three open bot PRs are already carrying, and only one of the three is fully superseded — so this is worth settling before landing rather than after.

  • #367 is fully superseded. e08a09d0 rewrites the same .lf-msg.claude:has(> .lf-msg-head > .lf-resolve) > .lf-react-strip > .lf-react-trigger declaration in both chrome.css and theme.css, and adds the same "a reaction palette" entry to RING_WALKS, RING_SCOPE_SURFACE and RING_SCOPE_CONTROL. Nothing is left over in that branch.
  • #369 is partly absorbed. e8e87b1c's lf-draft.js guard and 415ed8f3's test_render_anchors.py rewrite are the same two repairs in a different form, but #369 also carries the Resolve → Resolve thread rename in test_render_projection.py and the spent-face reading in test_render_widgets.py, neither of which this branch touches. Closing it as a duplicate drops those.
  • #366 is partly absorbed. e8e87b1c's test_render_controls.py hunk — the stable-playground markup and the playground-actions archetype — is byte-identical to #366's, comment included. What is not here is #366's product fix, render-checks/standalone.js taking the group role off a baked copy that kept no control, plus its render_cases_interaction.py case; those are what test_an_exported_page_fixture_stands_on_its_own and test_the_render_gate_applies_every_standing_action_a_second_time need.

The one place the two implementations disagree on substance is the trigger's clearance. .lf-btn:is(:focus-visible, .lf-focus-visible) in chrome.css names outline-offset: 2px, and --here-ring-w is 2px (theme.css), so Resolve's ring ends 4px outside its box. This branch reserves 2px + var(--here-ring-w) — exactly 4px, so the trigger's edge lands flush on the ring's outer edge with no gap; #367 reserves var(--here-ring-w) + 2px + 2px and keeps the 2px. Both clear the census (I ran it), so this is a look rather than a defect — but the literal 2px here is standing in for .lf-btn's outline-offset rather than deriving from it, and at zero clearance a later change to that floor under-reserves silently. theme.css reuses the same literal where the governing offset is 1px (.lf-conversation-thread :is(.lf-btn, textarea, summary):is(:focus-visible, .lf-focus-visible)), so the two sheets agree by coincidence rather than by shared derivation.

The pillow>=12.1 finding from the last pass is fixed and uv lock --check is clean. Nothing else in the three commits reads wrong to me.

Verification against 8463651

Ran on this head, -n0:

  • tests/test_render_controls.py -k "control_row_archetype or ring" — 10 passed. This covers both the new playground-actions archetype and test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus, which is the reading the trigger offset is for.
  • tests/test_render_drafts.py -k empty_draft_survives_reload and tests/test_render_anchors.py -k diff_surface_keeps_the_complete_thread_lifecycle — 3 passed.
  • uv lock --check — resolved, no drift.

On the draft guard: #ta is assigned in #open immediately after this.#row.replaceChildren(this.#save, this.#cancel), and #close clears it immediately before putting the pencil back, so at the moment the deferred measurement runs the row already holds exactly what the guard preserves. replaceChildren appears at only those three sites in the module, so no other path can leave #ta set over a row in a different shape. The reserve itself is unaffected — #save is still in the live row when its width is read.

On 415ed8f3: x was the thread.resolve row in keyboard/page.js, removed by #347 (ca4ac82d) when the conversation controls became icon actions, so the old press genuinely no-ops now. THREAD keeps only Enter for reply/reopen, and Resolve keeps its keyboard route as an ordinary Tab stop, which is what the rewritten test walks.

On the archetype hunk: diff of the added lines in e8e87b1c against #366's addition to the same file reports no difference across all 27 lines.

…r-paint

# Conflicts:
#	skills/leaf/assets/theme.css
#	tests/test_render_margin.py
…r-paint

# Conflicts:
#	skills/leaf/assets/runtime/chrome.css
#	skills/leaf/assets/theme.css
#	tests/test_render_controls.py
…r-paint

# Conflicts:
#	skills/leaf/packages/default/widgets/lf-draft.js
#	tests/test_render_anchors.py
#	tests/test_render_drafts.py
@max-sixty
max-sixty merged commit 5d57131 into main Sep 7, 2026
4 checks passed
@max-sixty
max-sixty deleted the codex/canonical-border-paint branch September 7, 2026 03:20
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