Skip to content

Preserve unfinished comments across target and revision changes - #2650

Merged
max-sixty merged 16 commits into
mainfrom
codex/retain-comment-drafts
Oct 13, 2026
Merged

max-sixty merged 16 commits into
mainfrom
codex/retain-comment-drafts

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Unfinished comments could disappear when a widget's words changed or a responsive layout hid their target. Preserve the native editor, words, caret and focus through those changes. Comment, Resume writing and reload can recover a draft whose subject is hidden or gone; an editor already beside a subject waits for it to return.

Resume, reload and shared-tab updates keep the draft's semantic anchor together with its captured document revision. A fresh aim at a passage captures the document currently on screen while retaining any saved words and modes. Placement uses the resolver's canonical datum fallback or containing section without changing what the eventual comment means. One adopter handles reopening and shared-tab updates, and sending uses the stored capture revision. Mirrored updates keep dismissed response bars closed.

The canonical auxiliary-surface reading withholds the passage editor whenever an auxiliary surface covers the page. Questions and Threads use the same rule, preserving the native field, caret and draft for Resume writing.

Floating surfaces observe the shared visible-target-parts reading. For display: contents, they watch descendants while the subject has no box, so comment and reply editors withhold and return when the actual target parts become hidden or visible without a resize or render trigger. The native editing frame also carries across attachment changes, including a position chosen by dragging the comment box.

Validation on the integrated candidate:

  • 392 runtime tests passed.
  • Five focused browser regressions passed for display-contents comment/reply targets, visibility-only changes, pin placement, and retained drafts.
  • Scoped pre-commit checks passed.
  • Fresh full-diff Claude review recommends MERGE and found no further demonstrated underlying fix. It exercised display-contents descendant visibility, responsive display changes, external seating, zero-area targets, Page Map/pin placement, reply visibility, reopen/reload/revision send, and the shared watcher path.

This was written by Codex on behalf of max-sixty

Explicit reveal uses the shared window posture while a subject is hidden, and that posture survives replacement of the subject node. Withheld surfaces retain their observation owner so a visibility-only return restores the native editor.

Retain the canonical resolved datum after its quote changes. Persist the anchor capture revision and adopt the complete draft through one owner, including shared-tab changes; sending then preserves the document that gave the anchor its meaning. Mirroring never reopens a dismissed bar.

Cover Resume, reload, Comment, visibility-only returns, active and hidden revisions, changed-quote sends, canonical datum fallback, and shared-tab revision and dismissal behavior.
leaf-agent
leaf-agent previously approved these changes Oct 12, 2026
Keep surfaceGrip and its moved placement capture alongside hidden-target retention. The shared placement owner now holds an adopted initial frame, so composition no longer repeats that hold. Exercise a real drag followed by changed quoted words, revision adoption, and sending with the original captured revision.

@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 saved draft can send against the wrong document revision after the writer visits another passage and returns. The inline suggestion preserves the captured revision when the saved anchor itself is reused.

leaf-agent
leaf-agent previously approved these changes Oct 12, 2026
leaf-agent
leaf-agent previously approved these changes Oct 12, 2026
@max-sixty
max-sixty merged commit 11b49f2 into main Oct 13, 2026
3 checks passed
@max-sixty
max-sixty deleted the codex/retain-comment-drafts branch October 13, 2026 00:42
leaf-agent added a commit that referenced this pull request Oct 13, 2026
The old-drawing browser fixture now includes the composer record's
required `revision`. Without it, startup discarded the entire draft, so
the test never reached its intended check that obsolete drawing ink is
omitted while the draft's words return. The requirement was added in
#2650; this fixes the drawing failure in [main CI run
38333313254](https://github.com/max-sixty/leaf/actions/runs/38333313254).

The focused browser test failed before this one-field fixture correction
and passes after it.

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 13, 2026
The folded-diff draft test now checks the behavior introduced by #2650:
folding a file withholds its seated comment box, and reopening the file
returns the same draft with focus and caret intact. The previous test
expected the hidden box to stay focused and set the caret while the file
was already folded, so both variants timed out in [main CI run
38333313254](https://github.com/max-sixty/leaf/actions/runs/38333313254).

Both browser variants, with native retained moves and with the fallback
move, fail before this correction and pass after it. The check still
verifies that typing after reopening inserts at the pre-fold caret.

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 13, 2026
Native CSS anchors carry a floating comment card with its passage during
scroll, but the placement solver was rewriting the card's fallback
viewport coordinate on every scroll. Those writes triggered page-wide
highlight repaints and failed two no-write browser checks in [main CI
run
38333313254](https://github.com/max-sixty/leaf/actions/runs/38333313254).
Keep the authored CSS position while the anchor, held edges, and
relative offset are unchanged; recompute it when any of those change.
The fallback added by #2650 remains available if the anchor disappears
between placements.

Both failing scroll checks pass after this change. The neighboring
response-bar scroll check and retained-draft check pass, and `pnpm run
test:runtime` passes all 413 tests.

---------

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

When a revision moved an open margin card's passage into a closed tab,
or hid it, the thread the user was reading left the page. #3305 left
this case: it made `openPageThread` decide where every thread opens (the
card beside a drawn passage, else the floating panel), but a card
carried across a revision didn't go through it.

What happened before:

- **A revision installed in place** kept the card. A card Leaf opened
(`openPageThread`) stayed open and unseen, waiting for a passage nothing
would draw again. One opened from its margin marker was closed by the
next margin render, since its entry was no longer drawn.
- **A revision that loads a fresh document** reopened the card with
`showPreview` (`margin-projection.js`, `restoreStanding`). It never
placed, and the next margin render closed it.

Both installations now capture the margin's and the panel's standing
before the revision and restore it after (`version.js`; until now only
the fresh document did). The margin restores an open card by opening its
thread through `openPageThread` with `scroll: false`, so a revision the
user didn't ask for opens no tab or disclosure over the passage. A user
who stood in the card stands in the thread wherever it opens, and one on
its Close button returns to Close when it reopens in the card.

- A card the in-place revision kept, and that still has somewhere to
stand (`card.stands()`), stays as it was, with its reading.
- A card that accompanied the target the user stood on, with the user
outside the card, comes back only beside that target's marker
(`openInlineThread`, `unfold: false`), so it never takes the panel from
a thread the user is reading there.
- A reply the user is writing in the card is left to its editing
continuity, which reopens the thread itself (and, as before, reveals the
passage when the reply was in view).
- Focus on a margin entry comes back whether or not a card was open too.
- The panel's restore and the entry-focus restore change nothing where
the in-place revision already kept that view or focus.

A card whose passage is hidden by anything else, such as a narrower
window, still waits for it (#2650).

`test_a_card_open_across_a_revision_opens_where_its_passage_stands`
covers both installations with the passage drawn and moved into a closed
tab; the closed-tab cases fail without the change. Focused revision
tests in `test_revisions.py`, `test_render_anchors.py`,
`test_render_aim.py`, `test_round_trip.py` and two
`journeys/test_render_drafts.py` cases pass, as does `pnpm run
test:runtime`. Two independent Codex reviews found five issues in
earlier versions (a stray panel beside a reply's own restore, an
accompanying card taking the panel, focus lost to the body, focus in an
entered accompanying card, entry focus skipped beside an open card);
each is fixed here and confirmed by browser runs or a re-review.

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