Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(settings): compact the Terminal section, custom theme picker, per-section reset
enes6901b5087fd2
diff --git a/src/renderer/components/settings/SectionReset.tsx b/src/renderer/components/settings/SectionReset.tsxnew file mode 100644index 000000000..06acb6812--- /dev/null+++ b/src/renderer/components/settings/SectionReset.tsx@@ -0,0 +1,57 @@+import { useState } from 'react'+import { Button } from '@renderer/ui/Button'+import { ConfirmDialog } from '../ConfirmDialog'+import { useSettings } from '../../state/settings'+import { isPristine, resetPatch } from '@renderer/lib/settingsReset'+import type { Settings } from '@shared/types'++/**+ * "Reset to defaults" for the settings ONE section owns.+ *+ * Disabled while everything is already at its default — which does two jobs: it keeps a+ * destructive control from firing for nothing, and it answers the question that brought the user+ * here ("have I actually changed anything?"), otherwise unanswerable without remembering what the+ * defaults were.+ */+export function SectionReset<K extends keyof Settings>({+ keys,+ label,+ what+}: {+ keys: readonly K[]+ /** Button text, e.g. "Reset terminal appearance". */+ label: string+ /** Completes the confirm sentence: "Reset <what> to their defaults?" */+ what: string+}): React.JSX.Element {+ const settings = useSettings((s) => s.settings)+ const update = useSettings((s) => s.update)+ const [asking, setAsking] = useState(false)+ const pristine = isPristine(keys, settings)++ return (+ <>+ <div className="flex items-center justify-between gap-6">+ <p className="text-[13px] leading-relaxed text-muted">+ {pristine+ ? `${what[0].toUpperCase()}${what.slice(1)} are at their defaults.`+ : `Put ${what} back the way they shipped. Nothing else is touched.`}+ </p>+ <Button disabled={pristine} onClick={() => setAsking(true)}>+ {label}+ </Button>+ </div>+ {asking && (+ <ConfirmDialog+ message={`Reset ${what} to their defaults?`}+ confirmLabel="Reset"+ onConfirm={() => {+ update(resetPatch(keys))+ setAsking(false)+ }}+ onCancel={() => setAsking(false)}+ />+ )}+ </>+ )+}diff --git a/src/renderer/components/settings/ThemeSelect.tsx b/src/renderer/components/settings/ThemeSelect.tsxnew file mode 100644index 000000000..53a67cc3e--- /dev/null+++ b/src/renderer/components/settings/ThemeSelect.tsx@@ -0,0 +1,138 @@+import { useState, type MouseEvent } from 'react'+import { createPortal } from 'react-dom'+import { useMenuFlip } from '@renderer/ui/useMenuFlip'+import { TERMINAL_THEMES, resolveTerminalTheme, type TerminalTheme } from '@renderer/terminal/themes'++/** The colours worth showing at a glance: the field, then the hues a prompt actually uses. */+function swatchColors(t: TerminalTheme): string[] {+ const c = t.theme+ return [c.foreground, c.red, c.green, c.yellow, c.blue, c.magenta, c.cyan].filter(+ (x): x is string => !!x+ )+}++/** The theme's own background with a strip of its own palette on it — a theme IS its palette, and+ * a name alone ("Nord", "Gruvbox") tells you nothing if you haven't seen it before. */+function Swatch({ theme }: { theme: TerminalTheme }): React.JSX.Element {+ return (+ <span className="theme-swatch" style={{ background: theme.theme.background }} aria-hidden="true">+ {swatchColors(theme).map((c, i) => (+ <span key={i} className="theme-swatch__dot" style={{ background: c }} />+ ))}+ </span>+ )+}++function Group({+ label,+ themes,+ value,+ onPick+}: {+ label: string+ themes: TerminalTheme[]+ value: string+ onPick: (id: string) => void+}): React.JSX.Element | null {+ if (!themes.length) return null+ return (+ <>+ <div className="theme-select__group">{label}</div>+ {themes.map((t) => (+ <button type="button" key={t.id} onClick={() => onPick(t.id)}>+ <span className="tab-menu__check">{t.id === value ? '✓' : ''}</span>+ <Swatch theme={t} />+ <span className="theme-select__name">{t.label}</span>+ </button>+ ))}+ </>+ )+}++/**+ * Terminal colour-theme picker.+ *+ * A native `<select>` can only show names, and the thing being chosen is a set of colours — so+ * this is the app's own dropdown idiom instead (portal + full-screen `.tab-backdrop` click-catcher+ * + `.tab-menu`, exactly as BranchSelect and the tab caret menu do), with every row carrying its+ * own palette.+ */+export function ThemeSelect({+ value,+ onChange+}: {+ value: string+ onChange: (id: string) => void+}): React.JSX.Element {+ const [menu, setMenu] = useState<{ top: number; left: number; width: number; base: number } | null>(+ null+ )+ const current = resolveTerminalTheme(value)++ const open = (e: MouseEvent<HTMLButtonElement>): void => {+ const r = e.currentTarget.getBoundingClientRect()+ // `base` is the trigger's TOP edge: when the list would overflow the viewport it flips to open+ // ABOVE the trigger rather than above the 4px gap (see useMenuFlip).+ setMenu({ top: r.bottom + 4, left: r.left, width: r.width, base: r.top })+ }++ return (+ <>+ <button type="button" className="bind-select theme-select__trigger" onClick={open}>+ <Swatch theme={current} />+ <span className="bind-select__val">{current.label}</span>+ <span className="bind-select__chev">⌄</span>+ </button>+ {menu && (+ <ThemeMenu+ anchor={menu}+ value={current.id}+ onPick={(id) => {+ onChange(id)+ setMenu(null)+ }}+ onClose={() => setMenu(null)}+ />+ )}+ </>+ )+}++function ThemeMenu({+ anchor,+ value,+ onPick,+ onClose+}: {+ anchor: { top: number; left: number; width: number; base: number }+ value: string+ onPick: (id: string) => void+ onClose: () => void+}): React.ReactPortal {+ // Hook lives in its own component so it isn't called conditionally in ThemeSelect.+ const flip = useMenuFlip(anchor.top, anchor.left, anchor.base)+ return createPortal(+ <>+ <div className="tab-backdrop" style={{ zIndex: 78 }} onClick={onClose} />+ <div+ ref={flip.ref}+ className="tab-menu theme-select__menu"+ style={{ top: flip.top, left: flip.left, minWidth: anchor.width, zIndex: 80 }}+ >+ <Group+ label="Dark"+ themes={TERMINAL_THEMES.filter((t) => t.dark)}+ value={value}+ onPick={onPick}+ />+ <Group+ label="Light"+ themes={TERMINAL_THEMES.filter((t) => !t.dark)}+ value={value}+ onPick={onPick}+ />+ </div>+ </>,+ document.body+ )+}diff --git a/src/renderer/components/settings/sections/AppearanceSection.tsx b/src/renderer/components/settings/sections/AppearanceSection.tsxindex 4db712917..f1726af16 100644--- a/src/renderer/components/settings/sections/AppearanceSection.tsx+++ b/src/renderer/components/settings/sections/AppearanceSection.tsx@@ -12,6 +12,8 @@ import {type HideableRow} from '@renderer/lib/ui-visibility'import { cn } from '@renderer/ui/cn'+import { SectionReset } from '../SectionReset'+import { APPEARANCE_RESET_KEYS } from '@renderer/lib/settingsReset'const ROWS = {appTheme: {@@ -26,6 +28,10 @@ const ROWS = {headerButtons: {title: 'Terminal header buttons',keywords: ['terminal', 'header', 'buttons', 'icons', 'hide']+ },+ reset: {+ title: 'Reset appearance',+ keywords: ['reset', 'default', 'defaults', 'factory', 'restore', 'revert', 'undo']}}const ENTRIES = Object.values(ROWS)@@ -156,6 +162,13 @@ export function AppearanceSection({ isActive }: { isActive: boolean }): React.JS/></div></SearchableRow>+ <SearchableRow {...ROWS.reset}>+ <SectionReset+ keys={APPEARANCE_RESET_KEYS}+ label="Reset appearance"+ what="the appearance settings"+ />+ </SearchableRow></SettingsSection>)}diff --git a/src/renderer/components/settings/sections/TerminalSection.tsx b/src/renderer/components/settings/sections/TerminalSection.tsxindex b84538625..11048f2fb 100644--- a/src/renderer/components/settings/sections/TerminalSection.tsx+++ b/src/renderer/components/settings/sections/TerminalSection.tsx@@ -4,11 +4,13 @@ import { SearchableRow } from '../SearchableRow'import { FieldRow } from '../FieldRow'import { TerminalPreview } from '../TerminalPreview'import { FontPicker } from '../FontPicker'+import { ThemeSelect } from '../ThemeSelect'+import { SectionReset } from '../SectionReset'import { Switch } from '@renderer/ui/Switch'import { Select } from '@renderer/ui/Select'import { NumberField } from '@renderer/ui/NumberField'import { SegmentedPill } from '@renderer/ui/SegmentedPill'-import { TERMINAL_THEMES, resolveTerminalTheme } from '@renderer/terminal/themes'+import { TERMINAL_RESET_KEYS } from '@renderer/lib/settingsReset'import {TERMINAL_LETTER_SPACING_MAX,TERMINAL_LETTER_SPACING_MIN,@@ -19,79 +21,78 @@ import { resolveGpuRendering } from '@shared/webgl'import { isMacPlatform } from '@shared/platform-utils'import type { TerminalCursorInactiveStyle, TerminalCursorStyle } from '@shared/types'-// One entry per row. The keywords matter as much as the titles: settings search matches on them,-// and an appearance setting is far more often looked for by symptom ("colors", "scheme",-// "spacing") than by whatever we chose to call it.+/**+ * Row metadata for the settings search. Keywords matter as much as titles: an appearance setting+ * is far more often looked for by symptom ("colors", "flicker", "spacing") than by our label.+ *+ * Rows that carry two related controls (size+weight, line+letter) list the keywords for BOTH, so+ * searching either word still surfaces the row that holds it.+ */const ROWS = {- fontSize: { title: 'Font size', keywords: ['font', 'size', 'text', 'zoom'] },- fontFamily: {- title: 'Font family',- keywords: ['font', 'family', 'typeface', 'monospace', 'mono']- },theme: {title: 'Colour theme',keywords: [- 'theme',- 'color',- 'colour',- 'scheme',- 'palette',- 'ansi',- 'dracula',- 'nord',- 'gruvbox',- 'solarized',- 'tokyo',- 'catppuccin',- 'dark',- 'light'+ 'theme', 'color', 'colour', 'scheme', 'palette', 'ansi', 'dracula', 'nord', 'gruvbox',+ 'solarized', 'tokyo', 'catppuccin', 'dark', 'light']},- fontWeight: {- title: 'Font weight',- keywords: ['font', 'weight', 'bold', 'thin', 'light', 'heavy']+ fontFamily: {+ title: 'Font',+ keywords: ['font', 'family', 'typeface', 'monospace', 'mono', 'ligature']},- boldBright: {- title: 'Bold text uses bright colours',- keywords: ['bold', 'bright', 'color', 'colour', 'intense']+ fontSize: {+ title: 'Size and weight',+ keywords: ['font', 'size', 'text', 'zoom', 'weight', 'bold', 'thin', 'light', 'heavy']},- minContrast: {- title: 'Minimum contrast',+ spacing: {+ title: 'Spacing',keywords: [- 'contrast',- 'readable',- 'legible',- 'accessibility',- 'a11y',- 'wcag',- 'dim',- 'unreadable'+ 'spacing', 'line', 'height', 'leading', 'density', 'letter', 'tracking', 'character']},- cursorStyle: {- title: 'Cursor style',- keywords: ['cursor', 'style', 'block', 'bar', 'beam', 'underline']+ cursor: {+ title: 'Cursor',+ keywords: ['cursor', 'style', 'block', 'bar', 'beam', 'underline', 'blink', 'caret']},cursorInactive: {title: 'Cursor when unfocused',keywords: ['cursor', 'inactive', 'unfocused', 'blurred', 'outline']},- cursorBlink: { title: 'Cursor blink', keywords: ['cursor', 'blink'] },- lineHeight: {- title: 'Line height',- keywords: ['line', 'height', 'leading', 'spacing', 'density']+ boldBright: {+ title: 'Bold text uses bright colours',+ keywords: ['bold', 'bright', 'color', 'colour', 'intense']},- letterSpacing: {- title: 'Letter spacing',- keywords: ['letter', 'spacing', 'tracking', 'character', 'width']+ minContrast: {+ title: 'Minimum contrast',+ keywords: [+ 'contrast', 'readable', 'legible', 'accessibility', 'a11y', 'wcag', 'dim', 'unreadable'+ ]},gpu: {title: 'GPU terminal rendering',keywords: ['gpu', 'webgl', 'renderer', 'flicker', 'performance', 'graphics', 'acceleration']+ },+ reset: {+ title: 'Reset terminal appearance',+ keywords: ['reset', 'default', 'defaults', 'factory', 'restore', 'revert', 'undo']}}const ENTRIES = Object.values(ROWS)+const CURSOR_STYLES: { value: TerminalCursorStyle; label: string }[] = [+ { value: 'block', label: 'Block' },+ { value: 'bar', label: 'Bar' },+ { value: 'underline', label: 'Underline' }+]++const CURSOR_INACTIVE_STYLES: { value: TerminalCursorInactiveStyle; label: string }[] = [+ { value: 'outline', label: 'Outline' },+ { value: 'block', label: 'Block' },+ { value: 'bar', label: 'Bar' },+ { value: 'underline', label: 'Underline' },+ { value: 'none', label: 'Hidden' }+]+const FONT_WEIGHTS: { value: number; label: string }[] = [{ value: 100, label: 'Thin' },{ value: 200, label: 'Extra light' },@@ -114,91 +115,72 @@ const MIN_CONTRAST_OPTIONS: { value: number; label: string }[] = [{ value: 21, label: 'Maximum' }]-const CURSOR_STYLES: { value: TerminalCursorStyle; label: string }[] = [- { value: 'block', label: 'Block' },- { value: 'bar', label: 'Bar' },- { value: 'underline', label: 'Underline' }-]--const CURSOR_INACTIVE_STYLES: { value: TerminalCursorInactiveStyle; label: string }[] = [- { value: 'outline', label: 'Outline' },- { value: 'block', label: 'Block' },- { value: 'bar', label: 'Bar' },- { value: 'underline', label: 'Underline' },- { value: 'none', label: 'Hidden' }-]--/** A sub-heading inside the section. Terminal grew past the point where one flat list of rows- * reads as anything — the groups are what keep it scannable. */+/** A sub-heading inside the section, riding on the first row of its group so a search that hides+ * every row in the group takes the heading with it. */function GroupHeading({ children }: { children: React.ReactNode }): React.JSX.Element {return (<h4 className="text-[11px] font-semibold uppercase tracking-wide text-muted-2">{children}</h4>)}-/** The theme's background plus a few of its colours, so the picker is legible without reading- * every option's name. */-function ThemeSwatch({ themeId }: { themeId: string }): React.JSX.Element {- const { theme } = resolveTerminalTheme(themeId)- return (- <span- className="inline-flex items-center gap-1 rounded border border-border px-1.5 py-1"- style={{ background: theme.background }}- aria-hidden="true"- >- {[theme.foreground, theme.red, theme.green, theme.yellow, theme.blue, theme.magenta].map(- (c, i) => (- <span key={i} className="size-2 rounded-full" style={{ background: c }} />- )- )}- </span>- )+/** A secondary label between two controls sharing one row ("13 · bold 700"). */+function Sub({ children }: { children: React.ReactNode }): React.JSX.Element {+ return <span className="text-[13px] text-muted">{children}</span>}export function TerminalSection({ isActive }: { isActive: boolean }): React.JSX.Element {const settings = useSettings((s) => s.settings)const update = useSettings((s) => s.update)- const darkThemes = TERMINAL_THEMES.filter((t) => t.dark)- const lightThemes = TERMINAL_THEMES.filter((t) => !t.dark)return (<SettingsSection id="terminal" title="Terminal" isActive={isActive} searchEntries={ENTRIES}>- {/* The group headings ride on the FIRST row of each group rather than standing alone, so a- search that hides every row in a group takes its heading with it. */}- <SearchableRow {...ROWS.fontSize}>+ {/* The preview leads. Every control below changes what it shows, so anchoring it at the top+ means a choice is a look rather than a scroll back up — and it keeps the section short+ enough that the troubleshooting toggle at the foot is still on screen. */}+ <SearchableRow {...ROWS.theme}><div className="space-y-3">- <GroupHeading>Font</GroupHeading>+ <TerminalPreview /><FieldRow- label="Font size"+ label="Colour theme"+ description="Applies to every terminal — on the canvas and in kanban cards. A light theme also turns the app light (Settings → Appearance)."control={- <NumberField- value={settings.fontSize}- min={8}- max={28}- onChange={(v) => update({ fontSize: v || 13 })}+ <ThemeSelect+ value={settings.terminalTheme}+ onChange={(id) => update({ terminalTheme: id })}/>}/></div></SearchableRow>+<SearchableRow {...ROWS.fontFamily}>- <FieldRow- label="Font family"- description="Only fonts installed on this machine are listed. The field below is the full CSS stack — keep a generic monospace last, so the setting still works on a machine without your font."- control={- <FontPicker- value={settings.fontFamily}- onChange={(stack) => update({ fontFamily: stack })}- />- }- />+ <div className="space-y-3">+ <GroupHeading>Font</GroupHeading>+ <FieldRow+ label="Font"+ description="Only fonts installed on this machine are listed. The field below is the full CSS stack — keep a generic monospace last, so the setting still works on a machine without your font."+ control={+ <FontPicker+ value={settings.fontFamily}+ onChange={(stack) => update({ fontFamily: stack })}+ />+ }+ />+ </div></SearchableRow>- <SearchableRow {...ROWS.fontWeight}>+ <SearchableRow {...ROWS.fontSize}><FieldRow- label="Font weight"+ label="Size and weight"control={<span className="flex items-center gap-2">+ <NumberField+ className="w-16"+ value={settings.fontSize}+ min={8}+ max={28}+ onChange={(v) => update({ fontSize: v || 13 })}+ /><Select- className="w-32"+ className="w-28"value={String(settings.fontWeight)}onChange={(e) => update({ fontWeight: Number(e.target.value) })}aria-label="Font weight"@@ -209,9 +191,9 @@ export function TerminalSection({ isActive }: { isActive: boolean }): React.JSX.</option>))}</Select>- <span className="text-[13px] text-muted">bold</span>+ <Sub>bold</Sub><Select- className="w-32"+ className="w-28"value={String(settings.fontWeightBold)}onChange={(e) => update({ fontWeightBold: Number(e.target.value) })}aria-label="Bold font weight"@@ -226,70 +208,73 @@ export function TerminalSection({ isActive }: { isActive: boolean }): React.JSX.}/></SearchableRow>- <SearchableRow {...ROWS.boldBright}>+ <SearchableRow {...ROWS.spacing}><FieldRow- label="Bold text uses bright colours"- description="The historical terminal convention, and xterm's default. Turn it off to keep bold purely a weight, so a program's colour choice survives."+ label="Spacing"+ description="Line height multiplies the font size; letter spacing adds pixels between characters. Push either far and the box-drawing characters agent CLIs frame their output with stop meeting."control={- <Switch- checked={settings.drawBoldTextInBrightColors}- onChange={(v) => update({ drawBoldTextInBrightColors: v })}- ariaLabel="Bold text uses bright colours"- />+ <span className="flex items-center gap-2">+ <Sub>line</Sub>+ <NumberField+ className="w-20"+ value={settings.terminalLineHeight}+ min={TERMINAL_LINE_HEIGHT_MIN}+ max={TERMINAL_LINE_HEIGHT_MAX}+ step={0.05}+ onChange={(v) => update({ terminalLineHeight: v || 1 })}+ />+ <Sub>letter</Sub>+ <NumberField+ className="w-20"+ value={settings.terminalLetterSpacing}+ min={TERMINAL_LETTER_SPACING_MIN}+ max={TERMINAL_LETTER_SPACING_MAX}+ step={0.5}+ onChange={(v) => update({ terminalLetterSpacing: v ?? 0 })}+ />+ </span>}/></SearchableRow>- <SearchableRow {...ROWS.theme}>+ <SearchableRow {...ROWS.cursor}><div className="space-y-3">- <GroupHeading>Colours</GroupHeading>+ <GroupHeading>Cursor</GroupHeading><FieldRow- label="Colour theme"- description="Applies to every terminal — on the canvas and in kanban cards."+ label="Cursor"control={- <span className="flex items-center gap-2">- <ThemeSwatch themeId={settings.terminalTheme} />- {/* Value goes through the resolver so a stored id we no longer ship shows the- default as selected, instead of leaving the picker apparently blank. */}- <Select- className="w-48"- value={resolveTerminalTheme(settings.terminalTheme).id}- onChange={(e) => update({ terminalTheme: e.target.value })}- aria-label="Colour theme"- >- <optgroup label="Dark">- {darkThemes.map((t) => (- <option key={t.id} value={t.id}>- {t.label}- </option>- ))}- </optgroup>- <optgroup label="Light">- {lightThemes.map((t) => (- <option key={t.id} value={t.id}>- {t.label}- </option>- ))}- </optgroup>- </Select>+ <span className="flex items-center gap-3">+ <SegmentedPill+ value={settings.cursorStyle}+ options={CURSOR_STYLES}+ onChange={(v) => update({ cursorStyle: v })}+ ariaLabel="Cursor style"+ />+ <Sub>blink</Sub>+ <Switch+ checked={settings.cursorBlink}+ onChange={(v) => update({ cursorBlink: v })}+ ariaLabel="Cursor blink"+ /></span>}/>- <TerminalPreview /></div></SearchableRow>- <SearchableRow {...ROWS.minContrast}>+ <SearchableRow {...ROWS.cursorInactive}><FieldRow- label="Minimum contrast"- description="Lightens or darkens foreground colours that fall below the ratio against their background — the fix for a theme whose dark blue is unreadable. Costs per-cell work in the renderer, so it is off by default."+ label="When unfocused"+ description="What the cursor looks like in a terminal that isn't taking your keystrokes — the quickest way to tell which of a canvas full of terminals is focused."control={<Select- className="w-44"- value={String(settings.terminalMinContrast)}- onChange={(e) => update({ terminalMinContrast: Number(e.target.value) })}- aria-label="Minimum contrast"+ className="w-36"+ value={settings.cursorInactiveStyle}+ onChange={(e) =>+ update({ cursorInactiveStyle: e.target.value as TerminalCursorInactiveStyle })+ }+ aria-label="Cursor when unfocused">- {MIN_CONTRAST_OPTIONS.map((o) => (+ {CURSOR_INACTIVE_STYLES.map((o) => (<option key={o.value} value={o.value}>{o.label}</option>@@ -299,36 +284,34 @@ export function TerminalSection({ isActive }: { isActive: boolean }): React.JSX./></SearchableRow>- <SearchableRow {...ROWS.cursorStyle}>+ <SearchableRow {...ROWS.boldBright}><div className="space-y-3">- <GroupHeading>Cursor</GroupHeading>+ <GroupHeading>Advanced</GroupHeading><FieldRow- label="Cursor style"+ label="Bold text uses bright colours"+ description="The historical terminal convention, and xterm's default. Turn it off to keep bold purely a weight, so a program's colour choice survives."control={- <SegmentedPill- value={settings.cursorStyle}- options={CURSOR_STYLES}- onChange={(v) => update({ cursorStyle: v })}- ariaLabel="Cursor style"+ <Switch+ checked={settings.drawBoldTextInBrightColors}+ onChange={(v) => update({ drawBoldTextInBrightColors: v })}+ ariaLabel="Bold text uses bright colours"/>}/></div></SearchableRow>- <SearchableRow {...ROWS.cursorInactive}>+ <SearchableRow {...ROWS.minContrast}><FieldRow- label="Cursor when unfocused"- description="What the cursor looks like in a terminal that isn't taking your keystrokes — the quickest way to tell which of a canvas full of terminals is focused."+ label="Minimum contrast"+ description="Lightens or darkens foreground colours that fall below the ratio against their background — the fix for a theme whose dark blue is unreadable. Costs per-cell work in the renderer, so it is off by default."control={<Select- className="w-36"- value={settings.cursorInactiveStyle}- onChange={(e) =>- update({ cursorInactiveStyle: e.target.value as TerminalCursorInactiveStyle })- }- aria-label="Cursor when unfocused"+ className="w-44"+ value={String(settings.terminalMinContrast)}+ onChange={(e) => update({ terminalMinContrast: Number(e.target.value) })}+ aria-label="Minimum contrast">- {CURSOR_INACTIVE_STYLES.map((o) => (+ {MIN_CONTRAST_OPTIONS.map((o) => (<option key={o.value} value={o.value}>{o.label}</option>@@ -337,73 +320,31 @@ export function TerminalSection({ isActive }: { isActive: boolean }): React.JSX.}/></SearchableRow>- <SearchableRow {...ROWS.cursorBlink}>+ <SearchableRow {...ROWS.gpu}><FieldRow- label="Cursor blink"+ label="GPU terminal rendering"+ description={+ isMacPlatform()+ ? 'Off by default on macOS (WebGL terminals can flicker or composite black there). Turning it on is an explicit opt-in.'+ : 'Turn off if the window flickers. Terminals then use the DOM renderer (no WebGL).'+ }control={<Switch- checked={settings.cursorBlink}- onChange={(v) => update({ cursorBlink: v })}- ariaLabel="Cursor blink"+ checked={resolveGpuRendering(settings.terminalGpuRendering, isMacPlatform())}+ onChange={(v) => update({ terminalGpuRendering: v ? 'on' : 'off' })}+ ariaLabel="GPU terminal rendering"/>}/></SearchableRow>- <SearchableRow {...ROWS.lineHeight}>- <div className="space-y-3">- <GroupHeading>Spacing</GroupHeading>- <FieldRow- label="Line height"- description="A multiple of the font size. Higher is airier but fits fewer rows."- control={- <NumberField- value={settings.terminalLineHeight}- min={TERMINAL_LINE_HEIGHT_MIN}- max={TERMINAL_LINE_HEIGHT_MAX}- step={0.05}- onChange={(v) => update({ terminalLineHeight: v || 1 })}- />- }- />- </div>- </SearchableRow>- <SearchableRow {...ROWS.letterSpacing}>- <FieldRow- label="Letter spacing"- description="Extra pixels between characters. Past a point the box-drawing characters agent CLIs frame their output with stop meeting."- control={- <NumberField- value={settings.terminalLetterSpacing}- min={TERMINAL_LETTER_SPACING_MIN}- max={TERMINAL_LETTER_SPACING_MAX}- step={0.5}- onChange={(v) => update({ terminalLetterSpacing: v ?? 0 })}- />- }+ <SearchableRow {...ROWS.reset}>+ <SectionReset+ keys={TERMINAL_RESET_KEYS}+ label="Reset terminal appearance"+ what="the terminal appearance settings"/></SearchableRow>-- <SearchableRow {...ROWS.gpu}>- <div className="space-y-3">- <GroupHeading>Advanced</GroupHeading>- <FieldRow- label="GPU terminal rendering"- description={- isMacPlatform()- ? 'Off by default on macOS (WebGL terminals can flicker or composite black there). Turning it on is an explicit opt-in.'- : 'Turn off if the window flickers. Terminals then use the DOM renderer (no WebGL).'- }- control={- <Switch- checked={resolveGpuRendering(settings.terminalGpuRendering, isMacPlatform())}- onChange={(v) => update({ terminalGpuRendering: v ? 'on' : 'off' })}- ariaLabel="GPU terminal rendering"- />- }- />- </div>- </SearchableRow></SettingsSection>)}diff --git a/src/renderer/lib/settingsReset.test.ts b/src/renderer/lib/settingsReset.test.tsnew file mode 100644index 000000000..26ac5d2a6--- /dev/null+++ b/src/renderer/lib/settingsReset.test.ts@@ -0,0 +1,80 @@+import { describe, it, expect } from 'vitest'+import { DEFAULT_SETTINGS, type Settings } from '@shared/types'+import {+ APPEARANCE_RESET_KEYS,+ TERMINAL_RESET_KEYS,+ isPristine,+ resetPatch+} from './settingsReset'++describe('reset key lists', () => {+ it.each([+ ['terminal', TERMINAL_RESET_KEYS],+ ['appearance', APPEARANCE_RESET_KEYS]+ ])('%s keys all exist in DEFAULT_SETTINGS', (_name, keys) => {+ for (const k of keys) expect(DEFAULT_SETTINGS).toHaveProperty(k)+ })++ it.each([+ ['terminal', TERMINAL_RESET_KEYS],+ ['appearance', APPEARANCE_RESET_KEYS]+ ])('%s keys have no duplicates', (_name, keys) => {+ expect(new Set(keys).size).toBe(keys.length)+ })++ it('the two sections claim no key in common — a reset must have one owner', () => {+ const overlap = TERMINAL_RESET_KEYS.filter((k) =>+ (APPEARANCE_RESET_KEYS as readonly string[]).includes(k)+ )+ expect(overlap).toEqual([])+ })++ // Deliberate exclusion: the terminal renders with it, but it belongs to the tmux section, and+ // resetting a scrollback limit from an appearance button would be a surprise.+ it('does not claim tmuxScrollback', () => {+ expect(TERMINAL_RESET_KEYS).not.toContain('tmuxScrollback')+ })++ // A global "reset everything" would empty these; per-section lists must never reach them.+ it.each(['claudeAccounts', 'customAgents', 'seenOnboarding', 'phoneAccessEnabled'])(+ 'never resets %s',+ (danger) => {+ expect([...TERMINAL_RESET_KEYS, ...APPEARANCE_RESET_KEYS]).not.toContain(danger)+ }+ )+})++describe('resetPatch', () => {+ it('returns exactly the defaults for the listed keys', () => {+ const patch = resetPatch(TERMINAL_RESET_KEYS)+ expect(Object.keys(patch).sort()).toEqual([...TERMINAL_RESET_KEYS].sort())+ for (const k of TERMINAL_RESET_KEYS) expect(patch[k]).toEqual(DEFAULT_SETTINGS[k])+ })++ it('touches nothing outside the list', () => {+ expect(resetPatch(['fontSize'] as const)).toEqual({ fontSize: DEFAULT_SETTINGS.fontSize })+ })+})++describe('isPristine', () => {+ it('is true for untouched defaults', () => {+ expect(isPristine(TERMINAL_RESET_KEYS, DEFAULT_SETTINGS)).toBe(true)+ })++ it('is false once any listed key differs', () => {+ const changed: Settings = { ...DEFAULT_SETTINGS, terminalTheme: 'dracula' }+ expect(isPristine(TERMINAL_RESET_KEYS, changed)).toBe(false)+ })++ it('ignores changes to keys it was not asked about', () => {+ const changed: Settings = { ...DEFAULT_SETTINGS, tmuxScrollback: 999 }+ expect(isPristine(TERMINAL_RESET_KEYS, changed)).toBe(true)+ })++ it('compares list-valued keys structurally, not by identity', () => {+ const sameContent: Settings = { ...DEFAULT_SETTINGS, hiddenHeaderButtons: [] }+ expect(isPristine(APPEARANCE_RESET_KEYS, sameContent)).toBe(true)+ const different: Settings = { ...DEFAULT_SETTINGS, hiddenHeaderButtons: ['branch'] }+ expect(isPristine(APPEARANCE_RESET_KEYS, different)).toBe(false)+ })+})diff --git a/src/renderer/lib/settingsReset.ts b/src/renderer/lib/settingsReset.tsnew file mode 100644index 000000000..764f78891--- /dev/null+++ b/src/renderer/lib/settingsReset.ts@@ -0,0 +1,61 @@+import { DEFAULT_SETTINGS, type Settings } from '@shared/types'++/**+ * Restoring a SECTION of settings to their shipped defaults.+ *+ * Deliberately per-section rather than one global "reset everything". `DEFAULT_SETTINGS` is the+ * state of a fresh install, which means a global reset would also empty `claudeAccounts` (logged-in+ * identities), `customAgents` and `disabledAgents`, and re-arm the first-run tour — destroying real+ * work to undo a font choice. A reset the user reaches for after fiddling with appearance should+ * put back exactly what they were fiddling with.+ */++/** The appearance settings the Terminal section owns. */+export const TERMINAL_RESET_KEYS = [+ 'fontFamily',+ 'fontSize',+ 'fontWeight',+ 'fontWeightBold',+ 'drawBoldTextInBrightColors',+ 'terminalMinContrast',+ 'terminalTheme',+ 'cursorStyle',+ 'cursorInactiveStyle',+ 'cursorBlink',+ 'terminalLineHeight',+ 'terminalLetterSpacing',+ 'terminalGpuRendering'+] as const satisfies readonly (keyof Settings)[]+// NOTE: `tmuxScrollback` is deliberately absent even though the terminal renders with it — it+// belongs to the tmux section, and resetting a history limit from an appearance button would be a+// surprise. Anything shared between sections stays with the section that PRESENTS it.++/** The appearance settings the Appearance section owns. */+export const APPEARANCE_RESET_KEYS = [+ 'appTheme',+ 'accent',+ 'hiddenNodeMenuItems',+ 'hiddenHeaderButtons'+] as const satisfies readonly (keyof Settings)[]++/** The defaults for `keys`, as a patch for `useSettings.update`. */+export function resetPatch<K extends keyof Settings>(keys: readonly K[]): Pick<Settings, K> {+ const out = {} as Pick<Settings, K>+ for (const k of keys) out[k] = DEFAULT_SETTINGS[k]+ return out+}++/**+ * Is every one of `keys` already at its default?+ *+ * Drives the button's disabled state, which is doing two jobs: it keeps a destructive-ish control+ * from being clicked for nothing, and it ANSWERS the question the user opened the section with —+ * "have I changed anything here?" — which is otherwise unanswerable without remembering the+ * defaults. Structural compare, so list-valued keys (the hidden-row arrays) work too.+ */+export function isPristine<K extends keyof Settings>(+ keys: readonly K[],+ current: Pick<Settings, K>+): boolean {+ return keys.every((k) => JSON.stringify(current[k]) === JSON.stringify(DEFAULT_SETTINGS[k]))+}diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex fc47f0e61..657f9ed33 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -9267,3 +9267,44 @@ body,width: 0;height: 0;}++/* ---- Settings → Terminal: the colour-theme dropdown ---- */+/* A theme IS its palette, so every row carries one. Built on the app's own menu idiom+ (`.bind-select` trigger + portaled `.tab-menu`), not a native <select>, which can only show+ names. */+.theme-swatch {+ display: inline-flex;+ align-items: center;+ gap: 3px;+ flex-shrink: 0;+ padding: 3px 5px;+ border-radius: 4px;+ border: 1px solid var(--border);+}+.theme-swatch__dot {+ width: 6px;+ height: 6px;+ border-radius: 50%;+}+.theme-select__trigger {+ /* The trigger sits in a FieldRow's control slot, which is `shrink-0` — so it needs a width of+ its own rather than the `width: 100%` .bind-select takes inside a dialog form. */+ width: 260px;+}+.theme-select__menu {+ max-height: 340px;+ overflow-y: auto;+}+.theme-select__group {+ padding: 6px 10px 2px;+ font-size: 11px;+ font-weight: 600;+ text-transform: uppercase;+ letter-spacing: 0.04em;+ color: var(--muted-2);+}+.theme-select__name {+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}