From f40ec551fa14207f68d5f62b52c7178c53464cfa Mon Sep 17 00:00:00 2001 From: sunanmau5 Date: Fri, 3 Jul 2026 19:54:25 +0200 Subject: [PATCH] fix: preserve transparent TUI diff row tints --- .changeset/transparent-tui-diff-tints.md | 5 ++++ src/ui/App.tsx | 4 +-- src/ui/AppHost.interactions.test.tsx | 34 ++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 .changeset/transparent-tui-diff-tints.md diff --git a/.changeset/transparent-tui-diff-tints.md b/.changeset/transparent-tui-diff-tints.md new file mode 100644 index 00000000..7b3cfb2c --- /dev/null +++ b/.changeset/transparent-tui-diff-tints.md @@ -0,0 +1,5 @@ +--- +"hunkdiff": patch +--- + +Preserve added and removed diff row tints when transparent background mode is enabled in the interactive TUI. diff --git a/src/ui/App.tsx b/src/ui/App.tsx index 8b5b0985..63f8225a 100644 --- a/src/ui/App.tsx +++ b/src/ui/App.tsx @@ -28,7 +28,7 @@ import { fileRowId } from "./lib/ids"; import { openSelectedFileInEditor } from "./lib/openInEditor"; import { resolveResponsiveLayout } from "./lib/responsive"; import { resizeSidebarWidth } from "./lib/sidebar"; -import { availableThemes, resolveTheme, withTransparentBackground } from "./themes"; +import { availableThemes, resolveTheme, withTransparentSurfaces } from "./themes"; type FocusArea = "files" | "filter" | "note"; type ActiveAddNoteTarget = ActiveAddNoteAffordance & { fileId: string }; @@ -166,7 +166,7 @@ export function App({ const activeTheme = useMemo( () => bootstrap.input.options.transparentBackground - ? withTransparentBackground(baseTheme) + ? withTransparentSurfaces(baseTheme) : baseTheme, [baseTheme, bootstrap.input.options.transparentBackground], ); diff --git a/src/ui/AppHost.interactions.test.tsx b/src/ui/AppHost.interactions.test.tsx index cb5adda1..94daad81 100644 --- a/src/ui/AppHost.interactions.test.tsx +++ b/src/ui/AppHost.interactions.test.tsx @@ -2752,6 +2752,40 @@ describe("App interactions", () => { } }); + test("transparent background keeps added and removed diff row tints", async () => { + const bootstrap = createBootstrap(); + bootstrap.input.options.transparentBackground = true; + const theme = resolveTheme(bootstrap.initialTheme, null); + const setup = await testRender(, { + width: 220, + height: 60, + }); + + try { + await flush(setup); + + const frame = setup.captureSpans(); + const lineIncludesBackground = (text: string, backgroundColor: string) => + frame.lines.some((line) => { + const lineText = line.spans.map((span) => span.text).join(""); + return ( + lineText.includes(text) && + line.spans.some( + (span) => + capturedTestColorToHex(span.bg)?.toLowerCase() === backgroundColor.toLowerCase(), + ) + ); + }); + + expect(lineIncludesBackground("betaValue", theme.addedBg)).toBe(true); + expect(lineIncludesBackground("beta = 1", theme.removedBg)).toBe(true); + } finally { + await act(async () => { + setup.renderer.destroy(); + }); + } + }); + test("draft note focus suppresses app shortcuts while accepting typed shortcut keys", async () => { const setup = await testRender(, { width: 240,