Repository navigation
Read comparison counts from the canonical version reading - #2376
Merged
Merged
Conversation
leaf-agent
approved these changes
Oct 11, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 12, 2026
…directly (#2496) 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_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.
Tabs and settled answers now count canonical version-comparison changes instead of counting CSS marker classes. A connection-bound watch refreshes on reconnection and stops listening while detached.
Survey item 16. I extended the existing comparisonChanges(owner = null) API instead of adding changesWithin: descendant selection belongs in the canonical reading. Comparison deduplication also uses its own Set rather than reading a marker class. Annotations now import this same reading directly, removing its forwarding chain through the controller, bootstrap, and application. Measured JavaScript across the seven changed modules: 5,548 → 5,571 (+23). The connection watch uses the shared whileConnected primitive; reference documentation adds 12 lines. The existing reconnect regression now exercises real revisions, both consumers, detached updates, and marker-independent counts.
Validation: three focused browser checks passed, covering annotation navigation, state-only revisions, and the comparison regression with real revisions, both consumers, stray CSS markers, detached updates, and reconnection. Source review, lint, and 323 runtime tests passed; CI runs the complete landing gates.