Skip to content

feat(ui): honor transparent background in static pager output#418

Open
franky47 wants to merge 1 commit into
modem-dev:mainfrom
franky47:static-pager-transparent-bg
Open

feat(ui): honor transparent background in static pager output#418
franky47 wants to merge 1 commit into
modem-dev:mainfrom
franky47:static-pager-transparent-bg

Conversation

@franky47

Copy link
Copy Markdown

When using hunk as a pager in lazygit in a transparent-background terminal (Ghostty), the static ANSI output of the pager caused solid backgrounds on context lines and other non-diff elements:

Before

CleanShot 2026-06-11 at 22 15 08@2x

After

This change uses a similar system as the TUI to mark surfaces as transparent in the pager output, but keeps +/- background tints painted so they're easier to see visually in diffs:

CleanShot 2026-06-11 at 22 16 25@2x

When using hunk as a pager in lazygit in a transparent-background
terminal (Ghostty),
the static ANSI output of the pager caused solid backgrounds on context
lines and other non-diff elements.

This uses a similar system as the TUI to mark surfaces as transparent in
the pager output,
but keeps +/- background tints painted so they're easier to see visually
in diffs.
@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds transparent-background support to the static pager output path so that tools like LazyGit running in translucent terminals (e.g. Ghostty) no longer paint solid backgrounds on context lines, gutters, and hunk headers.

  • Adds withTransparentSurfaces in themes.ts — a sibling to the existing withTransparentBackground — that zeros out neutral surface colors (background, panel, panelAlt, contextBg, contextContentBg, lineNumberBg) while intentionally preserving addedBg, removedBg, movedAddedBg, movedRemovedBg, addedContentBg, and removedContentBg so diff rows remain visually distinct.
  • Wires the new function into renderStaticDiffPager behind the existing options.transparentBackground flag, and backs the change with integration tests that assert exact ANSI codes on both transparent and painted rows.

Confidence Score: 5/5

Safe to merge — the change is additive, isolated to theme resolution in the static pager path, and cannot affect the interactive TUI.

The new withTransparentSurfaces function is a straightforward spread-and-override of the theme struct, following the exact same pattern as the already-tested withTransparentBackground. The static pager only consumes panel, panelAlt, lineNumberBg, contextBg, addedBg, removedBg, movedAddedBg, and movedRemovedBg — all correctly handled. Tests assert specific ANSI escape codes on both transparent and painted rows, and the implementation aligns with what stackCellPalette and renderStaticRow actually read from the theme. No pre-existing paths are touched.

No files require special attention.

Important Files Changed

Filename Overview
src/ui/themes.ts Adds withTransparentSurfaces, a new theme utility that makes neutral backgrounds transparent while preserving diff-semantic tints; correctly mirrors the existing withTransparentBackground pattern.
src/ui/staticDiffPager.ts Applies withTransparentSurfaces when options.transparentBackground is true; minimal, focused change to the theme resolution step before rendering.
src/ui/staticDiffPager.test.ts New test verifies that context lines, hunk headers, and gutter carry no background ANSI codes while added/removed lines retain their expected RGB backgrounds.
src/ui/themes.test.ts New test validates withTransparentSurfaces field-by-field, checking transparent surfaces and preserved diff tints; clean and thorough.
CHANGELOG.md Documents the transparent background fix for the static pager under Fixed; entry is accurate and descriptive.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[renderStaticDiffPager] --> B[resolveTheme]
    B --> C{options.transparentBackground?}
    C -- yes --> D[withTransparentSurfaces]
    C -- no --> E[resolvedTheme as-is]
    D --> F[theme with transparent neutrals\nbackground, panel, panelAlt\ncontextBg, contextContentBg, lineNumberBg]
    D --> G[diff tints kept painted\naddedBg, removedBg\nmovedAddedBg, movedRemovedBg\naddedContentBg, removedContentBg]
    F --> H[renderStaticFile → renderStaticRow]
    G --> H
    E --> H
    H --> I{row type}
    I -- hunk-header / collapsed --> J[bg = panelAlt = transparent]
    I -- stack-line addition --> K[bg = addedBg painted]
    I -- stack-line deletion --> L[bg = removedBg painted]
    I -- stack-line context --> M[bg = contextBg = transparent]
Loading

Reviews (1): Last reviewed commit: "feat(ui): honor transparent background i..." | Re-trigger Greptile

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.

1 participant