feat(ui): Transparent Background#246
Conversation
…rk and light themes
Greptile SummaryThis PR adds transparent background support and automatic light/dark theme switching based on system preferences. It introduces
Confidence Score: 3/5The transparent-bg default is inverted in App.tsx, causing the UI to start in transparent mode in any bootstrap path that leaves the field unset. The inverted src/ui/App.tsx (inverted default), src/ui/lib/color.ts (black fallback in blendHex), src/ui/themes.ts (null themeMode resolution) Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User Config / CLI flags] -->|themeLight, themeDark, transparentBg| B[config.ts mergeOptions]
B --> C[loadAppBootstrap]
C -->|initialThemeMode| D{usesPipedPatchInput?}
D -->|yes| E[detectSystemThemeMode\nmacOS only]
D -->|no| F[renderer.themeMode\nfrom terminal]
E --> G[App.tsx useState]
F --> G
G --> H{themeId === 'auto'?}
H -->|yes| I[resolveTheme with\nsystemThemeMode +\nthemeLight/themeDark]
H -->|no| J[resolveTheme with\nexplicit themeId]
I --> K{transparentBg?}
J --> K
K -->|true| L[Strip background/panel\nfields from theme]
K -->|false| M[Use theme as-is]
L --> N[Render UI]
M --> N
Prompt To Fix All With AIFix the following 3 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 3
src/ui/App.tsx:122
**Transparent-bg default is inverted vs. every other layer**
The `useState` fallback here uses `?? true`, but every other definition of this option — `DEFAULT_VIEW_PREFERENCES.transparentBg`, the `config.ts` merge/resolution logic, `loadAppBootstrap`'s `input.options.transparentBg ?? false`, and the README example — all default to `false`. Any code path that constructs an `AppBootstrap` without explicitly setting `initialTransparentBg` (e.g., unit tests or shallow mounts) will incorrectly start in transparent mode instead of opaque mode.
```suggestion
const [transparentBg, _setTransparentBg] = useState(bootstrap.initialTransparentBg ?? false);
```
### Issue 2 of 3
src/ui/lib/color.ts:20-21
**Transparent-bg blends toward black regardless of terminal background**
When `transparentBg` is enabled the theme fields `background`, `panel`, `panelAlt`, `contextBg`, `contextContentBg`, and `lineNumberBg` are set to `undefined`. Any caller that passes one of those fields to `blendHex` will now blend the foreground color toward `#000000` (hardcoded fallback). On a light terminal this produces a perceptually wrong result — text that should appear slightly lightened ends up darkened toward black instead. Blending should either be skipped when `bg` is `undefined`, or the caller should guard against it.
### Issue 3 of 3
src/ui/themes.ts:290-296
**`resolveTheme("auto", null)` silently resolves to the dark theme**
When `themeMode` is `null` (unknown) and the requested theme is `"auto"`, the expression `themeMode === "light" ? themeLight : themeDark` evaluates to `themeDark` because `null !== "light"`. This means any caller that passes `null` will always receive the dark-mode fallback when `"auto"` is requested, even in contexts where the correct fallback should be light or neutral. A three-way check (`themeMode === "dark" ? themeDark : themeLight`) or an explicit `null` case would be safer.
Reviews (1): Last reviewed commit: "feat(ui): transparent background" | Re-trigger Greptile |
Currently depends on #241 but it's not difficult to separate if it's not getting merged.
closes #245