Repository navigation
Show what a change replaced in a card over it, and mark a removal as a change - #5249
Conversation
… a change
A version comparison's change is now a hunk of the block diff: its run of changed
blocks together with the base blocks it took out (version.js, `changeRuns`). Behaviour
that changes for the user:
- Pressing a change's ⇄ opens one card over the change instead of splicing the old
words into the live blocks. The card reads what the change did ("2 paragraphs
replaced by 3 · v1 → v2"), the blocks it took out struck, a block that kept its id as
its word diff, and the new blocks as the page shows them. The page under it doesn't
move; one card stands at a time; ⇄ again or Escape closes it. A section rewritten
into new blocks now shows its old text, where the splice showed nothing visible. The
inline splice, its quiet labels, the `lf-version-insert` highlight and the
`.lf-version-inline-deletion` rules are gone.
- A paragraph removed with nothing in its place is a change like any other: a short
change bar in its gap, a ⇄ by the block after the gap, a place in the panel's and a
widget's Δ count, and a stop for `h`. Before, it had no mark at all.
- Hovering or focusing a change's ⇄ outlines every block of the change, or its gap,
and the entry's label says what it did, such as "2 paragraphs replaced by 3 since
v1". The Page Map row carries the same account.
- The change's ⇄ wears an action's raised face, while staying a disclosure.
`comparisonChanges` now returns `{blocks, removed, at, after}` objects;
module-reading.md says so. The tests that pinned the splice now check the card, and
test_changes_in_place.py checks a removal's bar, entry, walk stop, outline and card.
The user picked this design on the session's Leaf page on 3 November.
# Conflicts: # dist/kernel/kernel.json # dist/kernel/runtime/bundle-data.js
A rewritten table read "12 cells replaced by 15": the account counted every cell as a block. It now counts what a reader counts, a cell as its row, on both sides: a live cell by its row element, and a block the hunk took out by a token for its base row, recorded while the base document is in hand so the record keeps no node of it. test_a_section_rewritten_whole_is_one_change now gives the old section a table too and reads the card's head.
This reverts commit 32e8538.
…e read and scrolled Review of the card build found four faults in what the card shows: - It listed every block a change took out before the blocks it kept, so a paragraph removed between two edited ones read first. Each taken-out block now records where it stood among the base's blocks, and the card places it after the last of the change's blocks whose base version stood before it. - A block new to this version read as plain text beside an edited block's green insertions, so it looked like unchanged context. It now reads as inserted. - Every paint stand was aria-hidden, which hid the card the ⇄ entry discloses from assistive technology. Each painter already hides its own decoration at its root (the key chips' layers, the legend, ink, visual marks, the aim's shapes), so the stand no longer does, and the card is read while the bars and outline stay empty boxes. - A redline taller than the window ran off its foot with no way to reach the rest. The card is now at most the window's height less the floating panel's room, and scrolls inside. test_a_change_s_card_reads_it_in_order covers each; flipping any one fix back fails it. This also drops the account's row counting (reverted in the previous commit): a removed cell counted as its row read "1 row removed" while the row survived, so the label counts cells again.
# Conflicts: # dist/kernel/kernel.json
leaf-agent
left a comment
There was a problem hiding this comment.
test_a_change_opens_what_it_replaced_in_a_card_over_it fails at this head. It counts one <ins> on the card, but redlineOf marks every block the base had no element for as inserted: diffPaired.has(block) ? "same" : "insert". That matches the PR description ("each new block, marked as inserted") and test_a_change_s_card_reads_it_in_order. So the new ret-cost-keep paragraph is a second <ins>, and the count times out at 2. This test runs in the default tier, so the PR's test job will go red on it. The suggestion below keeps the test's intent, and it passes locally. The docstring's "then the change's other blocks as the page shows them" should say "inserted" too.
Running locally, these also pass: the two new tests in test_changes_in_place.py, the other three rewritten card tests in test_render_anchors.py, and the rewritten pane test in test_versions.py.
…test The card now marks a block new to this version as inserted, so the log-retention change's card holds two insertions: the edited paragraph's words and the paragraph the revision added. Found by the PR review.
# Conflicts: # browser/runtime/margin-bars.js # dist/kernel/kernel.json # dist/kernel/runtime/bundle-data.js # dist/kernel/runtime/bundle-page-layout.js
leaf-agent
left a comment
There was a problem hiding this comment.
After the merge from main, the test job fails test_every_rule_of_the_interface_names_a_declared_font (tests/model/test_interface_fonts.py). That test came in with #5243, after this branch was cut. It requires every rule that selects an lf- class to set its type by naming a --font-* token from browser/styles/tokens.css, or with an allowed weight, family, size or line height. The four new .lf-change-card rules in chrome.css each set a font of their own.
The inline suggestions name existing tokens wherever one fits. The card body's serif at 1rem / 1.55 has no equivalent token, so it needs one more entry in the font list in tokens.css, for example just above --font-emoji:
/* The page's words quoted in the chrome, as a change's card reads them. */
--font-excerpt: 1rem / 1.55 var(--serif);With that token and the four suggestions applied, the test passes locally.
The other failure in that run, test_the_diff_marks_what_the_author_changed_and_no_word_a_script_wrote in test_versions.py, isn't caused by this PR. It fails the same way on current main (e6aafd0b6): after the revision the readout shows "Tallying…" and the paragraph the script appended is gone.
Main now requires every rule of Leaf's interface to name a theme font (test_interface_fonts, #5243). The card's words take --font-widget, the font for the words a card holds beside the page's prose, where they were the document's serif; its head takes --font-small, a heading line 600, and code the source face's own inputs. The order test's long paragraph grows so it still overflows the card in the smaller face.
# Conflicts: # dist/kernel/runtime/bundle-page-layout.js
… a page's CSS can't name (#5244) Leaf wrote 84 data attributes on its own elements outside the `lf-` namespace that `page check` reserves for it: the floating panel's state (`data-open`, `data-rest`, `data-shown`, `data-expanded`, `data-tone` and two dozen more), a thread's and a message's identity (`data-thread`, `data-event`, `data-message`, `data-attempt`), the paint boxes' `data-for`, the composer's `data-words` and send corner, and the parts the bundled widgets draw: lf-code's line numbers and elided rows, lf-tabs' scroll buttons, the trace timeline's marks, the timeline's events, the deck's pips, the call diff's lines and the diff's file rows. It also wrote the `scroll` class on its own scroll surfaces. A page's own CSS for one of those names restyled Leaf. On a probe page whose `<style>` held `[data-tone] { --warn: red }`, `[data-event] { --lf-msg-text-end: 123px }`, `[data-line] { background: blue }` and `.scroll { outline: 4px solid magenta }`, main painted the panel's away leaf red (rgb(255, 0, 0)), gave a margin card's messages a 123px text end, painted lf-code's lines blue (rgb(0, 0, 255)) over its highlight, and outlined lf-tabs' strip and panel, lf-code's scroller and lf-options' "Add another option" field in magenta (4px rgb(255, 0, 255)). The chrome's `all: revert-layer` guard stops a plain declaration but not a custom property, and a widget's parts in the page have no guard at all. Each is now the same name under `data-lf-`, its values unchanged, except where that name already meant something a document-wide reader or an unscoped rule relies on: - the panel view's `data-view` became `data-lf-route`, since prepaint.js sweeps `[data-lf-view]`, a revision's view members; - the panel status's `data-held` became `data-lf-held-lines`, since thread/presentation.js strips `data-lf-held` from every node no thread holds; - an On me item's `data-obligation` became `data-lf-obligation-id`, since obligations/view.js sweeps `data-lf-obligation`, the location mark, and chrome.css gives every `[data-lf-obligation]` a landing margin; - the composer field's `data-scrolls` became `data-lf-overflows`, the name the margin card's transcript already gives the same fact, since reach.js writes `data-lf-scrolls` on that field too. Where the prefixed name was already in use for the same kind of fact on other elements (`data-lf-tone`, `data-lf-state`, `data-lf-open`, `data-lf-unread`, `data-lf-place`, `data-lf-ready`, `data-lf-line`), every selector and query names its element, so the uses share a word without meeting. The video bar's `data-hovered` and `data-keyed`, built from one template, are `data-lf-hovered` and `data-lf-keyed`. The `scroll` class stays the page's: page-authoring.md tells an author to add `class="scroll"` to a custom horizontal scroll box, and `page check` would refuse `data-lf-scroll` in markup. Leaf's own surfaces, and a package module's (module-scroll-and-motion.md now says so, as it already did for `data-lf-track`), wear `data-lf-scroll`, and reach.js and the shared containment rule in controls.css read both. Where the runtime marks an element the page owns (a code block, a part beside the Layout's views, a bounded block's body), the mark joins `RUNTIME_PAINT_ATTRIBUTE`, so a reading of the author's attributes looks past it, as it did past `class`. Kept as they are: the attributes an author writes (`data-width`, `data-height`, `data-bound`, `data-sample*`, `data-annotations`, `data-rail`, and `data-room`, which Leaf's own controls also use, one rule for both), the playground's `data-playground-*` on its host, which the author's preview CSS reads by design, Pierre's attributes on the DOM it renders (`data-line`, `data-line-type`, `data-code`, `data-content`, `data-separator` and the rest), including the ones lf-diff copies onto its own rows and `pre` so Pierre's vocabulary keeps reading them, and the diagram's `data-id`, which pele writes. On the same probe this change shows Leaf's own styling: the away leaf in the theme's warn (rgb(180, 116, 26)), the message's own 13px text end, lf-code's lines unpainted but for the highlight, and no outline on any widget part. Nothing changes on a page that doesn't target the old names, and specificity is unchanged: each `[data-x]` became `[data-lf-x]`, and `:where(.scroll)` became `:where(.scroll, [data-lf-scroll])`. Tests and dev tools read the new names. Attributes a test gives its own fixture, which only share a word with Leaf's, stay: the `data-row` key test_focus.py, focus.test.mjs and an application-boundary widget hand to `holdFocus`, a test widget's `data-words` and `data-ready`, the shift watch test's `data-key` on `body`, the write watch test's `data-for`, and the examples' own `data-state` and `data-status`. The shift and words watches' expected node paths lose the `.scroll` class (`leaf-text#field`, `lf-diff#patch.lf-rendered`), and reach.test.mjs asks a native code block for `data-lf-scroll`. ### Checks - Main is merged in, and with it three new readers of the old names, which now read `data-lf-obligation-id` (the On card selector, `ON_CARD`), `data-lf-key` (the queue walk), `data-lf-event` (undo's message lookup) and `data-lf-number` (a text document's line number, in #5226's lf-text-document code and test). #5249's change bars write theirs as `data-lf-for`, `data-lf-gap` and `data-lf-kind`, the stills drivers that moved to `dev/leaf_dev/states.py` in #5259 read the new names, as do #5263's fold test (`data-lf-says`, `data-lf-rest`) and #5264's dev browser helper (`data-lf-open`). - The pull request's `test` job: its failures outside the journeys fail on main too; of the journeys, `test_the_feature_gallery_exercises_its_core_journeys` failed here because the test read the gallery's own preset buttons as `data-lf-route`, and now reads the author's `data-view`. The pressed-controls sweep's 28 cases, `test_an_aimed_comment_keeps_its_place_with_on_me_open`, and the navigation, controls and website-server journeys that failed fail the same way on main. - `pnpm run check` and `pnpm run test:runtime` (753 pass), pre-commit over the changed files, and the kernel rebuilt with `pnpm run build:browser`. - 67 browser tests, by node id, that read the renamed attributes: the floating panel's status peek, passing notices, versions, menu lists and Threads' New; thread summaries, attempts, failure receipts and message obligations; reactions; the send corner; the shift and words watches' field paths; reach for an authored `.scroll` box; the trace timeline and overview; timeline steps; lf-code excerpts and text-document numbers; the diff's cut path; the call diff; overflowing tabs; On me cards; rings and aim; a board's lifecycle; the recording bar; the smoke tier's three changed tests; and read state. `test_a_pointer_folds_the_panel_from_its_corner` fails the same way on main: the corner button calls `foldPanel` directly, so no `lf-command-invoked` arrives for the test to read. - `leaf-dev stills` over the 61 catalogue states that draw the renamed attributes found no computed style that differs; the style lists only re-key the elements that lost the `scroll` class. Stills differ only where every run differs: About's fingerprint and port, a caret's blink, an overlay scrollbar's fade, and a target trace one arm caught mid-transition, in the other arm on a second run. The stills drivers name the new attributes, so for this comparison 21 states drove the merge base's runtime through a local patch that accepted either name. > _This was written by Claude Code on behalf of max-sixty_
…ns and words now live (#5299) Comments in the theme, runtime, bundled packages and two test docstrings still sent readers to `base.css` for tokens that #5121 moved into `browser/styles/tokens.css`. Two comments in `browser/runtime/version.js` still described the inline comparison that #5249 replaced with a change card. This PR updates those pointers. It changes comments only, so nothing behaves differently. - **Tokens:** every edited pointer names a token that `tokens.css` declares and `base.css` no longer does: `--font-ui`, `--font-compact`, `--font-status`, `--font-message`, `--font-heading`, `--font-*`, `--muted`, `--chip-r`, `--r`, `--mark-size`, `--wide`, `--raise-*`, `--focus-shadow`, `--lf-rail-room`, `--lf-top-covered` and `--aim-floor`'s pointer query. I checked each by grepping both files for its declaration. Pointers to rules still in `base.css` are unchanged, such as `--lf-top`, `--lf-block-frame` and `--lf-wears-ring`. - **`version.js`:** the comment above `diffWords` now names the change card's `diffWordsOf`. The guard in the revision's `activates` now gives its real reason: `activateRevision` turns a selected comparison off and restores it, and that comparison's marks can own the rendered subject. `prek run` passes on the changed files. The same stale `base.css` pointers also appear in `browser/AGENTS.md`, the developing-leaf glossary and `skills/leaf/references/package-themes.md`. Those paths need the control-plane owner's approval, so they go in a separate PR. Co-authored-by: leaf-agent <[email protected]>
…5322) In a version comparison, a block removed with nothing in its place stood at the unchanged block after its gap (#5249). That caused three problems. A paragraph removed from the end of a `details` or a tab was marked outside it and missed from the tab's Δ count. Two removals on either side of one block both stood on that block, so `h` could not step from one to the other. And `h` focused the unchanged block, which read as if it had changed. - **A removal stands in the part of the page it left.** `changedSince` puts each removed block after the unchanged block before its gap, unless the element the two shared (found in this version as many levels up as in the base) also holds the block after the gap; then it goes before that next block. A block whose element lost every block stands in that element, found by its id. The element the gap stands beside is the shared element's child, so a paragraph removed just before a `details` stands before the `details`, not inside it. A change carries `gap: "before" | "after" | "in" | null` in place of `after`, and `gapHolder(change)` names the element a gap is in, which run grouping and `comparisonChanges(owner)` read. - **`h` lands on a stand-in for the gap.** Each gap has a focusable stand-in on the details shelf (`control-faces.js`, `proxy`), named by what the change did ("1 paragraph removed since v1"); pressing it opens the change's card. Focusing it opens any fold that hides the gap, scrolls the gap into view with a line of text on either side within the scroller that holds it, and rings the gap. The shelf's new `presents: false` leaves revealing, scrolling and ringing to the note's owner, so a closed `details` just after a gap stays closed. A gap bar's far edge is the nearest box across the gap, climbing past a parent that leaves no room. - **Each removal outlines its own gap.** A gap's outline keeps to the gap with no vertical padding, and the ring gives way to an open card. Hovering one of several Change readings in a margin cluster outlines its own change rather than the cluster's first. Behavior change: `h` on a removal focuses the gap's stand-in, not the block after the gap. `test_a_paragraph_removed_is_a_change_at_its_gap` now asserts that, and `test_a_removal_stands_in_the_part_of_the_page_it_left` covers the placements on one page: a removal at the end of a fold, removals on both sides of one block, an emptied tab counted in its Δ, a rewritten block after a fold, a fold wrapped in a new element, a gap below a block taller than the window, a gap inside a scrolling box, and a closed fold left closed. Review: two rounds of Codex review found six cases beyond the three reported (the emptied tab, the rewritten next block, a new wrapper, the tall block, the scroller and the closed fold); each is fixed and in the test above. Each of 14 mutations that undo one part of the fix fails a test. Costs and limits: - The runtime grows by about 290 lines (+422 −135), 80 of them comments, mostly the gap's placement in `version.js` and its stand-in, ring and geometry in `margin-bars.js`. - A removal's ⇄ stands beside the block its gap follows or precedes, at that block's first line, so after a long block the ⇄ is far above the gap; its bar, outline and ring stand at the gap. - An element emptied of every block is found by its id. A tab and a region a disclosure names always have one; a plain `<div>` without one, whose only paragraph went, marks its removal beside the next block outside it. > _This was written by Claude Code on behalf of max-sixty_
In a version comparison ("Changes since vN"), pressing a change's ⇄ margin entry used to splice the old words into the live blocks. The text under the press moved, a block the revision took out whole had nowhere to show, and a block whose id changed showed nothing. On 3 November the user picked a replacement from sketches on a Leaf page:
hwalk and a place in the change count, as an addition does.Where it lives:
version.js:changedSinceandchangeRunsreturn each change as{blocks, removed, at, after}, with the base blocks its hunk took out.changeAccountwrites the label andchangeRedlinethe card. The inline splice and its styles are deleted.margin-bars.js: block bars, gap bars, the hover outline and the card, all through onepaintSet.target-paint-geometry.js: a paint stand is no longeraria-hidden, so assistive technology reads the card. Every other painter already hides its own decoration at its root.annotation-inventory.js,margin-projection.js,change-walk.js,keyboard/register.js: the entry and its label, the outline on hover and focus,hlanding atchange.at, and Escape closing the card.comparisonChanges()returns the new change objects to packages;module-reading.mddocuments them.Costs and limits:
detailsor a tab stands at the next block after it, which can be outside that view. When a revision removes blocks on both sides of one unchanged block, both removals stand at that block, andhcan't step from the first to the second.The tests that asserted the splice now assert the card and its 0px hold.
test_a_paragraph_removed_is_a_change_at_its_gapcovers a removal, andtest_a_change_s_card_reads_it_in_ordercovers the card's order, its insertions, its accessible role and its scrolling.