Skip to content

feat(themes): add themeable bgTitleBar token for the window title bar#1103

Merged
pedramamini merged 1 commit into
rcfrom
feat/theme-title-bar-color-rc
Jun 16, 2026
Merged

feat(themes): add themeable bgTitleBar token for the window title bar#1103
pedramamini merged 1 commit into
rcfrom
feat/theme-title-bar-color-rc

Conversation

@pedramamini

@pedramamini pedramamini commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

RC-targeted counterpart of #1102 (single commit cherry-picked onto rc, so this PR contains only the theme change and none of the unrelated commits that are on main but not yet on rc).

The draggable window title bar (the top strip with the traffic-light buttons and the centered agent title) rendered transparent and showed bgMain behind it. Themes had no way to color that strip independently, so on light themes it always read as the lightest color in the palette. This adds a themeable bgTitleBar token.

What changed

  • src/shared/theme-types.ts - new optional bgTitleBar? field on ThemeColors. Optional (like the ANSI keys) so pre-existing saved/imported custom themes degrade gracefully.
  • src/shared/themes.ts - set bgTitleBar on all 20 built-in themes, each mirroring its own bgMain, so every existing theme looks pixel-identical after this change.
  • src/renderer/App.tsx - wire the title bar background to bgTitleBar ?? bgMain.
  • src/renderer/components/CustomThemeBuilder.tsx - new editable "Title Bar Background" field + a title-bar strip in the live preview.
  • src/__tests__/renderer/constants/themes.test.ts - add bgTitleBar to REQUIRED_COLORS.

Backward compatibility

bgTitleBar defaults to bgMain everywhere it is unset. No theme changes appearance unless its bgTitleBar is deliberately set to something different.

Validation

  • Theme test suite: 11 pass / 0 fail
  • Touched files: 0 TypeScript errors, 0 ESLint errors

Notes

Summary by CodeRabbit

  • New Features
    • Added a customizable title bar background color to the theme builder, allowing users to independently customize the draggable window title bar appearance from the main background color.

The draggable title bar (App.tsx) rendered transparent and showed bgMain
behind it, so themes had no way to color that top strip independently.

Add an optional bgTitleBar color token:
- New optional field on ThemeColors (falls back to bgMain when unset, so
  pre-existing saved/imported custom themes are unchanged).
- Wire the title bar to bgTitleBar ?? bgMain.
- Set bgTitleBar on all 20 built-in themes, each mirroring its own bgMain,
  so every existing theme looks pixel-identical.
- Expose it as an editable field in the Custom Theme Builder, with a
  title-bar strip added to the live preview.
- Add bgTitleBar to the REQUIRED_COLORS theme test.
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new optional bgTitleBar color property to the ThemeColors interface. All built-in themes are updated to include this color (set equal to each theme's bgMain). The draggable title bar in App.tsx and the custom theme builder's preview and color editor are updated to consume bgTitleBar with a fallback to bgMain. The themes test is extended to require this new color key.

Changes

bgTitleBar Theme Color

Layer / File(s) Summary
ThemeColors type contract
src/shared/theme-types.ts
Adds optional bgTitleBar?: string to ThemeColors with JSDoc describing fallback behavior when the property is absent.
Built-in theme data population
src/shared/themes.ts
Adds bgTitleBar (equal to each theme's bgMain) to every dark, light, vibe, and custom theme entry.
Title bar rendering and custom theme builder UI
src/renderer/App.tsx, src/renderer/components/CustomThemeBuilder.tsx
App.tsx applies bgTitleBar with fallback to bgMain for the title bar background. CustomThemeBuilder registers bgTitleBar in COLOR_CONFIG, adds a title-bar strip to MiniUIPreview, and defaults the color input to bgMain when the value is missing.
Required-colors test update
src/__tests__/renderer/constants/themes.test.ts
Adds 'bgTitleBar' to REQUIRED_COLORS so the existing theme validation test also asserts its presence.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A new stripe atop the window appears,
bgTitleBar hops in, the palette cheers! 🎨
Each theme gets a matching hue assigned,
The builder preview reflects the design.
No title bar left transparent or bare —
This bunny painted color everywhere! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a themeable bgTitleBar token for window title bar styling, which is the central objective of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/theme-title-bar-color-rc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a bgTitleBar theme token that lets each built-in theme explicitly color the draggable window title bar, replacing the previous transparent/bgMain bleed-through. All 20 built-in themes set bgTitleBar equal to their own bgMain, so the visual result is pixel-identical to before unless a theme deliberately sets a different value.

  • theme-types.ts / themes.ts: bgTitleBar? added as an optional field; every built-in theme populated with its bgMain value.
  • App.tsx: title-bar backgroundColor wired to bgTitleBar ?? bgMain with a clear fallback comment.
  • CustomThemeBuilder.tsx: new color row + preview strip added, but bgTitleBar is placed in COLOR_CONFIG, which drives import validation — this inadvertently makes the field required when importing JSON files, breaking re-import of any theme file exported before this change.

Confidence Score: 3/5

Safe to merge for new installs and for users who never import custom theme files; breaks re-import of any theme JSON exported before this change.

The title-bar wiring and built-in theme updates are solid. The one flaw is that bgTitleBar lands in COLOR_CONFIG, which is also used to build the list of required keys during theme-file import. Any user who previously exported their custom theme and tries to re-import it will hit an error ("missing color keys: bgTitleBar") rather than the graceful bgMain fallback the PR promises.

src/renderer/components/CustomThemeBuilder.tsx — specifically the import validation logic at lines 382–390 where COLOR_CONFIG drives required-key enforcement.

Important Files Changed

Filename Overview
src/shared/theme-types.ts Adds optional bgTitleBar? to ThemeColors; well-documented and consistent with the ANSI optional pattern.
src/shared/themes.ts Sets bgTitleBar equal to bgMain on all 20 built-in themes; pixel-identical to pre-PR appearance.
src/renderer/App.tsx Wires backgroundColor: bgTitleBar ?? bgMain to the fixed title-bar div; fallback is correct.
src/renderer/components/CustomThemeBuilder.tsx Adds bgTitleBar to COLOR_CONFIG, which silently promotes it to a required key in import validation, breaking import of previously exported custom theme files.
src/tests/renderer/constants/themes.test.ts Adds bgTitleBar to REQUIRED_COLORS to guard built-in themes; all 20 themes now provide it so tests pass.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[App renders title bar div] --> B{theme.colors.bgTitleBar set?}
    B -- yes --> C[backgroundColor = bgTitleBar]
    B -- no / undefined --> D[backgroundColor = bgMain fallback]

    E[User imports theme JSON] --> F{bgTitleBar key present in file?}
    F -- yes --> G[Import succeeds]
    F -- no / old file --> H[❌ Validation error: missing color keys]

    I[CustomThemeBuilder display] --> J{customThemeColors.bgTitleBar set?}
    J -- yes --> K[Show actual bgTitleBar value]
    J -- no --> L[Show bgMain value as placeholder]
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[App renders title bar div] --> B{theme.colors.bgTitleBar set?}
    B -- yes --> C[backgroundColor = bgTitleBar]
    B -- no / undefined --> D[backgroundColor = bgMain fallback]

    E[User imports theme JSON] --> F{bgTitleBar key present in file?}
    F -- yes --> G[Import succeeds]
    F -- no / old file --> H[❌ Validation error: missing color keys]

    I[CustomThemeBuilder display] --> J{customThemeColors.bgTitleBar set?}
    J -- yes --> K[Show actual bgTitleBar value]
    J -- no --> L[Show bgMain value as placeholder]
Loading

Comments Outside Diff (1)

  1. src/renderer/components/CustomThemeBuilder.tsx, line 382-390 (link)

    P1 Import validation rejects old theme files that lack bgTitleBar

    COLOR_CONFIG now includes bgTitleBar, so requiredKeys (derived at line 382) requires every imported JSON to contain that key. Any custom theme that was exported before this PR ships will fail with "Invalid theme file: missing color keys (bgTitleBar)". The PR description and type definition both promise graceful degradation for pre-existing themes, but the import path doesn't honor it — a user who tries to re-import their saved theme file will see a validation error instead of the expected bgMain fallback.

Reviews (1): Last reviewed commit: "feat(themes): add themeable bgTitleBar t..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/renderer/components/CustomThemeBuilder.tsx`:
- Line 40: The addition of bgTitleBar to COLOR_CONFIG makes it a required key
during theme import validation, which breaks compatibility with older exported
theme files that lack this field. Modify the handleImport function to treat
bgTitleBar as optional during validation (do not enforce it as a required key
derived from COLOR_CONFIG), and add logic to synthesize bgTitleBar from bgMain
when the imported theme object does not include a bgTitleBar value, ensuring
backward compatibility with pre-bgTitleBar theme files.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 836f2d7c-d458-420d-a55c-f4b6bd2fbdc3

📥 Commits

Reviewing files that changed from the base of the PR and between b176813 and 2c54355.

📒 Files selected for processing (5)
  • src/__tests__/renderer/constants/themes.test.ts
  • src/renderer/App.tsx
  • src/renderer/components/CustomThemeBuilder.tsx
  • src/shared/theme-types.ts
  • src/shared/themes.ts

{ key: 'bgMain', label: 'Main Background', description: 'Primary content area' },
{ key: 'bgSidebar', label: 'Sidebar Background', description: 'Left & right panels' },
{ key: 'bgActivity', label: 'Activity Background', description: 'Hover, active states' },
{ key: 'bgTitleBar', label: 'Title Bar Background', description: 'Top draggable window strip' },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Preserve import compatibility for pre-bgTitleBar theme files.

Adding bgTitleBar to COLOR_CONFIG also makes it required by handleImport (because required keys are derived from COLOR_CONFIG). That rejects older exported custom themes lacking this optional token. Keep bgTitleBar optional in import validation and synthesize it from bgMain when absent.

Suggested fix
-						// Validate all required color keys exist
-						const requiredKeys = COLOR_CONFIG.map((c) => c.key);
+						// Validate required keys (keep bgTitleBar backward-compatible/optional)
+						const requiredKeys = COLOR_CONFIG
+							.map((c) => c.key)
+							.filter((k) => k !== 'bgTitleBar');
 						const hasAllKeys = requiredKeys.every((key) => key in data.colors);
@@
-						// Validate all color values are valid CSS colors
-						const invalidColors = requiredKeys.filter((key) => !isValidColor(data.colors[key]));
+						// Validate all required color values; validate bgTitleBar only when provided
+						const keysToValidate: (keyof ThemeColors)[] =
+							'bgTitleBar' in data.colors
+								? [...requiredKeys, 'bgTitleBar']
+								: requiredKeys;
+						const invalidColors = keysToValidate.filter((key) => !isValidColor(data.colors[key]));
@@
-						// All validations passed - apply the theme
-						setCustomThemeColors(data.colors);
+						// All validations passed - apply normalized theme
+						const normalizedColors: ThemeColors = {
+							...data.colors,
+							bgTitleBar: data.colors.bgTitleBar ?? data.colors.bgMain,
+						};
+						setCustomThemeColors(normalizedColors);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{ key: 'bgTitleBar', label: 'Title Bar Background', description: 'Top draggable window strip' },
// Validate required keys (keep bgTitleBar backward-compatible/optional)
const requiredKeys = COLOR_CONFIG
.map((c) => c.key)
.filter((k) => k !== 'bgTitleBar');
const hasAllKeys = requiredKeys.every((key) => key in data.colors);
// Validate all required color values; validate bgTitleBar only when provided
const keysToValidate: (keyof ThemeColors)[] =
'bgTitleBar' in data.colors
? [...requiredKeys, 'bgTitleBar']
: requiredKeys;
const invalidColors = keysToValidate.filter((key) => !isValidColor(data.colors[key]));
// All validations passed - apply normalized theme
const normalizedColors: ThemeColors = {
...data.colors,
bgTitleBar: data.colors.bgTitleBar ?? data.colors.bgMain,
};
setCustomThemeColors(normalizedColors);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/renderer/components/CustomThemeBuilder.tsx` at line 40, The addition of
bgTitleBar to COLOR_CONFIG makes it a required key during theme import
validation, which breaks compatibility with older exported theme files that lack
this field. Modify the handleImport function to treat bgTitleBar as optional
during validation (do not enforce it as a required key derived from
COLOR_CONFIG), and add logic to synthesize bgTitleBar from bgMain when the
imported theme object does not include a bgTitleBar value, ensuring backward
compatibility with pre-bgTitleBar theme files.

@pedramamini
pedramamini merged commit 8113b29 into rc Jun 16, 2026
4 of 5 checks passed
@pedramamini
pedramamini deleted the feat/theme-title-bar-color-rc branch June 16, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant