Skip to content

Stand a removed block in its own gap, and walk to it on a stand-in - #5322

Merged
max-sixty merged 4 commits into
mainfrom
fewer-change-marks
Nov 4, 2026
Merged

max-sixty merged 4 commits into
mainfrom
fewer-change-marks

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

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, a block removed with nothing in its place stood at the
unchanged block after its gap. 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 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.

- `changedSince` stands each removed block in the part of the page it left: after
  the unchanged block before the gap where the element it shared with that block
  (found in this version as many elements up) doesn't hold the block after the gap,
  else before the block after it, and in an element emptied of every block, found by
  its id. The element the gap stands beside is that shared element's child, so a
  paragraph removed just before a `details` stands before the `details`. A change
  carries `gap: "before" | "after" | "in" | null` in place of `after`, and
  `gapHolder` names the element a gap is in, which grouping and
  `comparisonChanges(owner)` read.
- Each gap has a stand-in on the details shelf (control-faces.js, `proxy`), named by
  what the change did, whose press opens its card. `h` lands on it; its focus opens
  what folds the gap away, scrolls the gap with a line either side into view within
  the scroller holding it, and rings the gap. The shelf's `presents: false` leaves
  that to the note's owner. A gap's far edge is the nearest box across it, climbing
  past a parent that leaves no room.
- A gap's outline keeps to the gap, and the ring gives way to an open card. Hovering
  one of several Change readings in a margin cluster outlines its own change.

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.
# Conflicts:
#	dist/kernel/kernel.json
#	dist/kernel/leaf.js
#	dist/kernel/runtime/bundle-annotation-overlay.js
#	dist/kernel/runtime/bundle-box-motion.js
#	dist/kernel/runtime/bundle-data.js
#	dist/kernel/runtime/bundle-page-layout.js
leaf-agent
leaf-agent previously approved these changes Nov 4, 2026

@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.

One non-blocking wording fix to the shipped reference, inline.

@max-sixty
max-sixty merged commit dc27bd0 into main Nov 4, 2026
5 checks passed
@max-sixty
max-sixty deleted the fewer-change-marks branch November 4, 2026 09:09
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