[Diff] Add the external diff pager package - #51
Merged
Conversation
This was referenced Jul 26, 2026
KCaverly
force-pushed
the
ct/diff_view/6ff42d48
branch
from
July 26, 2026 19:24
83c8655 to
7309fed
Compare
KCaverly
force-pushed
the
ct/diff_view/ecdcdaf3
branch
from
July 26, 2026 19:24
bf58975 to
f171fc0
Compare
KCaverly
force-pushed
the
ct/diff_view/6ff42d48
branch
from
July 26, 2026 19:30
7309fed to
ad1aca8
Compare
KCaverly
force-pushed
the
ct/diff_view/ecdcdaf3
branch
from
July 26, 2026 19:31
f171fc0 to
22ec827
Compare
KCaverly
force-pushed
the
ct/diff_view/6ff42d48
branch
from
July 26, 2026 19:34
ad1aca8 to
53a423d
Compare
KCaverly
force-pushed
the
ct/diff_view/ecdcdaf3
branch
from
July 26, 2026 19:34
22ec827 to
28be7c0
Compare
KCaverly
force-pushed
the
ct/diff_view/6ff42d48
branch
from
July 26, 2026 19:40
53a423d to
136b45f
Compare
KCaverly
force-pushed
the
ct/diff_view/ecdcdaf3
branch
from
July 26, 2026 19:40
28be7c0 to
e95e5f5
Compare
KCaverly
force-pushed
the
ct/diff_view/6ff42d48
branch
from
July 26, 2026 19:41
136b45f to
ca09a8e
Compare
KCaverly
force-pushed
the
ct/diff_view/ecdcdaf3
branch
from
July 26, 2026 19:41
e95e5f5 to
a8efe62
Compare
KCaverly
force-pushed
the
ct/diff_view/6ff42d48
branch
from
July 26, 2026 20:27
ca09a8e to
9aefdf5
Compare
KCaverly
force-pushed
the
ct/diff_view/ecdcdaf3
branch
from
July 26, 2026 20:27
a8efe62 to
73c72f3
Compare
diffpager pipes each file's patch through an external formatter (delta, diff-so-fancy, bat) while ct keeps ownership of scrolling and keybindings. A zero-value Pager is inert, so the default stays ct's built-in styling. The body is split on `diff --git` boundaries and each file rendered as its own Chunk, which is what preserves the viewer's file-jump index. Headers are matched against ANSI-stripped text so a user running --color=always does not collapse the whole patch into one chunk and lose that index. Rendering is all-or-nothing: the caller's fallback is to re-render with ct's built-in styling, and a half-formatted patch would be worse than either. Chunks render concurrently under a worker cap, since a 40-file diff spawning processes serially would cost 40x a single process's latency on the fetch path. A 30s timeout bounds the whole call so a formatter that hangs cannot strand the fetch goroutine, and the first failure cancels the rest rather than waiting out the budget. cmd.Dir is set to the repo so a formatter reading .gitattributes or git config sees the right repo, and COLUMNS is set because several formatters size their output from it when stdout is not a terminal — which, piped into a Builder, it never is. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> ct-stack-id: ecdcdaf3
KCaverly
force-pushed
the
ct/diff_view/ecdcdaf3
branch
from
July 26, 2026 20:32
73c72f3 to
327de85
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
diffpager pipes each file's patch through an external formatter (delta,
diff-so-fancy, bat) while ct keeps ownership of scrolling and keybindings.
A zero-value Pager is inert, so the default stays ct's built-in styling.
The body is split on
diff --gitboundaries and each file rendered as itsown Chunk, which is what preserves the viewer's file-jump index. Headers
are matched against ANSI-stripped text so a user running --color=always
does not collapse the whole patch into one chunk and lose that index.
Rendering is all-or-nothing: the caller's fallback is to re-render with
ct's built-in styling, and a half-formatted patch would be worse than
either. Chunks render concurrently under a worker cap, since a 40-file
diff spawning processes serially would cost 40x a single process's
latency on the fetch path. A 30s timeout bounds the whole call so a
formatter that hangs cannot strand the fetch goroutine, and the first
failure cancels the rest rather than waiting out the budget.
cmd.Dir is set to the repo so a formatter reading .gitattributes or git
config sees the right repo, and COLUMNS is set because several formatters
size their output from it when stdout is not a terminal — which, piped
into a Builder, it never is.
Co-Authored-By: Claude Opus 5 noreply@anthropic.com
Stack (bottom → top):