Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 85 additions & 2 deletions src/renderer/src/app-shell/use-document-appearance.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => ({
Expand All @@ -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'),
Expand All @@ -39,6 +65,7 @@ describe('useDocumentAppearance', () => {

afterEach(() => {
useAppStore.setState(initialState, true)
vi.unstubAllGlobals()
})

it('ignores unrelated settings object replacements', () => {
Expand Down Expand Up @@ -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()
})
})
40 changes: 31 additions & 9 deletions src/renderer/src/app-shell/use-document-appearance.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,60 @@
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<typeof applyTabGroupSplitDividerAppearance>[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()
}
mq.addEventListener('change', handler)
return () => mq.removeEventListener('change', handler)
}, [theme])

useEffect(() => {
if (!theme) {
return
}
applyWorkspaceSplitDivider(theme, {
tabGroupSplitDividerColorDark: splitDividerDark,
tabGroupSplitDividerColorLight: splitDividerLight
})
}, [theme, splitDividerDark, splitDividerLight])
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved

useEffect(() => {
document.documentElement.style.setProperty(
'--app-font-family',
Expand Down
19 changes: 16 additions & 3 deletions src/renderer/src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 ───────────────────────────────────────── */
Expand Down Expand Up @@ -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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Extreme colors lose hover feedback In dark mode, a white divider mixed toward white has the same color on hover and drag. The light-mode mix toward black has the same problem for a black divider. Because the handle uses that mixed color for its hover and drag states, these valid choices lose the visual drag cue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 05033640297641fa6da9d114ea14219f2f72e01d. Hover and drag now grow only the visible divider from 3px to 4px in both orientations, so light-mode black and dark-mode white retain an interaction cue. Chosen colors, existing mixes/defaults, centered positioning, the 6px hit area and pane layout are unchanged.

Actual Electron before/after coverage checks both orientations and six theme/color combinations through idle, hover, pointer drag, release and drag-without-hover: 60 paired color/geometry samples preserve every value except active thickness. Parent reran 96 focused tests, four freshly rebuilt hidden Electron tests, full pnpm tc, normal hooks and the unchanged review-delta quality gate; all pass.

}

.plugin-security-chrome {
Expand Down Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions src/renderer/src/components/settings/AppearancePane.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLInputElement>('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 = [
{
Expand Down
6 changes: 4 additions & 2 deletions src/renderer/src/components/settings/AppearancePane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
getThemeEntries,
getTitlebarEntries,
getTypographyEntries,
getWorkspaceSplitDividerEntries,
getZoomEntries
} from './appearance-search'
import { getTerminalAppearanceSearchEntries } from './terminal-search'
Expand Down Expand Up @@ -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'
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

// Search-entry buckets per section so a query can force-open the matching one.
Expand Down Expand Up @@ -160,7 +161,8 @@ export function AppearancePane({
...getSidebarEntries(),
...getLayoutEntries(),
getLeftSidebarAppearanceEntry(),
getWorkspaceCardLayoutEntry()
getWorkspaceCardLayoutEntry(),
...getWorkspaceSplitDividerEntries()
]

const interfaceMatches = matchesSettingsSearch(searchQuery, interfaceSearchEntries)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -125,6 +126,12 @@ export function AppearanceWindowSidebarSection({
<LeftSidebarAppearanceSetting settings={settings} updateSettings={updateSettings} />
</SearchableSetting>

<AppearanceWorkspaceSplitDividerSettings
settings={settings}
updateSettings={updateSettings}
forceVisiblePrimary={forceVisiblePrimary}
/>

<SearchableSetting
title={statusBarTitle}
keywords={statusBarKeywords}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import type React from 'react'
import type { GlobalSettings } from '../../../../shared/global-settings-types'
import {
DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK,
DEFAULT_TAB_GROUP_SPLIT_DIVIDER_LIGHT
} from '../../../../shared/tab-group-split-divider'
import { ColorField } from './SettingsFormControls'
import { SearchableSetting } from './SearchableSetting'
import { getWorkspaceSplitDividerEntries } from './appearance-search'

export function AppearanceWorkspaceSplitDividerSettings({
settings,
updateSettings,
forceVisiblePrimary = false
}: {
settings: GlobalSettings
updateSettings: (updates: Partial<GlobalSettings>) => void
forceVisiblePrimary?: boolean
}): React.JSX.Element {
const [darkEntry, lightEntry] = getWorkspaceSplitDividerEntries()

return (
<>
<SearchableSetting
title={darkEntry.title}
description={darkEntry.description}
keywords={darkEntry.keywords}
forceVisible={forceVisiblePrimary}
>
<ColorField
label={darkEntry.title}
description={darkEntry.description ?? ''}
value={settings.tabGroupSplitDividerColorDark}
fallback={DEFAULT_TAB_GROUP_SPLIT_DIVIDER_DARK}
onChange={(value) => updateSettings({ tabGroupSplitDividerColorDark: value })}
/>
</SearchableSetting>
<SearchableSetting
title={lightEntry.title}
description={lightEntry.description}
keywords={lightEntry.keywords}
forceVisible={forceVisiblePrimary}
>
<ColorField
label={lightEntry.title}
description={lightEntry.description ?? ''}
value={settings.tabGroupSplitDividerColorLight}
fallback={DEFAULT_TAB_GROUP_SPLIT_DIVIDER_LIGHT}
onChange={(value) => updateSettings({ tabGroupSplitDividerColorLight: value })}
/>
</SearchableSetting>
</>
)
}
Loading