Skip to content

Remove dead runtime paths and correct comments whose reasons stopped being true - #989

Merged
max-sixty merged 4 commits into
mainfrom
nightly/runtime-leftovers
Sep 23, 2026
Merged

max-sixty merged 4 commits into
mainfrom
nightly/runtime-leftovers

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

This removes runtime code that nothing reaches any more and corrects comments that justify code with reasons that stopped being true. The one reader-visible change: the first-unread button's accessible name used to announce "1 unread messages" and now says "1 unread message".

Stale reasons. Both lf-chart.js and keyboard/scopes.js justified their shape with "every x-upgrade module loads on every page". Since importWidgets became import-on-demand, that is false: widget-loader.js imports only the declared tags that stand in the markup. The code in both places is still right, for a different reason:

  • Plot import: Plot still loads on the first draw, so a chart in a shut panel keeps the 384KB bundle waiting until measure releases the draw.
  • Scopes: keyboard scopes still register at upgrade, because a module outlives the elements it upgraded.

Both comments now say that. In the same vein, widget-elements.js pointed at keyboard/page.js for unaccountedGesture, which lives in composing/engagement.js. lf-tabs.js compared its tab memory to the scroll position, which storage.js's own header already names beside it — "the reading position, which panel of a widget stands open, whether design mode is on" — so the analogy was a second copy of what the store settles, not a fact the widget owns.

Dead code:

  • capture.js / selectionAnchor: computed section from datum?.dataset.lfProjection before returning anchorForDatum(datum), which sets section itself. section is now computed only on the path that reads it.
  • state-application.js: threads ?? [] and receipts ?? [] guard fields the served state always carries. The same function already reads threads.flatMap unguarded a few lines later.
  • engagement.js: replyBoxHasDraft(...) ?? null repeated a null the callee already returns.
  • read.js: no caller outside the module uses scan or scheduleScan, so they are no longer in createReadAcknowledgement's returned object.

widget-api.js: who imports the facade. The first push removed the pageScroller re-export after reading the runtime tree for importers and finding none. The importer is leaf/render-checks/layout.js, which loads the facade over HTTP from the served page, so no runtime-tree search reaches it; every render gate then failed to parse its probe module (does not provide an export named 'pageScroller') and test went red. The export is back, and the facade's header now states the rule once rather than annotating the one export that broke: seven modules under leaf/render-checks/ import seventeen names this way, and each is as invisible to a runtime/ search as pageScroller was.

Reference. None. This branch had added the Thread's unreadCount and the message's unread flag to packages.md; #987 landed first, dropped unreadCount from the Thread model in favour of an unread list of {message, version}, and documented both fields itself. Merging main took its text for those two sentences, so the reference is unchanged by this PR.

Checks. lint and test were green on 9a4d0815, before main was merged in. tests/test_smoke.py::test_a_shipped_page_passes_the_real_browser_gate fails on c4f5edf8 with the SyntaxError above and passes on 9a4d0815. npm run test:runtime passes at the current head (77 tests). The plural fix has no regression test: pinning one aria-label string would need a browser case whose only assertion is that string, which tests/CLAUDE.md would not keep.

…being true

lf-chart and keyboard scopes justified their shape by every x-upgrade module
loading on every page, which import-on-demand ended; the comments now give the
reasons that still hold. Drops selectionAnchor's unreachable datum section,
state-application's guards on always-served fields, a redundant ?? null,
read.js's unused scan/scheduleScan members and widget-api's unused pageScroller
re-export, and fixes "1 unread messages" in the first-unread button's name.
packages.md now lists the Thread's unreadCount and the message's unread flag.
…rts it

The removal read the runtime tree for importers and found none, because the
importer is leaf/render-checks/layout.js, which loads the facade over HTTP
from the served page. Every render gate then failed to parse its probe module:
"does not provide an export named 'pageScroller'".

tests/test_smoke.py::test_a_shipped_page_passes_the_real_browser_gate fails on
c4f5edf with that SyntaxError and passes with the export restored.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment added above export { pageScroller } settles at one export a fact that holds for the whole facade, so the next sweep pays the same cost. widget-api.js's own header calls it "The one helper surface behavior modules import" — that is the reading under which removing the re-export looked safe, and it leaves out the render gate's probes. Seven modules under skills/leaf/scripts/leaf/render-checks/ import seventeen names from /runtime/widget-api.js over HTTP from the served page: shallowSigs, READER_VIEW_RESTORE_CASES, uiInside, verbatimOwnerIdentity and the rest are each exactly as invisible to a runtime-tree search as pageScroller was. A sweep that reaches any one of them reproduces the red test and writes this comment one export lower. The statement belongs in the header, where it covers every export at once — skills/leaf/assets/CLAUDE.md opens with "Keep each rule with the modules it constrains: local contracts in module headers".

Separately, #987 rewrites the same two packages.md sentences this PR edits, and removes unreadCount from the Thread model in conversation/model.js in favour of a Thread-level unread list of {message, version}. They are not duplicates, but whichever lands second has to reconcile the contract line: after #987, the unreadCount this PR documents is no longer a field a package can read off readThreads().

@max-sixty
max-sixty merged commit 9237e9d into main Sep 23, 2026
4 checks passed
@max-sixty
max-sixty deleted the nightly/runtime-leftovers branch September 23, 2026 17:56
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