Skip to content

Place the comment box and the thread card by one rule, through Floating UI - #1526

Merged
max-sixty merged 11 commits into
mainfrom
thread-send-placement
Oct 1, 2026
Merged

max-sixty merged 11 commits into
mainfrom
thread-send-placement

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

A sent comment's thread card could open far from the comment box it was typed in: up to 283px down, under the whole paragraph, at 1260–1380px wide, and on the other side of the target at 900px. The box (Floating UI in composing/surface.js) and the card (its own arithmetic in thread-card-geometry.js) chose their side, the line they stand level with, and their inline lane by different rules, and chose the side from different minimum widths (the box's 256px, the card's 320px).

comment-placement.js now states one rule both surfaces use, and Floating UI's offset, size and shift place them; thread-card-geometry.js is gone. The rule:

  • Side: chosen once from the card's minimum width, so the box stands where its card can: right, else left, else under or over by the room the page can make (shown room plus scroll travel). A touch screen prefers under. At 1220–1380px this puts the box under the paragraph with its card, rather than beside the words; a card narrowed to stand beside them read only slightly better.
  • Line: beside, level with the quoted words or the pointed row; under or over, clear of the block, with the inline start where the card's minimum would end on the words' right edge.
  • Margin row: past the target's margin row where the room beyond holds the card's minimum, else over it. margin-layout.js's marginSpot says where that row stands, or will stand once the comment is sent.
  • One boundary for both (commentBoundary), and both scroll the reading region to make room under or over (makeRoom).

The card keeps its own holds on top of that: its top while it is read or a reply line is added, and its foot, with the reply row, while a turn joins the transcript during drafting.

The eval

tests/test_render_send_placement.py types a comment in 13 cases (passages and ⌥-clicked elements, phone to 1920 wide, touch, a clipped tall block, a thread already there), reads where the box stands, sends it, and reads where the card stands. Its YAML snapshot records the effect rather than pixels: each surface's side (the case's allowed sides where it allows two and the surface took one, since which of under and over has more room turns on the fonts a platform draws), whether it stands where that side puts it, and how far the card moved from the box, bucketed still (≤ 8px), near (≤ 48px) or away. It joins known_faults.py for the shortcut line's known shift, which load can push past the press's own frames. On main every case moves, 9 of them away; here all 13 are still. Each case also writes its box/card pair to .tmp/send-placement/ to review a snapshot diff against. It runs in the everyday gate.

Behaviour that moved, with the tests that recorded it

  • The card no longer right-aligns to the window edge when it covers its cluster; it stands beside the words as the box does (margin: forced inline, answered in the margin, shipped long thread).
  • Under or over, the card ends on the words' right edge rather than the window's (readable card across page claims).
  • The card's top is level with its words' line, not the cluster's top, and it leaves with that line on a scroll (free margin).
  • A card may stand left of its words when only that side holds it (the short-rail test is now "stands on the side with room").
  • The box chooses its side for an element by reachable room rather than Floating UI's visible-room flip (rechooses after vertical target motion).
  • Card lengths under a transformed ancestor are the card's own (scale 0.25 case).

This was written by Claude Code on behalf of max-sixty

🤖 Generated with Claude Code

max-sixty and others added 10 commits September 30, 2026 13:31
A snapshot test types a comment in nine cases (passages and ⌥-clicked
elements, from a phone to 1920 wide), reads where the comment box stands,
sends it, and reads where the thread card stands. The YAML snapshot records
the effect rather than pixels: each surface's side, whether it stands where
that side puts it, and how far the card moved from the box, bucketed as
still, near or away. Each case also writes a before/after picture to
.tmp/send-placement/ to review a snapshot diff against.

The recording starts from today's behavior, which moves the card away from
the box in five of the nine cases, because the box (Floating UI in
composing/surface.js) and the card (thread-card-geometry.js) choose their
side, row and lane by separate rules.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ng UI

A sent comment's card could open far from the box it was typed in: up to
283px down, under the whole paragraph, at 1260-1380px wide, and on the
other side of the target at 900px. The box (Floating UI in
composing/surface.js) and the card (its own arithmetic in
thread-card-geometry.js) chose their side, the line they stand level
with, and their inline lane by different rules, and chose the side from
different minimum widths (the box's 256px, the card's 320px).

comment-placement.js now states one rule that both surfaces use, and
Floating UI's offset, size and shift place them; thread-card-geometry.js
is gone. The rule:

- Side: chosen once from the card's minimum width, so the box stands
  where its card can: right, else left, else under or over by the room
  the page can make (shown room plus scroll travel). A touch screen
  prefers under.
- Line: beside, level with the quoted words or the pointed row; under or
  over, clear of the block, with the inline start where the card's
  minimum would end on its right edge.
- Margin row: past the target's margin row where the room beyond holds
  the card's minimum, else over it. margin-layout.js's `marginSpot` says
  where that row stands, or will stand once the comment is sent.
- One boundary for both (`commentBoundary`), and both scroll the reading
  region to make room under or over (`makeRoom`).

The card keeps its own holds on top of that: its top while it is read or
a reply line is added, and its foot, with the reply row, while a turn
joins the transcript during drafting.

tests/test_render_send_placement.py now records every case as `still`.
Behaviour that moved, with the tests that recorded it:

- The card no longer right-aligns to the window edge when it covers its
  cluster. It stands beside the words as the box does (margin tests:
  forced inline, answered in the margin, shipped long thread).
- Under or over, the card ends on the words' right edge rather than the
  window's (readable card across page claims).
- The card's top is level with its words' line, not the cluster's top,
  and it leaves with that line on a scroll (free margin).
- A card may stand left of its words when only that side holds it (the
  short-rail test is now "stands on the side with room").
- The box chooses its side for an element by reachable room rather than
  Floating UI's visible-room flip (rechooses after vertical target
  motion).
- Card lengths under a transformed ancestor are the card's own (scale
  0.25 case).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	docs/how-it-works.html
# Conflicts:
#	skills/leaf/assets/runtime/margin-projection.js
#	skills/leaf/assets/runtime/thread-card-geometry.js
# Conflicts:
#	skills/leaf/assets/runtime/margin-layout.js
The eval kept all thirteen cases' pages open until the test ended. Since
main's shift sensor judges news after a press as without input (#1494), a
page left open past a minute failed the test: its sent message's age turns
from "just now" to "1m ago", which moves the card head's "Sent" 6px left.
Each case now closes its context once read, so the test reads placement
alone. The age label moving its neighbour is a defect of its own, on main
too.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	skills/leaf/assets/runtime/composing/surface.js
Closing a case's page skipped the shift and lost-words judgment the test's
end runs, which reads only open pages, so a jump of the card on Send's
final frame would have gone unreported. Each case now runs that judgment
before it closes.

Co-Authored-By: Claude Opus 5.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.

The new placement snapshot makes the gate depend on a side this case explicitly leaves open. phone-passage declares below or above, but the golden file fixes both surfaces to above. Running uv run pytest tests/test_render_send_placement.py -q -n0 here produced below for both, each clear of the block and still aligned across Send; the test failed solely on those two snapshot lines. Please make this case's assertion accept either vertical side while still requiring the box and card to agree, or arrange the fixture so one side is guaranteed.

…s fonts pick

CI on Ubuntu put the phone-passage case's box and card under the
paragraph, where macOS puts both over it: which side has more room turns
on the fonts the page is drawn in. The case allows either, and the
snapshot pinned one. Where a case allows more than one side and a surface
took one of them, the snapshot now records the case's `expected`, and
`stands` says "clear of the block" for either; `moves` still fails a card
that left the box's side.

Under concurrent load, the answer to the send can land past the press's
own frames, and the shortcut line's More moving as its hints change then
reads as a shift without input. That is the known shortcut-line defect
other tests list in `known_faults.py`; this test joins them. 18 of 18
concurrent copies pass with it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 837ea68 into main Oct 1, 2026
5 checks passed
@max-sixty
max-sixty deleted the thread-send-placement branch October 1, 2026 22:18
max-sixty added a commit that referenced this pull request Oct 5, 2026
…1781)

A thread card beside its words stood past the margin row for its target
whenever the room beyond that row still held the card's 320px minimum
(`--thread-card-min`), so a row of one or two controls narrowed the card
by their width. On an Ask at a 1600px window the card was 341px wide
with 424px free beside the words, and at 1440 it covered the row and
came out wider (344px) than at 1600.

`comment-placement.js` now keeps the row clear only where the room past
it holds the card's whole measure (`--thread-card`, 592px). Anywhere
narrower, the card stands over the row, beside the words: it carries its
own close and step controls, and the row shows again once it closes. The
comment box uses the same rule, so Send still leaves the card where the
box stood. The row is one box to the rule, so nothing declares which
margin items may be covered; this settles the TODO entry that asked for
such a mechanism.

`commentPlacement` also reads both card widths itself. Its callers used
to pass `minimumWidth: cardMinimum()` while the placement read
`cardMeasure()` on its own, and #1526 began as the box and the card
being placed from two different minimum widths.

| Window | Card before | Card after |
|---|---|---|
| 1440 | 344 (over the row) | 344 |
| 1600 | 341 | 424 |
| 1728 | 405 | 488 |
| 2200 | 592 (past the row) | 592 (past the row) |

Behaviour that moved, with the tests that record it:

- At 1600 in the feature gallery the card no longer keeps a gap past the
pin on its words: it starts 8px from the words' edge, over whatever of
the pin reaches that far, and takes the room from there
(`test_a_thread_beside_its_words_takes_the_room_to_the_visible_edge`).
- At 1920 the margin-answered thread covers its cluster; a 2400 case
keeps the past-the-row branch covered
(`test_a_thread_can_be_answered_in_the_margin_without_opening_threads`).
- A Node test pins the rule at its owner: a row is kept clear with 592px
past it and covered with 591px (`comment-placement.test.mjs`).

All three fail on the old minimum-width rule.

The rule reads the card's declared measure rather than its content, so a
short thread that would fit past the row still covers it. Choosing by
content width would let the card move on Send and jump sides as replies
arrive.

> _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 25, 2026
The first thread card a page opened, by `t` or a margin entry, slid
up over the passage it is about whenever the card was taller than the
room below the passage. Later opens of the same card scrolled the page
to make room first, as the placement rule intends.

A card makes room only on its fresh placement (`makeRoom` in
thread-preview.js), and `commentPlacement().choose` called a placement
fresh only when it picked the side. The first open places the card
again within milliseconds, while Floating UI's module is still
loading, which supersedes the first placement before it fits; the
placement that does fit was no longer fresh. A surface is now fresh
until it first lands, so the placement that opens it makes the room.
The rule dates from #1526; the render gate's closed-surfaces journey
read it on ship-review as the second `t` round trip leaving the page
scrolled where the first had not.

The region-scroll runtime test now lands its card before asserting
that a later choice keeps its side, and asserts that a choice before
landing stays fresh.

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

Adds a nightly macOS run of every test tier, and fixes every test that
failed in its first run or in the Linux nightly beside it: 89 tests in
[run
40156291557](https://github.com/max-sixty/leaf/actions/runs/40156291557),
60 of them only on macOS.

## The macOS nightly

`ci.yaml` gains a `test-macos` job: every tier on `macos-15`, `-n 2` on
its three cores, in the daily schedule and a dispatch. It belongs to
`ci`, so a failure turns that run red and reaches tend through the
existing `workflow_run` trigger, with no tend configuration change.
GitHub doesn't bill hosted runners for public repositories; the job
holds one of the account's macOS slots for about three hours. The test
step names `shell: bash`, without which a step runs without `pipefail`
and piping pytest through `tee` reported the first run's failures as a
green job. The setup action's Ubuntu mirror step now runs only on Linux.

`tests/AGENTS.md` counts `test-macos` among what tend repairs and leaves
only failures no CI run shows to local sessions. It drops the
instruction to confirm a macOS-only failure at normal priority because
`taskpolicy -b` slows headless Chrome: a test that fails on a slower
host depends on timing, and the fix is to the test. `running-tend` tells
the session fixing a red run, which has only a Linux runner, to verify a
macOS-only fix by dispatching `ci` on its branch.

## The fixes, by cause

Product fixes:

- A drafted margin card rose against the window's foot and never came
back as the draft shrank (#3524). It now holds the top it opened at and
drops back.
- A tapped pin reseated 11px lower as it unfolded, because the
hold-to-read toggle was pressed before the browser focused it (#3341).
- A page's first thread card could cover its passage, because the
placement that makes room was dropped while Floating UI loaded (since
#1526).
- A heading's "Copy link to section" stayed at the heading's far end
after the window narrowed and widened, since every engine keeps its last
`position-try` fallback (#3836). It now picks its place from the current
width.
- Putting the response bar away moved focus off the button the press had
just focused, so the next `e` found nothing (#3756).
- A trace's image-tools status shared a class with the image's loading
notice, whose rules hid it (#3707).
- WebKit scrolled the outer page 1,386px when a sample editor took focus
(#3634).
- In draw mode a press left the previous press's release timer pending,
so a fast second click reached the page.
- Hint refreshes read the geometry of every target inside a closed
disclosure, forcing layout of skipped content.
- A sidebar page's sticky track clipped focus rings (#3918). A stuck
track body now keeps the ring's room inside its edges, so its blocks
stand 5px in from each side.
- Tab revealed a block's Copy flush with its scroller, cutting its ring
(#3916).
- The hidden "my change" word inside a choose group took a cell's
padding and read as clipped content (exposed by #3837's check).
- Visual review case buttons kept their wide padding after the first
breakpoint crossing, a Chromium restyle bug avoided by making the case
list a plain container.
- A held shot's scrolling stage didn't declare that it holds its height
(#3703/#3704).
- When the log refused a reply, the floating panel's head moved down
69px and the restored draft pushed its controls up 21px (#3400). Through
a refusal the panel now holds its head and the field its height, on the
holds a press already takes; the refused turn's room goes at the user's
next turn.
- A reply box's ↑ (edit your last message) appeared only after an
unrelated repaint once its last message became editable (#3855). Every
message draw, by any thread reader, now recomputes that row's keys.
- A trace's images took the page's scroll anchor, so a lane change in
the timeline scrolled the page 62px under an arrow key; they no longer
anchor scroll. The trace overview wrote its window's new start before
reading its size, so for one layout the window ran past its strip and
Chromium scrolled the page up to 838px; it now reads before it writes.
The image tools' status keeps its line when its text clears.
- Web Awesome's radio group moves focus on an arrow with a bare
`focus()`, which Leaf's ring scroll margin turned into a page scroll.
The vendored bundle is patched (`build/vendor.mjs`) so both calls pass
`preventScroll`.
- A Leaf page inside an iframe took focus from the page around it when
it finished arriving. Its arrival recovery now runs only at top level or
in a frame that holds focus.
- The margin rail's one Tab stop stayed on whichever row last held it,
so a resize could leave it below a row the user sees first. It is now
the highest row in view; a focused row keeps it.
- A resize that moved a sidebar page's track into the page, with neither
place made by the reader, took the track's place over the page's:
live-progress jumped 1861px (#3918). On a tie the page's own place wins.
- The whole-page rule read a shut disclosure whose children are all
generated as showing what it holds (#3908); it now skips only `.lf-ui`
apparatus.
- The gallery revealed its stamped frame at the centre, carrying the
pressed button 45px; it now scrolls only as far as needed.

Test fixes:

- The Codex fixture copies the running interpreter as `codex`; on a
framework Python, as on the runner, the copy fails its code signature
and macOS kills it at launch. That broke 39 tests. The copy is now
re-signed ad hoc, and the fixture no longer leaks `PYTHONHOME` into the
command it runs.
- The plain-HTTP copy test missed Chromium's lower-cased host; the
event-door refusal test read its answer after the server's reset; the
stale-keys sweep raced the browser entering fullscreen; the words watch
didn't credit a blur from a press elsewhere.
- Several tests read state before it settled (a shown gesture's arm, a
side list's smooth scroll, a sample's focus returning, a held reply's
menu), and now wait for it. Assertions predating #3830, #3916, #3670,
#3673 and #3217 now read the current behavior.
- Three waits fixed their own deadline instead of the suite's, among
them the async-probe test's 500ms.
- The command hub's record now sticks in view, so the Atlas journey
opens its news before reading each row; the region-capture journey drags
over the unreadable image it means to fail on (#3861 draws only the
element that alone paints the crop).
- The touch-capture removal test, which fails intermittently on main,
now reads the shelf right after the tap and names the elements the tap
reached, so its next failure says whether the tap missed or the image
came back.
- The feature-gallery scroll pass allows a third of its steps to write
the contents' `aria-current`, as gestures already do, since the count
depends on where sections fall under the platform's fonts.

The branch also merges the four open `grind/f-main-tests-*` pull
requests, whose fixes cover five more of the run's tests: #3871, #3882,
#3887 and #3906. This pull request lands them.

Each fix was reproduced failing and then passing by node id, on this Mac
or, for a Linux- or runner-only failure, against a run's log, except
where its commit says otherwise. Dispatched full runs on this branch
([40156291557](https://github.com/max-sixty/leaf/actions/runs/40156291557),
[40186545420](https://github.com/max-sixty/leaf/actions/runs/40186545420),
[40196342887](https://github.com/max-sixty/leaf/actions/runs/40196342887))
check both platforms; the second took the macOS job from 86 failures to
38, most of the rest fixed since. A few macOS-only failures pass on
every local attempt (two reading-place tests, a scroll repaint, Back
from a thread, opening a line under the last, the Android composer's
Return, margin-entry order, a card paging on, a turn arriving out of
view) and have no fix here; once this lands, the macOS nightly reports
them to tend.

> _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