Skip to content

Say a file editor's failure and conflict in its header status - #2867

Merged
max-sixty merged 6 commits into
mainfrom
agent-a9bd7b1e4ff2dc2a4
Oct 14, 2026
Merged

max-sixty merged 6 commits into
mainfrom
agent-a9bd7b1e4ff2dc2a4

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

A file editor's save failure and its conflict with another writer now say so in the header's status slot, where "Saving changes…" already sits, instead of in a pane that opened below the editor. The editor's top and height measure the same at rest, on a failure and on a conflict. This is the design the maintainer chose for unit 57 of the Lit follow-up review, and it adds the UI principle behind it to skills/leaf/assets/AGENTS.md.

Unit 57: where lf-file-editor shows a failure and a conflict

Behaviour that changed

  • Failure. The status reads "Not saved · Retry". The error is the status's tooltip and Retry's description. Where no file could be read at all (an export, an unbound page), it reads "Unavailable", and the empty editor shows the reason as its CodeMirror placeholder.
  • Conflict. The status reads "Changed on disk ▾" in the warning tone (--warn-ink, --warn-tint under the pointer). That one control opens a native popover="auto" menu with Compare, Save draft (was "Save my version") and Use file version.
    • The arrow keys walk the menu (rowWalk + rove). Escape, or a choice, puts it away onto its control (closeLayer + handBack). Tab leaves the menu as it leaves a menu button's menu, and a press elsewhere dismisses it.
    • The page's keys wait while the reader stands in the menu.
  • Compare. Compare opens the comparison below the editor, on the reader's press only. A comparing custom state gives the comparison half of the host's grid, so it sizes against a definite row rather than the old min(50%, 20rem) cap on an auto row.
  • Failed Save draft. The control stays, reads "Not saved", and keeps its choices; Save draft is the retry.
  • Touch and pointer targets. Each status press spans the header's full height through the header's padding. The header doesn't grow, and the press doesn't reach into the editor.
  • Announcements. Each failure and conflict is announced once through the page's live region (announce). This replaces the widget's own alert and status regions.
  • Error sentences. boundFile turns every failure into a sentence, so "The draft is kept." follows a full stop. A request with no answer reads "The page's server did not answer."; a status-only answer reads "…answered HTTP 502."; an unreadable answer has its own sentence. requestJson now keeps the server's own words as said.
  • Caret. Landing the reader back in the editor reveals the caret.

Runtime additions this needed

  • Element command scopes take a claims option (keyboard/scopes.js).
  • The widget API exports allButCommandReference, documented in module-input.md, "How scopes compose". Before this, only Leaf's page-scope menus could hold the page's keys.
  • The CodeMirror bundle exports placeholder (+1 KB, rebuilt).

Line deltas

  • Hand-written source (excluding tests, vendored bundles and Markdown): +322 / −88, net +234. Most of it is lf-file-editor.js (+193/−63) and its shadow.css (+80/−15).
  • Tests: +138 / −62, net +76.

Tests

  • test_file_editor_saves_quietly_and_preserves_inflight_edits measures the editor's room through a failure and a conflict. It failed on main, where the pane cut the editor from 547px to 455px.
  • The same journey now drives:
    • the conflict through the menu, by pointer and keyboard (arrows, Escape, Tab, Enter on a row, c held);
    • Compare, sharing the room;
    • a failed Save draft keeping its choices;
    • a 502 HTML answer;
    • Retry turning into a conflict.
  • The sample test checks the unbound placeholder.
  • The file-editor grows-with-content known finding no longer occurs, so it is deleted.

Stability principle

The new bullet is "An unlikely event fits into what is already there." It sits beside "Generated interface first appears in its settled position", and says that bullet covers interface that ordinary use brings.

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

max-sixty and others added 6 commits October 14, 2026 10:22
A save failure and a conflict with another writer used to open a pane below
the editor holding the error, the choices and the comparison. It took the
editor's room as each problem arrived, a failure turning into a conflict
moved it again, and its `min(50%, 20rem)` cap resolved against an auto grid
row, so the pane clipped its own content.

Both now stand in the header's status slot, where "Saving changes…" already
sits, and the editor's top and height measure the same in every state. A
failure reads "Not saved · Retry", the error as the status's tooltip and
Retry's description. A conflict reads "Changed on disk" in the warning tone;
that one control opens a native popover menu (Compare, Save draft, Use file
version) that the keyboard walks with the arrows and leaves with Escape or
Tab, handing the reader back to the control. Compare opens the comparison
below the editor on the reader's press, and the host's grid gives it half
the editing room through a `comparing` custom state, so it sizes against a
definite row. "Save my version" is now "Save draft".

The status presses take no block aim floor, which would grow the header as
they arrive; each spans the header's full height through its padding.

Failures and conflicts are announced once each through the page's live
region (`announce`), replacing the widget's own alert and status regions.
`boundFile` gives a request that got no answer its own sentence in place of
the engine's ("Failed to fetch"), so "The draft is kept." follows a full
stop, and drops the draft clause it duplicated on a layer change.

Landing the reader back in the editor reveals the caret, since its room may
have shrunk under it while they stood in the menu.

Adds the stability rule this applies to `assets/AGENTS.md`: an unlikely
event fits into what is already there.

Tests: the in-flight save journey measures the editor's room through a
failure and a conflict (it failed on main, where the pane took 92px), drives
the conflict through the menu by pointer and keyboard, and opens Compare.
The file-editor `grows-with-content` known finding is fixed and removed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…keys in its menu

A Save draft that got no answer hid "Changed on disk" behind "Not saved ·
Retry", stranding Use file version and the open comparison's Compare toggle.
The conflict control now stays whenever a disk version waits, carrying the
failure as its description; Save draft is its retry.

Pressing a page key such as `c` inside the conflict menu reached the page
while the menu stayed open. Leaf's own menus claim every key but the command
reference through a page scope; an element scope had no way to say the same.
`commandsOn` and `commands` now take a `claims` option, and the widget API
exports `allButCommandReference` for it (module-input.md, "How scopes
compose").

A failure answered by a page without the server's words, such as a proxy's
502, read "file: HTTP 502" before "The draft is kept." `requestJson` keeps
the server's own words as `said`, and `boundFile` gives a status-only answer
its own sentence.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
With the pane gone, an editor that could read no file (an export, an
unbound page) said why only in the status's tooltip, which a finger and the
keyboard cannot reach. The empty editor now shows the reason as its
CodeMirror placeholder, in the room it already has. The CodeMirror bundle
exports `placeholder` for it (+1 KB).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
After a failed Save draft the header still read "Changed on disk", so a
pointer or touch user saw the menu close and nothing change. The control
now reads "Not saved" while the failure stands, opening the same choices;
the slot's one line has no room for both words. A server answer that does
not parse now reads as a failure sentence rather than "answered HTTP 200".

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 301f794 into main Oct 14, 2026
3 checks passed
@max-sixty
max-sixty deleted the agent-a9bd7b1e4ff2dc2a4 branch October 14, 2026 18:03
max-sixty added a commit that referenced this pull request Oct 14, 2026
…aim after updated

A failed draw replaced the render root's children with the fail-soft box, so a widget
that paints retained nodes, as lf-options paints its authored options, had nothing to
draw on afterwards: the next reading removed the box and left the options gone. The
box now stands at the head of the render root beside what the element drew, and the
next update that draws takes it away (`placesFailure` in widget-upgrade.js, which a
LeafElement registers). The same placement takes a rejected `present()` preparation
and a module's own `failSoft(this, …)`, which had replaced a shadow widget's whole
stage and detached its render root. A `setup()` that throws shows its failure and the
element draws nothing after it, so lf-file-editor-style builds need no catch of their
own.

An update's claim now moves at its gate and settles once Lit has run all of it,
`updated` included; a failure anywhere, `willUpdate` too, rejects it rather than the
coordinator recording a commit before work after the draw failed (leaf-agent's
finding). A draw nested in another's `updated` with no claim of its own fails the
enclosing one. The hold is one flag, since the controller's `defer()` refuses a
second, and the refresh is a private method rather than a symbol.

lf-file-editor.js takes prettier's indentation after the merge of #2867.

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