Repository navigation
Hold a re-vendor's reload while the user is writing - #3098
Merged
Merged
Conversation
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
leaf-agent
approved these changes
Oct 16, 2026
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]>
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.
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/newsanswered 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, solayer-client.jsreloaded 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-Layerto the layer of the revision the tab names (_named_layerinhttp.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_layerandtest_a_tab_on_a_revision_past_a_protocol_bump_hears_the_newer_layer(process), andtest_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.