diff --git a/src/renderer/src/app-shell/use-document-appearance.ts b/src/renderer/src/app-shell/use-document-appearance.ts index 5b3aefb47e56..3b7eff543143 100644 --- a/src/renderer/src/app-shell/use-document-appearance.ts +++ b/src/renderer/src/app-shell/use-document-appearance.ts @@ -3,6 +3,7 @@ import { useShallow } from 'zustand/react/shallow' import { buildAppFontFamily } from '@/lib/app-font-family' import { applyCodeFontSmoothing } from '@/lib/code-font-smoothing' import { applyMarkdownCodeFontFamily } from '@/lib/markdown-code-font' +import { useSplitDividerSetting } from '@/hooks/use-split-divider-setting' import { rebuildAllTerminalWebglRenderers } from '@/lib/pane-manager/pane-manager-registry' import { applyDocumentTheme, applyPluginAppTheme } from '../lib/document-theme' import { applyThemeBackground } from '../lib/theme-background' @@ -82,6 +83,7 @@ export function useDocumentAppearance(): void { const ready = matchTerminal || pluginThemesLoaded usePluginTerminalPaletteRefresh() usePluginAppThemeSync() + useSplitDividerSetting() const appFontFamily = useAppStore((s) => s.settings?.appFontFamily) const codeFontSmoothing = useAppStore((s) => s.settings?.codeFontSmoothing) const editorFontFamily = useAppStore((s) => s.settings?.editorFontFamily) diff --git a/src/renderer/src/assets/main.css b/src/renderer/src/assets/main.css index cb98881ad362..a27de1608ab7 100644 --- a/src/renderer/src/assets/main.css +++ b/src/renderer/src/assets/main.css @@ -1024,7 +1024,8 @@ html.native-shell .app-layout { content: ''; position: absolute; border-radius: 1px; - background: var(--split-divider); + /* Set only when Settings changed the divider color from its default. */ + background: var(--split-divider-setting, var(--split-divider)); transition: background 100ms ease; } diff --git a/src/renderer/src/hooks/use-split-divider-setting.ts b/src/renderer/src/hooks/use-split-divider-setting.ts new file mode 100644 index 000000000000..877e0bae685a --- /dev/null +++ b/src/renderer/src/hooks/use-split-divider-setting.ts @@ -0,0 +1,30 @@ +import { useEffect } from 'react' +import { useAppStore } from '@/store' +import { useSystemPrefersDark } from '@/components/terminal-pane/use-system-prefers-dark' +import { DEFAULT_TERMINAL_DIVIDER_DARK, DEFAULT_TERMINAL_DIVIDER_LIGHT } from '@/lib/terminal-theme' +import { selectTerminalTheme } from '../../../shared/terminal-theme-selection' + +/** + * A divider color changed from its default also paints tab-group splits, above any theme token; + * the default stays unset so the built-in 3:1 split color (or the theme's) shows. + */ +export function useSplitDividerSetting(): void { + const systemPrefersDark = useSystemPrefersDark() + // Why the terminal's variant, not the app mode: it is the one field Settings shows, and the one panes paint. + const light = useAppStore((s) => + s.settings ? selectTerminalTheme(s.settings, systemPrefersDark).useLightVariant : false + ) + const color = useAppStore((s) => + light ? s.settings?.terminalDividerColorLight : s.settings?.terminalDividerColorDark + ) + useEffect(() => { + const style = document.documentElement.style + const value = color?.trim() + const fallback = light ? DEFAULT_TERMINAL_DIVIDER_LIGHT : DEFAULT_TERMINAL_DIVIDER_DARK + if (value && value.toLowerCase() !== fallback && CSS.supports('color', value)) { + style.setProperty('--split-divider-setting', value) + } else { + style.removeProperty('--split-divider-setting') + } + }, [color, light]) +} diff --git a/src/renderer/src/lib/terminal-theme.ts b/src/renderer/src/lib/terminal-theme.ts index 5a597e12446d..80f766b29e7e 100644 --- a/src/renderer/src/lib/terminal-theme.ts +++ b/src/renderer/src/lib/terminal-theme.ts @@ -21,7 +21,7 @@ export const BUILTIN_TERMINAL_THEME_NAMES = getThemeNames() export { DEFAULT_TERMINAL_THEME_DARK, DEFAULT_TERMINAL_THEME_LIGHT } export const DEFAULT_TERMINAL_DIVIDER_DARK = '#3f3f46' -const DEFAULT_TERMINAL_DIVIDER_LIGHT = '#d4d4d8' +export const DEFAULT_TERMINAL_DIVIDER_LIGHT = '#d4d4d8' export type EffectiveTerminalAppearance = { mode: 'dark' | 'light'