feat: allow transparent background via config or flag#322
Conversation
Greptile SummaryAdds an opt-in
Confidence Score: 3/5Safe to merge for users who leave transparent mode off; the default path is unchanged. Enabling transparent mode will render word-diff highlight spans as dark opaque blocks. The transparent path in wordDiffHighlightBg computes backgrounds by passing the string 'transparent' into hexToRgb, which silently falls back to black. Every word-diff emphasis span gets a dark opaque color instead of transparent whenever the feature is used, directly breaking the feature's core promise for syntax-highlighted content. src/ui/diff/pierre.ts — the wordDiffHighlightBg function needs a guard for 'transparent' backgrounds before the hex-distance computation runs. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[CLI --transparent-background] --> B[parseCli transparentBackground: true]
C[config.toml transparent_background = true] --> D[readConfigPreferences]
D --> E[mergeOptions]
B --> E
E --> F[resolvedOptions.transparentBackground]
F --> G[bootstrap.input.options.transparentBackground]
G --> H{transparent?}
H -- yes --> I[withTransparentBackground baseTheme]
H -- no --> J[baseTheme unchanged]
I --> K[activeTheme all bg = transparent]
J --> K2[activeTheme normal hex colors]
K --> L[pierre.ts wordDiffHighlightBg]
K2 --> L
L --> M{addedBg === transparent?}
M -- yes --> N[return transparent - fix needed]
M -- no --> O[hexColorDistance + strengthen normal hex path]
|
so terminal/IDE themes show through. Adds a `--transparent` CLI flag and a `transparent_background` config key. When set, the diff theme omits the background color and uses the terminal default. Fixes modem-dev#245
9257566 to
b69a607
Compare
Summary
Adds an opt-in transparent-background mode for the diff UI. Users can pass
--transparenton the command line or settransparent_background = truein their config. When enabled, the diff theme omits the background fill so terminal or IDE theming shows through.Why this matters
#245 wanted hunk's output to blend with their terminal color scheme rather than re-stating a hard-coded background. This change is opt-in and keeps the default rendering untouched.
Changes
src/core/cli.ts+src/core/cli.test.ts- new--transparentflag.src/core/config.ts+src/core/config.test.ts- newtransparent_backgroundconfig key.src/core/types.ts- thread the option through the config type.src/ui/App.tsx- read the option and apply it to the diff theme.src/ui/themes.ts+src/ui/themes.test.ts- theme variant that drops the background fill.src/ui/diff/pierre.ts- omit the background ink when the theme says so.README.md+CHANGELOG.md- document the new option.Testing
New unit tests cover the flag, the config key, and the transparent theme. Existing tests still pass.
Fixes #245