diff --git a/.changeset/remove-transparent-background-helper.md b/.changeset/remove-transparent-background-helper.md new file mode 100644 index 00000000..a845151c --- /dev/null +++ b/.changeset/remove-transparent-background-helper.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/src/ui/diff/pierre.test.ts b/src/ui/diff/pierre.test.ts index a315e823..b4d56614 100644 --- a/src/ui/diff/pierre.test.ts +++ b/src/ui/diff/pierre.test.ts @@ -14,7 +14,7 @@ import { renderCodeOnlyPlannedRowText, renderDecoratedPlannedRowText } from "./r import { stackCellPalette } from "./rowStyle"; import { buildReviewRenderPlan } from "./reviewRenderPlan"; import { measureTextWidth } from "../lib/text"; -import { TRANSPARENT_BACKGROUND, resolveTheme, withTransparentBackground } from "../themes"; +import { TRANSPARENT_BACKGROUND, resolveTheme } from "../themes"; function createDiffFile(): DiffFile { const metadata = parseDiffFromFile( @@ -147,9 +147,17 @@ describe("Pierre diff rows", () => { ).toBe(true); }); - test("keeps word-diff highlight backgrounds transparent in transparent mode", async () => { + test("keeps word-diff highlight backgrounds transparent when a theme uses transparent tints", async () => { const file = createDiffFile(); - const theme = withTransparentBackground(resolveTheme("github-dark-default", null)); + // Custom themes may declare "transparent" row/content tints; the renderer must not feed + // them into blend math and turn them into black backgrounds. + const theme = { + ...resolveTheme("github-dark-default", null), + addedBg: TRANSPARENT_BACKGROUND, + removedBg: TRANSPARENT_BACKGROUND, + addedContentBg: TRANSPARENT_BACKGROUND, + removedContentBg: TRANSPARENT_BACKGROUND, + }; const highlighted = await loadHighlightedDiff(file); const rows = buildSplitRows(file, highlighted, theme); const changedRow = rows.find( diff --git a/src/ui/themes.test.ts b/src/ui/themes.test.ts index 2d72a32d..355c9d3a 100644 --- a/src/ui/themes.test.ts +++ b/src/ui/themes.test.ts @@ -8,7 +8,6 @@ import { DEFAULT_LIGHT_THEME_ID, resolveTheme, TRANSPARENT_BACKGROUND, - withTransparentBackground, withTransparentSurfaces, } from "./themes"; @@ -247,35 +246,6 @@ describe("themes", () => { expect(custom.syntaxColors.keyword).toBe("#ff00ff"); }); - test("withTransparentBackground only swaps painted background fields", () => { - const theme = resolveTheme("github-dark-default", null); - const transparent = withTransparentBackground(theme); - - expect(transparent).toMatchObject({ - background: TRANSPARENT_BACKGROUND, - panel: TRANSPARENT_BACKGROUND, - panelAlt: TRANSPARENT_BACKGROUND, - addedBg: TRANSPARENT_BACKGROUND, - removedBg: TRANSPARENT_BACKGROUND, - contextBg: TRANSPARENT_BACKGROUND, - addedContentBg: TRANSPARENT_BACKGROUND, - removedContentBg: TRANSPARENT_BACKGROUND, - contextContentBg: TRANSPARENT_BACKGROUND, - lineNumberBg: TRANSPARENT_BACKGROUND, - selectedHunk: TRANSPARENT_BACKGROUND, - noteBackground: TRANSPARENT_BACKGROUND, - noteTitleBackground: TRANSPARENT_BACKGROUND, - }); - expect(transparent.id).toBe(theme.id); - expect(transparent.label).toBe(theme.label); - expect(transparent.text).toBe(theme.text); - expect(transparent.muted).toBe(theme.muted); - expect(transparent.addedSignColor).toBe(theme.addedSignColor); - expect(transparent.removedSignColor).toBe(theme.removedSignColor); - expect(transparent.syntaxColors).toBe(theme.syntaxColors); - expect(theme.background).not.toBe(TRANSPARENT_BACKGROUND); - }); - test("withTransparentSurfaces keeps added/removed row tints", () => { const theme = resolveTheme("github-dark-default", null); const transparent = withTransparentSurfaces(theme); diff --git a/src/ui/themes.ts b/src/ui/themes.ts index 78a91864..29126738 100644 --- a/src/ui/themes.ts +++ b/src/ui/themes.ts @@ -352,30 +352,10 @@ export function bundledThemeDiffColors(themeId: string): BundledShikiThemeDiffCo return getBundledShikiThemeDiffColors(themeId); } -/** Return a copy of a theme whose painted surfaces allow the terminal background through. */ -export function withTransparentBackground(theme: AppTheme): AppTheme { - return { - ...theme, - background: TRANSPARENT_BACKGROUND, - panel: TRANSPARENT_BACKGROUND, - panelAlt: TRANSPARENT_BACKGROUND, - addedBg: TRANSPARENT_BACKGROUND, - removedBg: TRANSPARENT_BACKGROUND, - contextBg: TRANSPARENT_BACKGROUND, - addedContentBg: TRANSPARENT_BACKGROUND, - removedContentBg: TRANSPARENT_BACKGROUND, - contextContentBg: TRANSPARENT_BACKGROUND, - lineNumberBg: TRANSPARENT_BACKGROUND, - selectedHunk: TRANSPARENT_BACKGROUND, - noteBackground: TRANSPARENT_BACKGROUND, - noteTitleBackground: TRANSPARENT_BACKGROUND, - }; -} - /** * Return a copy of a theme whose neutral surfaces allow the terminal background through while - * added/removed row tints stay painted. Static pager hosts use this so diff rows keep their - * semantic backgrounds on translucent terminals. + * added/removed row tints stay painted. Both the interactive TUI and static pager hosts use + * this so diff rows keep their semantic backgrounds on translucent terminals. */ export function withTransparentSurfaces(theme: AppTheme): AppTheme { return {