Skip to content

Run a diff row's fill to the end of its line - #784

Merged
max-sixty merged 5 commits into
mainfrom
diff-row-fill
Sep 18, 2026
Merged

max-sixty merged 5 commits into
mainfrom
diff-row-fill

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

Pierre sizes the diff's code column 1fr, which is the width of the box that scrolls, so a changed row painted its green or red only as far as the reader could already see. On the walkthrough's widest file the line runs 3,234px inside a 718px box and the fill stopped at 671px: scrolling right left every addition and deletion sitting on the file's plain paper with nothing to say which it was.

The track now takes its floor from the longest line and keeps 1fr over it, so a file whose lines all fit still fills its box rather than ending at its longest line. That floor measures everything standing in the column, which is where the other two changes come from. A thread outlet stands there with the lines, and what it contributes is not its remark's own length but the thread's own max-width: 760px cap plus the outlet's padding — a 796px contribution from any remark long enough to reach that cap, against the 671px of rows in the file it was measured on, so one ordinary remark set a file that fit its box scrolling sideways with 843px of content in 718px of room. Inline-size containment keeps the outlet out of the measure while it still stretches and wraps. And the wrap switch and the print sheet both force pre-wrap while a wrapped line still measures its unwrapped self, so both drop the floor.

Three probes had to move with it, because the rows are now all one width — each sized to the longest line in its file — and a reading taken off a row's own box no longer says anything about that row's line. DIFF_CLIPPING and _SELECT_IN_ROW both measure the row's text now, by a Range over its contents, against the room the scrolling box gives it; without that, DIFF_CLIPPING reported the file's overhang for all 18 of one file's rows where one line overflows, and named a trailing-context line the reader could see whole. Each has an assertion holding it to naming the overflowing line, so it cannot quietly degenerate again. The new DIFF_ROW_FILL case asserts the fill reaches both the line's end and the box's edge, and reads again after a comment lands; every one of those was verified paired, green with the change and red without it.

Measured on the 47-file patch: 3,769 rows relayout in 147-150ms against the baseline's 154-156ms, across two paired rounds, so the intrinsic sizing costs nothing here.

One commit only adds a TODO: lf-code has a milder version of the same defect, where a short highlighted line's tint ends at the scrollport rather than at the block's width. Its notes share the column and position sticky, so that fix wants its own change.

Thanks to @leaf-agent for both review findings — the untested containment and the degenerated probe.

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

max-sixty and others added 3 commits September 17, 2026 23:31
Pierre sizes the code column `1fr`, which is the width of the box that
scrolls, so a changed row painted its green or red only as far as the
reader could already see. On the walkthrough's widest file the fill ran
out 2,563px short of the line's end: scrolling right left every addition
and deletion sitting on the file's plain paper with nothing to say which
it was.

The track takes its floor from the longest line and keeps `1fr` over it,
so a file whose lines all fit still fills its box rather than ending at
its longest line. A thread's prose shares that column and its max-content
is the whole comment on one line, which would size the code by the longest
remark instead — 1579px where the lines wanted 745px — so the outlet is
contained in the inline axis and stays out of the measure. The wrap switch
and the print sheet both drop the floor, since a wrapped line still
measures its unwrapped self.

Two probes read a row against its own box, which this resizes; both now
read it against the file's scrolling box, which is what "can the reader
see the end of this line" means either way.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The tint on a highlighted line stops at the scrollport, which is the same
question the diff just answered from the track. Name the fix beside the
rule, with the two parts of lf-code that make it a separate change: its
notes share the column, and they position sticky.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

@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 floor makes the diff's code column content-sized for the first time, so every element standing in that column now decides how wide a file's rows are. contain: inline-size on the thread outlet is the only thing keeping reader prose out of that measure, and nothing in the suite holds it there: I removed that one declaration and ran tests/test_render_widgets.py with tests/test_render_visual_review_journey.py — 177 passed, unchanged.

The regression it prevents is reachable from the fixture the new case already uses. On LONG_LINE_DIFF_PAGE, app/routes.py is the short file — box 718px, gutter 47px, rows 671px, code[data-code].scrollWidth 718px, so it fits and narrow is zero. Leave one ordinary remark on line 201 and, with the containment removed, the rows go to 796px and scrollWidth to 843px: a file that fit its box starts scrolling sideways, and every row overhangs what the reader can see. With the declaration in place the same sequence leaves 671/718 untouched.

The new case reads a page with no threads, so a green result there is consistent with the outlet being back in the measure. _bound_diff and _SELECT_IN_ROW already do the work — reading DIFF_ROW_FILL once more after a comment lands would pin that half the way short and narrow pin the other two.

Separately, _bound_diff's docstring still opens "The review the three diff tests below read"; this PR makes it four.

The floor measures everything standing in that column, and nothing held
the outlet's containment there: removed, one ordinary remark on the file
whose rows fit their box took them from 671px to 796px and set a file the
reader could see whole scrolling sideways, 843px of content in 718px of
room.

What binds is not the remark's own length but the thread's own 760px cap,
plus the outlet's padding, so any remark long enough to reach it does the
same. The reading goes in before the wrap step, so the wrapped rows are
measured with a thread among them too.

Found by leaf-agent in review, which named the file and the line.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@max-sixty

Copy link
Copy Markdown
Owner Author

Both taken, in bcf9beea. The fill case now reads DIFF_ROW_FILL a third time after a comment lands on app/routes.py, placed before the wrap step so the wrapped rows are measured with a thread among them too; and _bound_diff's docstring says four.

I reproduced your deletion control and got your numbers exactly — 671px of rows to 796px, 843px of content in 718px of room, scrolls 1 to 2. One refinement, which is now in the comment beside the declaration: what binds is not the remark's own unwrapped length but the thread's own max-width: 760px, plus the outlet's 2×18px padding. Any remark long enough to reach that cap produces the same 796px, and one shorter than it produces none at all — my first draft of the case used a remark that stayed under the file's 671px and passed with the containment deleted, which is what sent me to measure rather than trust the first green. The comment previously cited 1579px, from a scratch probe that injected raw text with no thread wrapper and so no cap; it now carries the real figures.

_DIFF_TAIL and _SELECT_IN_ROW moved up beside _bound_diff, since the new reading uses them and they belong with that fixture.

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

@leaf-agent

Copy link
Copy Markdown
Collaborator

Both closed. I ran the control on bcf9beea rather than reading it: with contain: inline-size deleted from .lf-diff-thread-outlet, the new reading fails at the line it is there for — assert 2 == 1, scrolls 2 against the 1 the first reading established, with short and narrow still 0. Restored, tests/test_render_widgets.py with tests/test_render_visual_review_journey.py is 177 passed.

Your refinement is the more useful fact, and it changes what the case has to hold: since the 796px comes from the thread's own cap rather than the remark, the case is only sound while its remark clears that cap — a shorter one passes with the declaration gone, which is the failure mode your first draft found. The comment beside the declaration now carries the figure that says so, so the next person to shorten that string has the reason in front of them.

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

DIFF_CLIPPING still reads each row against the row's own box, and this PR is what made that box the width of the file's longest line rather than the line's own. Every row in a file that scrolls now reports the same overhang, so the probe no longer names the line that overflows: on LONG_LINE_DIFF_PAGE it reads {'rows': 24, 'cut': 18, 'worst': 1143, 'widest': ' # third tail'} — all 18 of app/handlers.py's rows counted cut where one line overflows, with widest naming a trailing-context line the reader can see whole. That is also the reading test_a_wrapped_diff_shows_every_line_whole_and_paper_wraps_whatever_the_switch_says leans on: cut["cut"] > 0 and cut["worst"] > 300 is the population that makes the wrapped result mean something, and it now establishes only that some file scrolls.

Measuring the row's text rather than its box restores it — a Range over the row's contents, which is the measurement _SELECT_IN_ROW moved to for its own cut in this same PR. With the suggestion below applied the same fixture reads {'rows': 24, 'cut': 1, 'worst': 1120, 'widest': ' return "The comparison base is the merge-base'} unwrapped, cut: 0 wrapped and cut: 0 under print media, and pytest tests/test_render_widgets.py -k diff -n0 stays at 5 passed. The probe's comment wants the matching edit — what it measures is the row's text against the room, not the row against its box. Say the word and I'll push both.

Separately, the description still carries the 1579px figure and the mechanism bcf9beea retracted: "its max-content is the whole comment on one line, which sized the code to 1579px where the lines wanted 745px". The merge takes PR_BODY as main's commit message for this change, so that is what history keeps rather than the cap-and-padding reading the CSS comment now carries.

Comment thread tests/render_cases_widgets.py Resolved
Every row is sized to the longest line in its file so its fill reaches the
end of it, which leaves `row.scrollWidth` the same number for all of them
and the reading taken off it saying nothing about any one line: 18 of 24
rows counted cut where one line overflows, and `widest` naming a trailing
context line the reader can see whole.

A Range over the row's contents measures the line instead, which is what
`_SELECT_IN_ROW` moved to in this same branch and for the same reason. The
reading names the overflowing line again, and an assertion now holds it to
naming it — the box reading passed the whole suite while it was wrong,
which is what let it through.

Found by leaf-agent in review, with the fixture's numbers both ways.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@max-sixty

Copy link
Copy Markdown
Owner Author

Both taken, in 2c0d6baa. I reproduced your reading first and got your figures exactly: {'rows': 24, 'cut': 18, 'worst': 1143, 'widest': ' # third tail'} before, {'rows': 24, 'cut': 1, 'worst': 1120, 'widest': ' return "The comparison base is the merge-base'} after. This was my own residue — I moved that probe off the row's own box earlier in the branch and put it back onto row.scrollWidth, which this change makes one number for every row in a file.

One addition to your patch. The box reading passed the whole suite while it was wrong, so the count alone could not tell the two apart and nothing stopped it degenerating again; the unwrapped reading now also asserts that widest names the line that overflows, and reverting to row.scrollWidth fails it with the # third tail message rather than passing. Same for the contain: inline-size case from your last review, which is pinned paired.

The description is rewritten — the 1579px figure came from a scratch probe that injected raw text with no thread wrapper and so no cap, which is exactly why it disagreed with the page. I confirmed your premise rather than assuming it: squash_merge_commit_title is PR_TITLE and squash_merge_commit_message is PR_BODY on this repo, so the body is what main keeps.

Thanks for both findings — each named the file, the line and the numbers, which is what made them quick to confirm. I pushed them myself rather than taking you up on the offer, since the branch is mine.

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

@leaf-agent

Copy link
Copy Markdown
Collaborator

Ran the control rather than reading it. On 2c0d6baa, reverting DIFF_CLIPPING's Range back to row.scrollWidth reddens the new assertion with exactly the reading you quoted — {'rows': 24, 'cut': 18, 'worst': 1143, 'widest': ' # third tail'} — rather than passing it; restored, tests/test_render_widgets.py with tests/test_render_visual_review_journey.py on -k "diff or review" is 10 passed.

That assertion is the whole guard on the probe, since DIFF_CLIPPING has one reader and the population check above it is satisfied by any file-wide overhang. Nothing outstanding from my side; the description carries the cap-and-padding reading now.

@max-sixty
max-sixty merged commit c9a5f20 into main Sep 18, 2026
5 checks passed
@max-sixty
max-sixty deleted the diff-row-fill branch September 18, 2026 07:42
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