Skip to content

Keep a sent comment's words in place as its thread card grows out - #2985

Merged
max-sixty merged 5 commits into
mainfrom
send-shared-geometry
Oct 15, 2026
Merged

max-sixty merged 5 commits into
mainfrom
send-shared-geometry

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Pressing Send turns the comment box into the new thread's margin card without moving a word, and the card still grows out of the box. The box and card now share a text column and placement rule, replacing the earlier carry that pinned the first message to measured width, writing measure, height, inner scroll, and Send room. Send still carries the box's placement and its distance from the editor's scroll end, so a draft scrolled back from its end opens at the same lines.

What users see

  • Words stay put on Send in every case measured: short, multi-line and long scrolled comments, at 1280 and 390 wide, zoom 1.1, and touch.
  • The grow-out stays. A CSS animation on the card (data-lf-grows) opens a clip from the field's edges to the card's over 240 ms. The field's edges are the frame's existing size tokens (--lf-comment-frame-top/inline/bottom), so nothing is measured. The card is whole and pressable under the clip.
  • An empty comment box is wider at rest: 242 → 320 px. Its minimum width is now the card's (--thread-card-min), so the clip starts exactly on the field's right edge.
  • Reduced motion swaps box for card with no animation.
  • On desktop, margin-card text ends 30 px from the edge instead of 13. The box and the card share one text column (--lf-comment-text-end, which is Send's hit box plus its inset). The box keeps Send's room on every line, not only after the last one, and card messages end at the same inset. Touch is unchanged, since it already reserved Send's room on every line.
  • A long comment's card opens at the lines the box showed (showArrival). The box and the card share their text column and their bottom edge, so the box's distance from its end, carried with the frame the card already adopts, places the card's words where the box showed them. That holds whether the draft rests at its end or the user scrolled back through it. The field's caret reveal now includes the caret line's leading and its scroll-padding, so a draft typed to its end rests at its true end.
  • A one-line comment's card is 10 px taller than its box. A turn of the user's now reserves its one-line rewrite room from first paint rather than from delivery. Without the carry, Reserve one-line rewrite height in margin messages #2959's reservation made every one-line card grow 10 px when "Sent" arrived, and a card holding its foot moved its words up.

Why not View Transitions

I tried a view transition first: the box and the card shared a view-transition-name, and the morph held the words still (0 px in every captured frame). I dropped it for three reasons:

  • It holds the page's paint from Send until the card stands: the first frame came 37–51 ms after the key, against 5–21 ms today.
  • Presses at the card's position reach the page underneath for the 240 ms.
  • Its paint hold let the server's reading land before the gesture's first frame, which needed changes to the test harness's input and shift watches and still failed the long-draft case in 6 of 8 runs.

Size

Against main (git diff --numstat):

added removed
Code (runtime JS, CSS, stills) 95 215
Tests 22 101
Generated kernel/CSS 54 137

Word displacement on Send

Settled positions are measured from layout with leaf-dev probe --base. Mid-animation positions compare the pixels of each frozen frame (0/60/120/180 ms and settled) against the draft.

Case Before this change Deleting the carry alone This change (settled) This change (mid-animation)
short, 1280 / 390 0 0 0 0
multi-line, 1280 0 0 (no rewrap by luck) 0 0
multi-line, 390 0 299 px 0 0
long scrolled, 1280 0 399 px 0 0
long, scrolled back to its start, 900 — — ≤0.75 px (test) —
long scrolled, 390 0.02 586 px 0.02 1 px (rounding; also before)
multi-line, zoom 1.1, 1280 / 390 0.07 / 0.06 363 / 282 px 0.04 / 0.04 0
touch, multi-line / long 0 / 0.02 — 0 / 0.02 0

Markdown drafts still reflow on Send, since the message renders what the draft shows as markup. A rendered table can also make the card narrower than the box, so the clip then starts left of the field's right edge.

Tests

  • test_send_grows_thread_around_the_words again asserts every word's position through Send, and now also that the card grew. It fails with the shared end inset removed (7 of 8 cases) and with the growth disabled.
  • Tests that asserted the carried frame, the endRoom mode, or the measured clip were trimmed to what they still protect.
  • The diff-controls journey dresses the one new token.
  • The smoke test for reading keys in a submitted comment (test_reading_keys_follow_a_submitted_comment_s_viewport) now reads the card's transcript. Since the first message no longer scrolls on its own, the transcript is that comment's viewport.

Ran on the merged tree:

  • tests/smoke
  • tests/browser/test_render_send_placement.py
  • the send, rewrite, zoom and scaled-draft tests in test_render_threads.py and test_render_projection.py
  • test_render_aim.py::test_a_compact_comment_carries_its_box_into_the_inline_thread
  • test_render_margin.py::test_a_sent_comment_keeps_its_text_viewport
  • test_chrome_contracts.py::test_send_room_moves_to_every_line_only_while_the_field_scrolls
  • test_render_outbox.py::test_a_comment_field_scrolled_away_and_back_is_still_there
  • the diff-controls journey

That is 82 tests, all passing. pnpm run test:runtime passes 493/493 and pnpm run check:browser is clean. On main before the last commit here, test_send_grows_thread_around_the_words (three cases) errors on the same 10 px delivery move.

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

max-sixty and others added 4 commits October 14, 2026 19:22
…carrying the box

Pressing Send used to measure the comment box (its width, writing measure, height,
inner scroll and Send's room) and carry those numbers into the new thread card,
whose first message wore them until the card closed, while a clip-path animation
grew the card out of the box. Five modules and a block of frame rules held that
carry, and fractional zoom kept breaking it.

The box and the card now share the geometry by construction, so nothing is carried:

- One text column. Both start the words `--lf-thread-text-inset` inside the field's
  or transcript's edge and end them `--lf-comment-text-end` (Send's hit box and its
  inset) inside it, on every line. The comment box holds Send's room as padding
  rather than after its last line, and every message in a margin card ends its
  words at the same inset. On desktop the box's lines lose 17px and card messages
  30px of measure; under a finger nothing changes, since both already held Send's
  room on every line.
- One scroll end. A card Send opened stands its transcript at the end
  (`showArrival`), and a comment box reveals its caret's whole line inside its
  `scroll-padding`, so a draft typed to its end rests at its true end too.

Measured on triage-board (short, multi-line and scrolled drafts; 1280 and 390 wide;
zoom 1.1; touch), each word stands within 0.07px of where it was typed, as with the
carry. The grow-out animation is gone: it needed the box's measured frame.

Tests: test_send_grows_thread_around_the_words again checks every word's position
through Send (the carry's attribute, endRoom mode and inner-scroll checks go), and
the compact-comment, rewrite and zoom tests stop asserting the carried frame and the
animation's clip. The diff-controls journey dresses the one new token.

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

The previous commit dropped Send's grow-out because it clipped from the comment box's
measured rect. The box's frame and the card already share their corner, height and text
column, so the clip can open from tokens instead: the field stands the frame's insets
(`--lf-comment-frame-top/inline/bottom`) inside the card, and a CSS animation on the
card (`data-lf-grows`) opens `inset()` from those to the card's edge over 240ms, as the
measured version did. The card is whole and live beneath the clip, so no word moves and
presses reach it throughout.

The one dimension the frames did not share was width: the box rested at 242px, the card
at its 320px minimum. The box's minimum is now the card's (`--thread-card-min`, capped
by the same room), so the clip starts on the field's right edge too. A resting comment
box is 78px wider than before.

Reduced motion skips the growth; the card simply replaces the box. A view transition
(the browser morphing box into card) held the words still too, but it holds the page's
paint for two to three frames after Send, leaves the card unpressable while it runs, and
lets the server's reading land before the gesture's first frame.

Tests: test_send_grows_thread_around_the_words also asserts the card played its growth
(it fails with the growth disabled).

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

#2959 reserved a short editable margin message's one-line rewrite height only once the
message carried Edit, which arrives with delivery. With Send no longer carrying the
comment box's frame into the card, every one-line comment card then grew 10px when
"Sent" arrived, and a card holding its foot while sending moved its words up 10px.
Reserving the room for any turn of the user's from its first paint keeps both the
delivery and the rewrite still.

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.

A long draft scrolled away from its end jumps to the end on Send. showArrival always calls scrollToEnd for a sent card, while the removed frame carry preserved the editor's scroll position. In a 900 × 600 browser reproduction, I scrolled the draft to 0 with a scroll limit of 1771 px, then pressed Ctrl+Enter; the new card opened at 1771 px. The words the user was reading disappear, despite the PR's word-placement guarantee. Preserve the draft's visible reading position across Send, and cover a draft scrolled away from its end in the Send test.

… its end

The review found that a long draft the user had scrolled back through jumped to its
end on Send: the card always opened at its transcript's end. The box and the card
share their text column and their foot, so the box's distance from its end
(`fromEnd`, carried with the frame the card already adopts) places the card's words
where the box showed them, at the end or anywhere above it.

Tests: test_send_grows_thread_around_the_words gains a draft scrolled back to its
start (it fails without this change). The smoke test for reading keys in a submitted
comment now reads the card's transcript, which is that comment's viewport since the
first message no longer scrolls on its own.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@leaf-agent leaf-agent changed the title Keep a sent comment's words in place, and its grow-out, by sharing one geometry instead of carrying the box Keep a sent comment's words in place as its thread card grows out Oct 15, 2026
@max-sixty
max-sixty merged commit fd68e39 into main Oct 15, 2026
3 checks passed
@max-sixty
max-sixty deleted the send-shared-geometry branch October 15, 2026 06:26
leaf-agent added a commit that referenced this pull request Oct 15, 2026
The sent-drawing browser case now reads its retained scroll from the
thread transcript. #2985 intentionally moved a long sent comment's
scrollport from the first message to that transcript, but this case
still required an inner `.lf-msg-text` scrollbar and failed on the new
layout.

The test continues to check the drawing-reference behavior introduced by
#2136: the reference follows the comment text, the message body does not
clip it, and it remains inside the visible transcript after a long card
is resized. Its short phone and long desktop variants both pass with the
transcript as the scrollport.

Verification: both focused browser variants pass; Ruff format and `git
diff --check` pass. The long variant failed at the old inner-scroll
assertion before this change.

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Oct 18, 2026
…ving room (#3064)

A one-line comment's sent margin card is now as tall as the comment box
it came from (148 px, against 158 on main), and nothing in it moves when
"Sent" arrives or when its rewrite opens.

## Why the card was taller

Every user message in a margin card kept room from its first paint for
the reply box's taller rewrite field (#2959, moved to first paint in
#2985), whether or not the user ever opened the rewrite. Delivery itself
needs no room, since "Sent" and the Edit control already stand in the
message's head.

## What changes

- **The card's rewrite is the comment box the card grew from.** Its
frame and padding fit the 5.5 px each card line already keeps, and its
words end at the card's text column, so opening it on plain words moves
none of them and changes no height. On main, a two-line comment
rewrapped to one line in the wider editor and the card shrank 11 px.
Markdown still opens as its source, which can be longer than the drawn
message, as on main. Outside the margin card the rewrite still matches
the reply box, as #2813 decided.
- **The card's rewrite field is 10 px shorter than the reply field below
it.** The user chose this over matching the reply box, which would make
the card grow 10 px when a rewrite opens.
- **`skills/leaf/assets/AGENTS.md` states the principle.** Hold room
before first paint only for what will be drawn. Hold no empty room for a
state that may never come, however likely; show it in a slot already on
screen and let the user's gesture make the room it needs.

## Tests

The card cases of
`test_a_rewrite_is_the_reply_box_where_the_words_stood` and
`test_a_rewrite_of_a_comment_just_sent_is_the_reply_box` now assert that
the message keeps its height and its words their line, in place of the
field matching the reply box's height and padding.

Ran, after updating from main (which moved these tests to
`tests/browser/threads/test_rewrites.py`): that file,
`tests/browser/margin/test_card_reply.py`,
`tests/browser/margin/test_card_placement.py`,
`tests/browser/test_render_send_placement.py`,
`tests/browser/test_render_aim.py`,
`tests/browser/threads/test_composing.py`, and `pnpm run check:browser`.
All 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