Skip to content

fix(cli): honor custom theme border.default when terminal reports OSC 11 background#27887

Open
KirtiRamchandani wants to merge 1 commit into
google-gemini:mainfrom
KirtiRamchandani:fix/custom-theme-border-colors
Open

fix(cli): honor custom theme border.default when terminal reports OSC 11 background#27887
KirtiRamchandani wants to merge 1 commit into
google-gemini:mainfrom
KirtiRamchandani:fix/custom-theme-border-colors

Conversation

@KirtiRamchandani

Copy link
Copy Markdown

Summary

Makes documented custom theme border colors actually apply, including on terminals that report background color via OSC 11.

Fixes #27786

Problem

docs/cli/themes.md documents border.default (and border.focused), but two code paths prevented custom border colors from sticking:

  1. createCustomTheme() ignored border.defaultsemanticColors.border.default always came from computed DarkGray.
  2. ThemeManager.getColors() always recomputed DarkGray when OSC 11 background was detected, even if the user explicitly configured border colors. That override flowed into getSemanticColors() via border.default.

Additionally, when loading settings themes, DEFAULT_THEME.colors is merged in first. That injects a default DarkGray which previously took precedence over a user-provided border.default.

Root cause

// border.default never read
DarkGray: customTheme.DarkGray ?? interpolateColor(...)

// terminal background always wins
DarkGray: interpolateColor(terminalBackground, colors.Gray, DEFAULT_BORDER_OPACITY)

Fix

  1. createCustomTheme()

    • Resolve border.default and use it before fallback interpolation.
    • Prefer border.default over merged-in default DarkGray.
    • Track whether the user explicitly configured border colors.
  2. ThemeManager

    • Detect user-specified border config before default merge (border.default or DarkGray in the raw settings entry).
    • Pass hasExplicitBorderColor into createCustomTheme().
    • Skip terminal-background recomputation of DarkGray when the user explicitly set border colors.
  3. Tests

    • border.default maps to colors.DarkGray and semanticColors.border.default.
    • Custom theme with border.default: '#282c34' keeps that color after setTerminalBackground('#282c34').

Testing

cd packages/cli && npx vitest run src/ui/themes/theme.test.ts src/ui/themes/theme-manager.test.ts
# 41 passed

@KirtiRamchandani KirtiRamchandani requested a review from a team as a code owner June 13, 2026 16:57
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where custom theme border colors were being ignored or overwritten by terminal background color detection. By introducing explicit tracking for user-defined border colors and updating the theme creation logic, the system now correctly honors custom border.default settings even when the terminal reports its background color dynamically.

Highlights

  • Custom Border Color Resolution: Updated createCustomTheme to correctly prioritize and resolve border.default from custom theme configurations before falling back to default interpolation.
  • Explicit Border Tracking: Introduced a hasExplicitBorderColor flag to track whether a user has manually configured border colors, preventing the ThemeManager from overriding these values when the terminal reports a background color via OSC 11.
  • Refactored Theme Configuration: Centralized theme configuration logic into buildCustomThemeConfig to ensure consistent merging of default values and user-provided settings.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added the size/m A medium sized PR label Jun 13, 2026
@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown

📊 PR Size: size/M

  • Lines changed: 131
  • Additions: +103
  • Deletions: -28
  • Files changed: 4

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces changes to preserve explicit custom border colors when a terminal background is set, refactoring custom theme creation and caching to track whether a theme has an explicit border color. The reviewer identified an inconsistency in the precedence of explicitBorderDefault and customTheme.DarkGray when resolving colors.DarkGray versus semanticColors.border.default, and suggested a fix to ensure consistent behavior.

Comment thread packages/cli/src/ui/themes/theme.ts Outdated
},
border: {
default: colors.DarkGray,
default: customTheme.DarkGray ?? explicitBorderDefault ?? colors.DarkGray,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

There is an inconsistency in how border.default is resolved.

In colors.DarkGray (lines 424-431), explicitBorderDefault takes precedence over customTheme.DarkGray:

    DarkGray:
      explicitBorderDefault ??
      customTheme.DarkGray ??
      ...

However, in semanticColors.border.default (line 611), customTheme.DarkGray takes precedence over explicitBorderDefault:

    border: {
      default: customTheme.DarkGray ?? explicitBorderDefault ?? colors.DarkGray,
    },

If a user configures both border.default and DarkGray in their custom theme, this inconsistency causes the border color to change depending on whether the terminal background is detected/set (since ThemeManager.getSemanticColors() overwrites border.default with colors.DarkGray when a terminal background is active).

To ensure consistent behavior, explicitBorderDefault should take precedence in both places.

Suggested change
default: customTheme.DarkGray ?? explicitBorderDefault ?? colors.DarkGray,
default: explicitBorderDefault ?? customTheme.DarkGray ?? colors.DarkGray,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 3627886semanticColors.border.default now uses explicitBorderDefault ?? customTheme.DarkGray ?? colors.DarkGray, matching the colors.DarkGray precedence.

@KirtiRamchandani KirtiRamchandani force-pushed the fix/custom-theme-border-colors branch from 7cde408 to 3627886 Compare June 13, 2026 17:25
@gemini-cli gemini-cli Bot added priority/p2 Important but can be addressed in a future release. area/core Issues related to User Interface, OS Support, Core Functionality labels Jun 13, 2026
… 11 background

fix(cli): honor custom theme border.default under OSC 11;fix(cli): align border.default precedence in semantic colors
@KirtiRamchandani KirtiRamchandani force-pushed the fix/custom-theme-border-colors branch from 3627886 to a7377c3 Compare June 14, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality priority/p2 Important but can be addressed in a future release. size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom theme border.default/border.focused are documented but ignored; explicit DarkGray is overridden when terminal background is detected

1 participant