Skip to content

Preserve comment drafts and stabilize floating editors - #1536

Merged
max-sixty merged 5 commits into
mainfrom
codex/preserve-comment-drafts
Oct 2, 2026
Merged

max-sixty merged 5 commits into
mainfrom
codex/preserve-comment-drafts

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

An agent resolving a thread could remove the reply being typed, while an earlier hidden comment draft could redirect c away from the user's current item. Floating composers also briefly returned at the wrong attachment after a wheel jump, and growing replies could move their whole card.

This change gives drafts and placement one rule across their surfaces:

  • Retain a resolved thread's editor while its shared draft holds unfinished words, including surface replacement and refused sends. Sending the reply reopens the conversation; clearing it lets the resolved surface close.
  • Choose a comment's destination from live selection and current page/thread standing, then carry ordinary words into an empty destination. Existing destination drafts win. Transfer settles the exact source generation only after destination persistence succeeds.
  • Cover actual compositor frames on wheel return. The canonical window/attachment posture landed in #1538; integration removes the redundant middleware change.
  • Cap reading and drafting by the same room from the held edge. Preserve the transcript’s room so typing leaves the editor top fixed; extra draft lines scroll inside the editor. The shared text field measures its focused caret after its host’s available size changes and scrolls only that host, including a large paste whose first reveal preceded the owner’s sizing pass. A mechanical resize preserves the enclosing pane’s reading position.

Browser coverage exercises panel, inline, bounded-pane and margin replies; resolution, clearing, reload, replacement and send refusal; page/thread retargeting and rejected storage writes; and native-wheel compositor frames for element/selection comments in the document and panes. The old draft-loss exemptions are removed. The gallery includes the kept-draft move.

The startup verifier now collects every resource rather than truncating at the browser's 250-entry buffer; a real HTTP/browser regression covers 260 responses.

Validation: 1,529 Python tests passed with changed nightly cases; 189 runtime, 74 browser-framework and 66 Worker tests passed; browser/Worker type checks, pre-commit and committed bundle reproduction passed. Focused browser regressions, original-baseline failure controls and independent code/render review passed. The served corpus loads the same 244 code requests (241 JavaScript requests), with approximately 6KB more code at presentation; elapsed differences are diagnostic.

This was written by Codex on behalf of max-sixty

Editor lifetime follows the unsettled shared draft instead of conversation resolution; sending still reopens a resolved thread. Current page or thread standing chooses the next comment, with generation-safe draft transfer and durable-source retention on failed storage writes.

Offscreen floating surfaces retain their declared attachment for native compositor scroll. Reading and drafting share the same held-edge room cap, so editor growth scrolls internally. Replace the known draft-loss exemptions with browser behavior coverage and observe actual painted wheel-return frames.

Collect every startup resource through PerformanceObserver, avoiding the browser timing buffer truncation exposed by the required corpus comparison.
leaf-agent
leaf-agent previously approved these changes Oct 1, 2026

@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 margin card still moves the text being answered when a long reply reaches its height cap. The test_margin_card_holds_its_top_as_a_turn_arrives_and_as_a_reply_wraps failure reproduces locally on both the original and merged PR heads: after 60 lines, the card top stays fixed, but the existing turn and editor top each rise about 24 px. This breaks the held-edge behavior the change claims for drafting. The cap and overflow handoff in placeThreadPreview needs to keep the transcript and editor top in place as the editor starts scrolling. I can help push a fix if useful.

@leaf-agent
leaf-agent dismissed their stale review October 1, 2026 23:33

CI fails: a long margin reply moves the turn and editor top at the height cap.

…lport

Typing keeps the transcript and editor top where the reply began. A long transcript retains its room instead of giving it up to a pasted block; the former growth assertion now proves stationary editor edges, answered-turn visibility, and the actual caret. Short threads still lend their free room to the editor.

The shared field measures its focused caret after its host cap changes and scrolls only that host. CodeMirror edit reveal can precede the external sizing pass; its ancestor-scrolling reveal is not appropriate for mechanical resize. Browser regressions cover paste, native typing, incoming turns, and an offscreen focused editor whose reading pane remains where the user left it.
…t-drafts

# Conflicts:
#	examples/corpus.html
#	examples/developer/feature-gallery.html
#	skills/leaf/assets/runtime/comment-placement.js
#	skills/leaf/assets/runtime/thread/thread-list-view.js
leaf-agent
leaf-agent previously approved these changes Oct 1, 2026
The integrated active-draft contract preserves the old editor after its subject scrolls out of view. Keep the real retargeting journey: the old passage is offscreen, its editor still holds its original words and anchor, and a new passage or thread holds focus. Comment must then choose that new standing and preserve the existing send and storage assertions.
@max-sixty
max-sixty merged commit 87983c2 into main Oct 2, 2026
4 checks passed
@max-sixty
max-sixty deleted the codex/preserve-comment-drafts branch October 2, 2026 00:19
max-sixty pushed a commit that referenced this pull request Oct 2, 2026
The complete-suite run on [main at
87983c2](https://github.com/max-sixty/leaf/actions/runs/36945384717)
found browser tests that still expected an open comment editor to leave
with its passage. The runtime now keeps a writer's draft and focus in
the usable window when the passage scrolls away, including inside a
bounded pane. These tests now check that attachment while the passage is
visible and the focused, word-preserving window posture after it leaves.

The five affected cases failed on current main before this change and
pass locally after it. This updates test expectations for the behavior
shipped in #1536; it does not change the runtime. Other failures in the
run have separate causes.

---------

Co-authored-by: leaf-agent <[email protected]>
max-sixty pushed a commit that referenced this pull request Oct 2, 2026
…ation (#1554)

## Summary

Align three reaction browser tests with the current retained-editor and
navigation behavior after #1536 and #1544.

- A diagram comment editor stays in the window while its target scrolls
away, then returns to target placement when the target is visible again.
- The mobile Threads test opens the panel through its visible button,
leaving the reaction keyboard behavior under test.
- The response-row test explicitly constrains the bar to 280px, so it
still proves the seven choices hold one row under tight space after the
floating bar gained more room.

## Evidence

All three tests failed in [main CI run
36945384717](https://github.com/max-sixty/leaf/actions/runs/36945384717)
and were reproduced against current main before the edits. The three
focused tests pass after the edits; the response-row case was rerun at
its original 1024px viewport. `uvx pre-commit run --files
tests/test_render_reactions.py` passes.

> _This was written by Codex on behalf of max-sixty_

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