Repository navigation
Release core's composer before a widget removes the thread outlet holding it - #2580
Merged
Merged
Conversation
…utlet A comment being written on a diff line now stays focused when the line goes away without a re-render keeping its outlet: a new patch that drops the file, a file whose next deferred patch fails to load, a cleared source, and a patch the widget refuses. Before, each removed the outlet holding the composer before the thread placement committed. A dropped file lost focus altogether; the other three blurred once and the restore hold put the user back. `releaseOutlets(node)` (thread/surfaces.js, exported from widget-api) moves core's composer out of every outlet under `node` now, to where the next commit would put it. lf-diff calls it before dropping a file, before a file's error box replaces its lines, and before a cleared source empties its stage. `failSoft` calls it for the widget it replaces, so every thread surface widget is covered. module-authoring.md states the rule beside `onCommit`. The test of #2570 runs four more cases, one per path; each fails on main. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…source removes A comment being written on an lf-visual-review case now stays focused when a new run drops that case or the source is cleared. Before, the case's article took the composer out of the document: a cleared source blurred it once, and a dropped case left the user on the next case's title. `#show` releases the outlets of dropped cases before its focus hold, as lf-diff's error box does. The lf-diff test also checks that the released box is in the viewport, and module-authoring.md says the release goes ahead of any focus hold. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The dependency gate forbids widget-upgrade.js importing the thread layer: it closes a cycle through markdown.js and projection/authored.js. lf-diff and lf-visual-review, the two widgets that place threads, release their outlets before calling failSoft. A refused patch still keeps the composer in hand. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
previously approved these changes
Oct 12, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # skills/leaf/assets/runtime/widget-api.js
leaf-agent
approved these changes
Oct 12, 2026
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 72 of the Lit follow-up review. That review numbers its own items, so #72 is not a GitHub issue.
Item 72: a comment being written stays in hand when its outlet's content goes
What changed. A comment being written on a diff line now keeps focus, with no blur, when a change removes the line without a redraw that would keep its outlet. There are four such changes: a new patch that drops the line's file, the file's next deferred patch failing to load, the source being cleared, and a patch the widget refuses (
failSoft). Before, each of them removed the thread outlet holding core's composer before the thread placement committed. A dropped file lost focus altogether, and the user was left on the page. In the other three the box blurred once andrestoreFab's hold put the user back. The same cause affectedlf-visual-review: a new run that dropped the case being commented on left the user on the next case's title, and a cleared source blurred the box once. Both now keep the user typing too.How. #2570 gave the placement an
onCommithook, so a widget removes unused outlets only once core has moved the composer. Its hook didn't cover a removal outside the placement, and the runtime had nothing a widget could call first.releaseOutlets(node)(thread/surfaces.js, exported fromwidget-api) moves core's composer out of every registered outlet undernodeimmediately, to where the next commit would put it. On every path this covers, the composer's datum is gone, so the next commit puts it in the same place and doesn't move it again. The move goes throughmove(), which keeps focus. The released box is in the viewport.lf-diffcalls it before dropping a file, before a file's error box replaces its lines, before a cleared source empties its stage, and beforefailSoft.lf-visual-reviewcalls it for the cases a new run drops, at the top of#show, and beforefailSoft.failSoftdoesn't call it itself. The dependency gate forbidswidget-upgrade.jsfrom importing the thread layer, because that import closes a cycle throughmarkdown.jsandprojection/authored.js. These two are the only widgets that place threads.holdFocusaround the removal. Otherwise that hold reads the user as having left and hands them to Retry or to the case title.module-authoring.md("Widget-local Thread placement") states this next toonCommit.Not done here. I didn't add a removal hook in
dom-children.js.lf-visual-reviewremoves cases through Litrepeatrather thansetChildren, so the hook wouldn't reach it. A release made during removal would also come after the widget's own focus hold. While the floating bar is still being placed at home, that hold would not count it as drawn. A revision that removes the whole widget while the user is composing is deferred (midCompositioninversion.js). I checked this: the revision was not applied within 120 s.Lines. Hand-written source: +31 / −1 (surfaces.js +11, widget-api.js +1, lf-diff.js +12/−1, lf-visual-review.js +7). Tests: +102 / −6.
Tests.
test_a_comment_being_written_on_a_diff_line_stays_in_hand_across_a_new_patchruns four new cases:file-dropped,file-refused,source-clearedandpatch-refused. It now also checks that the box is in the viewport. Each new case fails onmain.file-droppedloses focus, and the other three blur once.patch-refusedwas checked by disabling the release beforefailSoft.test_a_comment_being_written_on_a_visual_case_stays_in_hand_as_the_case_goeshas two cases,case-droppedandsource-cleared. Both fail without the release in#show.Checks
These pass:
npm run test:runtime; the diff, visual-review and failure selections oftest_render_threads.py,test_render_diff_controls.py,test_render_anchors.py,test_render_widgets.py,test_render_read_state.py,test_render_drafts.py,test_thread_response_continuity.py,test_response_pointer.pyandtest_render_visual_review_journey.py; the widget-api export test; and pre-commit.