Skip to content

Show what a key adds to a floating box at once; only a line taken away travels - #4844

Merged
max-sixty merged 5 commits into
mainfrom
comment-box-growth
Oct 31, 2026
Merged

max-sixty merged 5 commits into
mainfrom
comment-box-growth

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Typing now changes a floating box (the comment box, the panel's field, a card's reply) in the frame the key lands, as a textarea sized to its words does. Only a line a key takes away still travels on the boxes' 300 ms tween. The user reported that typing in a comment box felt "smoother" than a normal textbox, worst for horizontal growth, and chose this split.

What was wrong. Every key that changed a box's size started the tween (box-motion.js). A comment box sizes to its words, so past its least width every key widened it, and at typing speed the tween never settled: its edge trailed the caret by up to about 9 px. The field cuts its words to the travelling outline, so the glyph just typed and the caret were about 75% hidden in their first frame and appeared over 40 to 60 ms. A key that wrapped hid the word being typed and the caret for about 100 ms, and a four-line paste hid the caret for about 80 ms. Measured frame by frame in Chromium and Firefox; now nothing typed is hidden in any frame.

What still travels. A line a key takes away moves both edges on one tween, so words the box carries down with its top edge stay where the eye follows them (the user's 26 October request); nothing the user reads waits on it. Sends (the card opening out of the comment box included), More room and news are unchanged. At a window's foot, a line typed past it now shifts the box up in one frame, words with it, as a chat composer's field does.

How. follow() takes a reading the user's typing makes as it stands, as it does a reading while motion doesn't play, unless the box's height shrinks. The box-motion.js header records the rule and both choices.

Tests. New: test_a_key_that_widens_the_comment_box_draws_it_at_once. Rewritten for the new behaviour, each still guarding what it protected: the side comment and panel field tests now check that a line added stands at once and a line removed rides the top edge; the panel's attachment test and the moving-card press test drive their motion with a line removed; the margin reply's ring test checks the ring whole at the grown size in the key's frame; the caret-room test replaces wrapped words with their first line, read from the browser's layout so it holds on any platform's fonts, so a removal moves the box with the caret at its column's end. Each rewritten test fails with added lines travelling again or with removals made instant. test_a_growing_draft_holds_its_card_s_side_and_the_editor_s_top[size0] fails identically with this change switched off, so it is inherited.

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

…o its words

A comment box sizes to its words, so past its least width every key widens
it. Each key started the floating boxes' 300 ms tween (box-motion.js), so
while the user typed, the box's edge was always gliding and trailing the
caret, and the field's cut, measured from the editor's old edge, hid most of
the glyph just typed until the tween caught up. Measured at 1000x800 on
`log-retention`, 120 ms between keys: on 18 of 21 widening keys the first
painted frame hid 70-85% of the new glyph and the caret, for about 40 ms,
and the drawn edge trailed the layout edge by about 8 px at each key.
Chromium and Firefox alike.

Typing now sets the box's measure at once: every part stands at its new
inline edges in the frame the key lands, and only what a line the key adds
or removes moves still travels. The same reading measured 0 hidden px and 0
px of trailing edge on every widening key, in both engines. Presses, sends,
more room and news still travel sideways as before.

Tests:

- New: `test_a_key_that_widens_the_comment_box_draws_it_at_once` holds every
  motion and checks that the outline stands at the box's new width with the
  field uncut. It fails without the change (the outline stood 15 px short).
- `test_a_caret_at_a_lines_end_paints_inside_the_field` drove its caret-room
  check through a box widening as text was inserted, which no longer moves
  in Firefox, where the text fitted one line. It now replaces two lines with
  one that ends the box's column, so the line given up moves the box with the
  caret at the column's end. It still fails in both engines with the 2 px
  caret room removed.
- `test_a_growing_draft_holds_its_card_s_side_and_the_editor_s_top[size0]`
  fails identically with and without this change, so it is inherited.
…y travels

The previous commit made a key's change to the comment box's width stand in
the frame the key lands. A line a key added still travelled on the 300 ms
tween, and the field's cut hid the word being typed and the caret on the new
line for about 100 ms at each wrap (measured in Chromium and Firefox; a
four-line paste hid the caret for about 80 ms). A key that wrapped also moved
the box's corner on two clocks: the width at once, the height on the tween.

Now a key's change to any floating box (the comment box, the panel's field,
a card's reply) stands in the frame the key lands, as a textarea sized to
its words does, unless it takes a line away. A line taken away still
travels, both edges on one tween, so words the box carries down with its top
edge stay where the eye follows them, as the user chose on 26 October; it
hides nothing the user reads. The user chose this split on 31 October over
moving every typed change at once. Sends, More room and news still travel
as before, the card opening out of the comment box at Send included.

At a window's foot, a line typed past it now shifts the box up in one frame,
words with it, as a chat composer's field does.

Tests (each rewritten test fails with lines added travelling again, and the
removal checks fail with removals made instant):

- `test_a_side_comment_s_words_and_send_keep_to_its_edges_as_lines_come_and_go`
  (was `..._ride_its_edges_as_it_grows`): a line gained at the window's foot
  now draws the box at its new place in that frame; the removal half still
  checks the words and Send ride the edges through the tween.
- `test_the_field_s_words_and_mark_keep_to_its_top_edge_both_ways` (was
  `..._ride_...`): the same split for the panel's field and its more-room
  mark.
- `test_a_line_the_field_gives_up_rides_the_box_s_top_edge` (was
  `test_a_line_the_field_grows_rides_...`): the attachment hanging over the
  panel rides the top edge as a line is removed, since an added line no
  longer travels.
- `test_a_press_on_a_moving_card_reaches_what_it_aims_at` drives its motion
  with a line removed.
- `test_a_growing_margin_reply_keeps_its_whole_ring_from_the_first_frame`
  checks the ring whole at the reply's grown size in the key's frame.
leaf-agent
leaf-agent previously approved these changes Oct 31, 2026
…entence

The caret-room test replaced a two-line sentence with its first line's words,
both fixed for macOS's fonts. On CI's Linux fonts the longer sentence fit one
line, so the box never lost a line and the test waited out its timeout in both
engines. It now writes words that wrap on any platform and reads the first
line's words from the browser's layout, so the box loses lines wherever it
runs. The behaviour it protects is unchanged: the caret after the last word of
a box that sized to its words keeps room to paint as the box shrinks.

Typing the same words one at a time would also find the wrap, but in Firefox
the key that wraps the comment box raises a ResizeObserver loop notice (the
box measures 1/60 px short of its width, then exact), on main as on this
branch, which the suite reports as a page fault.
@max-sixty
max-sixty merged commit 4085143 into main Oct 31, 2026
4 checks passed
@max-sixty
max-sixty deleted the comment-box-growth branch October 31, 2026 20:45
leaf-agent added a commit that referenced this pull request Nov 7, 2026
…refox (#5674)

In Firefox, an input method's composition that starts over selected
words in Leaf's text field is dropped. `compositionstart` names the
selected words as its range, the composition commits, and the field
still holds the old words. A bare CodeMirror 6.43.15 page in the same
Firefox replaces the selection, and so do a plain textarea and a
contenteditable. The loss comes from the field's shadow root, the same
Firefox defect `field-editor.js`'s `beforeinput` handler already works
around for typed words. That handler skipped compositions, because a
composition's `beforeinput` can't be cancelled. Now, on a composition's
first `insertCompositionText` over a selection, the editor takes the
selected words away itself, so the composition starts at a collapsed
caret. The deletion is an `input.type.compose.start` change, which
CodeMirror's history joins with the composed words, so one undo brings
back the original text. EditContext fields and updates after the first
are left alone.

This is why
`test_a_caret_is_drawn_at_a_lines_end_and_after_a_list_bullet[firefox_browser]`
timed out. Playwright's `insert_text` reaches Firefox as a composition,
so the test's select-all-and-replace never replaced anything, and the
field never shrank to the one line the wait expects. #4844 added that
step to the test's predecessor, which already failed at `09e524975`,
before #5409 merged the two tests. The caret assertions themselves
needed no change.

Tests:
- The caret test passes in both engines.
- `test_words_typed_over_formatted_words_replace_them_in_firefox` now
also puts an input method's words over a whole and a partial selection,
and undoes them. Without the `field-editor.js` change it fails, with the
field still holding `aa **bold** zz`.
- Also passing: `test_render_words_watch.py`, the Chromium IME test
`test_a_pointer_send_finishes_the_words_an_input_method_holds`,
`drafts/test_draft_editing.py`, `drafts/test_composer.py`, `pnpm run
test:runtime`, `pnpm run check:framework`, and pre-commit.

`tests/words_watch.js` also needed a fix. It settled a `leaf-text` edit
at the field's first announcement, so the deletion's announcement made
it miss the composed words that arrive after Firefox's own `input`, and
it reported "aa **bold**" as words that left the screen. Now a native
`input` that arrives after its field's edit has settled reopens the
edit. An earlier attempt that held every composition until its native
input broke the Chromium IME test, so the watch change is limited to
this reopening.

Closes #5652 — automated triage

Co-authored-by: leaf-agent <[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