chadtmiller.com/knotless
git that lives in your Atmosphere account
1
10
A diff shows more of a file as asked, and links to the file
Merged Approved
This pull adds arrows to each hunk header that put back 20 hidden lines at a time. It also adds a header button that expands or collapses the whole file, and a "View file" item in a new "…" menu. I read all the changed files: context.ts, DiffFile, Diff, PullDiff, ActionMenu, diffs.ts, icons.ts, the three pages, the CSS and the docs. I checked them against highlight.ts and found nothing that must change.
- Old and new line numbers:
gaps()handles zero-count hunks (-5,0) correctly, and the old-side shift is constant across a gap. - Highlight text: the joined text matches what
highlight.tsreads. It takes the<code>elements in DOM order, and only line rows have one. The hunk-header rows and the expander cells don't. - Concurrent reads: reads that overlap with a change of commit or file are handled by the
kept.of !== mine.ofcheck. A failed read clears the open state, so it can be retried. - Docs and changeset:
docs/design/serve.mdis updated. The change touches only the web pages, so no changeset is needed.
The "arrow after the last hunk even when the file ends there" behaviour is a known shortcoming, and it is acceptable.
All checks have passed
8 passed, 2 skipped
Merged as 573bae0
A diff can now show more of a file, as GitHub's does: arrows in each hunk's header put back hidden lines 20 at a time, a button in the file's header shows the whole file or folds it back, and a "…" menu has View file, which opens the file's page on the pull's branch (or at the commit). It touches only the pages, no query changes; the commit, merged-commit and pull files pages move.
Claude Opus 5.5 · medium
What changes
More lines. On a pull's Files changed tab, a commit's page and a new pull's compare, a file changed in place shows arrows where its diff leaves lines out: in each hunk's header (down from the hunk above, up from the hunk below, or one button for a gap of 20 or fewer), and in a row after the last hunk. Each press puts back 20 lines; a gap shown whole joins the hunks either side of it. The first press reads the file once with
dev.knotless.getFileat the commit the diff's new side is at (an open pull'schanges.head, a merged pull'smerged, the commit itself), and the lines put back are painted with the file's own highlighting. The lines put back take no comments.Expand all. An icon button in the file's header shows every line, then folds them back ("Collapse expanded lines").
View file. A "…" menu in the file's header links to the file's blob page: an open pull's on its head branch (a fork's when the pull comes from one), a merged pull's and a commit's at that commit. A deleted file has no link.
web/src/lib/context.tsholds the logic: the gaps read from the hunk headers, the rows as drawn with lines put back, and the diff's and the file's highlight ranges joined into one string for the rows drawn.ActionMenunow takes anhrefand aniconfor an item.docs/design/serve.mdsays what the diff does.Why
Asked for: reading a change without its surroundings means opening the file elsewhere. Reading the file through
getFileneeds no new query: every page already knows the commit and repository of the diff's new side.How it was checked
svelte-check, the layers check and
just fmt. A throwaway script ranexpandover a two-hunk diff: each line put back matched the file at its new number, its old number was right on both sides of a change that adds a line, and the file's highlight ranges landed on the right text after joining.just lookdrew the pull files and commit pages: as first shown, with a gap over 20 lines (two arrows), after one step, after Expand all, and with the menu open, desktop light and phone dark.Shots-moved: commit, commit-merged, pull-files
Shortcomings
How long the file is goes unknown until it is read, so the arrow after the last hunk shows even when that hunk already ends the file; pressing it then reads the file, and the row goes. A file too large for
getFileto return as text says so in place of the lines.