Skip to content

Give shared CSS behavior canonical source owners - #2252

Merged
max-sixty merged 32 commits into
mainfrom
codex/canonical-message-spacing
Oct 10, 2026
Merged

max-sixty merged 32 commits into
mainfrom
codex/canonical-message-spacing

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Repeated styles across document, shadow and runtime chrome roots let comment fields, reading content and dependency widgets drift. This refactor gives shared behavior one editable source while retaining Leaf's existing cascade and ready delivery sheets. Floating and inline responses now share the same face, newly sent Markdown gets the same reading primitives, and supported page/package inputs consistently reach their owners.

The large CSS diff is primarily source extraction and regenerated output. Review assets/styles/components/ for shared surfaces, reading, controls and responses; build/styles.mjs composes these into the existing sheets and checks freshness without adding browser requests or a consumer build. Package source entrypoints are discovered automatically.

  • lf-shot owns image inspection, crop, scale, overlay/flip and geometry; visual-review uses its public inspection API and allocates the evidence pane.
  • Stylesheet inputs own shared motion durations, banner posture and the default panel width. Runtime owners retain user choices and measure the native rail primitive instead of guessing its first allocation.
  • CodeMirror's style provider joins lf-base, Plot/trace reuse the dependency adapter, registry roles own the source fallback, and diff fills share one recipe that preserves local semantic color overrides.
  • references/packages.md, “Styles and composition”, defines rule ownership, root reach and precedence, public theme inputs, layout declarations, runtime outputs and vendor bridges.

Validation: 306 runtime tests; focused browser journeys for composer reparenting, sent Markdown, calculated inputs, first rail allocation, image inspection and real file editing; reproducible styles/browser bundles and pre-commit checks. Reviewed all 48 Mac thread appearance states and accepted the intentional shared-response changes. The served baseline/candidate comparison used the same 251 requests before authoritative presentation, with no added CSS requests. Opus independently reviewed the implementation and the subsequent fixes; full landing checks run in CI.

This was written by Codex on behalf of max-sixty

Use maintained dependencies for established capabilities, including prototypes,
while retaining native platform and standard-library reuse. Keep browser builds
in Leaf's development and release pipeline so consumers receive ready assets.
Compose shared reading, response, control and integration rules into the existing
ready sheets. Keep the delivery roots and cascade tiers distinct from source
ownership, and document supported inputs versus runtime measurements.

Move screenshot inspection into lf-shot, derive runtime geometry and motion from
their owners, and layer dependency styles at their providers. Preserve local
palette overrides and rendered widget faces without package reset recipes.

Link editor and sent-message insets through one response owner. Leaf-text owns
its internal editor CSS now that CodeMirror defaults participate in lf-base.
Tests hold the authored inset relationship, upgrade-state boundary, native rail
allocation, package typography, image inspection and retained user choices.
leaf-agent
leaf-agent previously approved these changes Oct 10, 2026
leaf-agent
leaf-agent previously approved these changes Oct 10, 2026
leaf-agent
leaf-agent previously approved these changes Oct 10, 2026
leaf-agent
leaf-agent previously approved these changes Oct 10, 2026
leaf-agent
leaf-agent previously approved these changes Oct 10, 2026
leaf-agent
leaf-agent previously approved these changes Oct 10, 2026
@max-sixty
max-sixty merged commit a67d8f1 into main Oct 10, 2026
10 of 12 checks passed
@max-sixty
max-sixty deleted the codex/canonical-message-spacing branch October 10, 2026 12:13
max-sixty added a commit that referenced this pull request Oct 10, 2026
main (#2252) generates the kernel and package sheets from sources under
`styles/`, so the derived focus margin, the root's covered band, the
dropped landing-room restatements and the visual review's sticky
navigation now live in those sources, and the sheets are rebuilt from
them. main also shifts every region when only the window's height
changes; the page's own width and band check joins that same
measurement, still observed on the root so it is seeded on a page
without regions.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 10, 2026
The stylesheet extraction in [PR
#2252](#2252) formatted the
`--sans` and `--mono` font lists across lines. Two nightly browser
checks compared those raw custom-property strings with normalized
computed `font-family` values, so they failed despite the same families
rendering. The checks now collapse whitespace in the declared lists
before comparing, while retaining their assertions that code notes and
keyboard hints use the intended faces.

Both cases failed in the [main CI
run](https://github.com/max-sixty/leaf/actions/runs/38051185604) and
pass locally after the change (`uv run pytest
tests/test_render_anchors.py::test_code_is_colored_without_a_word_moving
tests/test_render_options_addition.py::test_the_draft_binding_badge_and_send_press_share_the_row_end
-q -n0`).

Co-authored-by: leaf-agent <[email protected]>
max-sixty pushed a commit that referenced this pull request Oct 10, 2026
The sent drawing card can wrap fewer lines than its draft editor at
phone width. In the nightly [main CI
run](https://github.com/max-sixty/leaf/actions/runs/38051185604), the
editor's 1227px scroll offset exceeded the sent text's 921px maximum, so
the browser correctly clamped it. The existing check required the
impossible absolute offset.

The check now verifies that sending keeps the draft's scroll offset
where the sent text can hold it and otherwise lands at the sent text's
scroll limit. It continues to check that the drawing reference remains
outside the text viewport and visible after resizing. All four
desktop/phone and short/scrolled variants pass locally (`uv run pytest
-q -n 2
tests/test_render_drawing.py::test_sent_drawing_keeps_its_reference_outside_the_retained_text_viewport`).
This reflects the shared response layout in [PR
#2252](#2252) while keeping the
user's reading position under native scroll behavior.

---------

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Oct 10, 2026
… the focus margin from the sticky-header slot (#2302)

Two follow-ups from #2039, each fixed where its cause is rather than
where it showed.

### A page keeps its place below the banner when the window changes
width

The follow-up said Leaf's reading-position code overrode the browser's
scroll anchoring for a pane on a document page: after a jump, narrowing
moved the landed line 36px. The pane was right. Below about 800px the
banner takes a second row, and the browser's anchoring keeps the
reader's line at the same distance from the window's top, which is then
under the taller banner. A plain document page left the line covered; a
pane only escaped because its own restore measures from the landing band
below the banner.

- `reading-regions.js` watches the page as it watches regions: its width
and the top of its landing band, announced as a shift with no region, in
the same measurement that announces main's window-height shifts.
`regionsSettled` waits for it. A band change without a width change,
such as a page tab strip arriving, is adopted rather than read as
unsettled.
- `version.js` moves the page with the band, then restores regions
against the new band from the readings snapshotted when the shift was
announced (#2303). The page keeps no record of its own: the browser's
anchoring already holds its words, and main now keeps a focused control
in view across the reflow.
- Narrowing then widening returns a pane's line to where the reader left
it (it ended 36px low).

### The focus margin is derived from the sticky-header slot; a visual
review's navigation stays in reach

The visual review's case navigation and view controls scrolled away
above a pair taller than the window. Sticking them needs focus inside a
stuck header to scroll nothing. #2135 did that by having each header
declare where its controls stand (`--lf-head-inset`) and each scroller
restate its landing room, so every new sticky header, the visual
review's two included, needed its own declarations.

- The layer's focus margin is read from the sticky-header slot
(`styles/components/surfaces.css`). A scroller's band has two parts, the
slot it covers whole (`--lf-top-covered`) and the room below it
(`--lf-landing-room`); the root's `scroll-padding-top` reads the same
two, and a box that scrolls restarts them (`state.css`). A focused box's
`--lf-top` less the covered slot is the headers over it the band does
not count, so it lands below them; a box in a header that sticks at its
top also takes the room back, so it counts as shown where it sticks.
- The runtime marks every box that sticks at its top (`data-lf-sticks`,
`reach.js`), so a header declares nothing unless its controls stand
inset from its stick line (the tab strip, the trace toolbar, the
screenshot toolbar). The thread title's and diff header's declarations,
the tab panels' landing-room restatement and `--lf-landing-gap` are
gone.
- The visual review's pane header sticks under the banner at a stated
height (two rows where the review is narrow) and stacks `--lf-top` for
the cases; the shown case's view controls stick under it. The capture
stage isolates its stacking, so a flip's handle and marked regions pass
under them.

The CSS changes are in the `styles/` sources (#2252); the committed
sheets are rebuilt from them.

### Tests

-
`test_a_page_keeps_its_place_below_the_banner_as_the_window_changes_width`
(document and pane): without the change, the document fails narrowing
and the pane fails widening.
- `test_a_visual_review_in_flow_keeps_its_navigation_over_a_tall_pair`:
without the change, the navigation stands 495px above the window.
- `test_focus_in_a_stuck_header_leaves_the_page_where_it_is` keeps
passing with every per-header declaration but the tab strip's removed.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 11, 2026
The shared stylesheet refactor in [PR
#2252](#2252) exposed a diff code
region that overflows horizontally. Its generated line-comment buttons
have `tabindex="-1"`, but `reachScrollers` treated any descendant button
as a Tab route and withheld the region's own stop. Keyboard readers
could not reach the clipped lines, both on the page and in a panel
reply.

Use the existing `tabStops` reading from the focus owner to decide
whether a scroll box already contains a reachable control. This counts
enabled, visible controls actually in the Tab order and lends the diff
code region a stop when its buttons are programmatic only. Both failing
browser journeys pass locally, as do 308 runtime tests. A served 420px
comparison loaded the same 254 requests through authoritative
presentation in base and candidate; the candidate delivered 247 more
bytes on that path for the reachability fix, with the same three
diagnostic startup shifts.

The failures appeared in the [main CI
run](https://github.com/max-sixty/leaf/actions/runs/38051185604).

---------

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Oct 11, 2026
#2252 renamed the remote Question outline's focus ring from `ask` to
`question`, so test_each_sampled_focus_ring_is_shown_whole_in_its_surface
reported a missing ring even where the Question was painted correctly. The
sweep now expects `question` and still marks the exact carrier, so a ring
drawn on the wrong node still fails. Carried from #2308.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 11, 2026
…build (#2327)

Code-quality survey batch for `tests/`, `dev/` and `build/`: the test
page pool's regression, plus small cleanups, one commit each.

**Test page pool (F125).** Since #2155 put the `work` fixture package in
`serve`'s default selection by path, every default `serve(markup)` ran a
full `page init`. `serve` pooled only selections of bare package names,
because it named each template directory after the selection.
`initialized_page` now owns the key and the `page init` command. A shape
is keyed by the selection, the package directories it resolves to as
`page init` resolves them, and an optional named preparation step: an
example's stamped versions, or `page_dir`'s document. `serve`,
`page_dir` and the fixture check share that one keyed lend, templates
are numbered, and a selection naming a package under the test's own
`tmp_path` (a `layer_registry` or `./.leaf` page) is initialized in
place. On this host under load 40 to 58, a default `serve(markup)` went
from about 6 s to about 0.75 s after each worker's first.

pytest's own fixture caching can't hold this pool by itself. `serve`'s
selection is an argument of a call made inside the test body, sometimes
twice in one test, and fixture caching keys only on scope and
collection-time params. So the pool keeps the shape it had: a
worker-scoped `_page_pool` with a function-scoped lender.

**Wait deadlines (F79).** The deadline lint loses its per-file
allowance. The 33 literal deadlines it held now take the suite's
default, `HANDOVER_DEADLINE_MS` for a reload, or a bound past the
runtime's 10 s presentation wait. The gate tests whose deadline is meant
to expire share `EXPECTED_STALL_MS` (5 s), so two of them now wait 5 s
where they waited 2 s and 1 s.

**Console errors (F39).** `render_gate.scheme` gains `console_error`,
the error branch `console_problem` already had, and
`collect_page_errors`. probe, verify-site and the plain arrangement gate
use them: still errors only, and a failed load now names its URL. A
layout case drops its `response` listener, since the console entry
already reports error statuses.

**Stylesheets (F128).** `build/styles.mjs` exports `styleOutputs()`,
which `build/browser/build.mjs` merges into the outputs it writes and
checks. `build:styles` and `check:styles` are gone, and `check:bundles`
no longer rebuilds the sheets. The sheets' banner now names
`build/styles.mjs`.

**Framework facade (F66).** The ESLint rules now refuse deep imports
into `vendor/browser-runtime/`, which bypassed both the semantic
publisher's ownership rule and the content-module boundary. The rule
also drops a check on `createApplicationPublisher`, which the facade
never exported.

**Smaller items.**

- From #2308: the focus-ring sweep now reads the Question ring by
`question`, the canonical name since #2252. #2308 can close once this
lands.

- F131: `leaf-dev probe --do drive:NAME` reaches all 71 stills drivers.
13 were refused before.
- F130: `publish-site` now runs on any `dev/` change. Its hand-written
list had missed `startup.py`.
- F75: two unused test helpers are deleted.
- F117 and F118: maintainer docs now match the CLI and the suite, and
let `--help` own leaf-dev's flags.

**Not done.**

- F40, launching catalog previews through `chrome()`: #342 chose
Playwright's locked headless shell to keep previews reproducible, and
this would reverse that.
- F129, moving the package-lock check: #2317 deleted both lock checks
when it moved to pnpm.
- F58, the shared Lit binding: verification rated it low value and
recommended folding it into the next change to either binding.
- F34, the usability eval scorers: rewriting eight scorers onto
`SourceDocument` needs the stored runs re-scored before and after, which
is more than a small change.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 14, 2026
)

On a page where every margin row is a pin, each thread step (`t`) spent
about 100 ms restyling the whole document for a width it never used.
`layoutMarginRows` reads a rail entry's width at the start of every
pass, and with no live rail entry `restingRail()` inserts a measuring
clone and removes it, two whole-document restyles (about 3,070 elements
on the test page) plus a third at the pass's next `skipped()` read. A
step runs two passes. The width feeds only `rowPosture`, which returns
`"pin"` without it wherever the rail does not stand or does not stand
beside the target's scroller. The path came in with #2252.

The pass now reads the width lazily, once per pass, for the first row
the rail stands beside. Pin pages, and rail pages with no rows, no
longer clone; a rail page's first comment still measures the native
primitive, as `restingRail`'s contract above it requires.

I did not cache the measurement per viewport and theme. The comment on
`restingRail` rules out a cached size, since the allocation comes from
the live cascade, package and author overrides included, and a revision
can change those without a resize or theme switch. After this change the
clone runs only on a rail page that has no rail row yet, or whose rows
have all pinned (blocks wider than the rail's inner edge, or sidenotes
level with them), so a cache would buy little and add an invalidation
rule.

Thread step median, 104-thread page, headless Chrome 153 at 1440x900, 5
runs x 8 steps from the top of a fresh page, keydown to the first
painted frame showing the thread:

| page | main | this PR |
|---|---|---|
| bare `<main>` (every row a pin) | 186 ms | 82 ms |
| `layout-column` (rail rows) | 75 ms | 69 ms |

Tests run: `pnpm run test:runtime` (419 pass); the margin rail/pin
posture, first-rail-allocation, sidenote and pin-seating tests in
`tests/browser/test_render_margin.py`, and the thread-walk and
thread-travel tests in `tests/browser/test_render_navigation.py` (33
pass).

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

Co-authored-by: Claude Opus 5.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