Skip to content

Stop reloading an open page when two Leaf versions read its source - #5798

Merged
max-sixty merged 3 commits into
mainfrom
fewer-page-reloads
Nov 10, 2026
Merged

max-sixty merged 3 commits into
mainfrom
fewer-page-reloads

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

An open page now keeps its document when the page server and the agent's leaf commands run different Leaf versions. Before, each version took the other's capture of the same index.html for a change, published it again as a new revision, and the tab reloaded at every one.

What was happening

A page server keeps the Leaf it started with, while the agent's commands run the session's current Leaf: a plugin update since the server started, or a worktree's bin/leaf. Since #4551 each Leaf composes the page's vocabulary from its own bundled packages, so two versions compose different vocabularies whenever any bundled registry changed between them, which most commits do.

A revision's executable digest decides whether an open tab patches in place or loads a fresh document, and it included a digest of that composed vocabulary. The revision's identity (its manifest digest) includes executable. So on every state read the server captured the source as revision N with its vocabulary, the agent's next leaf thread reply captured the identical source as N+1 with its own, the server's next read captured N+2, and so on. Every revision had a different executable from the last, and each one reloaded the tab.

Evidence from the pages on this machine, read from each page's observations.jsonl and revision manifests:

  • On the 68 pages where a Firefox tab was replaced since October, 678 of the 805 executable changes between consecutive revisions from 2026-10-28 on, the day Compose each page's layer from the Leaf reading it, so only the log and records bump the protocol #4551 landed, had identical scripts, page modules and layer generation; 417 revision pairs differed in nothing but executable. Before that day there were none.
  • In the week of Nov 2-8, 56 of the 79 same-tab reloads in Firefox were this. One page's executable alternated between two values for an hour, with revisions minted in pairs a second apart, server then CLI.
  • Reproduced with two copies of the tree, one with a bundled registry description reworded, alternating leaf page state on one page: 6 reads made 6 revisions with alternating executables on main, and 1 revision with this change.

The change

The executable digest now covers only what the page owns: the layer generation, the annotation mode, the page's own declarations (page/registry.json), its modules and its script elements. What an open document runs under comes from the serving Leaf, and each part already reaches the tab by another route: a runtime or bundled-package change as a server that refuses the tab (runtime_selection), and a new selection or changed package copy as a new generation (vendoring).

The manifest also drops public_modules, the capturing Leaf's list of public runtime modules, which nothing read and which minted duplicate revisions the same way whenever that list changed between versions.

Behavior change in tests: test_two_leaf_versions_capture_one_source_as_the_same_revision holds that two vocabularies capture the same revision and that a change to the page's declarations still loads a fresh document; test_authored_lazy_positioning_import_uses_the_runtimes_public_provider no longer asserts the dropped public_modules field.

What's left

  • A package installed by name (leaf package install) and updated while a server runs changes what the next revision runs under without changing the generation or the runtime identity, so the tab now patches in place and keeps the old widget code until it reloads. The vocabulary digest caught this only when the update changed the package's registry; an update to its modules alone already escaped it. No page on this machine selects an installed package. The fix is to judge the reload against what the server serves the revision with, the execution identity runtime_selection.executing already computes for resource addresses, or to have an install move the generation of the pages that select it.
  • The manifest's declarations and implementations still list the capturing Leaf's layer-owned tags, so two versions that differ in which bundled widgets exist still mint a duplicate revision, which patches in place rather than reloading. Making them page-owned changes what an older Leaf at the same protocol reads, so it belongs with the next protocol bump.
  • The other reloads observed were a server restarted under a newer Leaf: the tab's runtime code no longer matches the server's, so it has to load a fresh document.

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

max-sixty and others added 2 commits November 10, 2026 10:35
An open page reloaded each time the page server and the agent's `leaf`
commands, running different Leaf versions, looked at the same source. Since
#4551 each Leaf composes the page's vocabulary from its own bundled packages,
and the revision's executable digest included that vocabulary, so each
version took the other's capture for a change, published it again, and every
new executable reloaded the tab. In the week of Nov 2-8 that was 56 of the 79
same-tab reloads in Firefox on this machine's pages.

The executable now digests only what the page owns: the generation, the
annotation mode, the page's own declarations, its modules and its script
elements. Runtime and bundled-package changes already reach an open tab as a
server that refuses it, and selection or package-copy changes as a new
generation. The manifest also drops `public_modules`, which nothing read and
which differed between Leaf versions the same way.

Behavior changed: two vocabularies over one source now capture the same
revision (test_two_leaf_versions_capture_one_source_as_the_same_revision);
the manifest no longer lists public modules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
leaf-agent previously approved these changes Nov 10, 2026
@max-sixty
max-sixty merged commit e74d07d into main Nov 10, 2026
5 checks passed
@max-sixty
max-sixty deleted the fewer-page-reloads branch November 10, 2026 19:17
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