Skip to content

Stand a floating box by the edges that hold it, so typing grows the comment box in place - #1453

Merged
max-sixty merged 3 commits into
mainfrom
agent-a82c3bbb8cade9831
Sep 30, 2026
Merged

max-sixty merged 3 commits into
mainfrom
agent-a82c3bbb8cade9831

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Typing into a comment box that stands left of its passage (left-start) carried the box sideways, which the shift watch reported on two nightly tests (test_the_catalog_sidenote_can_be_aimed_whole and test_a_side_comment_grows_down_from_the_line_it_was_opened_on[250-left-start]).

Cause, measured frame by frame. floatingPlacement (runtime/floating.js) wrote every box's spot as left and top insets. A left-start box is held by its right edge, so when a keystroke widened it, the browser grew it rightward, past the passage, in the frame the key painted. The placement that follows the resize ran a frame later and moved it back left. In the side-comment test the box painted at x=348 with its right edge at 667, then at x=285 with its right edge at 604, where it belonged: the whole box moved 63px under the user's keys. With this change the right edge stays at 604 in every frame and only the left edge moves.

Fix. A floating box now stands by the edges that hold it, one per axis (held middleware in floating.js): on the axis its placement stands it beside something, the edge facing it; on the other axis, the edge its alignment names; and on an axis where the boundary shifted it in, the edge against that boundary. stand writes those insets (right, bottom, or left, top), in the page's plane as offsets from the anchor and in the window's plane from the containing block, so content growth moves only the free edges in the same layout pass, and the next placement finds the same insets and writes nothing. The inline thread card places itself with its own middleware under the default bottom placement, so it still stands by left and top.

The comment box's placements above and below a passage were named top-end and bottom-end, although its offset kept the box's start edge fixed. They are now top-start and bottom-start, with the same offset expressed from the start, so the placement names the edge that holds the box and held can read it from there. The tests that read data-lf-placement follow the rename.

Evidence. Before #1460, tests/test_render_aim.py with --run-nightly watched shifts: against the merge base, the side-comment carry error was the only change, and the 27 remaining errors were the same "moved without input" reports main had, none from typing. Since #1460 the nightly-marked tests no longer watch shifts, so that run is the carry evidence. npm run test:runtime and uv run pytest tests pass on the merged tree.

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

🤖 Generated with Claude Code

max-sixty and others added 2 commits September 29, 2026 17:56
…omment box in place

A comment box standing left of its passage (`left-start`) is held by its
right edge, but floatingPlacement wrote every spot as `left` and `top`. A
keystroke that widened the box grew it rightward, past the passage, in the
frame the key painted, and the placement that follows the resize carried
it back left a frame later: 63px in the side-comment test. The shift watch
reported it on test_the_catalog_sidenote_can_be_aimed_whole and
test_a_side_comment_grows_down_from_the_line_it_was_opened_on[250-left-start].

The `held` middleware now names the edge that holds the box on each axis:
the edge facing what it stands beside, the edge its alignment names, or
the edge against a boundary that shifted it in. `stand` takes the answer
and writes those insets, so growth moves only the free edges in the same
layout. The comment box's above and below placements become `top-start`
and `bottom-start`, with the same offset stated from the start, since the
box keeps its start edge; the tests reading `data-lf-placement` follow.
The runtime test stands an answer rather than bare coordinates.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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 focused nightly selection is still red, so I’m withholding approval. On this head, test_the_catalog_sidenote_can_be_aimed_whole reports a page-content shift and test_a_text_comment_chooses_above_when_the_page_has_more_room_there reports a comment-bar shift. I reproduced both on the merge base (5ed41df4), so they are not regressions from this diff; the 250-left-start typing shift appears on the base and is gone here. The two remaining shift failures need to be cleared before the touched test file can pass its landing gate.

@max-sixty
max-sixty merged commit 7dc83ea into main Sep 30, 2026
5 checks passed
@max-sixty
max-sixty deleted the agent-a82c3bbb8cade9831 branch September 30, 2026 05:52
max-sixty added a commit that referenced this pull request Oct 5, 2026
A placement design review found that the comment box and the thread card
share one rule for their side and line, but the card decided on its own
which edge to hold as its thread grows. That held-edge policy has been
reversed once and patched five more times (#1147, #1159, #1303, #1380,
#1429, #1453, #1552, #1574). This change gives it one owner.

- `comment-placement.js` now owns the policy (`holding`, `heldAt`,
`heldHeight`) for both surfaces. `margin-projection.js` reports what it
knows of the thread (the transcript's extent, whether the user is
drafting, the latest turn and the draft's words) and no longer keeps
`previewHold`. The logic moved verbatim. The comment box has no turns,
so it never asks.
- The "One writer for each fact" table in `skills/leaf/assets/AGENTS.md`
names the owners of comment placement and of margin-row seating, so a
change that decides either elsewhere shows up in review.
- Margin-entry labels measure their room through `shownWindow` instead
of reading `.lf-banner` and `.lf-shortcut-bar` themselves.
- Two TODO items whose tests already pass are removed: landing a sent
comment's thread where its box stood, and the composer on a page with a
margin on `html`.
`test_an_aimed_comment_keeps_its_place_with_the_asks_drawer_open` now
also runs at 1200px, the width that TODO described.

No user-visible behavior changes. An earlier commit on this branch also
moved the box's scrolled-away trigger into the shared module and applied
it to the card. That part came out when #1705 changed the box to follow
its passage out of view.

New runtime tests cover the held-edge policy. `npm run test:runtime`
passes. The focused browser tests for send placement, the comment box,
the margin card and replies pass, except three cases of
`test_a_thread_resolved_while_its_reply_is_written_keeps_the_user_on_it`,
which fail identically on `main`.

> _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 9, 2026
…e page (#1784)

Typing in a floating comment box scrolled the page whenever the box
stood
under or over its passage and grew past the room shown on that side. On
every content change, `floating-response.js` asked `makeRoom` to scroll
the reading region until the whole box fit clear of the passage. A
stack-logged probe at 900x700 measured it. With the box over its passage
at mid-window, the first keystroke scrolled the page 162px. With the box
under a passage near the top, the page scrolled 55px once the box
reached
the window's foot. The user's rule is that the box moves and the page
stays.

The comment box's height may now reach the whole boundary on every side,
as it already could beside its passage, and growth never spends scroll
travel. It grows from the edge that holds it (#1890 holds a landed box
by
that edge). Once the window stops that edge, shift
slides it over its passage, and once it fills the window it scrolls its
own words. This is what a box beside its passage already did at the
window's foot. Only a thread card opening under or over its target still
scrolls to make room. The margin card's reply never scrolled the page
while typing; the same probe confirmed that at both widths.

Letting the box fill the window exposed a 2px mismatch at Send. The box
reserved 2px less beneath its words than the card's reply row takes, so
a
card capped at the window's height shrank its transcript and shifted the
sent words up 2px (`test_send_grows_thread_around_the_words` at
900x600).
One token, `--lf-comment-reply-row`, now sizes both.

Behavior changes the tests now protect:

- `test_typing_moves_the_comment_box_and_leaves_the_page_still` (new)
  types line by line into a box under and over its passage and checks
that the page never scrolls and the box stays in the window. Both cases
  fail on main.
- `test_a_growing_text_comment_keeps_its_side_and_the_page_still` (was
  `..._keeps_its_passage_clear_without_changing_sides`) and
  `test_a_text_comment_chooses_above_when_the_page_has_more_room_there`
asserted that typing scrolled the page and kept the passage clear. They
now assert that the page stays put, and that a later scroll carries the
  grown box with its passage.
-
`test_a_wheel_return_attaches_the_comment_box_in_the_first_visible_frame`
types a shorter draft. In its pane cases, typing used to scroll the pane
  to make room under the passage, and the test expected the box there.
- `test_where_a_comment_stands_before_and_after_send`'s phone case
  required the box to overlap its block only when the two couldn't show
  together, which only held while typing scrolled the page. It now
  requires a box that overlaps to stand at the window's edge.

The assets AGENTS.md "Stability" section now says a floating box grows
inside the window and never scrolls the page for its growth. A field in
flow, which cannot move apart from the page, still keeps its controls in
view.


## Add-on F: one shared reading of where the user works

The design review proposed one reading of the user's working point,
shared
by the card's held edge (`holding`, fed by `drafting` in
`margin-projection.js`), the place keeper (`recentPlaceInput` in
`user-place.js`) and typing growth. This change doesn't add it. I sorted
the place- and landing-hold repairs since 2026-09-23 by the question
each
answered:

- Which edge of the card stays still: #1429, #1536, #1552, #1574, #1587,
  #1771. #1552 and #1574 fixed how the hold was keyed across a second
  placement pass and across Send's admission, not which point the user
  works at.
- Which item in a scroller stays still: #1045, #1464, #1480, #1549,
#1694,
  #1715, #1735.
- What waits behind a notice: #1473, #1493, #1725, #1738, #1742.
- What a landing reveals on entering, sending or typing: #1303, #1364,
  #1571, #1602, #1624, #1626, #1645.
- Whether the box or the page moves as the box grows: #1453 and this
one.

None of these commits names a case where `drafting` and
`recentPlaceInput` disagreed, so a shared reading wouldn't have
prevented
them. The two readings also differ by design. `drafting` counts words
left
in the reply and a send still in flight, both of which outlast focus and
the pointer. The place keeper deliberately follows whichever of pointer
and focus came last. Their outputs differ in kind too: one is an edge of
a
floating surface, the other a node in a scroller's list. The typing
scroll
was a question of which thing moves, so it needed no working-point
reading.

One rule does repeat: a focused control counts as the user's place only
while it is on screen. `holdBox` (`reply-landing.js`), the place
keeper's
"begins in the band" filter, and #1735's resize landing each state it.
It
is a candidate for a shared predicate, but not the primitive F
described.

## Overlap with work in other worktrees

`leaf.shift-a-thread-jitter` has uncommitted changes to
`comment-placement.js`, `floating.js` and `floating-response.js`, based
on
#1705. Its `floating-response.js` hunk is small. Its
`comment-placement.js`
header rewrite overlaps the paragraph this change rewrites, so expect a
textual conflict there. `leaf.thread-card-margin-avoidance` is mid-merge
in
`comment-placement.js` and `margin-projection.js`. Neither touches
`makeRoom`'s call from `floating-response.js` or the frame tokens.

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