Repository navigation
Add a deploy-config example whose file editor holds several files a tree opens, and keep a reveal inside a workspace from moving the page - #6019
Conversation
An lf-file-editor now takes several bindings (`binding="values alerts runbook"`), one open at a time, and publishes them as a `files` output, so an `<lf-file-tree for="editor">` lists them and opens the one the reader picks, by mouse, Enter or a link to `#<editor>:<binding>`. Leaving a file saves it at once, and each file keeps its text, selection, undo history and scroll while another is open. Each bound file now has a label the browser shows: its path below the deepest folder holding every file the page binds, so several files read as a tree and one file still reads as its name. The served state's `files` carries it beside the stamp, and `boundFile(binding).label` reads it. A file inside the page's own directory is granted by its path from there, so a copied page, or a published page restored in its visitor's container, edits its own copy. Since an older Leaf would read such a path from its working directory, `files.json` moves to format 44; a grant written before reads as absent, so bind the file again. An outside write, such as the agent's, to lines apart from the reader's unsaved edit now joins the draft instead of raising "Changed on disk"; a write to the same or adjacent lines still keeps both versions for the reader to choose, as a line merge would. Both widgets fill a workspace pane without a second frame inside it, and the editor's last line scrolls clear of Leaf's panel there; a page no longer needs its own CSS to place either in a pane.
"Finish a worker's production config" (examples/deploy-config.html) puts a service's six deploy files in a file tree beside the editor and the agent's notes on the four values only the reader can set. Each file saves to disk as the reader types, and a write from the agent while the page is open shows in the editor. An example now carries the files its editors edit: `<stem>.files/` holds them as their project lays them out, and `<stem>.files.json` names each one's binding. `prepare_page` copies them into the page directory's `files/` and binds them there, so a preview, the corpus, a test and each leaf.page visitor's container edit their own copy. The developer file-editor page carries its notes file the same way, so on leaf.page it shows the file rather than "Unavailable".
The Specialized examples group gains "Finish a production config", the receipts-worker page where a file tree and the file editor work on a service's deploy files. The card needs its preview image, which `wt refresh-previews` publishes to max-sixty/leaf-assets and pins in leaf-assets.json. Until that runs, composing docs/examples.html finds no example-deploy-config.jpg, so the site build and the catalog card tests in dev/tests/model/test_product_page.py fail.
…r holds The file editor rebuilt its whole file list for the navigator on every draw, and typing draws on each key, so a keystroke's work grew with the files the editor holds. It now builds that list only when a file's name or the open file changes. A file two bindings name is listed once, since a navigator keys its rows by path. Where only the filesystem's root holds a page's files, each label is the fewest trailing parts of its path that no other file shares. That was found by comparing every file with every other on each state answer, read and save; it now counts each run of trailing parts once, so it grows with the files rather than their pairs. Bindings of one file share its label there too.
# Conflicts: # browser/types/contract.d.ts
Max ran the catalog's preview capture for this branch, which published example-deploy-config.jpg to leaf-assets and moved the pin and the README's image URLs. The site's catalog now composes on this branch.
Picking a file in the deploy-config example's tree scrolled the page down about 50 px, hiding most of its heading, in any browser where something after `main` gave the document room to scroll. Every region of a held workspace reaches the window's foot and keeps room there for the floating panel, so a landing that measured the region whole found it taller than the band above the panel, and a start landing put its opening at the band's top. The editor filling its pane was one such region; a link to a pane is another. A landing now measures a region that keeps that room (`--lf-end-room`) without the window's foot band, since the region lays its content out to clear it. The tree's pick and a link to `#editor:file` or to a pane leave the page where it stands. A plain fragment link to an element, such as `#ar-queue`, still lands its start at the band's top, as the browser's own fragment rule does.
The file editor highlighted only Markdown, so the deploy-config example's YAML read as plain text. It now chooses each file's language from its name, as code blocks do (`langForPath`), and highlights YAML with CodeMirror's own language support, in the theme's code colours: keys in `--syn-type`, values and quoted strings in `--syn-string`, comments in italic `--syn-comment`, as a code block or a diff colours the same file. Each language beyond Markdown is a module of the file-editor package, loaded the first time a file of it opens: YAML's is 39.6 KB and loads only then. Its parser binds to the editor core's Lezer, which now exports the names a language module imports (7.6 KB more in the core, which the runtime loads only for an editor or a composer); a second Lezer would read none of the core's node props. Another language is one entry and one dependency.
Conflicts: browser/types/contract.d.ts, regenerated; leaf-assets.json, keeping this branch's later revision in main's one-pin shape; the file editor's highlight style and imports, where main prefixed the theme's tokens and moved render to lit.js. main's protocol is 45, so the file grants' format moves to 45 too.
A file the agent edited while the reader had it open changed in place with no sign of where. Now each line a write from elsewhere changed, whether the editor followed it or merged it into an unsaved draft, wears a bar and tint in the accent until the next such write or until the reader edits that line. A file the reader has left for another keeps its marks for when they return to it; a file's first reading marks nothing.
leaf-agent
left a comment
There was a problem hiding this comment.
Two places where the description no longer matches the diff. Merging squashes with the description as main's commit message, so both need fixing before this is ready:
- It says "
files.jsonmoves to format 44". Since the latest merge frommain, the protocol is 45 andBINDINGSinsrc/leaf/file_bindings.pysayssince=45(the protocol baseline agrees). The number in the description should be 45. - The
browser/runtime/landing-scroll.jschange isn't mentioned.destinationBoxnow subtracts the window's foot band from any region whose--lf-end-roomis above zero, so it changes how a link or reveal lands on any held workspace's region, not only the file editor's. That runtime change belongs in "What changes for a user and an author", withtest_a_link_to_a_held_workspaces_region_leaves_the_page_where_it_standsas its evidence, so a reader weighing the PR sees that it reaches beyond the two packages.
An agent coming to a page later, such as leaf.page's hosted agent answering a comment on the deploy-config example, had no way to learn which files the page's editors edit short of reading files.json. `leaf page state` now lists them under `files`, the served state's name for them, each by binding with the label the page shows and the path to write it at.
leaf-agent
left a comment
There was a problem hiding this comment.
The two new commits do two items from the description's "Not done" list: the editor now marks the lines an outside write changed, and leaf page state lists bound files. The list still names both as not done, so it no longer matches the diff.
followKept gives a file the reader has left a different undo history from follow on the open file. adopt swaps in a fresh history(), as createEditor's contract says ("Adopting changed external text starts a new undo history: earlier local edits belong to the replaced version"). followKept keeps the kept state's history. Before this push that branch set of.kept = null, so a file reopened after an agent's write started a fresh history. Now a reader who switches back and presses Undo reverts edits they had already saved, mapped onto the agent's version, and the editor saves the result. Its docstring's "as follow takes the open file" makes the same claim. Either reset the history there too, as adopt does, or say in createEditor's contract that a hidden file keeps its history.
The deploy-config example's notes each linked a file, and following "Memory limit" opened values-production.yaml at its top, 21 lines above the value it was about. A key may now name a line as `<binding>:<line>`: a link to `#editor:values:29` opens the file with the caret at the start of that line, in the middle of the editor's view, and the reader types there.
…otes at their lines A workspace's header is one row; the example's three-line lede in it took the editor's room and, where the window is narrow and the header sticks, covered the notes beneath it. The lede now opens the notes pane, and each note links the line it is about. On a phone the tree takes the height its rows need.
Opening one YAML file after another cleared the editor's language and set it again in two updates, so CodeMirror wrote the content's data-language twice with the value it already had, which the suite's write watch reports. The language now goes in with the state's other settings.
…ghting The example's first screen now highlights its YAML and keeps its header to the title, so its catalog card's preview is captured again (uv run leaf-dev site previews).
CodeMirror maps the history it keeps through a change it doesn't record, and an earlier edit that change overlaps then undoes into neither version: "one" typed over as "user", then written "agent" elsewhere, undid to "agonent", which autosave would write to disk. Following a write into the open file already restarted the history. Three other routes take in text written elsewhere and kept it: following a write into a kept file (`followKept`, a refresh of a clean file another one is open over), merging one into a kept draft (`mergeKept`, when that file's request settles), and merging one into the open draft (`merge`). All four now go through `writeFromElsewhere`, which restarts the history in the same update, from one compartment the module shares so a kept state can be restarted too. Behavior change: after a version written elsewhere joins the reader's unsaved edit, Undo no longer reaches that edit's earlier keystrokes; they belong to the version the write replaced.
… it took lines away A whole line inserted above an unchanged one marked both, since the diff's change runs to the next line's start and the marking took every line the change's range reached. The range is not where the lines differ: the diff starts and ends a change wherever the two texts stop agreeing, so a line inserted above "three" arrives as "wo\nt" after the "t" of "three", and one appended below a last line with no break as "\ntwo" after it. Each change is now read as the whole lines it touches before and after, and the lines the two ends of that run share go unmarked. Lines taken away with nothing in their place used to mark the unchanged line after them; they now draw a rule in the accent across the gap, above the line after it, or below the last line where the gap ends the file. Behavior change: an inserted line marks itself alone, at the start, middle or end of a file; a deleted line marks the gap it leaves rather than its neighbour.
The landing measure took the window's whole foot band off a region reaching the foot, on the ground that the region lays its content out to clear that band. It clears only the band at rest: the region states the room it keeps after its last content (`--lf-end-room`, the foot's room), and the resting band is that room with the root's landing room past it. A draft of several lines opens the panel higher, the band grows over the region's content, and the measure took that content off too, so a file opened from the tree under it left the editor's last lines behind the panel (they ended at 827 px with the panel's card at 674 px). The measure now takes off the region's stated room and the landing room, never more than the band. Behavior change: a landing on a region under an opened panel brings the region's content clear of the panel; at rest, picking a file or following a link to a region still leaves a held workspace where it stands.
|
On the undo history in the review of 1fb090a: fixed in b4a7000. A second review also found that the landing change discounted the floating panel's current band where it should discount only what the region reserved, so a destination under an expanded panel counted as shown while covered. bf917bb takes off the smaller of the two, with a browser test of a file picked under an open panel. The description's two mismatches named in the review of d3f9b16 were fixed in the rewrite.
|
|
Thanks, |
# Conflicts: # README.md # browser/types/contract.d.ts # leaf-assets.json # packages/file-editor/registry.json
… doesn't cut it (#6395) When a keyboard user tabs into the deploy-config file tree's search field, the top edge of its focus ring is cut off. Trees' search field stands 1px below the top of the tree's clipping viewport. It didn't say where its ring stands, so Leaf's band drew outside it at a control's gap (5px) and lost its top 4px. The field now uses the inset ring position (`--lf-focus-ring-inset`), as the tree's rows already do. The ring now draws whole over the field's border, which `tokens.css`, "Where it stands", prescribes for a box whose clip leaves no room outside it. #6019 added deploy-config, the first corpus page with a file tree, so this was the first time the nightly ring sweep reached the field. **Verification:** `test_each_sampled_focus_ring_is_shown_whole_in_its_surface` (`--run-nightly`, Linux) reported `the ring on input "" is not all there: its top edge is 4px outside div ".github.github… / workfl"` on main. With this change its only remaining fault is motion-playground's 1px cut, which belongs to #6297. A focused Tab walk of deploy-config alone fails before the change and passes after it. The `ring` tests in `tests/model/test_interact_layer.py` pass. **On screen:** the one state that changes is the file tree's search field while it holds keyboard focus. Light theme, deploy-config at 1200×900: | Before | After | | --- | --- | |  |  | Closes #6391 — automated triage Co-authored-by: leaf-agent <[email protected]>
Fixes a file editor leftover from #6019: on a phone, a wrapped YAML row started at the editor's edge, like a new key. **Wrapped rows hang from their line's indent.** Rows now start two columns past the indent, behind the ↪ mark code blocks use. That hang now has one rule, in `marks.css`, which the document, every shadow stage and now the composer adopt; code blocks, drafts and the editor mark their lines `data-lf-pre-line` and state only their padding. `lf-code` keeps its own, since its `::before` is the line number. The editor takes the look code blocks and the reply box already have, so a file wraps the same way in each. Max left the pick to me. The alternative was rows at the indent with no mark, as VS Code does: it would give the editor a look of its own, and at phone width a wrapped row then reads as a value under its key. To weigh: the core bundle exports CodeMirror's `countColumn`; the write watch allows CodeMirror's restated line `style`. Left out: the marks for a write that rewrites a line and removes the next ones stay as on `main`, on Max's pick; YAML number and boolean colours merged as #6776; a plain link to a pane no longer moves the page on `main`. Tests: a phone check of where wrapped rows start, and one runtime case for a rewrapped paragraph's marks; `pnpm run test:runtime`. > _This was written by Claude Code on behalf of max-sixty_
Adds
examples/deploy-config.html, "Finish a worker's production config", to the catalog. A file tree lists a service's six deploy files, picking one opens it in the file editor, and each saves to disk as the reader types. Max asked for an example that features the file editor and suggested combining it with the file tree's; until now both packages appeared only on developer pages. He then used it and reported two defects, both fixed here, and approved two follow-ups, both built here.What changes for a user and an author:
lf-file-editortakes several bindings (binding="a b c") and publishes afilesoutput on thefile-listcontract, so<lf-file-tree for="editor">follows it with no change to the tree. Switching files keeps each file's caret, undo history and scroll. A link opens a file, and can name a line:#dc-editor:alerts:22puts the caret there.@codemirror/lang-yamlbuilt in Leaf's pipeline, in the theme's code colors. Its module is 39,619 bytes (14,368 gzipped) and loads only when a YAML file opens; the CodeMirror core grows by 7,599 bytes.leaf page statelists a page's bound files underfiles, the name the browser's state uses, with each one's label and path.<stem>.files/companion and<stem>.files.json, whichprepare_pagecopies into the page directory and binds. A file inside the page directory is granted by its path relative to the page, so on leaf.page a visitor gets their own copy to edit.browser/runtime/landing-scroll.js). Every region of such a workspace runs to the window's foot and keeps room there for the floating panel, so a landing measured it as taller than the visible band and scrolled the page to bring its top up. Max's click on a file moved his page 49 px. It showed only where something aftermaingave the document room to scroll, which is why no test had caught it. A landing now takes off such a region only the room the region itself reserved (--lf-end-roomplus the root's landing room), never more than the panel's current band, so content under an expanded panel is still brought clear. Picking a file, a link to a file, and a link to a pane each moved the page 31 to 49 px before and move it 0 now.To weigh:
#dc-editor, a tab set's panel) still moves the page about 20 to 40 px where the document has room: that route copies the browser's own fragment rule inanchor-travel.js, which Keep m's card clear of its words, and land m on a question in a card's answer as the thread lands #6010 is changing, so it is left with a recommendation to ask "already shown?" there too.files.jsontakes the page protocol's number as its format, now 50. Grants written before read as absent, so those files need binding again.Reviews: the building agent's own found six defects in the first version and fixed them or listed them; Codex looked hardest at the relative-path grant, the file routes and the merge, and found no way to read or write outside what was bound and two performance defects, both fixed. A second Codex review of the later commits found three defects, two of them also reported by the review bot, and all three are fixed with a failing test first: stale undo history after a write to a file the reader had left, which could garble its text; the landing change discounting the panel's whole band; and a mark on the unchanged line after an inserted one.
Checked with
pnpm run check, the file-binding model tests, the twelve files browser tests and the file-editor journey test by node id, the nearby landing tests,page check --render, andpre-commit. Two new tests fail onmain's runtime: a link to a held workspace's region, and picking a file, each with room given to the document. A third holds the other direction: a file picked under an open panel is brought clear of it. The broad suite is left to CI.