Skip to content

Give version comparison one module-scope home and import its readers directly - #2496

Merged
max-sixty merged 3 commits into
mainfrom
fix/version-comparison-home
Oct 12, 2026
Merged

max-sixty merged 3 commits into
mainfrom
fix/version-comparison-home

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Version comparison now has one home: its state and readers live at module scope in skills/leaf/assets/runtime/version.js, and the surfaces that read them import them directly. The forwarding that carried them through leaf.js and application.js is gone. Numbering below is the Lit-survey review's (items 20–41), not GitHub issues.

Review item 31: comparison state split across two scopes. #2376 moved diffOn and diffMarked to module scope, but diffBase, diffPendingBase and diffBefore were still inside createVersionController, and the closure wrote the module values. comparisonBase, inlineComparison and toggleInlineComparison still went leaf.js → application.js → annotation inventory. renderVersions reached state application the same way, and closeVersionMenu reached the response surface the same way. The comparison and the picker's presentation read only runtime, the registry and the documents they fetch, so they moved to module scope unchanged apart from dedent and Prettier rewraps. The annotation inventory and state application now import them. closeVersionMenu was only a wrapper around the picker view, so it now lives in version-picker.js beside versionMenuIsOpen, and the response surface imports both from there. createVersionController stays a factory: what remains in it (travel, activation, arrival continuity, the menu's key scopes) needs readAndApply, midComposition, syncLayout and the standing captures, which exist only once leaf.js has wired the application. Its runtime neighbours with that shape are also factories called once from leaf.js.

  • Behaviour: none visible. Comparison, inline diffs, the picker and activation behave as before.
  • Source lines: −19 (749 added, 768 removed, almost all a moved block).
  • Test lines: 0 for this item.

Review item 41 (part): the test asserted how the count is computed. tests/test_render_options_settled.py hand-added an lf-ins-block class and asserted the counts ignored it. No user path adds that class, so that block is removed. The rest of the test still drives real revisions through both consumers and detach/reattach. watchComparison no longer re-checks owner.isConnected. whileConnected aborts its listener at the arrival batch after the owner leaves. No lf-comparison dispatch falls between a removal and that batch: activation clears the comparison before it patches, and restores it only after landing. A stray read would only count marks under the detached owner, and reconnection reads again.

  • Behaviour: none visible.
  • Source lines: −2 (inside the version.js figure above).
  • Test lines: −9.

Checks: npm run test:runtime, plus focused browser cases for settled-options/tabs counts, inline version diffs, versions-menu close routes, pending comparison across a live revision, comparison replay, the margin map's comparison and comparison retry.

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

max-sixty and others added 3 commits October 11, 2026 22:23
…directly

#2376 moved `diffOn` and `diffMarked` to module scope but left `diffBase`,
`diffPendingBase` and `diffBefore` inside `createVersionController`, which wrote the
module values from its closure. `comparisonBase`, `inlineComparison` and
`toggleInlineComparison` still travelled leaf.js -> application.js -> the annotation
inventory, and `renderVersions` and `closeVersionMenu` took the same route into state
application and the response surface.

None of that needs an application capability: the comparison and the picker's
presentation read only `runtime`, the registry and the documents they fetch. They now
live at module scope in version.js, one per document, and the annotation inventory,
state application and response surface import them. The forwarding entries in
leaf.js, application.js and the three factories' parameters are gone.

`createVersionController` stays a factory. What remains in it (travel, activation,
arrival continuity, the menu's key scopes) needs `readAndApply`, `midComposition`,
`syncLayout` and the standing captures, which exist only once leaf.js has wired the
application; neighbouring runtime modules with that shape are factories called once
from leaf.js.

`watchComparison` no longer re-checks `owner.isConnected`: `whileConnected` aborts
the listener when the owner leaves.

The settled-options test no longer hand-adds `lf-ins-block` and asserts it is not
counted. No user path adds that class; the test asserted how the count is computed.
The rest of the test still drives real revisions through both consumers and
detach/reattach. No user-visible behaviour changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit a372879 into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the fix/version-comparison-home branch October 12, 2026 06:06
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