Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(settings): add tabbed layout to appearance panel

Steven Enamakel75b1c1d0453b
diff --git a/app/src/components/settings/panels/AppearancePanel.tsx b/app/src/components/settings/panels/AppearancePanel.tsx
index 91bce5cec8..a8696caf3b 100644
--- a/app/src/components/settings/panels/AppearancePanel.tsx
+++ b/app/src/components/settings/panels/AppearancePanel.tsx
@@ -1,4 +1,5 @@
import { useState } from 'react';
+import { useLocation, useNavigate } from 'react-router-dom';
import { useT } from '../../../lib/i18n/I18nContext';
import { useAppDispatch, useAppSelector } from '../../../store/hooks';
@@ -18,6 +19,8 @@ import { SettingsNumberField } from '../controls';
import SettingsPanel from '../layout/SettingsPanel';
import ThemeStudioPanel from './ThemeStudioPanel';
+type AppearanceTab = 'general' | 'studio';
+
interface FontSizeOption {
id: FontSize;
label: string;
@@ -30,6 +33,16 @@ const AppearancePanel = () => {
const { t } = useT();
const dispatch = useAppDispatch();
const effectiveFontSizePx = useAppSelector(selectEffectiveFontSizePx);
+ const location = useLocation();
+ const navigate = useNavigate();
+ // The URL hash is the source of truth for the tab, so `/settings/theme`
+ // (which redirects to `#studio`) and deep links land on the right one.
+ const tab: AppearanceTab = location.hash === '#studio' ? 'studio' : 'general';
+ const selectTab = (next: AppearanceTab) => {
+ navigate(`${location.pathname}${location.search}${next === 'studio' ? '#studio' : ''}`, {
+ replace: true,
+ });
+ };
// Local draft for the numeric px field so partial typing doesn't thrash the
// store; commits (blur / Enter) clamp and dispatch, while the slider dispatches
@@ -88,107 +101,130 @@ const AppearancePanel = () => {
},
];
- return (
- <SettingsPanel description={t('settings.appearance.menuDesc')}>
- {/* Everyday controls first — theme, text size, language — then the
- Theme Studio customizer, collapsed. The theme gallery's header holds
- the Light / Dark / Auto toggle: `setThemeMode` and `setThemeVariant`
- write the same two slice fields, so there is one control, not two. */}
- <ThemeStudioPanel embedded part="gallery" />
+ const general = (
+ <>
+ <ThemeStudioPanel embedded part="gallery" />
- <Card
- title={t('settings.appearance.fontSizeHeading')}
- description={t('settings.appearance.fontSizeHelperText')}
- data-testid="font-size-card">
- {/* Card forwards no `role`/`aria-label` to its wrapper, so the
- radiogroup semantics sit on an inner div that encloses every
- option — `within(group)` in the specs resolves the same. */}
- <div
- role="radiogroup"
- aria-label={t('settings.appearance.fontSizeAria')}
- className="grid grid-cols-2 gap-2 p-4 sm:grid-cols-4">
- {FONT_SIZE_OPTIONS.map(opt => {
- // Highlight the preset whose px matches the effective size, so a
- // fine-tuned value landing exactly on a preset still lights it up.
- const selected = Number.parseInt(FONT_SIZE_PX[opt.id], 10) === effectiveFontSizePx;
- return (
- <button
- key={opt.id}
- type="button"
- role="radio"
- aria-checked={selected}
- title={opt.description}
- onClick={() => dispatch(setFontSize(opt.id))}
- className={cn(
- 'flex flex-col items-center gap-1.5 rounded-xl border px-3 py-3 transition-colors',
- 'focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/25',
- selected
- ? 'border-primary-500 bg-primary-50 ring-1 ring-primary-500 dark:bg-primary-500/10'
- : 'border-line hover:bg-surface-hover'
- )}>
- <span
+ <Card
+ title={t('settings.appearance.fontSizeHeading')}
+ description={t('settings.appearance.fontSizeHelperText')}
+ data-testid="font-size-card">
+ {/* Card forwards no `role`/`aria-label` to its wrapper, so the
+ radiogroup semantics sit on an inner div that encloses every
+ option — `within(group)` in the specs resolves the same. */}
+ <div
+ role="radiogroup"
+ aria-label={t('settings.appearance.fontSizeAria')}
+ className="grid grid-cols-2 gap-2 p-4 sm:grid-cols-4">
+ {FONT_SIZE_OPTIONS.map(opt => {
+ // Highlight the preset whose px matches the effective size, so a
+ // fine-tuned value landing exactly on a preset still lights it up.
+ const selected = Number.parseInt(FONT_SIZE_PX[opt.id], 10) === effectiveFontSizePx;
+ return (
+ <button
+ key={opt.id}
+ type="button"
+ role="radio"
+ aria-checked={selected}
+ title={opt.description}
+ onClick={() => dispatch(setFontSize(opt.id))}
className={cn(
- 'flex h-9 items-end font-semibold leading-none',
- opt.glyphClass,
- selected ? 'text-primary-500' : 'text-content-secondary'
- )}
- aria-hidden>
- Aa
- </span>
- <span className="text-xs font-medium text-content">{opt.label}</span>
- </button>
- );
- })}
- </div>
+ 'flex flex-col items-center gap-1.5 rounded-xl border px-3 py-3 transition-colors',
+ 'focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/25',
+ selected
+ ? 'border-primary-500 bg-primary-50 ring-1 ring-primary-500 dark:bg-primary-500/10'
+ : 'border-line hover:bg-surface-hover'
+ )}>
+ <span
+ className={cn(
+ 'flex h-9 items-end font-semibold leading-none',
+ opt.glyphClass,
+ selected ? 'text-primary-500' : 'text-content-secondary'
+ )}
+ aria-hidden>
+ Aa
+ </span>
+ <span className="text-xs font-medium text-content">{opt.label}</span>
+ </button>
+ );
+ })}
+ </div>
- {/* Fine-tune the exact size beyond the presets (issue #4246). */}
- <div className="px-4 py-3">
- <div className="flex items-center justify-between gap-3">
- <label htmlFor="font-size-custom-number" className="text-sm font-medium text-content">
- {t('settings.appearance.fontSizeCustomLabel')}
- </label>
- <SettingsNumberField
- id="font-size-custom-number"
- value={pxDraft}
- onChange={setPxDraft}
- onCommit={commitCustomFontSize}
- unit={t('settings.appearance.fontSizeUnit')}
+ {/* Fine-tune the exact size beyond the presets (issue #4246). */}
+ <div className="px-4 py-3">
+ <div className="flex items-center justify-between gap-3">
+ <label htmlFor="font-size-custom-number" className="text-sm font-medium text-content">
+ {t('settings.appearance.fontSizeCustomLabel')}
+ </label>
+ <SettingsNumberField
+ id="font-size-custom-number"
+ value={pxDraft}
+ onChange={setPxDraft}
+ onCommit={commitCustomFontSize}
+ unit={t('settings.appearance.fontSizeUnit')}
+ min={MIN_FONT_SIZE_PX}
+ max={MAX_FONT_SIZE_PX}
+ aria-label={t('settings.appearance.fontSizeCustomAria')}
+ data-testid="font-size-custom-number"
+ />
+ </div>
+ <Slider
+ id="font-size-slider"
min={MIN_FONT_SIZE_PX}
max={MAX_FONT_SIZE_PX}
- aria-label={t('settings.appearance.fontSizeCustomAria')}
- data-testid="font-size-custom-number"
+ step={1}
+ value={[effectiveFontSizePx]}
+ onValueChange={handleFontSizeSlider}
+ thumbLabels={[t('settings.appearance.fontSizeCustomSliderAria')]}
+ aria-valuetext={`${effectiveFontSizePx}${t('settings.appearance.fontSizeUnit')}`}
+ className="mt-3"
+ data-testid="font-size-slider"
/>
+ <div className="mt-1 flex items-center justify-between text-[11px] text-content-faint">
+ <span>{`${MIN_FONT_SIZE_PX}${t('settings.appearance.fontSizeUnit')}`}</span>
+ <span>{`${MAX_FONT_SIZE_PX}${t('settings.appearance.fontSizeUnit')}`}</span>
+ </div>
</div>
- <Slider
- id="font-size-slider"
- min={MIN_FONT_SIZE_PX}
- max={MAX_FONT_SIZE_PX}
- step={1}
- value={[effectiveFontSizePx]}
- onValueChange={handleFontSizeSlider}
- thumbLabels={[t('settings.appearance.fontSizeCustomSliderAria')]}
- aria-valuetext={`${effectiveFontSizePx}${t('settings.appearance.fontSizeUnit')}`}
- className="mt-3"
- data-testid="font-size-slider"
- />
- <div className="mt-1 flex items-center justify-between text-[11px] text-content-faint">
- <span>{`${MIN_FONT_SIZE_PX}${t('settings.appearance.fontSizeUnit')}`}</span>
- <span>{`${MAX_FONT_SIZE_PX}${t('settings.appearance.fontSizeUnit')}`}</span>
- </div>
- </div>
- </Card>
+ </Card>
- {/* Display language (moved from the old settings home list). */}
- <Card>
- <Field
- label={t('settings.language')}
- description={t('settings.languageDesc')}
- control={<LanguageSelect ariaLabel={t('settings.language')} />}
- />
- </Card>
+ {/* Display language (moved from the old settings home list). */}
+ <Card>
+ <Field
+ label={t('settings.language')}
+ description={t('settings.languageDesc')}
+ control={<LanguageSelect ariaLabel={t('settings.language')} />}
+ />
+ </Card>
+ </>
+ );
- <ThemeStudioPanel embedded part="customize" />
- </SettingsPanel>
+ return (
+ <SettingsPanel<AppearanceTab>
+ description={t('settings.appearance.menuDesc')}
+ tabsAriaLabel={t('settings.appearance.title')}
+ tabsTestIdPrefix="appearance-tab"
+ value={tab}
+ onChange={selectTab}
+ tabs={[
+ // Everyday controls: theme + Light/Dark/Auto, text size, language. The
+ // gallery's header holds the variant toggle — `setThemeMode` and
+ // `setThemeVariant` write the same two slice fields, so there is one
+ // control, not two.
+ {
+ id: 'general',
+ label: t('settings.general'),
+ content: general,
+ contentClassName: 'space-y-5',
+ },
+ // Colours, fonts, background and import/export for the active theme.
+ {
+ id: 'studio',
+ label: t('settings.theme.title'),
+ content: <ThemeStudioPanel embedded part="customize" />,
+ contentClassName: 'space-y-5',
+ },
+ ]}
+ />
);
};
diff --git a/app/src/components/settings/panels/ThemeStudioPanel.tsx b/app/src/components/settings/panels/ThemeStudioPanel.tsx
index 55f423f734..49c8737393 100644
--- a/app/src/components/settings/panels/ThemeStudioPanel.tsx
+++ b/app/src/components/settings/panels/ThemeStudioPanel.tsx
@@ -340,19 +340,14 @@ const ThemeStudioPanel = ({ embedded = false, part }: ThemeStudioPanelProps = {}
// and language settings, so the everyday controls sat a long scroll down.
const customize = (
<section className="space-y-2" data-testid="theme-customize">
- <div className="px-1">
- <h3 className="font-title text-sm font-semibold text-content">
- {t('settings.theme.title', 'Theme Studio')}
- </h3>
- {!isActiveCustom && (
- <p className="mt-0.5 text-xs text-content-muted">
- {t(
- 'settings.theme.autoForkHint',
- 'Editing a preset automatically saves your changes as a new custom theme.'
- )}
- </p>
- )}
- </div>
+ {!isActiveCustom && (
+ <p className="px-1 text-xs text-content-muted">
+ {t(
+ 'settings.theme.autoForkHint',
+ 'Editing a preset automatically saves your changes as a new custom theme.'
+ )}
+ </p>
+ )}
{isActiveCustom && contrastRisk && (
<Alert variant="warning" density="compact">
diff --git a/app/src/components/settings/settingsRouteElements.tsx b/app/src/components/settings/settingsRouteElements.tsx
index 0514aa02b9..fcecbd4f29 100644
--- a/app/src/components/settings/settingsRouteElements.tsx
+++ b/app/src/components/settings/settingsRouteElements.tsx
@@ -83,7 +83,7 @@ export function settingsRouteElements(): ReactNode {
<Route path="migration" element={wrapSettingsPage(<MigrationPanel />)} />
<Route path="appearance" element={wrapSettingsPage(<AppearancePanel />)} />
{/* Theme studio merged into Appearance — one page for one subject. */}
- <Route path="theme" element={<SettingsRedirect to="/settings/appearance" />} />
+ <Route path="theme" element={<SettingsRedirect to="/settings/appearance#studio" />} />
<Route path="notifications" element={wrapSettingsPage(<NotificationsPanel />)} />
{/* Real device-pairing panel (replaces the old "Coming Soon" stub). */}
<Route path="devices" element={wrapSettingsPage(<DevicesPanel />)} />