Skip to content

Take the user along when a thread moves between its margin card and its seat - #2638

Merged
max-sixty merged 2 commits into
mainfrom
agent-a0a8ae4cdd5cb0f98
Oct 14, 2026
Merged

max-sixty merged 2 commits into
mainfrom
agent-a0a8ae4cdd5cb0f98

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Item #88 of the Lit follow-up review (the review numbers its own items; #88 is not a GitHub issue). #2614 took a reply being written in the margin card back to the diff line with its thread. It left four cases where the card closes before the thread's new place exists or is chosen. This PR settles all four.

The rule

A thread moving between surfaces takes the user standing on it along:

  • The reply editor belongs to the editing session, not to the view showing it. A view that can no longer draw the thread releases the editor row (releaseReplies, thread/replies.js). That covers a seat the thread left, and the margin card, open or closed, once its thread has left the margin (releaseLeft, thread-preview.js).
    • The row goes to a view that draws the thread now. Where none does yet, it waits in a hidden park in the chrome.
    • The next view to draw the thread claims the row in the same task, in place of its own (claim): a seat once it stands in the document, the margin card once it places its thread, or a visible Threads card.
    • The editor moves with moveBefore, so focus, caret, IME state and undo history stay, and no blur fires. Leaf's dictation stays with the row too: a view handing its row on (give) no longer stops it, and a seat releases a leaving thread's row before retiring the rest of its card.
    • A closed card whose thread is still in the margin keeps its row, as a hidden Threads panel does, since the user goes on there when it opens again.
  • A user standing anywhere else on the thread goes with it (holdThreadPlace, thread/focus.js, generalizing Take the user back with their reply when a thread returns from the margin card to its outlet #2614's holdReply). "Anywhere else" means a margin card's controls, a seat's controls, or the thread's margin marker (entryThread, margin-projection.js).
    • When the pass takes away the node they stood on, they land on the thread itself where the pass seated it.
    • They hold no words that need showing, so the pass opens no card or panel for them.
    • It does nothing for a resolved thread, nor once another owner has placed them or they have acted.
    • A reply control names its thread from its own session (replyThreadKey), so a parked row still names its thread.

#88 A: the editor no longer blurs on a move

What changed. The editor keeps focus as it moves from the diff line to the margin card or Threads, and back. Before, it blurred once on each move, which cancelled an IME composition in progress and announced a focus change, and the move stopped Leaf's dictation, so the next words heard went nowhere.

  • Card → diff: the margin releases the row into the diff line's new seat as its thread leaves the margin, before the card hides.
  • Diff → card: the seat releases the row to the park, and the card claims it as it opens, in the same task.
  • holdBox (reply-landing.js) no longer scrolls the page to hold a control that left its thread view.

#88 B: leaving the card first keeps the editor

What changed. A user who left the card's reply before the patch returned gets the same editor on the diff line, undo history included. That holds whether they Tabbed onto the margin or closed the card. Before, the diff line drew a fresh editor with only the words, and the hidden card kept the original.

#88 C: the card's Close

What changed. A user on the card's Close when the thread returns to the diff lands on the thread on the diff line. Before, they landed on the banner's More button.

#88 D: the margin marker

What changed. A user on the thread's margin marker when the thread returns lands on the thread on the diff line. Before, they dropped to the page body.

Tests

These failed on main and pass now:

  • test_a_reply_dictated_on_the_diff_keeps_listening_as_its_thread_moves replaces the browser's speech recognizer at its boundary, as tests/runtime/dictation.test.mjs does. It dictates on the diff line, moves the thread to the card and back, and expects the heard words in the same box each time with the recognizer never aborted.
  • test_a_reply_box_whose_thread_leaves_the_diff_takes_the_user_to_its_card (overlay, resolved, page margins) and test_a_reply_box_whose_thread_returns_to_the_diff_takes_the_user_back now count blur events on the editor and expect none. On main each counted one.
  • test_a_reply_box_left_by_tab_returns_to_the_diff_with_its_history[open|closed] (B) failed at the undo.
  • test_a_user_on_a_thread_returning_to_the_diff_goes_with_it[close|marker] (C, D) failed with focus on the banner, and on the body.

test_a_diff_refresh_leaves_an_inline_reply_to_its_thread_owner now finds the focused editor with :focus instead of :focus-within. Chromium leaves an element moved through a display: none parent unmatched by its own native :focus-within, while its new ancestors still match. No Leaf style reads that pseudo-class; focus paints through data-lf-focus-within. The gap is recorded in notes/browser-support.md.

Lines

Hand-written source: +250 / −67.

  • replies.js +95/−21
  • focus.js +74/−33
  • inline.js +21/−1
  • margin-projection.js +16/−4
  • thread-preview.js +16/−1
  • presentation.js +10/−5
  • thread-card.js +6
  • reply-landing.js +5/−2
  • thread-list-view.js +4
  • application.js +3

Tests: +155 / −1.

Checks

  • The related browser selection passes: 881 tests across the thread, draft, widget, anchor, read-state, file, diff-control, margin, words-watch, response-continuity and response-pointer files. Three failed, and they fail on the base commit too: test_observed_scroll_retains_the_seat_of_a_constrained_target ×2, and test_a_reaction_list_opens_from_a_trigger_under_the_thread_panel, which Place the reaction trigger beneath the panel in its browser test #2625 has since fixed on main.
  • pnpm run test:runtime and pre-commit pass on the changed files.

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

@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.

An active reply dictation session still ends when its thread moves between the diff and the margin card.

…ts seat

Item #88 of the Lit follow-up review (the review numbers its own items; #88 is not a GitHub issue). #2614 took a reply being written in the margin card back to the diff line with its thread. It left four cases where the card closes before the thread's new place exists or is chosen. This PR settles all four.

## The rule

A thread moving between surfaces takes the user standing on it along:

- **The reply editor belongs to the editing session, not to the view showing it.** A view that can no longer draw the thread releases the editor row (`releaseReplies`, `thread/replies.js`). That covers a seat the thread left, and the margin card, open or closed, once its thread has left the margin (`releaseLeft`, `thread-preview.js`).
  - The row goes to a view that draws the thread now. Where none does yet, it waits in a hidden park in the chrome.
  - The next view to draw the thread claims the row in the same task, in place of its own (`claim`): a seat once it stands in the document, the margin card once it places its thread, or a visible Threads card.
  - The editor moves with `moveBefore`, so focus, caret, IME state and undo history stay, and no blur fires. Leaf's dictation stays with the row too: a view handing its row on (`give`) no longer stops it, and a seat releases a leaving thread's row before retiring the rest of its card.
  - A closed card whose thread is still in the margin keeps its row, as a hidden Threads panel does, since the user goes on there when it opens again.
- **A user standing anywhere else on the thread goes with it** (`holdThreadPlace`, `thread/focus.js`, generalizing #2614's `holdReply`). "Anywhere else" means a margin card's controls, a seat's controls, or the thread's margin marker (`entryThread`, `margin-projection.js`).
  - When the pass takes away the node they stood on, they land on the thread itself where the pass seated it.
  - They hold no words that need showing, so the pass opens no card or panel for them.
  - It does nothing for a resolved thread, nor once another owner has placed them or they have acted.
  - A reply control names its thread from its own session (`replyThreadKey`), so a parked row still names its thread.

## #88 A: the editor no longer blurs on a move

**What changed.** The editor keeps focus as it moves from the diff line to the margin card or Threads, and back. Before, it blurred once on each move, which cancelled an IME composition in progress and announced a focus change, and the move stopped Leaf's dictation, so the next words heard went nowhere.
- Card → diff: the margin releases the row into the diff line's new seat as its thread leaves the margin, before the card hides.
- Diff → card: the seat releases the row to the park, and the card claims it as it opens, in the same task.
- `holdBox` (`reply-landing.js`) no longer scrolls the page to hold a control that left its thread view.

## #88 B: leaving the card first keeps the editor

**What changed.** A user who left the card's reply before the patch returned gets the same editor on the diff line, undo history included. That holds whether they Tabbed onto the margin or closed the card. Before, the diff line drew a fresh editor with only the words, and the hidden card kept the original.

## #88 C: the card's Close

**What changed.** A user on the card's Close when the thread returns to the diff lands on the thread on the diff line. Before, they landed on the banner's More button.

## #88 D: the margin marker

**What changed.** A user on the thread's margin marker when the thread returns lands on the thread on the diff line. Before, they dropped to the page body.

## Tests

These failed on `main` and pass now:
- `test_a_reply_dictated_on_the_diff_keeps_listening_as_its_thread_moves` replaces the browser's speech recognizer at its boundary, as `tests/runtime/dictation.test.mjs` does. It dictates on the diff line, moves the thread to the card and back, and expects the heard words in the same box each time with the recognizer never aborted.
- `test_a_reply_box_whose_thread_leaves_the_diff_takes_the_user_to_its_card` (overlay, resolved, page margins) and `test_a_reply_box_whose_thread_returns_to_the_diff_takes_the_user_back` now count blur events on the editor and expect none. On `main` each counted one.
- `test_a_reply_box_left_by_tab_returns_to_the_diff_with_its_history[open|closed]` (B) failed at the undo.
- `test_a_user_on_a_thread_returning_to_the_diff_goes_with_it[close|marker]` (C, D) failed with focus on the banner, and on the body.

`test_a_diff_refresh_leaves_an_inline_reply_to_its_thread_owner` now finds the focused editor with `:focus` instead of `:focus-within`. Chromium leaves an element moved through a `display: none` parent unmatched by its own native `:focus-within`, while its new ancestors still match. No Leaf style reads that pseudo-class; focus paints through `data-lf-focus-within`. The gap is recorded in `notes/browser-support.md`.

## Lines

Hand-written source: +250 / −67.
- `replies.js` +95/−21
- `focus.js` +74/−33
- `inline.js` +21/−1
- `margin-projection.js` +16/−4
- `thread-preview.js` +16/−1
- `presentation.js` +10/−5
- `thread-card.js` +6
- `reply-landing.js` +5/−2
- `thread-list-view.js` +4
- `application.js` +3

Tests: +155 / −1.

## Checks

- The related browser selection passes: 881 tests across the thread, draft, widget, anchor, read-state, file, diff-control, margin, words-watch, response-continuity and response-pointer files. Three failed, and they fail on the base commit too: `test_observed_scroll_retains_the_seat_of_a_constrained_target` ×2, and `test_a_reaction_list_opens_from_a_trigger_under_the_thread_panel`, which #2625 has since fixed on `main`.
- `pnpm run test:runtime` and pre-commit pass on the changed files.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty force-pushed the agent-a0a8ae4cdd5cb0f98 branch from 2165a14 to 1b64b22 Compare October 12, 2026 19:12
leaf-agent
leaf-agent previously approved these changes Oct 12, 2026
@max-sixty

Copy link
Copy Markdown
Owner Author

@leaf-agent Please refresh this PR branch against current main and resolve its mechanical merge conflicts so it can get current CI. Preserve the proposed behavior and the current draft state, run the focused checks for the resulting diff, and report any conflict that requires a semantic or product decision.

This requests branch maintenance; the outstanding maintainer review remains pending.

This was written by Codex on behalf of max-sixty

# Conflicts:
#	skills/leaf/assets/runtime/annotation-overlay/margin-projection.js
#	skills/leaf/assets/runtime/thread/inline.js
#	skills/leaf/assets/runtime/thread/presentation.js
#	skills/leaf/assets/runtime/thread/replies.js
@leaf-agent

leaf-agent commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Refreshed this branch against main at f52e3d385 in merge commit fa65029e1. I resolved four source conflicts, preserving the proposed thread movement behavior alongside the newer presentation and settled-thread code. No conflict required a product decision, and I left the PR's review state unchanged.

Focused verification passed: pnpm run test:runtime (470 tests), nine thread movement browser cases, and two diff refresh browser cases. The head also test merges cleanly with the latest fetched main (6289e058a). GitHub's test, review, and relay checks all finished green on fa65029e1. The outstanding maintainer review remains pending.

@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 author said the outstanding maintainer review remains pending, so I am withholding approval until that review is complete.

@max-sixty

Copy link
Copy Markdown
Owner Author

@leaf-agent No maintainer review is pending on this PR: the maintainer has chosen to land it. Please review the current head (fa65029e1) on its merits and approve if it holds up.

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

@max-sixty
max-sixty merged commit 7b1dc50 into main Oct 14, 2026
4 checks passed
@max-sixty
max-sixty deleted the agent-a0a8ae4cdd5cb0f98 branch October 14, 2026 15:30
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