Repository navigation
Widen the comment box with its words, up to the measure - #6898
Conversation
… card at the box's width Beside its text, the comment box is now as wide as its words' longest line, from the card's least width (320 px) to the measure (592 px), and wraps them there. A first line widens it away from its start as it is typed. The card Send opens starts at the box's width, so the comment keeps the lines the box broke it into, and widens to the measure later only when a message stands taller than it is wide there. Another selection still starts at the least width. This reverses the call #5991 recorded in thread-preview.js, a box kept at the least width however much is typed in it, at Max's request. The rest of #5991 stands: slim cards, the shape rule for widening, the measure at once where a surface's start stands away from its text. Right to left, a comment's words start at the box's right edge, which widening would carry with each key, so the box keeps the least width there (`:dir(rtl)`). `leaf-dev bench --input draft` times a key typed in a comment box whose first line already fills the least width, so each key widens it. Tests: `test_a_box_widens_with_its_words_and_send_keeps_their_lines` replaces the test that the box keeps its least width; the short-lines case keeps its own test. `test_a_key_that_changes_the_comment_box_draws_it_at_once` covers a widening key beside a key that takes a line. The growing-text test in test_render_aim.py now lets the box widen into its room.
…and right-to-left words in place Review of the first commit (Codex) found four defects and a stale gallery reading. - Each key that widened the box placed it three times, and each placement walks every margin row (`marginSpot`), so the work grew with the page. A change of the box's width alone now leaves its placement standing: the words widen it inside the room the placement gave it, away from the edge that holds it, so its motion reads it where it stands. The box's watch also stops observing the box itself, which its motion already did (box-motion.js recorded this as a future change), and observes its reference alone. A widening key now places the box once, as any other key does. The card's watch is unchanged. - CodeMirror draws only the lines near what the box shows, so a long draft's longest drawn line changed as the reader scrolled, and the box's width with it, and the field then scrolled back to its caret. A draft that scrolls in its box now holds it at the measure (`:state(overflows)`). - The card started at the box's client width divided by the scale at each fit, so a zoom after Send stood it past the measure (711 px). It now starts at the box's width in its own CSS pixels, captured at Send. - `:dir(rtl)` missed a page that sets `direction` in its stylesheet, whose comment words then moved with each key. `fromSubject` (comment-placement.js) now reads the surface's computed direction: right to left, words start at the surface's right edge, so a box or card right of its text takes its widest at once, and one left of it widens leftward. This also stops a right-to-left card on the right moving its words when it widens once. - `leaf-dev placement cards` read every slim card's start as the least width; it now reads the box's width for a card Send opened. Tests: `test_a_draft_that_scrolls_in_its_box_keeps_its_width_as_it_scrolls` and `test_a_right_to_left_box_keeps_the_start_of_its_words_as_it_fills[style]` fail on the first commit and pass here. The Send test now sends at a width between the least width and the measure, after narrowing back to it. `leaf-dev bench --input draft --base` on the 256-section document page, lowest of 3 under load average ~40: 7.8 ms per key on main, 9.4 ms here (9.6 ms before this commit under lighter load, against 6.7 on main). The remaining cost is CodeMirror measuring its text again at each new width, and the field reading its corner; it doesn't grow with the page.
eafbe33 kept a widening comment box from asking its placement by comparing the bar's height with its height at the last landing. That also skipped the placement a draft's first picture needs: the shelf hangs outside the bar, so the bar keeps its height, and the placement chooses which side of the field the pictures hang on. A box held at the window's top then hung its pictures outside the window (`test_a_box_held_at_the_window_s_top_hangs_its_pictures_inside_the_window[pasted]`). box-motion.js, which owns "place, then read" for every placed box, now makes the call: a change that leaves each changed part as tall as it was last read is read where the box stands, and a part not read yet, such as the shelf, asks the placement. A placement stands a box by its parts' heights; their widths are its own to set, or, for the comment box, grow inside the room it gave them. The card gains the same rule, which skips only the placement a width it wrote itself asked for again.
… from a held start Codex's second review of eafbe33 found three defects that 1e46c44 still had: - The editing watch stopped observing the bar itself, so a box no motion follows (at rest, or open but not yet stood by a placement) went unplaced when its size changed. The watch observes the bar again and leaves only the open box a placement stands to its motion, which asks that placement itself (`followedOpen`). - A widening box kept the room its placement gave it when a workspace pane narrowed beside a target that kept its width, and its words then widened it past the pane's edge. The watch now observes the element whose box bounds the placement (`commentBoundary`'s `scroller`), as it observes the window, so the box is placed again in the narrowed pane (`test_a_box_widening_in_a_pane_stays_in_the_pane_after_it_narrows`). - A right-to-left box carried by its grip is held by its left edge, where its words end, but still widened, so each key moved the start of its words. `fromSubject` becomes `widens`, which names the edge the placement holds (its right beside its subject on the left, else its left, a carried one included) and lets the box widen only where that edge is the one its words start from. A carried right-to-left box now takes its widest as it lands, and a carried left-to-right one widens from its left edge (`test_a_right_to_left_box_carried_by_its_grip_keeps_the_start_of_its_words`). The card's start width is capped by the measure too, so a measure that narrows after Send narrows it. The size-width rule and the slim-box test's docstring now say what holds: short lines keep the box slim until they scroll, and a box with no text to stand by widens from the room's left edge in a left-to-right page. Left as they are: a page that changes direction while a box is open keeps the earlier direction's width rule until the box is next placed, and each key still runs `commentAttachment`'s scan of the margin's rows before the native attachment's early return in `placeFab`, as on main.
…s region's handoff Codex's third review of 782ddf8 found two more cases where a box widening in place outgrew the room its placement had checked: - Clearance from chrome such as the floating panel was computed across the box's current columns only. A comment near the window's foot widened from 320 to 535 px under the panel, Send included. The placement now reads the room across every column the surface may widen into, from its held edge to the measure or its lane (`comment-placement.js`, `overflow`, `lane`), so the box stands clear of the panel before it widens. A thread card reads the same room, so a slim card near such chrome stands where its one widening needs no move (tests/runtime/comment-placement.test.mjs, "a surface stands clear of chrome across the columns it may widen into"). - The editing watch observed the region it started in. When a wider window handed a pane's words from the page's scroll to the pane's own, a later narrowing of the pane went unheard, and the box widened 96 px past it. Each placement now moves the watch's observation to its current region (`watchRegion`). In the common case the box's reference resizes with the pane and places it again anyway; the region's own size matters where nothing else the watch hears changes, as beside a target of fixed width. The pane test now covers a box opened before the handoff, at a width where the box stays on its side, since a narrowing that moves the box moves it without input. Left as they are, as Codex also asked to change: the per-key margin-row scan on main (`placeFab` builds the attachment before its early return), and a page that switches direction mid-edit, which keeps the earlier rule until the box is next placed.
# Conflicts: # browser/runtime/annotation-overlay/composing/floating-response.js
leaf-agent
left a comment
There was a problem hiding this comment.
The description leaves two behaviours for the maintainer to decide but shows neither: Send hidden under a mouse while a one-line comment fills its box, and a reopened card starting at the least width rather than the comment's. Root AGENTS.md, "Working on the repository", asks that "every UI option you leave to the user carries a picture of its result ... That holds for the UI decisions a PR body leaves to the user too". A still of each (uv run leaf-dev stills) would let the maintainer settle them without checking out the branch. The same applies to the change as a whole: a before/after of a one-line comment widening, and of the card Send opens keeping its line breaks.
I'm leaving the verdict with the maintainer because those two decisions are still open. The runtime itself holds together. The width-only path in box-motion.js changed still sends a height change to the placement. The overflow reach keeps the box clear of chrome across the columns it can widen into. The new region observer follows fabRegion when the box's text moves between panes. comment-placement.test.mjs and the box-motion runtime tests pass locally.
|
The description now carries stills of the change (a one-line comment widening, and the card Send opens keeping its lines) and of both open behaviours, each with the alternative it would replace.
|
|
Thanks, that settles my finding: each open behaviour now has a still beside its alternative, and the change itself has a before/after. The two behaviours (Send hidden while a one-line comment fills the box, and a reopened card starting at the least width) remain the maintainer's to decide, so I'm still leaving the verdict with them. |
The comment box widens with its first line again, from the least width (320 px) up to the measure (592 px), then wraps; the card Send opens starts at the box's width, so the comment keeps the line breaks it was typed with. #5846 had removed the earlier growth because the card kept the box's width and wrapped every long answer at 320 px; since #5991 a tall answer widens a slim card, which removes that problem. Width comes from CSS intrinsic sizing (
width: max-contentbetweenmin-widthandmax-width) rather than script.What the diff doesn't show:
box-motion.js,changed): the words widen it inside the room the placement gave it. So the placement reserves that room when it places the box: it stands clear of chrome such as the floating panel across every column the box may widen into (comment-placement.js,overflow), and the comment box's watch also hears the pane that bounds it.comment-placement.js,widens); elsewhere (left of the text, right of right-to-left text, dragged in a right-to-left page) it takes the measure at once. A draft long enough to scroll also holds the box at the measure, since CodeMirror draws only the lines near what shows.leaf-dev bench --input draft), most of it the text field re-reading which words reach Send's corner; it doesn't grow with the page.Two behaviours were put to the maintainer, who kept both as built:
Send under a mouse. The box is exactly as wide as its words, so Send, which stands in the corner the words leave free (Experiment: give a draft's words Send's column under a mouse, with Send in the corner they leave free #4714), hides while a one-line comment fills the box (above, right); Enter still sends. Keeping Send's room on every line, as under a finger, would end every comment's lines about 30 px earlier.
A card reopened later. The card Send opens starts at the box's width (left); reopened later it starts at the least width (right), so reopened cards stay as slim as before. Opening at the first message's width would cost a measurement each time a card opens.
The maintainer asked for this change and chose both behaviours above; Codex reviewed it three times. New tests cover the widening and Send's line breaks, a key that widens drawing at once, right-to-left pages (by
dir, by CSS, and dragged), a scrolling draft, a narrowing pane, and clearance from the panel; about 190 focused browser tests, the runtime tests andpnpm run checkpass.