Skip to content

Count the changes since each older version before its Compare in Versions - #6811

Merged
max-sixty merged 3 commits into
mainfrom
changes-into-versions
Nov 23, 2026
Merged

max-sixty merged 3 commits into
mainfrom
changes-into-versions

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Each version older than the one shown now says, before its Compare's word, how many changes a comparison with it would mark: "v1 Earlier draft … 8 changes Compare". The count is part of the Compare press, so pressing it marks those changes, and the counts end one under another. Until a count is in, the press reads Compare with the count's room held, so a count coming in moves nothing beside it. A screen reader hears "8 changes, Compare with v1".

How it counts. A count runs the same diff Compare runs (changesSince), about 15 ms of script on the largest example page and 60–200 ms in all, mostly fetching the older version. While Versions is open it counts only the versions whose Compare shows in the window, newest first and one at a time, and a row scrolled into view gets its count then, so the work opening Versions or a pick sets off follows the rows on screen rather than how many versions the session has stamped (AGENTS.md, "Responsiveness"). Counts are kept per revision being read and per state of the page's widgets (the publisher keeps that object while the state holds), so reopening Versions shows them without asking the server, and a pick or a new revision recounts. changesSince now retries when the revision moves, so the return notice's loop in since-seen.js shrinks to one call. A comparison with no changes now says "No changes since v2" rather than "No text changes", since the diff counts widget state too.

Shared fix. A data-lf-room element that was a grid or flex item stood about 11 px below the row's baseline, because its zero-height room block gave the item its baseline. The shared rule in controls.css now puts the room and the words in one grid cell, with the words giving the baseline and centred as a button's are. Stills of the other room holders (thread news notice, transcript summary, diff progress, playground submit) show no pixel change in Chromium or Firefox.

Placement. Max picked the count before Compare's word, inside its press, over the count after the version's name. Two placements were out: replacing Compare's word breaks browser/AGENTS.md's one word per action, and a count outside the press opened the version on a click. The press grows about 80 px, which every row's note gives up.

Max asked for change counts in Versions as a follow-up to #6788; an independent review's findings are folded in. Tests: a new browser test covers the counts, their names, a reopen that fetches nothing and a recount after a pick, and another that only the rows in view are counted; the three tests that hold a comparison's /api/view request now hold only that request; the return-notice tests, pnpm run check:browser and pnpm run test:runtime pass.

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

…ions

Each version older than the one shown says, before its Compare's word and inside
the press, how many changes a comparison with it would mark ("8 changes Compare"),
so the counts end one under another and pressing a count marks those changes. The
press's name says "8 changes, Compare with v1". Compare keeps its word, as
browser/AGENTS.md has an action show one word wherever Leaf offers it; until a
count is in, the press reads Compare with the count's room held.

Versions counts the missing versions while it is open, newest first and one at a
time, with the diff Compare runs (version.js, `changesSince`, `changesCounted`).
Counts are kept per revision being read and per widget-state object, so reopening
Versions fetches nothing, and a pick or a new revision recounts. `changesSince`
takes a `wanted` predicate and retries when the revision moves, so the return
notice (since-seen.js) is one call. A comparison with no changes now says "No
changes since vN", since the diff counts widget state as well as text.

Shared fix in controls.css: a `data-lf-room` element that was a grid or flex item
stood about 11 px below its row's baseline, because the room's zero-height block
gave it its baseline. The room and the words now share one grid cell, the words
giving the baseline and standing at the middle as a button's do; both stay blocks,
so an element whose own rules set another display still stacks them. Stills of
the other room holders show no pixel change in Chromium or Firefox.

Tests: test_versions_counts_the_changes_since_each_older_version covers the
counts, their names, a reopen that sends no /api/view request and a recount after
a pick. The three tests that hold a comparison's /api/view request
(test_a_comparison_retries_when_the_live_projection_advances,
test_pending_comparison_moves_with_a_live_revision,
test_a_failed_comparison_clears_its_pending_choice_and_can_retry) now hold only
the comparison's request (`comparison_view`, which names `shown=`), since opening
Versions sends count requests first. Name matchers no longer anchor on "Compare
with". The stills states wait for the counts (states.py, `versions_counted`).

Where the count sits is still the maintainer's pick (before Compare in its press,
or after the version's name); this builds the first.

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

The description leaves an open pick for the maintainer: where the count sits ("Wait on the maintainer"). So this review is a COMMENT rather than an approval until they choose a placement. One cost below is also for the maintainer to weigh.

Comment thread browser/runtime/version.js Resolved
Versions counted every older version each time it opened on a new revision
and after every pick while it was open: one document fetch, one /api/view and
a whole-page diff per version. That work grew with the number of stamped
versions, which grows as the session runs, against AGENTS.md's
"Responsiveness" ("Neither an input's work in the browser nor the bytes it
moves grows with how long the session has run"). The tend reviewer raised it
on #6811.

Each Compare press now carries `countWhenShown(revision)` (version.js), a Lit
directive that observes the press with an IntersectionObserver. Versions
counts, newest first and one at a time, only the versions whose press shows in
the window, and a press scrolled into view wakes the counting. Rows out of view
keep Compare's word alone until they show. `nearObserver`'s 600px margin was
considered and left out: for counts it would fetch and compare another 600px of
rows on every pick.

Tests: test_versions_counts_only_the_versions_in_view stamps 15 versions in a
short window and checks that only the rows in view get counts, that Versions
asks /api/view once per row in view, and that the oldest row gets its count
once scrolled into view; it fails when every version is counted. The stills
helper `versions_counted` waits for the rows in view.
@max-sixty

Copy link
Copy Markdown
Owner Author

@leaf-agent Max has picked the placement this review waited on: the count stands before Compare's word, inside its press, as built at 0da0c68. The description now says so. Is anything else holding the approval?

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

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

Nothing else holds it. The placement was the only open pick, and the one finding, counting every stamped version, is settled at this head: Versions now counts only the rows whose Compare shows in the window, and test_versions_counts_only_the_versions_in_view passed in this head's test job.

@max-sixty
max-sixty merged commit b2a623a into main Nov 23, 2026
8 checks passed
@max-sixty
max-sixty deleted the changes-into-versions branch November 23, 2026 03:34
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