diff --git a/src/renderer/src/app-shell/use-document-appearance.test.tsx b/src/renderer/src/app-shell/use-document-appearance.test.tsx index b06b9c7517cc..5243bb9074c0 100644 --- a/src/renderer/src/app-shell/use-document-appearance.test.tsx +++ b/src/renderer/src/app-shell/use-document-appearance.test.tsx @@ -6,11 +6,18 @@ import { useAppStore } from '../store' const mocks = vi.hoisted(() => ({ applyDocumentTheme: vi.fn(), - buildAppFontFamily: vi.fn((fontFamily: string | null | undefined) => fontFamily ?? '') + buildAppFontFamily: vi.fn((fontFamily: string | null | undefined) => fontFamily ?? ''), + media: { + isDark: false, + listeners: new Set<() => void>() + } })) vi.mock('../lib/document-theme', () => ({ - applyDocumentTheme: mocks.applyDocumentTheme + applyDocumentTheme: mocks.applyDocumentTheme, + resolveDocumentTheme: (theme: string) => + theme === 'dark' || + (theme === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches) })) vi.mock('@/lib/app-font-family', () => ({ @@ -29,6 +36,25 @@ describe('useDocumentAppearance', () => { beforeEach(() => { mocks.applyDocumentTheme.mockReset() mocks.buildAppFontFamily.mockClear() + mocks.media.isDark = false + mocks.media.listeners.clear() + vi.stubGlobal( + 'matchMedia', + vi.fn(() => ({ + get matches() { + return mocks.media.isDark + }, + media: '(prefers-color-scheme: dark)', + onchange: null, + addListener: vi.fn(), + removeListener: vi.fn(), + addEventListener: (_type: string, listener: () => void) => + mocks.media.listeners.add(listener), + removeEventListener: (_type: string, listener: () => void) => + mocks.media.listeners.delete(listener), + dispatchEvent: vi.fn(() => true) + })) + ) useAppStore.setState({ settings: { ...getDefaultSettings('/tmp'), @@ -39,6 +65,7 @@ describe('useDocumentAppearance', () => { afterEach(() => { useAppStore.setState(initialState, true) + vi.unstubAllGlobals() }) it('ignores unrelated settings object replacements', () => { @@ -75,4 +102,60 @@ describe('useDocumentAppearance', () => { expect(mocks.buildAppFontFamily).toHaveBeenCalledTimes(2) unmount() }) + + it('re-applies the workspace split divider without interrupting document transitions', () => { + const { unmount } = renderHook(() => useDocumentAppearance()) + + act(() => { + const settings = useAppStore.getState().settings! + useAppStore.setState({ + settings: { ...settings, tabGroupSplitDividerColorDark: '#ff0000' } + }) + }) + + expect(document.documentElement.style.getPropertyValue('--tab-group-split-divider')).toBe( + '#ff0000' + ) + expect(mocks.applyDocumentTheme).toHaveBeenCalledTimes(1) + unmount() + }) + + it('uses the latest divider colors after a system theme change', () => { + useAppStore.setState({ + settings: { + ...useAppStore.getState().settings!, + theme: 'system', + tabGroupSplitDividerColorDark: '#111111', + tabGroupSplitDividerColorLight: '#eeeeee' + } + }) + const { unmount } = renderHook(() => useDocumentAppearance()) + + act(() => { + useAppStore.setState({ + settings: { + ...useAppStore.getState().settings!, + tabGroupSplitDividerColorDark: '#222222' + } + }) + }) + expect(mocks.applyDocumentTheme).toHaveBeenCalledTimes(1) + expect(document.documentElement.style.getPropertyValue('--tab-group-split-divider')).toBe( + '#eeeeee' + ) + + act(() => { + mocks.media.isDark = true + for (const listener of mocks.media.listeners) { + listener() + } + }) + + expect(mocks.applyDocumentTheme).toHaveBeenCalledTimes(2) + expect(mocks.applyDocumentTheme).toHaveBeenLastCalledWith('system') + expect(document.documentElement.style.getPropertyValue('--tab-group-split-divider')).toBe( + '#222222' + ) + unmount() + }) }) diff --git a/src/renderer/src/app-shell/use-document-appearance.ts b/src/renderer/src/app-shell/use-document-appearance.ts index 3d4c8e23dafd..acdb027ee2cb 100644 --- a/src/renderer/src/app-shell/use-document-appearance.ts +++ b/src/renderer/src/app-shell/use-document-appearance.ts @@ -1,31 +1,43 @@ import { useEffect } from 'react' +import type { GlobalSettings } from '../../../shared/global-settings-types' import { buildAppFontFamily } from '@/lib/app-font-family' -import { applyDocumentTheme } from '../lib/document-theme' +import { applyDocumentTheme, resolveDocumentTheme } from '../lib/document-theme' +import { applyTabGroupSplitDividerAppearance } from '../lib/tab-group-split-divider-appearance' import { scheduleRuntimeGraphSync } from '../runtime/sync-runtime-graph' import { useAppStore } from '../store' +type SplitDividerColors = Parameters[1] + +function applyWorkspaceSplitDivider( + theme: GlobalSettings['theme'], + colors: SplitDividerColors +): void { + applyTabGroupSplitDividerAppearance(document.documentElement, colors, resolveDocumentTheme(theme)) +} + /** Applies the settings-driven theme and app font to the document root. */ export function useDocumentAppearance(): void { const theme = useAppStore((s) => s.settings?.theme) const appFontFamily = useAppStore((s) => s.settings?.appFontFamily) + const splitDividerDark = useAppStore((s) => s.settings?.tabGroupSplitDividerColorDark) + const splitDividerLight = useAppStore((s) => s.settings?.tabGroupSplitDividerColorLight) useEffect(() => { if (!theme) { return } - - if (theme === 'dark') { - applyDocumentTheme('dark') - return undefined - } else if (theme === 'light') { - applyDocumentTheme('light') + applyDocumentTheme(theme) + if (theme !== 'system') { return undefined } - // system const mq = window.matchMedia('(prefers-color-scheme: dark)') - applyDocumentTheme('system') const handler = (): void => { applyDocumentTheme('system') + const settings = useAppStore.getState().settings + applyWorkspaceSplitDivider(theme, { + tabGroupSplitDividerColorDark: settings?.tabGroupSplitDividerColorDark, + tabGroupSplitDividerColorLight: settings?.tabGroupSplitDividerColorLight + }) // System theme changes don't mutate the store, so mobile terminal colors need an explicit graph republish. scheduleRuntimeGraphSync() } @@ -33,6 +45,16 @@ export function useDocumentAppearance(): void { return () => mq.removeEventListener('change', handler) }, [theme]) + useEffect(() => { + if (!theme) { + return + } + applyWorkspaceSplitDivider(theme, { + tabGroupSplitDividerColorDark: splitDividerDark, + tabGroupSplitDividerColorLight: splitDividerLight + }) + }, [theme, splitDividerDark, splitDividerLight]) + useEffect(() => { document.documentElement.style.setProperty( '--app-font-family', diff --git a/src/renderer/src/assets/main.css b/src/renderer/src/assets/main.css index 9f1b84d873e5..97c4aa58e33f 100644 --- a/src/renderer/src/assets/main.css +++ b/src/renderer/src/assets/main.css @@ -255,9 +255,11 @@ --markdown-search-match-active: #fb923c; /* Why: tab-group splits use a dedicated divider — `--border` is too faint on card/editor surfaces when panes are side-by-side or stacked. Default must - meet >=3:1 against `--card`, not only the hover/drag strong state. */ + meet >=3:1 against `--card`, not only the hover/drag strong state. + Settings can override --tab-group-split-divider; hover/drag stays a + stronger mix of that color so a custom value still has a drag affordance. */ --tab-group-split-divider: #868690; - --tab-group-split-divider-strong: #71717a; + --tab-group-split-divider-strong: color-mix(in srgb, var(--tab-group-split-divider) 82%, #000000); } /* ── Dark Mode ───────────────────────────────────────── */ @@ -374,7 +376,7 @@ --markdown-search-match-active: #fb923c; /* Brighter than terminal defaults so the always-visible line clears 3:1 on `--card`. */ --tab-group-split-divider: #71717a; - --tab-group-split-divider-strong: #a1a1aa; + --tab-group-split-divider-strong: color-mix(in srgb, var(--tab-group-split-divider) 70%, #ffffff); } .plugin-security-chrome { @@ -819,6 +821,17 @@ html.native-shell .app-layout { background: var(--tab-group-split-divider-strong); } +/* Extreme custom colors can match their strong mix, so thickness also signals interaction. */ +.tab-group-split-resize-handle.is-vertical:hover::after, +.tab-group-split-resize-handle.is-vertical.is-dragging::after { + width: 4px; +} + +.tab-group-split-resize-handle.is-horizontal:hover::after, +.tab-group-split-resize-handle.is-horizontal.is-dragging::after { + height: 4px; +} + /* ── Titlebar ────────────────────────────────────────── */ /* Why: Radix portals (dropdowns, popovers, dialogs, sheets) render at the diff --git a/src/renderer/src/components/settings/AppearancePane.test.tsx b/src/renderer/src/components/settings/AppearancePane.test.tsx index 01573d65b49d..963db47b9a84 100644 --- a/src/renderer/src/components/settings/AppearancePane.test.tsx +++ b/src/renderer/src/components/settings/AppearancePane.test.tsx @@ -491,10 +491,45 @@ describe('AppearancePane', () => { const container = await renderAppearancePane(getDefaultSettings('/tmp')) expect(container.textContent).toContain('Left Sidebar Appearance') + expect(container.textContent).toContain('Workspace Split Divider (Dark)') + expect(container.textContent).toContain('Workspace Split Divider (Light)') expect(container.textContent).toContain('Status Bar') expect(container.textContent).not.toContain('Advanced') }) + it('shows workspace split divider controls for a control-specific search', async () => { + mocks.state.settingsSearchQuery = 'tab group' + const container = await renderAppearancePane(getDefaultSettings('/tmp')) + + expect(container.textContent).toContain('Workspace Split Divider (Dark)') + expect(container.textContent).toContain('Workspace Split Divider (Light)') + expect(container.textContent).not.toContain('Theme') + expect(container.textContent).not.toContain('Advanced') + }) + + it('updates the workspace split divider color from Window & Sidebar', async () => { + mocks.state.settingsSearchQuery = '' + const updateSettings = vi.fn() + const container = await renderAppearancePane(getDefaultSettings('/tmp'), updateSettings) + const colorInput = Array.from(container.querySelectorAll('input')).find( + (input) => input.type !== 'color' && input.value.toLowerCase() === '#71717a' + ) + + expect(container.textContent).toContain('Workspace Split Divider (Dark)') + expect(colorInput).toBeDefined() + + await act(async () => { + if (!colorInput) { + throw new Error('expected a dark workspace split color input') + } + const assignValue = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set + assignValue?.call(colorInput, '#171717') + colorInput.dispatchEvent(new Event('input', { bubbles: true })) + }) + + expect(updateSettings).toHaveBeenCalledWith({ tabGroupSplitDividerColorDark: '#171717' }) + }) + it('expands status bar controls for a section-label search', async () => { mocks.state.availableStatusBarToggles = [ { diff --git a/src/renderer/src/components/settings/AppearancePane.tsx b/src/renderer/src/components/settings/AppearancePane.tsx index 24bb19f278a7..d8a02d397a23 100644 --- a/src/renderer/src/components/settings/AppearancePane.tsx +++ b/src/renderer/src/components/settings/AppearancePane.tsx @@ -23,6 +23,7 @@ import { getThemeEntries, getTitlebarEntries, getTypographyEntries, + getWorkspaceSplitDividerEntries, getZoomEntries } from './appearance-search' import { getTerminalAppearanceSearchEntries } from './terminal-search' @@ -131,7 +132,7 @@ export function AppearancePane({ ) const windowSidebarSummary = translate( 'auto.components.settings.AppearancePane.windowSidebarSummary', - 'Sidebar, status bar, and file explorer' + 'Sidebar, status bar, file explorer, and workspace split divider' ) // Search-entry buckets per section so a query can force-open the matching one. @@ -160,7 +161,8 @@ export function AppearancePane({ ...getSidebarEntries(), ...getLayoutEntries(), getLeftSidebarAppearanceEntry(), - getWorkspaceCardLayoutEntry() + getWorkspaceCardLayoutEntry(), + ...getWorkspaceSplitDividerEntries() ] const interfaceMatches = matchesSettingsSearch(searchQuery, interfaceSearchEntries) diff --git a/src/renderer/src/components/settings/AppearanceWindowSidebarSection.tsx b/src/renderer/src/components/settings/AppearanceWindowSidebarSection.tsx index 03c7912a7722..70e80a2acdd1 100644 --- a/src/renderer/src/components/settings/AppearanceWindowSidebarSection.tsx +++ b/src/renderer/src/components/settings/AppearanceWindowSidebarSection.tsx @@ -21,6 +21,7 @@ import { } from './appearance-search' import { USAGE_PERCENTAGE_DISPLAY_SETTING_ID } from './appearance-usage-percentage-search' import { LeftSidebarAppearanceSetting } from './LeftSidebarAppearanceSetting' +import { AppearanceWorkspaceSplitDividerSettings } from './AppearanceWorkspaceSplitDividerSettings' import { getLeftSidebarAppearanceEntry, getShowPinnedWorktreesInGroupsEntry, @@ -125,6 +126,12 @@ export function AppearanceWindowSidebarSection({ + + ) => void + forceVisiblePrimary?: boolean +}): React.JSX.Element { + const [darkEntry, lightEntry] = getWorkspaceSplitDividerEntries() + + return ( + <> + + updateSettings({ tabGroupSplitDividerColorDark: value })} + /> + + + updateSettings({ tabGroupSplitDividerColorLight: value })} + /> + + + ) +} diff --git a/src/renderer/src/components/settings/appearance-search.ts b/src/renderer/src/components/settings/appearance-search.ts index 096853581454..3ab67ba99a0f 100644 --- a/src/renderer/src/components/settings/appearance-search.ts +++ b/src/renderer/src/components/settings/appearance-search.ts @@ -175,6 +175,58 @@ export const getStatusBarEntries = createLocalizedCatalog((): SettingsSearchEntr export { getLeftSidebarAppearanceEntry, getSidebarEntries } +const workspaceSplitDividerKeywords = (): string[] => [ + ...translateSearchKeyword( + 'auto.components.settings.appearance.search.workspaceSplitDivider.workspace', + 'workspace' + ), + ...translateSearchKeyword( + 'auto.components.settings.appearance.search.workspaceSplitDivider.split', + 'split' + ), + ...translateSearchKeyword( + 'auto.components.settings.appearance.search.workspaceSplitDivider.divider', + 'divider' + ), + ...translateSearchKeyword( + 'auto.components.settings.appearance.search.workspaceSplitDivider.pane', + 'pane' + ), + ...translateSearchKeyword( + 'auto.components.settings.appearance.search.workspaceSplitDivider.color', + 'color' + ), + ...translateSearchKeyword( + 'auto.components.settings.appearance.search.workspaceSplitDivider.tabGroup', + 'tab group' + ) +] + +export const getWorkspaceSplitDividerEntries = createLocalizedCatalog((): SettingsSearchEntry[] => [ + { + title: translate( + 'auto.components.settings.AppearanceWorkspaceSplitDividerSettings.darkTitle', + 'Workspace Split Divider (Dark)' + ), + description: translate( + 'auto.components.settings.AppearanceWorkspaceSplitDividerSettings.darkDescription', + 'Color of the split line between workspace panes in dark mode. This is the column between a terminal tab and an editor, not the in-terminal split.' + ), + keywords: workspaceSplitDividerKeywords() + }, + { + title: translate( + 'auto.components.settings.AppearanceWorkspaceSplitDividerSettings.lightTitle', + 'Workspace Split Divider (Light)' + ), + description: translate( + 'auto.components.settings.AppearanceWorkspaceSplitDividerSettings.lightDescription', + 'Color of the split line between workspace panes in light mode.' + ), + keywords: workspaceSplitDividerKeywords() + } +]) + export const getAppIconEntries = createLocalizedCatalog((): SettingsSearchEntry[] => [ { title: translate('auto.components.settings.appearance.search.2b313598c6', 'App Icon'), @@ -217,7 +269,7 @@ const getAppearanceSectionEntries = createLocalizedCatalog((): SettingsSearchEnt ), description: translate( 'auto.components.settings.AppearancePane.windowSidebarSummary', - 'Sidebar, status bar, and file explorer' + 'Sidebar, status bar, file explorer, and workspace split divider' ) } ]) @@ -242,6 +294,7 @@ export function getAppearancePaneSearchEntries( ...getTitlebarEntries(), ...getStatusBarEntries(), ...getSidebarEntries(), + ...getWorkspaceSplitDividerEntries(), ...getAppIconEntries(), ...getSystemTrayEntries(options), ...getMenuBarIconEntries(options) diff --git a/src/renderer/src/components/settings/setting-labels.ts b/src/renderer/src/components/settings/setting-labels.ts index 92d8720f476c..44553a8926f1 100644 --- a/src/renderer/src/components/settings/setting-labels.ts +++ b/src/renderer/src/components/settings/setting-labels.ts @@ -25,6 +25,8 @@ export const SETTING_LABELS: Partial> = { terminalPaddingY: 'Padding Y', terminalDividerColorDark: 'Divider Color (Dark)', terminalDividerColorLight: 'Divider Color (Light)', + tabGroupSplitDividerColorDark: 'Workspace Split Divider (Dark)', + tabGroupSplitDividerColorLight: 'Workspace Split Divider (Light)', terminalInactivePaneOpacity: 'Inactive Pane Opacity', windowBackgroundBlur: 'Window Background Blur' } diff --git a/src/renderer/src/components/settings/terminal-search.test.ts b/src/renderer/src/components/settings/terminal-search.test.ts index ef7daf732e45..30f8106edb18 100644 --- a/src/renderer/src/components/settings/terminal-search.test.ts +++ b/src/renderer/src/components/settings/terminal-search.test.ts @@ -1,6 +1,10 @@ import { describe, expect, it } from 'vitest' import { getTerminalPaneSearchEntries } from './terminal-search' -import { getAppearancePaneSearchEntries, getSidebarEntries } from './appearance-search' +import { + getAppearancePaneSearchEntries, + getSidebarEntries, + getWorkspaceSplitDividerEntries +} from './appearance-search' import { getShowPinnedWorktreesInGroupsEntry, getWorkspaceCardLayoutEntry @@ -246,6 +250,14 @@ describe('getTerminalPaneSearchEntries', () => { } ) + it('includes workspace split divider controls in the Appearance catalog', () => { + const [darkEntry, lightEntry] = getWorkspaceSplitDividerEntries() + + expect(getAppearancePaneSearchEntries()).toContainEqual(darkEntry) + expect(getAppearancePaneSearchEntries()).toContainEqual(lightEntry) + expect(matchesSettingsSearch('tab group', getAppearancePaneSearchEntries())).toBe(true) + }) + it('includes pinned worktree duplicate display in sidebar and Appearance search', () => { const entry = getShowPinnedWorktreesInGroupsEntry() diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index bf67a5a1fc3d..ebe25dc90b34 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -6868,7 +6868,7 @@ "interfaceTitle": "Interface", "terminalTitle": "Terminal", "windowSidebarTitle": "Window & Sidebar", - "windowSidebarSummary": "Sidebar, status bar, and file explorer", + "windowSidebarSummary": "Sidebar, status bar, file explorer, and workspace split divider", "statusBarCount": "{{value0}} indicators visible.", "gitIgnoredGlossary": "Files matched by .gitignore.", "statusBarDescription": "Choose which indicators appear in the status bar.", @@ -9386,6 +9386,14 @@ "notification": "notification area", "background": "background" }, + "workspaceSplitDivider": { + "workspace": "workspace", + "split": "split", + "divider": "divider", + "pane": "pane", + "color": "color", + "tabGroup": "tab group" + }, "cursor": { "title": "Cursor Usage", "description": "Show monthly Cursor plan usage from the Cursor sign-in on this computer.", @@ -12203,6 +12211,12 @@ "6d4c55bacc": "Inline Images", "fffab5890b": "Display images directly in the terminal using SIXEL, iTerm2 (IIP), and Kitty graphics protocols." }, + "AppearanceWorkspaceSplitDividerSettings": { + "darkTitle": "Workspace Split Divider (Dark)", + "darkDescription": "Color of the split line between workspace panes in dark mode. This is the column between a terminal tab and an editor, not the in-terminal split.", + "lightTitle": "Workspace Split Divider (Light)", + "lightDescription": "Color of the split line between workspace panes in light mode." + }, "CursorAccountsSection": { "source": { "keychain": "macOS Keychain (cursor-agent)", diff --git a/src/renderer/src/lib/tab-group-split-divider-appearance.test.ts b/src/renderer/src/lib/tab-group-split-divider-appearance.test.ts new file mode 100644 index 000000000000..f89d74c379b1 --- /dev/null +++ b/src/renderer/src/lib/tab-group-split-divider-appearance.test.ts @@ -0,0 +1,51 @@ +import { describe, expect, it, vi } from 'vitest' +import { DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK } from '../../../shared/tab-group-split-divider' +import { + applyTabGroupSplitDividerAppearance, + resolveTabGroupSplitDividerAppearance +} from './tab-group-split-divider-appearance' + +describe('tab-group split divider appearance', () => { + it('uses the dark workspace setting when the document is dark', () => { + expect( + resolveTabGroupSplitDividerAppearance( + { + tabGroupSplitDividerColorDark: '#171717', + tabGroupSplitDividerColorLight: '#cccccc' + }, + true + ) + ).toBe('#171717') + }) + + it('uses the light workspace setting when the document is light', () => { + expect( + resolveTabGroupSplitDividerAppearance( + { + tabGroupSplitDividerColorDark: '#171717', + tabGroupSplitDividerColorLight: '#cccccc' + }, + false + ) + ).toBe('#cccccc') + }) + + it('writes the resolved color onto the document token', () => { + const setProperty = vi.fn() + applyTabGroupSplitDividerAppearance( + { style: { setProperty } }, + { + tabGroupSplitDividerColorDark: '#171717', + tabGroupSplitDividerColorLight: '#cccccc' + }, + true + ) + expect(setProperty).toHaveBeenCalledWith('--tab-group-split-divider', '#171717') + }) + + it('falls back to the shipped dark token when settings are missing', () => { + expect(resolveTabGroupSplitDividerAppearance(null, true)).toBe( + DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK + ) + }) +}) diff --git a/src/renderer/src/lib/tab-group-split-divider-appearance.ts b/src/renderer/src/lib/tab-group-split-divider-appearance.ts new file mode 100644 index 000000000000..66a3c7876611 --- /dev/null +++ b/src/renderer/src/lib/tab-group-split-divider-appearance.ts @@ -0,0 +1,31 @@ +import type { GlobalSettings } from '../../../shared/global-settings-types' +import { + DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK, + DEFAULT_TAB_GROUP_SPLIT_DIVIDER_LIGHT, + resolveTabGroupSplitDividerColor +} from '../../../shared/tab-group-split-divider' + +type TabGroupSplitDividerSettings = Partial< + Pick +> + +export function resolveTabGroupSplitDividerAppearance( + settings: TabGroupSplitDividerSettings | null | undefined, + isDark: boolean +): string { + return resolveTabGroupSplitDividerColor( + isDark ? settings?.tabGroupSplitDividerColorDark : settings?.tabGroupSplitDividerColorLight, + isDark ? DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK : DEFAULT_TAB_GROUP_SPLIT_DIVIDER_LIGHT + ) +} + +export function applyTabGroupSplitDividerAppearance( + root: { style: { setProperty: (name: string, value: string) => void } }, + settings: TabGroupSplitDividerSettings | null | undefined, + isDark: boolean +): void { + root.style.setProperty( + '--tab-group-split-divider', + resolveTabGroupSplitDividerAppearance(settings, isDark) + ) +} diff --git a/src/shared/default-global-settings.ts b/src/shared/default-global-settings.ts index a146be2a2c2b..9f707ea6dda5 100644 --- a/src/shared/default-global-settings.ts +++ b/src/shared/default-global-settings.ts @@ -16,6 +16,10 @@ import { } from './left-sidebar-appearance' import { DEFAULT_SOURCE_CONTROL_GROUP_ORDER } from './source-control-group-order' import { DESKTOP_TERMINAL_SCROLLBACK_ROWS_DEFAULT } from './terminal-scrollback-policy' +import { + DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK, + DEFAULT_TAB_GROUP_SPLIT_DIVIDER_LIGHT +} from './tab-group-split-divider' export function buildDefaultSettings(args: { workspaceDir: string @@ -84,6 +88,8 @@ export function buildDefaultSettings(args: { terminalThemeLight: 'Builtin Tango Light', terminalCustomThemes: [], terminalDividerColorLight: '#d4d4d8', + tabGroupSplitDividerColorDark: DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK, + tabGroupSplitDividerColorLight: DEFAULT_TAB_GROUP_SPLIT_DIVIDER_LIGHT, terminalInactivePaneOpacity: args.terminalInactivePaneOpacity, terminalActivePaneOpacity: 1, terminalPaneOpacityTransitionMs: 140, diff --git a/src/shared/global-settings-types.ts b/src/shared/global-settings-types.ts index 5f2419e9b2a0..a8f648636f22 100644 --- a/src/shared/global-settings-types.ts +++ b/src/shared/global-settings-types.ts @@ -145,6 +145,9 @@ export type GlobalSettings = { terminalUseSeparateLightTheme: boolean terminalThemeLight: string terminalDividerColorLight: string + /** Workspace tab-group split (terminal | editor), not the in-terminal pane divider. */ + tabGroupSplitDividerColorDark: string + tabGroupSplitDividerColorLight: string terminalInactivePaneOpacity: number terminalActivePaneOpacity: number terminalPaneOpacityTransitionMs: number diff --git a/src/shared/tab-group-split-divider.test.ts b/src/shared/tab-group-split-divider.test.ts new file mode 100644 index 000000000000..4ea94d456e87 --- /dev/null +++ b/src/shared/tab-group-split-divider.test.ts @@ -0,0 +1,31 @@ +import { describe, expect, it } from 'vitest' +import { + DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK, + resolveTabGroupSplitDividerColor +} from './tab-group-split-divider' + +describe('resolveTabGroupSplitDividerColor', () => { + it('keeps a valid hash color', () => { + expect(resolveTabGroupSplitDividerColor('#171717', DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK)).toBe( + '#171717' + ) + }) + + it('prefixes a valid hashless hex color', () => { + expect(resolveTabGroupSplitDividerColor('171717', DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK)).toBe( + '#171717' + ) + }) + + it('falls back for empty or invalid values', () => { + expect(resolveTabGroupSplitDividerColor(undefined, DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK)).toBe( + DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK + ) + expect(resolveTabGroupSplitDividerColor(' ', DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK)).toBe( + DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK + ) + expect( + resolveTabGroupSplitDividerColor('not-a-color', DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK) + ).toBe(DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK) + }) +}) diff --git a/src/shared/tab-group-split-divider.ts b/src/shared/tab-group-split-divider.ts new file mode 100644 index 000000000000..9b366df5c74d --- /dev/null +++ b/src/shared/tab-group-split-divider.ts @@ -0,0 +1,17 @@ +import { HEX_COLOR_RE } from './color-validation' + +/** Current dark workspace split token. Keep this the default so existing layouts do not shift. */ +export const DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK = '#71717a' +/** Current light workspace split token. */ +export const DEFAULT_TAB_GROUP_SPLIT_DIVIDER_LIGHT = '#868690' + +export function resolveTabGroupSplitDividerColor( + value: string | undefined, + fallback: string +): string { + const trimmed = value?.trim() + if (!trimmed || !HEX_COLOR_RE.test(trimmed)) { + return fallback + } + return trimmed.startsWith('#') ? trimmed : `#${trimmed}` +} diff --git a/tests/e2e/tab-group-split-divider-feedback.spec.ts b/tests/e2e/tab-group-split-divider-feedback.spec.ts new file mode 100644 index 000000000000..fe0ea8d011f2 --- /dev/null +++ b/tests/e2e/tab-group-split-divider-feedback.spec.ts @@ -0,0 +1,171 @@ +import { writeFileSync } from 'node:fs' +import type { Locator } from '@stablyai/playwright-test' +import { expect, test } from './helpers/orca-app' + +async function readDivider(handle: Locator) { + return handle.evaluate((element) => { + const style = getComputedStyle(element, '::after') + const rect = element.getBoundingClientRect() + const vertical = element.classList.contains('is-vertical') + const transform = new DOMMatrix(style.transform) + const thickness = Number.parseFloat(vertical ? style.width : style.height) + const offset = Number.parseFloat(vertical ? style.left : style.top) + const translation = vertical ? transform.e : transform.f + const hitThickness = vertical ? rect.width : rect.height + const box = (node: Element | null) => { + const bounds = node?.getBoundingClientRect() + return bounds ? [bounds.x, bounds.y, bounds.width, bounds.height] : null + } + return { + thickness, + hovered: element.matches(':hover'), + dragging: element.classList.contains('is-dragging'), + hitThickness, + centered: Math.abs(offset + translation + thickness / 2 - hitThickness / 2) < 0.01, + color: style.backgroundColor, + baseColor: getComputedStyle(document.documentElement) + .getPropertyValue('--tab-group-split-divider') + .trim(), + layout: { + handle: box(element), + firstPane: box(element.previousElementSibling), + secondPane: box(element.nextElementSibling) + } + } + }) +} + +for (const theme of ['light', 'dark'] as const) { + for (const orientation of ['vertical', 'horizontal'] as const) { + test(`workspace divider feedback preserves geometry (${theme}, ${orientation})`, async ({ + orcaPage, + electronApp + }, testInfo) => { + expect( + await electronApp.evaluate(({ BrowserWindow }) => + BrowserWindow.getAllWindows().every( + (window) => !window.isVisible() && !window.isFocused() + ) + ) + ).toBe(true) + await orcaPage.evaluate((orientation) => { + const state = window.__store?.getState() + const worktreeId = state?.activeWorktreeId + if (!state || !worktreeId) { + throw new Error('No active workspace') + } + const sourceGroupId = state.ensureWorktreeRootGroup(worktreeId) + const groupId = state.createEmptySplitGroup( + worktreeId, + sourceGroupId, + orientation === 'vertical' ? 'right' : 'down' + ) + if (!groupId) { + throw new Error('Workspace split creation failed') + } + const tab = state.createTab(worktreeId, groupId, undefined, { activate: true }) + state.focusGroup(worktreeId, groupId) + state.setActiveTab(tab.id) + state.setActiveTabType('terminal', worktreeId) + }, orientation) + const handle = orcaPage.locator(`.tab-group-split-resize-handle.is-${orientation}`).first() + await expect(handle).toBeVisible() + const colors = + theme === 'light' ? ['#000000', '#868690', '#171717'] : ['#ffffff', '#71717a', '#cccccc'] + for (const color of colors) { + await orcaPage.evaluate( + async ({ theme, color }) => { + const state = window.__store?.getState() + if (!state) { + throw new Error('Store unavailable') + } + await state.updateSettingsOrThrow({ + theme, + tabGroupSplitDividerColorDark: color, + tabGroupSplitDividerColorLight: color + }) + }, + { theme, color } + ) + await expect.poll(async () => (await readDivider(handle)).baseColor).toBe(color) + await orcaPage.mouse.move(0, 0) + await expect(handle).not.toHaveClass(/is-dragging/) + const capture = async (state: string) => { + const bounds = await handle.boundingBox() + if (!bounds) { + throw new Error('Divider missing') + } + const viewport = orcaPage.viewportSize() ?? { width: 1200, height: 800 } + const clip = { + x: Math.max(0, Math.min(viewport.width - 160, bounds.x + bounds.width / 2 - 80)), + y: Math.max(0, Math.min(viewport.height - 160, bounds.y + bounds.height / 2 - 80)), + width: 160, + height: 160 + } + const path = testInfo.outputPath(`${color.slice(1)}-${state}.png`) + await orcaPage.screenshot({ path, clip, animations: 'disabled' }) + await testInfo.attach(`${color}-${state}`, { path, contentType: 'image/png' }) + } + await capture('idle') + const idle = await readDivider(handle) + const samples = [{ state: 'idle', ...idle }] + await handle.hover() + await capture('hover') + const hovered = await readDivider(handle) + samples.push({ state: 'hover', ...hovered }) + await orcaPage.mouse.down() + await expect(handle).toHaveClass(/is-dragging/) + const bounds = await handle.boundingBox() + if (!bounds) { + throw new Error('Divider missing during drag') + } + // Move perpendicular to the resize axis so active-drag feedback cannot shift the panes. + await orcaPage.mouse.move( + orientation === 'vertical' ? bounds.x + bounds.width / 2 : 0, + orientation === 'horizontal' ? bounds.y + bounds.height / 2 : 0 + ) + const dragged = await readDivider(handle) + samples.push({ state: 'drag', ...dragged }) + await capture('drag') + await orcaPage.mouse.up() + await expect(handle).not.toHaveClass(/is-dragging/) + await capture('release') + const released = await readDivider(handle) + samples.push({ state: 'release', ...released }) + expect(released.hovered).toBe(false) + // Pointer capture retains :hover during the real gesture; also isolate the drag-only CSS state. + await handle.evaluate((element) => element.classList.add('is-dragging')) + await capture('drag-without-hover') + const dragOnly = await readDivider(handle) + samples.push({ state: 'drag-without-hover', ...dragOnly }) + expect(dragOnly.hovered).toBe(false) + await handle.evaluate((element) => element.classList.remove('is-dragging')) + const geometryPath = testInfo.outputPath(`${color.slice(1)}-geometry.json`) + writeFileSync(geometryPath, JSON.stringify(samples, null, 2)) + await testInfo.attach(`${color}-geometry`, { + path: geometryPath, + contentType: 'application/json' + }) + for (const sample of samples) { + expect.soft(sample.hitThickness, sample.state).toBe(6) + expect.soft(sample.centered, sample.state).toBe(true) + expect.soft(sample.baseColor, sample.state).toBe(color) + expect.soft(sample.layout, sample.state).toEqual(idle.layout) + expect + .soft(sample.thickness, sample.state) + .toBe(sample.state === 'hover' || sample.state.startsWith('drag') ? 4 : 3) + } + expect.soft(dragged.color).toBe(hovered.color) + expect.soft(dragOnly.color).toBe(hovered.color) + expect.soft(released.color).toBe(idle.color) + } + expect( + await electronApp.evaluate(({ BrowserWindow }) => + BrowserWindow.getAllWindows().every( + (window) => !window.isVisible() && !window.isFocused() + ) + ) + ).toBe(true) + }) + } +}