Skip to content

Keep withdrawn threads in place and preserve native state in Lit moves - #2387

Merged
max-sixty merged 3 commits into
mainfrom
lit-move
Oct 11, 2026
Merged

max-sixty merged 3 commits into
mainfrom
lit-move

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

When another actor withdrew the selected thread, the list pulled its neighbors up and opened a fallback conversation. The 34px jump was present before this change, but Lit's detach/reinsert moves hid it from Chrome's shift reporting. This fixes that presentation owner and completes the Lit portion of survey item #1, deferred in #2324.

The list keeps the withdrawn thread's measured space while removing it would disturb the reader, replaces its disconnected controls with “Thread withdrawn” and Dismiss, and keeps semantic counts and navigation current. Dismiss, choosing another conversation, changing the view, or leaving that reading releases the space. A selected notice prevents an unsolicited fallback conversation from opening. Complete-list rollback restores the committed native cards and editors. Frozen-message preparation now reads projected threads, so historical withdrawn markup no longer has to find an absent thread owner.

The locked lit-html keyed, child-part and root-marker insertion sites use the shared move primitive. Chrome retains focus, caret, edited values and iframe documents during reorders; named form fields cannot shadow the native methods. The focus-holding render wrapper remains for engines without moveBefore, where insertion can still reload frames.

Measured handwritten production sources (build script, dom-children, state-application, thread-list/view and source chrome stylesheet): 3,659 → 3,841 lines (+182). Generated assets, tests and documentation are excluded. This adds the withdrawal lifecycle needed to safely adopt native Lit moves; it is not a line-count reduction.

Validation: native/fallback × Leaf/Lit browser proof; withdrawal with selected and closed cards, a scrolled conversation with a frozen widget and saved draft, and a scaled panel; Dismiss, keyboard navigation and narrowing; complete-list failure/rollback and neighboring thread journeys. 335 runtime tests and 95 framework tests pass; pre-commit passes. Independent code review and a fresh user-task review completed. The paired startup probe made 242 requests in each version with no errors or initial shifts; candidate transfer grew by about 5.6KB for the required presentation behavior.

This was written by Codex on behalf of max-sixty

A passive root withdrawal used to pull neighboring cards up and open a fallback conversation. Ordinary Lit moves disconnected those cards and masked the resulting shift. Retain only the withdrawn root allocation and an explicit dismissal until the reader releases it; live controls disconnect and counts and navigation use current membership. Shared selection owns releasing a withdrawn choice, including keyboard and native reveal routes.

Prepare frozen messages from projected threads, since withdrawn log entries no longer have a current thread owner. Adapt the locked lit-html keyed, child-part and root-marker insertion seams to the shared move primitive; retain focus restoration for engines without state-preserving moves.

Browser proof covers native/fallback moves, named forms, focus/caret/iframe retention, withdrawal under selection/scroll/scale, saved drafts, and complete-list rollback. Runtime and framework checks and pre-commit pass.
Keep mechanical allocation rows inside ThreadListView, independently of the immutable semantic candidate that the coordinator retries. A rollback restores the committed visual rows and clears dismissal of a live root, so its later passive withdrawal measures a fresh allocation rather than reusing an earlier gesture. Unknown-count placeholders carry no withdrawn membership.

The rollback browser check now waits for the restored geometry to be observed before retry, and verifies that the surviving card stays in place. Update freshly landed template guidance to reflect native Lit moves and the insertion fallback.
@max-sixty
max-sixty merged commit c8dd05b into main Oct 11, 2026
6 checks passed
@max-sixty
max-sixty deleted the lit-move branch October 11, 2026 10:03
max-sixty added a commit that referenced this pull request Oct 12, 2026
…#2498)

Lit follow-up review, item 24:
[#2387](#2387) held a withdrawn
thread's allocation in the panel with its own copy of `keeping`'s
conditions (same intent, reading continuity, shown and not folding, no
gesture of the user's, visible when open and growth seen otherwise), and
spliced the allocation into each reading the list painted, so `commit()`
had to rebuild a parallel committed row list from the drawn rows. Every
later change to when a card may leave the list would have had to land
twice.

Now one rule, `#keeping` in `thread-list-view.js`, decides when any card
leaves, and the model builder asks it about both kinds of departure
while it builds the reading (`rowModel` in `thread-list.js`):
`keeping(thread, intent)` for a card the narrowing stops admitting, and
`withdrawal(row, intent)` for a committed card whose root the log no
longer has. A kept withdrawal is placed among its neighbours in the
reading itself, so it is an ordinary row of the committed model:
`#committedRows`, `#withWithdrawals` and the retaining branch in
`willUpdate` are gone, and rollback repaints the committed reading as it
stands. The one condition that differs is a parameter: a withdrawn root
passes `words: false`, since its controls disconnect with it and there
is no draft left to hold for. Whether a card is the open one is read
from the row the list last showed open, one fact for cards and withdrawn
allocations alike. The module header records the rule and the rejected
copy.

**Behaviour that changed:** none for the case #2387 fixed (another actor
withdrawing the selected thread keeps its room, shows "Thread withdrawn"
with Dismiss, and opens no fallback conversation). Three edges follow
the shared rule:
- A card held only for the user's words ("draft") that another actor
withdraws now leaves at once, as any card a turn of the user's own
released does, rather than standing as a Dismiss notice. No words are
lost by this: a withdrawn root's notice never held an editor, so under
#2387 too the reply editor ends with the root and the words leave the
screen, while `drafts.js` keeps them under `reply:<thread>` for a return
of the thread. The `scrolled` case of
`test_an_external_withdrawal_keeps_the_readers_allocation` asserts
exactly that (the words-left-the-screen report, then
`loadDraft('reply:first-thread')` still returning the typed text), and
it covers a selected card holding a draft, which the shared rule still
keeps as a notice. (#2387's copy also skipped a card while the user's
gesture on it stood, and a gesture is how a card comes to be kept for
its words, so the two differ only once that gesture has passed.)
- A resolved card already folding out when its root is withdrawn now
finishes leaving rather than freezing at its partial height as a notice.
The old copy read `descriptor.folding`, which the model always sets
false, so its folding test never fired.
- The withdrawal decision is made when the reading is built, as
`keeping`'s always was, so a retry after a failed paint draws the
reading it retries rather than deciding again mid-paint.

Choosing another card still releases a withdrawn allocation at once, as
#2387 chose, outside the geometry rule; the header now says so rather
than calling it a gesture on the withdrawn thread. The dead
`descriptor.folding` read in the list's eligibility (always false in the
reading) is gone.

**Source lines (hand-written, excluding tests):** +94 −99.
**Test lines:** +2 −10.
`test_an_external_withdrawal_keeps_the_readers_allocation` now asserts
the frozen widget is gone from the page instead of reading a captured
node's `isConnected`, and drops a node-identity check that its position
and focus assertions already cover.

Focused browser runs: the withdrawal test (closed, selected, scrolled,
scaled), the failed-candidate rollback test, and the held-news panel
tests
(`test_a_settlement_from_elsewhere_moves_nothing_in_a_short_panel_thread`,
`test_an_external_resolution_keeps_a_panel_reply_until_it_is_sent`,
`test_reaching_news_a_card_holds_keeps_the_view`,
`test_a_rewrite_in_a_card_news_kept_goes_with_its_thread`,
`test_resolving_an_early_thread_keeps_the_rest_in_place`,
`test_a_thread_resolved_while_its_reply_is_written_keeps_the_user_on_it`).

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