Skip to content

Add a quiet autosaving file editor - #2202

Merged
max-sixty merged 4 commits into
mainfrom
codex/quiet-file-editor
Oct 10, 2026
Merged

max-sixty merged 4 commits into
mainfrom
codex/quiet-file-editor

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Promote the quiet file-editor prototype into an optional file-editor package. <lf-file> edits one UTF-8 file explicitly granted with leaf file bind PAGE ID PATH, using CodeMirror for editing and conflict comparison.

Ordinary autosaves show no changing label or controls. Writes pending for a second show muted “Saving changes…”. Failed saves retain the draft; external conflicts show a separate read-only comparison and explicit recovery actions without changing the editable buffer. The compared version stays fixed until the reader chooses; saving checks that revision again. Keyboard focus, undo history, queued edits, and tab-local draft recovery survive the save loop.

The host checks file revisions before atomic replacement, preserves LF/CRLF and permission bits, and serializes Leaf writers across pages. An unrelated writer that ignores Leaf's lock can still race the final comparison and replacement. Captured views cannot edit live files, and binding paths remain private.

The package includes author instructions, an inspectable developer example, and catalog routing. Shared CodeMirror exports add about 43 KB to the startup core (about 1% in the served comparison); merge and autocomplete remain in the optional package. Empty height-capability markers now leave a widget's own height intact, fixing its first paint at the shared reservation rule.

Validation: real-browser typing, silent fast saves, held and queued writes, failed-save recovery, clean external updates, stale conflicts, keyboard comparison scrolling, long-file caret visibility through recovery, Retry-to-conflict focus recovery and focus preservation; six backend integration tests, including special permission bits; six widget first-paint checks; 288 runtime tests; 85 browser-build tests; package check and all pre-commit hooks. Independent source and live UI review passed, including a dark 390-pixel viewport.

This was written by Codex on behalf of max-sixty

Bind existing local UTF-8 files explicitly and edit them through CodeMirror with revision-checked autosave, draft recovery, and separate conflict comparison. Keep ordinary saves silent and expose only delayed writes or recovery needs. CLI help now includes file binding; boolean height capability markers preserve each widget’s own initial frame.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The save path does not preserve all file mode bits. save_file calls replace_bytes(..., True), whose fchmod mask keeps only 0o777. I reproduced a save changing a file from mode 0o2755 to 0o755. That contradicts the PR and storage contract's permission-preservation claim. The shared replacement boundary needs to preserve the intended mode, or the editor needs to refuse files whose permissions it cannot preserve.

The new browser journey is red after conflict recovery. With the pinned npm dependencies installed, I ran uv run pytest tests/test_render_files.py -q twice; both runs reached the final consume_browser_errors(page, "409 ") assertion with an additional movement diagnostic for text in div.cm-gutterElement.cm-activeLineGutter in the lf-file shadow root. The test establishes the conflict path's visible result, but its movement check remains unsatisfied. The gutter movement needs to be fixed or shown to be an intentional, permitted change and accounted for in the test before this can be approved.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The expanded recovery journey is intermittently red at the first “Save my version” receipt after Retry becomes a conflict. In three clean runs of uv run pytest tests/test_render_files.py::test_file_editor_saves_quietly_and_preserves_inflight_edits -q -n0, the first timed out for 30 seconds waiting for the expected 200 response at with receipt(failed_draft); the next two passed. The preceding visibility and 100 ms clock step do not establish that the editor still contains the expected draft when the save is requested. This needs a deterministic reading of the draft and request at that transition, then a fix to whichever focus or request ordering drops the save, before the recovery path is reliably covered.

@max-sixty
max-sixty merged commit 8939e51 into main Oct 10, 2026
6 checks passed
@max-sixty
max-sixty deleted the codex/quiet-file-editor branch October 10, 2026 05:48
leaf-agent pushed a commit that referenced this pull request Oct 11, 2026
A page whose file editor names a binding it lacks is a designed state:
the file-editor author instructions say a copied page "explains that it
is unavailable", and the developer worked example
(`examples/developer/file-editor.html`) ships unbound. The server
answered its read with 400, so Chrome logged "Failed to load resource"
on every live page holding one. That broke
`test_a_composed_page_does_not_offer_history_it_does_not_have` from
#2202 on, since the corpus composes the unbound example and the suite
rejects every console error.

`GET /api/files/<id>` now answers an unbound id with 200 and `null`, as
`/favicon.ico` answers 204 to keep the console clean. The browser
transport (`runtime/file-api.js`) turns that null into the same "No file
is bound as '<id>'." failure the editor already showed, so the reader
sees no change. A save against an unbound id still refuses with 400, and
a malformed bindings entry now says so rather than reading as unbound.

Tests: the HTTP door test asserts the null read and the refused save;
the sample editor test asserts the explanation's text instead of
consuming the 400 it no longer produces.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[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