Skip to content

Distinguish thread focus from control focus - #391

Merged
max-sixty merged 14 commits into
mainfrom
codex/focus-appearance
Sep 7, 2026
Merged

max-sixty merged 14 commits into
mainfrom
codex/focus-appearance

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Thread browsing used to surround an entire conversation with a persistent 2px accent outline, making a large composite region read like a focused control. This replaces that second box with a shared current-surface treatment: panel cards repaint their existing 1px edge, while unbordered inline conversations reserve a small symmetric resting gutter and draw the same quiet edge inside it. Both receive a slight wash, and compact controls retain the strong focus ring.

When the reply field takes focus, its ring becomes primary and the parent conversation recedes. Windows forced-colors mode restores a system Highlight outline where high contrast suppresses the surface paint. Browser coverage now distinguishes thread surface paint from compact focus rings and checks keyboard and pointer landings, content clearance without focus reflow, later inline siblings, scrolling, sticky headings, reduced motion, and forced colors.

Tested with uv run pytest tests (907 passed), the complete navigation browser file (93 passed), the Leaf Chrome render gate in light and dark, responsive browser sweeps, and a live keyboard and pointer user pass.

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 things, one verified in Chrome and one alignment gap. The rest of the change reads well — swapping the card's mark from a second perimeter to a repaint of its own edge is the right call for a composite region, and the test rewrite keeps the cut/covered halves honest (COVERED_TOP still runs at every landing of the walk).

The panel-side mark disappears under forced colors when the reader arrives by pointer

The removed comment named this case exactly: :focus-within and not :focus-visible, "because a reader who reached the comment with the mouse had the page marked and the card left plain". In normal colors the new treatment keeps that promise. Under Windows High Contrast Mode it does not, because forced colors overwrite border-color and background-color with the system palette but leave an outline standing as a distinct band.

I reproduced it against /usr/bin/google-chrome with the two rule bodies side by side, focused by click:

Repro and readings
[forced-colors=active] NEW focused: border rgb(0,0,0)  bg rgb(255,255,255)      outline none        :focus-visible False
[forced-colors=active] resting    : border rgb(0,0,0)  bg rgba(255,255,255,0)   outline none
[forced-colors=active] OLD focused: border rgb(0,0,0)  bg rgba(255,255,255,0)   outline solid 2px rgb(0,0,0)

The current card and a resting card compute to the same forced border, and Canvas over Canvas is not a wash — so there is nothing left on the card at all. The chrome layer's existing rescue, :scope :focus-visible { outline: 2px solid Highlight !important; } in the @media (forced-colors: active) block near the end of runtime/chrome.css, does not reach it: a click on a card gives :focus without :focus-visible.

The keyboard path is fine. I checked separately that a script focus() driven by a keydown does set :focus-visible in Chrome (both with and without forced colors), so the t/T walk still lands on the Highlight outline. It is the pointer landing that loses everything.

A Highlight border under @media (forced-colors: active), keyed on the same :focus-within predicate rather than on :focus-visible, would close it and stay next to the rules already there. Happy to push that as a commit if you want it in this PR.

Two runtime modules still describe the ring the thread no longer draws

CLAUDE.md asks that the implementation and its owning references stay aligned, and these two are the prose that owns the pairing rather than incidental comments.

skills/leaf/assets/runtime/anchors.js, in the block that explains the two halves of lf-mark-here:

While typing, the reply box carries the strong focus ring and the enclosing thread keeps a subdued outline.

The thread now writes outline: none and keeps a quiet border instead — a reader following this to the CSS finds the opposite of what it says.

skills/leaf/assets/runtime/conversation/landing.js, in the comment explaining why the landing hangs off focus and why block: "nearest":

The thread holding the focus, not the card alone: the ring is the thread's, drawn for :focus-within, so it is cut in the same place whether the reader is standing on the card or writing in its box.

The card's paint is now inside its own box, so "cut in the same place" is a claim about a ring that is gone. The scroll reasoning that follows it still holds, but its stated reason no longer does.

Both are outside the diff, so I have not put them inline — say the word and I will push them with the forced-colors rule.

Comment thread skills/leaf/assets/runtime/chrome.css 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.

The forced-colors rule closes the pointer landing on a card, and the prose realignments in anchors.js and landing.js now read correctly against the rules they describe. One case is still open, inline: the same rule is outranked while the reply box holds focus, so writing in a comment leaves the card with a resting card's edge under high contrast. Readings and a suggestion are on the line.

Comment thread skills/leaf/assets/runtime/chrome.css Resolved
leaf-agent
leaf-agent previously approved these changes Sep 7, 2026
@leaf-agent

Copy link
Copy Markdown
Collaborator

ci / test is red on bc14d6a2, and I could not attribute any of the three nightly cases to the focus change. I ran each one against main (6d4860a3) and against this branch merged with it.

  • test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus — the pageSettled timeout is the margin-placement repaint that Stop a margin placement move repainting the standing chrome on every frame #394 fixed on main, not a ring the walk cannot find. It is deterministic against this branch's merge base (8de0b9ac, which predates Stop a margin placement move repainting the standing chrome on every frame #394) and passes once 6d4860a3 is merged in. Taking main should clear it.
  • test_the_feature_gallery_exercises_core_reader_workflows — fails on main on its own, and has since 1061340d (Link contents to semantic sections #372); the parent 1de01fc2 passes. z no longer takes the sign-off back: the button stays ✓ Version approved.
  • test_coarse_pointer_resize_reach_stays_reachable_without_trapping_scroll — intermittent on main on its own, 3 failures in 14 runs at 6d4860a3, with the same assertion (the .lf-edge grip's ring bottom under the ✓ Sent just now receipt). It is not in the deterministic classes tests/CLAUDE.md describes for either tree.

So two of the three are live on main rather than introduced here, and the third is the merge base being behind. The lf-living-margin case bc14d6a2 widened arrived the same way — #390 put .lf-living-margin inside the chrome's @scope block while theme.css styles it at document level — so the branch is green on it and main still is not.

Runs behind each line

Each row is uv run pytest <case> --run-nightly on a worktree at the stated tree. "branch + main" is the PR head merged with 6d4860a3; CI's own merge for run 34104657187 was bc14d6a2 into 8de0b9ac, which is where #394 is missing.

case main 6d4860a3 branch + 8de0b9ac branch + main
test_every_ring_…_corpus pass ×2 fail ×3 (incl. CI) pass
test_the_feature_gallery_… fail fail fail
test_coarse_pointer_resize_… 3 fail / 14 pass ×2 2 fail / 6
test_a_coined_class_… fail fail before bc14d6a2 pass

For the ring walk, dumping getAnimations() at the timeout gives three transitions on SPAN.lf-margin-button-label (opacity, transform, visibility, 90ms each) still running, with focus on a .lf-margin-button — the label re-entering its reveal every frame, which is what #394's placingChrome guard stops.

Bisected on main: test_a_coined_class_… passes at e6adf0b2 and fails at 5b503dd7 (#390); test_the_feature_gallery_… passes at 1de01fc2 and fails at 1061340d (#372).

@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 panel half of this pair reads settled. The inline rule the last commit adds keys its current-region paint on :focus-visible, so a reader who arrives by pointer gets no mark at all — reproduced in Chrome, with a suggestion on the line. A second point sits on the forced-colors twin, whose test stays green with the rule it names deleted.

Comment thread skills/leaf/assets/theme.css Resolved
Comment thread tests/test_render_navigation.py Resolved
@leaf-agent
leaf-agent dismissed their stale review September 7, 2026 16:23

Superseded by the review on a later commit.

@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, inline on the rule: the inline half of the pair draws its quiet edge on the content rather than beside it, where the panel card's repaint stands 8px off. The remedy is a layout choice rather than a one-liner, so it is a note rather than a suggestion.

Comment thread skills/leaf/assets/theme.css 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 the room this commit reserves, inline on the rule: it is overridden for every inline thread after the first, so a conversation with two root comments paints its current region lopsided. Reproduced in Chrome with readings on the line. The remedy is the same kind of layout call as the last round, so it is a note rather than a suggestion.

Comment thread skills/leaf/assets/theme.css Resolved
@max-sixty
max-sixty merged commit 3f8dc9f into main Sep 7, 2026
13 checks passed
@max-sixty
max-sixty deleted the codex/focus-appearance branch September 7, 2026 17:25
max-sixty added a commit that referenced this pull request Sep 7, 2026
Closeout work from the UI and UX sweep that landed in #379, and the reds
it turned up on main along the way.

**The wide shelf's height was reading its chords.** #388 gave a banner
control that opens a stable destination a quiet second line carrying its
chord, and paid for that line with `padding-block: 3px 14px` on
`[data-lf-chord]` — the controls that happen to be carrying one. The
runtime writes that attribute only while a binding is live and
unshadowed, so it comes and goes as the reader moves: a letter typed
inside the go-to prefix filters the visible targets and takes every
chord off the row. Measured at 1200px, each control went 33px → 30.3px
and the row 41px → 38.3px on that gesture, which is a metric expressing
state. The wide shelf now reserves the line for every control it draws,
so the chord's text is the only thing left for state to paint, and
`test_the_shelf_keeps_its_height_when_its_chords_are_shadowed` pins it.

#407 landed the compact half of this while the branch was open, and its
answer stands: a forty-pixel aim has no second line to give, so the
compact block states the row's whole box and drops the hint there. It
does not reach the wide row, where the news chip carries no chord —
verified against `main`'s tip, where the shelf still loses 2.7px a
control. The sheet test goes back to reading each label centred in its
own box, which is what #407's fix restores.

**The margin thread's composer is read against the card's content box.**
`test_the_margin_groups_meanings_at_one_destination_without_moving_the_page`
asserted the composer's right edge meets the thread card's, which #391
made false by four pixels when it gave the card symmetric resting room
to draw its focus edge inside. That room is the design; the claim the
assertion was making — the composer spans its card — is about the
content box, and a composer genuinely inset from the card still fails
it.

#410 is open against the same two hunks of that test from the opposite
premise: that the card's inner gutter is a defect the margin seat should
spend rather than resting room to measure around. The two layouts are
compatible even though the accounts are not — under #410's geometry the
thread keeps its padding and `threadRight - threadPad` is still the
composer's right edge, so this assertion holds either way, and its CSS
stands or falls as a design change on its own. Whichever lands first,
the other's test hunks want a rebase.

**`scripts/linux-suite.sh` can now build for the host's architecture**
(`LEAF_SUITE_NATIVE=1`). Emulating amd64 is what makes the image CI's,
and on Apple silicon without Rosetta it is also what breaks: qemu kills
Chromium's GPU process before the first context opens, on `about:blank`
as readily as on a page, which surfaces as `TargetClosedError` and reads
like a product failure. The native build gives up Google Chrome, which
ships for amd64 only, and keeps CI's fonts — so it answers a question
about how wide something is with CI's own numbers, and is not the
control for a case that drives the installed launcher. CLAUDE.md's
landing-past-a-red rule now says which mode it means.

**A section is watched at its heading.** `lf-toc` observed each
section's destination, which for a generated destination is a 1×0 span
whose resize observation can never fire.

**One test no longer depends on where the run's temporary directory
is.**
`test_an_unidentified_old_service_is_not_mislabeled_as_the_calling_leaf`
read the whole startup note for the calling payload's path, which also
reads the page and stop lines — and the page directory legitimately sits
under the checkout whenever a run is given a `--basetemp` there.
Equality on the runtime line says what the absence was reaching for.

A full local `--run-nightly` run on this head is 2149 passed, 1 failed:
`test_render_widgets.py::test_suggestion_controls_stay_out_of_the_column[no-preference]`,
which reproduces deterministically with `main`'s own `chrome.css` in
place and belongs to a module this PR does not touch.

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

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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