Repository navigation
Take the user back with their reply when a thread returns from the margin card to its outlet - #2614
Merged
Merged
Conversation
…rgin card to its outlet Behaviour change: a thread can go back from the margin card into a widget's outlet, as a diff thread does when the patch it was written on returns, while the user is typing its reply in the card. The user now goes on in the same editor on the diff line, at the same caret, with its undo history. Before, the card closing under them landed them on the banner's More button, so the next letters ran page commands. - thread/focus.js: `holdReply` records the box its pass is carrying until its step has run, and `carryingReply` answers for it while the thread still stands with a reply and the user has not acted since. - margin-projection.js: `closePreview` places no one when the user stands in a carried reply, so the hand-off decides where they go. - thread/replies.js: `carry` takes the row from a view that holds it out of sight, as the closed card does. That view gives it up (`binding.give`) and draws a fresh row of its own once the taker has moved the row out. Before, `carry` refused any row a view still held, so the user landed in the outlet's own editor without its history. tests/words_watch.js now hears a `leaf-text`'s host input on the field itself. That event is not composed, so typing inside a widget's shadow tree, such as an lf-diff outlet, never reached the watch and the words it held went stale. `test_replaced_reply_compositions_keep_their_carets_and_leave_commands` now consumes the report it had hidden: the margin card shows one thread, so the other thread's words wait off screen until the user selects its route, as the test describes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 12, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 12, 2026
…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
added a commit
that referenced
this pull request
Oct 14, 2026
…ts seat (#2638) 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. > _This was written by Claude Code on behalf of max-sixty_ Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]> Co-authored-by: leaf-agent <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Item #86 of the Lit follow-up review. The review numbers its own items, so #86 is not a GitHub issue. This follows #2604, which carries a reply being written from a widget's outlet into the margin card.
#86 (a): a reply being written goes back with its thread to the outlet
What changed. A thread can go back from the margin card into a widget's outlet while the user is typing its reply in the card. A diff thread does this when the patch it was written on returns. The user now goes on in the same editor on the diff line, at the same caret, with its undo history. Before, the card closing under them landed them on the banner's More button, so the next letters ran page commands. This also happened before #2604.
Cause. The thread pass closes the card in
renderAnnotations, before its reply hand-off (holdReply) runs.closePreviewdefaults toletGo, and that placement voided the hand-off's hold. Once focus was handled, a second gap showed:carryrefused a row any view still held, so the hidden card kept the user's editor and the user landed in the outlet's own editor without its history.How.
thread/focus.js:holdReplyrecords the box its pass is carrying until its step has run.carryingReply(node)answers for it while the thread still stands with a reply and the user has done nothing since. The reply admission both use is one helper (mayReplyTo).margin-projection.js:closePreviewplaces no one when the user stands in a carried reply, so the hand-off decides where they go.thread/replies.js:carrytakes the row from a view that holds it out of sight, as the closed card does. That view gives it up (binding.give): it detaches, wires a fresh row, and draws it once the taker has moved the row out.Lines. Hand-written source: +73 / −26 (replies.js +37/−13, focus.js +31/−12, margin-projection.js +5/−1). Tests: +52 / −2.
Test.
test_a_reply_box_whose_thread_returns_to_the_diff_takes_the_user_backwrites on the diff line, follows the thread to the card, types more there, and brings the patch back. It then expects focus, words and caret on the diff line, typing to continue, and two undos to walk back through the card's typing. Onmain, focus lands onlf-banner-more. With only theclosePreviewchange, the user lands in the outlet's own editor and the undo fails.#86 (b): the remaining blur, not done
The editor still blurs once on each move. Going to the card, the outlet is removed before the card exists, so a blur-free move needs a connected, rendered place to park the row. Coming back, the blur comes from ordering: the card hides before the carry, and
openfocuses the outlet's own editor first. Removing it means opening the destination without focus (continueThreadalready does this), carrying the row in withmove(), which keeps focus throughmoveBefore, and only then closing the card. That changes the order inpresentation.js's commit and inopenPageThread's surface path, which closes the preview first. So this PR asserts no blur count.Test watch
tests/words_watch.jsnow hears aleaf-text's hostinputon the field itself. That event is not composed, so typing inside a widget's shadow tree, such as anlf-diffoutlet, never reached the watch, and the words it held went stale. With the watch fixed,test_replaced_reply_compositions_keep_their_carets_and_leave_commandsreports the words of the thread the margin card does not show. The test's own comment calls that state intended: that thread's session keeps its words and caret until the user selects its route. The test now consumes the report rather than asserting none. I read this as the rule's "no usable room" case inskills/leaf/assets/AGENTS.md, "Words stay where they were typed": the card shows one thread at a time.Checks
These pass:
test_render_threads.pyandtest_render_drafts.py;test_render_words_watch.py,test_thread_response_continuity.pyandtest_response_pointer.py;pnpm run test:runtime;test_the_reading_page_keys_follow_the_user_into_the_panelfailed once under load and passes alone. #2604 recorded it failing on the base too.