Skip to content

fix(pager): extend row backgrounds to host edge - #571

Merged
benvinegar merged 1 commit into
mainfrom
fix/static-pager-row-backgrounds
Jul 18, 2026
Merged

fix(pager): extend row backgrounds to host edge#571
benvinegar merged 1 commit into
mainfrom
fix/static-pager-row-backgrounds

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Summary

  • Extend static stacked diff-row backgrounds to the host panel edge with ANSI Erase in Line while the semantic row background is active.
  • Let hosts such as LazyGit determine the actual line boundary instead of padding to a guessed width.
  • Add regression coverage for added and removed rows plus a patch Changeset.

Closes #562.

Testing

  • bun run typecheck
  • bun run lint
  • bun test src/ui/staticDiffPager.test.ts (12 passed)
  • bun test ./src ./packages ./scripts ./test/cli ./test/session (1,182 passed, 5 skipped)
  • bun run test:tty-smoke (9 passed)
  • Manual side-by-side verification in LazyGit 0.62.1 against origin/main
  • bun run test:integration (54 passed, 1 unrelated watch-mode failure reproduced on origin/main)

This PR description was generated by Pi using OpenAI GPT-5.3 Codex

@greptile-apps

greptile-apps Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a visual bug in the static diff pager where colored row backgrounds (for added/removed lines) were truncated at the last character rather than extending to the host panel edge. The fix introduces a fillRemainingLine helper that emits an ANSI Erase-in-Line (\x1b[K) sequence after the row content so the terminal itself handles the fill width — no column-width guessing needed.

  • fillRemainingLine(bg) is appended at the end of every stack-line row in renderStaticStackRow, gated on a valid hex background color so unchanged/transparent rows emit nothing.
  • The stripColorSgr test helper is renamed to stripIntentionalAnsi and updated to also strip \x1b[K; a dedicated regression test asserts the fill sequence appears at the end of every changed line.

Confidence Score: 5/5

Safe to merge — the change is a minimal, well-scoped addition to the static stack renderer with no impact on the interactive TUI path or split mode.

The fill is correctly gated on a valid hex color so rows without a background emit nothing. The RESET after EL prevents bleed to the next line. Security tests were updated to strip the newly intentional \x1b[K before checking for unsafe controls, and the renamed helper's regex is accurate. The new regression test directly asserts the expected byte sequence on both the added and removed lines.

No files require special attention.

Important Files Changed

Filename Overview
src/ui/staticDiffPager.ts Adds fillRemainingLine helper and appends it to stack-line rows; implementation is clean and correctly gated on a valid hex background color.
src/ui/staticDiffPager.test.ts Renames stripColorSgr to stripIntentionalAnsi (regex now also covers \x1b[K) and adds a regression test asserting the background-fill pattern on both changed lines.
.changeset/fill-static-pager-rows.md Patch-level changeset entry for the hunkdiff package — correct version bump category.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[renderStaticStackRow] --> B{row.type?}
    B -->|collapsed| C[renderHeaderLikeRow
theme.panelAlt bg]
    B -->|hunk-header| D[renderHeaderLikeRow
theme.panelAlt bg]
    B -->|stack-line| E[stackCellPalette
resolve colors]
    E --> F[colorText marker]
    F --> G[colorText gutter]
    G --> H[serializeSpans
with contentBg]
    H --> I[fillRemainingLine
contentBg]
    I --> J{ansiColor valid?}
    J -->|yes - non-empty hex| K[emit background + EL + RESET
Extends bg to host panel edge]
    J -->|no - empty/transparent| L[emit empty string
no fill]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[renderStaticStackRow] --> B{row.type?}
    B -->|collapsed| C[renderHeaderLikeRow
theme.panelAlt bg]
    B -->|hunk-header| D[renderHeaderLikeRow
theme.panelAlt bg]
    B -->|stack-line| E[stackCellPalette
resolve colors]
    E --> F[colorText marker]
    F --> G[colorText gutter]
    G --> H[serializeSpans
with contentBg]
    H --> I[fillRemainingLine
contentBg]
    I --> J{ansiColor valid?}
    J -->|yes - non-empty hex| K[emit background + EL + RESET
Extends bg to host panel edge]
    J -->|no - empty/transparent| L[emit empty string
no fill]
Loading

Reviews (1): Last reviewed commit: "fix(pager): extend row backgrounds to ho..." | Re-trigger Greptile

@benvinegar
benvinegar merged commit 8888b2d into main Jul 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant