Skip to content

Make Lit DOM dependencies explicit and preserve review state - #3676

Merged
max-sixty merged 4 commits into
mainfrom
codex/lit-dom-completion
Oct 23, 2026
Merged

max-sixty merged 4 commits into
mainfrom
codex/lit-dom-completion

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Leaf’s presentation pass ordered renderer starts without guaranteeing that the DOM a later renderer reads had committed. This change retains Lit and its native lifecycle, and separates explicit DOM dependencies from the existing semantic presentation ledger. It also makes visual-review captures available offline and preserves unfinished replies when search is opened through the Page menu.

Changes

  • Replace numeric presentation ranks with declared DOM dependencies: widget ancestors → projection → threads → obligations → annotations. Widgets use native Lit updateComplete; imperative Lit renderers commit synchronously. Dependencies follow replacement and stay transitive through owners that do not repaint. Optimistic cyclic moves cannot block rendering before server refusal.
  • Keep asynchronous preparation, gesture holds and semantic proof separate. An owner’s held proof does not block unrelated drawing. The ledger still owns visible revisions, late failures, supersession and disconnection. Async thread materialization still refreshes the targets and annotations it changes; that coordination remains necessary because those nodes arrive after the synchronous commit.
  • Declare cases[].before and cases[].after in the visual-run resource contract. The existing export mechanism embeds captures for unopened cases too; no export-specific collector is added.
  • Retire attributed jobs before invoking callbacks that can reenter. Cancellation and completion cannot run the same job twice or consume its successor.
  • Let a menu command dismiss its invoking menu while preserving the underlying thread. Page search exposes its own Close search action above a retained thread, preserving the reply editor, text, caret and undo history through both pointer and keyboard routes.

Relation to the experiment

This uses the Solid 2 experiment and its assessment at dfd113f as behavioral references. Hidden-in-place summary folds, retained search editors, shared lf-shot inspection, indexed/off-document diff preparation, and logical versus visible focus already exist on main. They remain intact and are not new work here. Solid’s lifecycle/error adapters and upstream adaptations are unnecessary for Lit.

Public widget API exports and record/draft formats are unchanged. The branch inherits main’s protocol 20; this work needs no protocol bump. Lit, SignalWatcher, AsyncDirective, native computed selections, keyed templates and WebAwesome remain.

Validation

GitHub relay, review and test checks pass on cdc3b672aaba6f43069af0711434177f5b20b94a; the automated reviewer approved that exact head without findings.

Local validation includes pnpm run check (134 framework/build tests, 528 runtime tests and 85 Worker tests), every pre-commit gate, and focused real-browser selections covering offline export, search retention, stale image loads, parent ordering, widget lifetime, frozen thread widgets and input attribution. A separate seven-case selection exercises all three search routes, keyboard-reference retention, menu dismissal, version navigation and copying a link.

Regression cases distinguish native DOM completion from held proof, follow-up updates, idle intermediaries, supersession/disconnection and late failures. Retention checks assert search focus before fill() and wait for native stale-image load events before checking that current captures survive. Offline checks decode all four images, switch cases, use the keyboard comparison slider and observe no HTTP requests with networking disabled. Existing Chromium/WebKit iframe document and selection-retention cases pass.

Desktop-light and 390×844 dark-touch journeys exercise decision/undo, On me, and comment/reply search round trips with identical editor nodes, draft values and caret positions. Both have zero console errors and no horizontal overflow. The menu/reply defect was reproduced on main before the fix.

After integrating main at 783d3c150, the complete local check and applicable pre-commit gates pass again. A served startup comparison against that main uses 46 code requests (44 JavaScript) on both sides through widget upgrade and first server presentation. The candidate adds 1,820 code bytes, including 1,682 JavaScript bytes; all loaded bytes increase by 1,919. Both have zero startup layout shifts and console errors. Total requests vary from 51 to 53 because of polling; the single heavily loaded run is not timing evidence. The added code coordinates native completion on the path where another renderer needs that DOM.

The final visual sweep covers the shipped review example and focused search fixture, with Chromium/WebKit retention checks. It does not establish full-corpus, Firefox, print or physical mobile-keyboard behavior.

The resulting Lit implementation is a net improvement in correctness and ownership: it removes numeric ordering and the redundant annotation proof wait, keeps one native completion producer, and fixes concrete export, menu and reentrancy failures. No timing improvement is claimed; native completion adds necessary waiting only where a consumer actually needs that DOM.

This was written by Codex on behalf of max-sixty

@max-sixty
max-sixty merged commit 9799dd8 into main Oct 23, 2026
3 checks passed
@max-sixty
max-sixty deleted the codex/lit-dom-completion branch October 23, 2026 03:23
leaf-agent added a commit that referenced this pull request Oct 23, 2026
The selection-restoration browser test now expects Threads to remain
open after the user invokes Restore selection from its borrowed menu.
#3676 made the menu close while preserving its underlying view, the same
outcome as invoking the command by key; the old assertion still expected
the whole panel to close.

`test_restore_selection_has_touch_route_and_does_not_carry_draft` failed
at that assertion in [main CI run
39917870081](https://github.com/max-sixty/leaf/actions/runs/39917870081)
and passes locally with `uv run pytest -q -n0
tests/browser/navigation/test_reading_place.py::test_restore_selection_has_touch_route_and_does_not_carry_draft`.
The test still requires the restored selection, touch route, saved
draft, and subsequent keyboard routes. Refs #3695; this changes no
product behavior.

Co-authored-by: leaf-agent <[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