Skip to content

Hold a re-vendor's reload while the user is writing - #3098

Merged
max-sixty merged 4 commits into
mainfrom
quiet-page-updates
Oct 16, 2026
Merged

max-sixty merged 4 commits into
mainfrom
quiet-page-updates

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Since #2725 (2026-10-12), when an agent re-vendored a page, its open tab reloaded at once, even mid-keystroke, without the revision handoff that carries the reader's place and open editor across. The cause was the quarter-second freshness check: /api/news answered in the page's newer layer, which the stale tab refuses, and #2725 pointed the refusal's source probe at the page-root registry, which now says the source moved, so layer-client.js reloaded immediately. State, event and deferred answers already spoke the layer of the revision the tab names, so the version controller would otherwise have taken the newer layer as a revision with a changed executable: the fresh-document install that waits while the user composes and hands their place across.

Every authorized answer now defaults its Leaf-Layer to the layer of the revision the tab names (_named_layer in http.py), and the news check sends the layer headers that name it. A tab on the page's own layer skips the lookup. A revision this Leaf can no longer admit input against (incompatible_revision, a protocol bump) still answers in the page's layer, so that tab reloads at once rather than holding the user's send against a final refusal.

Behaviour change: a re-vendor now reloads an idle tab through the revision handoff, and a tab with an unsent comment or reply follows once it is sent or dropped; before, both reloaded on the next news answer. Revisions that change only prose, markup or styles were and remain applied in place.

Tests: test_a_tab_on_a_re_vendored_page_hears_news_in_its_own_layer and test_a_tab_on_a_revision_past_a_protocol_bump_hears_the_newer_layer (process), and test_a_re_vendor_waits_for_the_reply_being_written (browser, which replaces the server as a real re-vendor does); each fails on its own without the change.

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

max-sixty and others added 4 commits October 16, 2026 01:24
Since #2725 (2026-10-12) a tab whose page was re-vendored under it reloaded
at once, mid-keystroke, and without the revision handoff that carries the
user's place and open editor. The cause was the freshness token: /api/news
answered in the page's newer layer, which the stale tab refuses; #2725
pointed the refusal's source probe at the page-root registry, which now
says the source moved, so layer-client.js reloaded immediately. State, event
and deferred answers already spoke the layer of the revision the tab names,
so the version controller would otherwise have taken the newer layer as a
revision with a changed executable: a fresh-document install that waits
while the user composes and hands their place across.

Every authorized answer now defaults to the layer of the revision the tab
names (`_named_layer`), and the news look sends the layer headers that name
it. A tab on the page's own layer skips the lookup. Behaviour change: a
re-vendor reloads an idle tab through the revision handoff, and a tab with
an unsent comment or reply follows only once it is sent or dropped; before,
both reloaded on the next news answer.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A revision saved at another protocol admits no input (`incompatible_revision`),
so holding a composing tab on it would strand the user's send against a
final refusal. `_named_layer` answers such a tab in the page's layer, which
it refuses and reloads at once, as before. Also corrects version.js's note
on how a re-vendored layer reaches `prepareActivation`.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	tests/browser/test_render_drafts.py
@max-sixty
max-sixty merged commit ce11fdc into main Oct 16, 2026
3 checks passed
@max-sixty
max-sixty deleted the quiet-page-updates branch October 16, 2026 20:23
max-sixty added a commit that referenced this pull request Oct 16, 2026
The page server worked out in five places which layer an answer speaks
for the revision a tab reads: the default every authorized answer takes
(`_named_layer`), the write gate (`_layer_gate`), and the `/api/state`,
`/api/deferred` and `/api/view` routes. They agreed for ordinary tabs
and disagreed in rare cases: a tab naming no revision after a re-vendor
whose source failed to save, and a write from a tab on a revision past a
protocol bump. This follows #3098, which made every answer default to
the layer of the revision the tab names.

In `skills/leaf/scripts/leaf/http.py`, `named_revision` now says which
revision the tab reads: the one it names in the query or
`Leaf-View-Revision`, or the active one. `_revision_layer` says which
layer a tab reading that revision speaks: the revision's own, or the
page's where this Leaf refuses the revision or there is none. The
default, the gate and the state route call them; the deferred and view
routes take the default. `requested_view_revision` loses its header-only
mode, which only POSTs used, and they send the same header either way.

The default no longer skips the lookup for a tab on the page's own
layer. The lookup costs about 22 µs, measured against 0.5–1 ms for the
`/api/news` answer it most often rides on.

Behaviour changes:

- A write from a tab on a revision past a protocol bump is answered with
the page's layer, so the tab reloads at once, as its news already made
it do, instead of reaching the event door's final refusal.
- A tab naming no revision speaks the active revision's layer on every
route. Before, reads answered in the page's vendored layer and writes in
the active revision's.
- A state answer naming no revision speaks the layer of the revision its
read left active. Reading state activates the page's source, so that
revision may be newer than the one resolved before the read.

Tests:
`test_a_tab_on_a_revision_past_a_protocol_bump_hears_the_newer_layer`
now also sends a write, and
`test_a_state_answer_speaks_the_layer_of_the_revision_it_read` is new.
Each fails without its part of the change.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent added a commit that referenced this pull request Nov 1, 2026
The re-vendor reload test treated the log's final record as the sent
reply. It now identifies the original thread and requires exactly one
user reply containing the draft's exact words, preserving the existing
checks for unsent words, focus, deferred reload and the eventual fresh
document. This corrects the test introduced in #3098 without changing
product behavior.

An admitted `seen` record appended after delivery makes the old
assertion deterministically fail with `KeyError: 'text'`; the corrected
test passes with the same ordering. The historical failure's log does
not identify its final record's kind, so this reproduction establishes
the unsafe ordering assumption rather than claiming that historical
record was `seen`. The focused browser test, Ruff check, Ruff format
check and diff whitespace check pass.

Closes #4955 — automated triage

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