Skip to content

fix(pager): keep Git colors in non-diff output for captured pager hosts - #703

Open
DanielCarmingham wants to merge 1 commit into
modem-dev:mainfrom
DanielCarmingham:fix/pager-captured-host-color
Open

fix(pager): keep Git colors in non-diff output for captured pager hosts#703
DanielCarmingham wants to merge 1 commit into
modem-dev:mainfrom
DanielCarmingham:fix/pager-captured-host-color

Conversation

@DanielCarmingham

Copy link
Copy Markdown

Fixes #702.

Captured pager hosts like LazyGit advertise TERM=dumb while rendering ANSI in their own panel. Hunk already knows this for diffs — isCapturedPagerHost is what routes those hosts to the static colored renderer instead of launching the TUI. Non-diff input returns passthrough before reaching that check, and passthrough stripped SGR unconditionally, so LazyGit's branch log rendered in a single color.

This reuses that same predicate rather than adding a second heuristic: the fact that already tells the diff path "this host renders ANSI" now also decides whether passthrough preserves it.

const passthroughPlan = {
  kind: "passthrough" as const,
  text: stdinText,
  preserveColor: capturedPagerHost,
};

#381 fixed the same symptom for interactive terminals via pagePlainText, but captured hosts never reach pagePlainTextTERM=dumb sends them down passthrough first.

Before / after

released 0.18.0 this branch
branch log with no color branch log with color preserved

Same repo, same commit, same terminal size — only the pager binary differs.

Verification

  • bun run typecheck clean; bun test shows an identical failure set to main on the same base (no regressions, +2 new passing tests)
  • Reverting only the source change while keeping the new tests fails 5 of them, so the tests do detect the fix
  • Real git log --graph --color=always through hunk pager: 0 → 468 escape sequences under a LazyGit environment, and still 0 for a plain TERM=dumb terminal, so genuinely dumb terminals are unaffected
  • Confirmed end to end by driving real LazyGit 0.64.0 in a PTY (screenshots above)

Captured pager hosts like LazyGit advertise TERM=dumb while rendering ANSI
in their own panel. The diff path already knew this and routed those hosts
to the static colored renderer, but non-diff input fell through to
passthrough, which stripped SGR unconditionally. LazyGit's branch log
therefore lost its per-branch palette and rendered in a single color.

Reuse the existing isCapturedPagerHost detection to decide whether
passthrough preserves ANSI style, so both paths draw the same conclusion
from one predicate instead of a second heuristic.
@greptile-apps

greptile-apps Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

@DanielCarmingham is attempting to deploy a commit to the Modem Team on Vercel.

A member of the Team first needs to authorize it.

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.

hunk pager strips Git colors from LazyGit's non-diff output (branch log)

1 participant