Skip to content

Release core's composer before a widget removes the thread outlet holding it - #2580

Merged
max-sixty merged 6 commits into
mainfrom
agent-aecf92a71d3665447
Oct 12, 2026
Merged

max-sixty merged 6 commits into
mainfrom
agent-aecf92a71d3665447

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

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 and restoreFab's hold put the user back. The same cause affected lf-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 onCommit hook, 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 from widget-api) moves core's composer out of every registered outlet under node immediately, 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 through move(), which keeps focus. The released box is in the viewport.
  • lf-diff calls it before dropping a file, before a file's error box replaces its lines, before a cleared source empties its stage, and before failSoft.
  • lf-visual-review calls it for the cases a new run drops, at the top of #show, and before failSoft.
  • failSoft doesn't call it itself. The dependency gate forbids widget-upgrade.js from importing the thread layer, because that import closes a cycle through markdown.js and projection/authored.js. These two are the only widgets that place threads.
  • A release has to come before any holdFocus around 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 to onCommit.

Not done here. I didn't add a removal hook in dom-children.js. lf-visual-review removes cases through Lit repeat rather than setChildren, 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 (midComposition in version.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_patch runs four new cases: file-dropped, file-refused, source-cleared and patch-refused. It now also checks that the box is in the viewport. Each new case fails on main. file-dropped loses focus, and the other three blur once. patch-refused was checked by disabling the release before failSoft.
  • test_a_comment_being_written_on_a_visual_case_stays_in_hand_as_the_case_goes has two cases, case-dropped and source-cleared. Both fail without the release in #show.

Checks

These pass: npm run test:runtime; the diff, visual-review and failure selections of test_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.py and test_render_visual_review_journey.py; the widget-api export test; and pre-commit.

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

max-sixty and others added 3 commits October 12, 2026 04:19
…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
leaf-agent previously approved these changes Oct 12, 2026
max-sixty and others added 2 commits October 12, 2026 05:01
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	skills/leaf/assets/runtime/widget-api.js
@max-sixty
max-sixty merged commit 83da5d6 into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the agent-aecf92a71d3665447 branch October 12, 2026 14:22
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