Skip to content

Remove the file editor and the file bindings that existed for it - #5974

Closed
max-sixty wants to merge 5 commits into
mainfrom
agent-acf12ba976dda4778
Closed

max-sixty wants to merge 5 commits into
mainfrom
agent-acf12ba976dda4778

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Removes the file-editor package and the file-binding feature that existed only for it: file_bindings.py, leaf file bind and unbind, the /api/files/<binding> routes, the bound-file stamps in the page's reading and served state, file-api.js and its boundFile export, and the CodeMirror extensions only the editor loaded. A month of real use never reached it: lf-file-editor is on 0 of 400 page directories, none of the 74 pages with a layer record selected the package, and leaf file bind has no run among about 10,300 logged leaf commands (uv run leaf-dev usage, #5970). It is the one unused package woven into the server, so every change to the served state, the page reading or the HTTP routes carried it.

63 files, +196 −3,414: product code −1,535 net, tests −1,161, vendored bundles and the lock −257 (codemirror.esm.js drops from 341 KB to 260 KB, and the editor's 52 KB of extensions go).

What goes: a user editing a bound local text file on the page, with its save, conflict and reload handling; an agent granting that with leaf file bind; and a package module reading, saving or watching a host file. /vendor/codemirror.esm.js now exports only the 20 names the comment composer imports, so a package building its own editor on it finds no line numbers, highlighting, default keymap, merge view or autocomplete. The composer keeps editor-view.js, and files.py and file_changes.py keep serving page files and subscriptions. The served state loses its files key; AGENTS.md, "Pages across Leaf updates", bumps the protocol only for the log and for records kept outside a page, so this bumps nothing. A page directory that still holds a files.json is read as if it had none.

To weigh: this takes a feature away on the evidence of one person's month, so it is your call. Three packages with no server footprint go in a separate pull request, and the candidates not built are on the run's page.

A Codex review of the removal found nothing to change. Five of the deleted editor tests also reached code that stays, and the last commit accounts for each, checked by breaking the behavior and watching the named test fail: a caret key in a sample's comment box leaving the page around it still (new test), and the print rule hiding controls in a shadow tree (added to the diff's print test); the caret through a native move and CodeMirror's base styles yielding were already held by composer tests; and PageDown alignment the composer cannot reach. That leaves about 90 lines of editor-view.js (travel, and the scroll write in placeWithinEditor) reachable only by an editor a package builds through the exported leafEditorView, which I left for the package-interface work along with four other exports that lost their last importer (RequestError, rove, commandsOn, allButCommandReference). The inline press's warn tone lost its only bundled user too and stays, as a documented variant.

Requested as part of the "crust and big simplifications" run. Checks: pre-commit run -a; pnpm run check (27 build, 963 runtime and 91 Worker tests, and the protocol comparison accepted dropping the file-bindings record without a bump); 2,736 model, process and composer tests by node id, with two failures in dev/tests, which no gate runs, that fail the same way on a clean export of main. CI's test job passes; on the first push test_a_prompt_says_why_a_page_did_not_start_and_tries_again[port held], which this change doesn't reach, failed once, and it passes three times out of three on this branch locally.

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

Nobody reached this feature in the month to 2026-11-14. `<lf-file-editor>`
appears on 0 of the 349 real pages. Of the 72 pages with a current layer
record, none selected the `file-editor` package. `leaf file bind` is absent
from the 35 distinct `leaf` commands in about 10,300 logged runs. In the tree
its only page was the developer gallery `examples/developer/file-editor.html`.

Removed:

- The `file-editor` package: `lf-file-editor`, its CodeMirror adapter, styles
  and author instructions, and its vendored merge and autocomplete bundle
  (`extensions.esm.js`, 52 KB), with the gallery page, the
  `file-editor-save-context` eval, and the package's rows in the docs and the
  references.
- The server feature: `file_bindings.py`, `leaf file bind` and `leaf file
  unbind`, `GET` and `POST /api/files/<binding>`, the `file-bindings` record
  (`files.json` in a page directory), and the served state's `files` field
  with the `FileSnapshot` and `StaleFile` answers. The files a page's reading
  stamps outside its directory are now only its claim and its claimant
  session's files.
- The browser side: `boundFile()` (`runtime/file-api.js`) and its export from
  `widget-api.js`, and `RequestError`'s `current` and `said`, which only that
  module read. `RequestError` stays exported, so its sentence in
  `module-state.md` moves to "Authenticated HTTP connections".
- From the CodeMirror bundle, every export that only the editor's adapter or
  its extension bundle imported, the Markdown language among them. The bundle
  goes from 341 KB to 260 KB. `@codemirror/autocomplete`,
  `@codemirror/lang-markdown`, `@codemirror/merge` and `@lezer/markdown` leave
  the dependencies; `@codemirror/language` and `@lezer/highlight` leave
  `package.json` and stay in the lock as dependencies of `@codemirror/commands`.
- Code that served only the editor: `canonical_path`'s `strict` option, the
  inline press's warning tone (`data-lf-tone="warn"`, which the editor's
  conflict control wore), the lint exception for `EditorView.scrollIntoView`,
  and the write watch's allowances for CodeMirror's gutter and for line
  writes in a host other than `leaf-text`.

A user can no longer edit a text file on the serving machine from a page, and
an agent can no longer grant a page that access. A package module can no
longer read, save or watch a host file, or give an inline press the warning's
ink with `data-lf-tone="warn"`. A package that builds its own CodeMirror
editor from `/vendor/codemirror.esm.js` now finds only the names the composer
uses: no line numbers, syntax highlighting, default keymap, placeholder,
merge view or autocomplete.

`runtime/editor-view.js` keeps the code that scrolls an editor's own lines to
the alignment CodeMirror asks for (`placeWithinEditor`), though no editor in
the tree scrolls inside itself now: the composer's host is its scrollport.
That code serves an editor a package builds with the exported
`leafEditorView`, and the file editor's PageDown test was its only test.

Tests: the file editor's own tests go with it. Two of them reached behavior
the composer shares, and a search of the suite found no composer test of the
same: the caret surviving a native move while the user types, and a classic
scrollbar not triggering CodeMirror's cross-frame reveal in a sample. The two
watch tests no longer assert that a write to a bound file, or a rename above
it, moves the page's reading; the journey test's check that an input outside
the page was stamped now names the claim.
The file editor's removal took `data-lf-tone="warn"` on an inline press with
it, because the editor's conflict control was the only bundled press that set
it. The tone is part of the press roles a package author builds with
(`module-authoring.md`, "inline"), and a simplification is judged by the
package compositions it rules out, not by use in bundled widgets alone (root
`AGENTS.md`, "Leaf's role"). This restores the rule in `controls.css` and its
clauses in `control-faces.js` and `module-authoring.md`. The stylesheet's
comment no longer names the file editor's conflict as its example.
Five of the file editor's browser tests reached code the removal leaves in
place. Each is accounted for here, with a check that the test named fails
when the behavior is broken.

Added:

- A caret key in a live sample's comment box leaves the page around the
  sample still (`test_live_samples.py`). The editor's reveal goes through
  Leaf's scroll, which stops at the box's document; CodeMirror's own ends in a
  native `scrollIntoView` where a classic horizontal scrollbar shortens the
  visual viewport, and that scrolls the containing page. With the reveal
  handler in `editor-view.js` returning false, the page jumps 586px and the
  test fails. The editor's version of this resized the editor; a comment box's
  resize never reaches CodeMirror's reveal (`text-field.js`, `#sizes`), so
  the key is the route that does.
- The diff's print test now also asserts that a file's comment press, in the
  diff's shadow tree, shows on screen and leaves paper
  (`test_print_wraps_diff_lines_and_keeps_file_headers_in_place`). With the
  offer rule in `state.css` disabled, it fails.

Already held, so nothing is added:

- The caret surviving a native move while the user types:
  `test_a_comment_being_written_on_a_diff_line_stays_in_hand_across_a_new_patch`
  types into the comment box after the move and fails when
  `connectedMoveCallback` no longer restores the selection. The removal's
  commit message said no composer test covered this; that was wrong.
- CodeMirror's base styles yielding to the styles around it:
  `test_a_draft_wears_the_faces_its_sent_message_wears` fails, with a draft's
  words in monospace, when the bundle's rules leave the `lf-base` layer. No
  package or theme rule restyles a CodeMirror editor; the only rules that do
  are the text field's own shadow sheet.

Not ported: PageDown keeping the caret's offset in the editor's scrollport.
The comment box cannot reach it. Its `.cm-scroller` is as tall as its words in
every state (`overflow: visible`; the host scrolls), so CodeMirror asks for
that alignment nowhere in it, and `placeWithinEditor` writes no scroll: in a
121-line reply, three PageDowns, two PageUps and an edit made no scroll write
to the scroller. `travel` and the write in `placeWithinEditor` move something
only in an editor a package builds through the exported `leafEditorView`.
@max-sixty

Copy link
Copy Markdown
Owner Author

Closing: the maintainer chose to keep the file editor and its file bindings. The branch stays for reference, and the measured size in the description (63 files, net −3,218 lines) stands as what the removal would cost and save.

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

@max-sixty max-sixty closed this Nov 15, 2026
max-sixty added a commit that referenced this pull request Nov 22, 2026
Adds `leaf-dev logs usage`, which reads the page directories under the
state home and prints what they used: the pages holding each registered
widget, the packages their layer records select, each command a person
ran with its sessions and pages, and each `leaf` command with the runs
agents made against a page. "Regular maintenance" in the root
`AGENTS.md` asks who would notice a mechanism gone; until now the only
evidence was whether an example or a test named it, and the record of
real use in every page directory went unread. It sits in the `logs`
group with the other commands that read real pages' logs, and reads
`--since` as they do, refusing a time without its offset.

`/developing-leaf`'s `references/removals.md`, which a session opens
before proposing a removal, names the command and says what its count is
evidence for: a feature nothing here used is a candidate to test, and
the count alone decides no removal. The root `AGENTS.md` is unchanged.

On 2026-11-21 it read 462 page directories and 506 sessions. No page
held `lf-file-editor`, `lf-file-tree`, `lf-deck`, `lf-visual-review`,
`lf-dial` or `lf-call-diff`.

To weigh: it counts one machine's use. Max kept the three features whose
removal first cited it (#5972, #5974, #5976, all closed), on the ground
that his own use is not specific enough, and the examples built since
for three of those widgets are the test he asked for instead. Two
shortcuts are deliberate: a session counts as a person unless its
browser calls itself headless, and command ids minted per element
(`option.choose-<id>`) fold into one row where ten or more share a stem.
It has no tests, and `dev/tests` now runs daily, so a later change to
the logs' shape would break it unnoticed.

Requested as part of the "crust and big simplifications" run. Checked
with `pre-commit` on the changed files and by running it against the
state home, with and without a valid `--since`.

> _This was written by Claude Code on behalf of max-sixty_
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.

1 participant