Skip to content

Keep a hosted page's whole directory, and answer a file save once the store holds it - #7314

Merged
max-sixty merged 1 commit into
mainfrom
agent-a04e19c8613b01dff
Nov 26, 2026
Merged

max-sixty merged 1 commit into
mainfrom
agent-a04e19c8613b01dff

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

On leaf.page, a reader's save in the file editor was answered as saved and lost when the container slept, as Codex found reviewing #7306. The page's record held only the files Leaf writes, so a file the page binds from its own directory (files/) was never in it, and the save ran outside a page transaction, so nothing published it before the receipt.

The record is now the whole page directory, less the serving process's files, the drafts store, staged writes and symlinks, and restore replaces the release's page directory with it. The file routes commit a page transaction before answering when a commit provider is set. A save that fails after its write, as when the store refuses the commit, now reads to the editor as a save that may have reached the file, and Retry settles it by reading before it sends again.

Reproducer: test_a_save_to_a_file_the_page_binds_is_answered_once_the_page_store_holds_it in tests/process/website_server/test_saved_records.py.

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

… store holds it

On leaf.page, a reader's save in the file editor was answered as saved
and then lost when the container slept: restoring the session's record
over a fresh release brought back the published text. There were two
causes. The record held only the files Leaf itself writes
(`PAGE_OWNED_FILES` and `PAGE_OWNED_DIRS`), so a file the page binds
from its own directory, such as the example's `files/`, was never in it.
And a save runs outside a page transaction, so the host's commit
provider did not publish before the receipt went out.

The record is now the whole page directory, less the serving process's
files, the drafts store, staged writes, symlinks and records of another
shape. Restore replaces the release's page directory with it rather than
replacing the owned trees one by one. So a saved file is kept whatever
the page grants, and an unbind no longer drops it. A file the session
deleted stays deleted, and restore no longer writes through a file the
site build hard-linked to another page's. Files the hosted agent writes
in its working directory, which is the page directory, now survive a
sleep as they do on the user's machine. Such a file reaches the record
with the next commit whose page reading moved.

Where a commit provider is set, the file routes commit a page
transaction before answering a read, a save receipt or a stale-save 409,
so the host holds the text each names, or a later write to the file.

A save can now fail after its write, when the store refuses the commit.
The browser's file API treats a 5xx as no answer, since the save may
have reached the file; it took a JSON 500 as a refusal that wrote
nothing. And the editor's Retry reads the file first while an earlier
save's answer is lost, rather than sending again: a second send forgot
the first one's words, so a line the reader had typed away came back
from disk as a write from elsewhere.

Considered: adding the page's bound files to the owned list, taken from
`files.json`. Codex's review showed an unbind or a rebind then dropped a
file the reader had saved, and a deleted bound file came back on
restore.

Tests: a save through the website server survives a restart from the
release; so does a save followed by an unbind; a save whose commit the
store refuses fails, and its retry's 409 comes only once the store holds
the words; a JSON 500 rejects a file save (runtime); and a Retry while
saves keep losing their answers leaves the file holding the reader's
last text (browser).

> _This was written by Claude Code on behalf of max-sixty_
@max-sixty
max-sixty merged commit 72ccedf into main Nov 26, 2026
6 checks passed
@max-sixty
max-sixty deleted the agent-a04e19c8613b01dff branch November 26, 2026 22:12
leaf-agent added a commit that referenced this pull request Nov 27, 2026
…journey (#7416)

`test_file_editor_saves_quietly_and_preserves_inflight_edits` has failed
since #7314, which made Retry after a save with no answer read the file
before sending again, because that save may have reached the file. The
journey's last section still held the POST it expected Retry to send.
Retry now reads first, the read clears the failure, and the save that
follows runs with no Retry button, so `expect(retry).to_be_focused()`
found no element.

The section now holds Retry's read instead, moves the file on disk, and
releases the read. The read finds the conflict, Retry disappears, and
typing returns to the editor. That is the behavior the section protects
("When a focused Retry becomes a conflict, the disappearing button
returns typing to the retained editor"), now reached through #7314's
read-first path. The change touches only the test and moves no product
behavior, so it keeps all of #7314's intent.

Verification: on `main` the test fails at line 343 with `element(s) not
found`, the error in the issue. With this change it passes in two runs,
run by node id on Linux.

Closes #7407 — 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