diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts
index 8444a7f82e..3a4107b194 100644
--- a/apps/desktop/src/main.ts
+++ b/apps/desktop/src/main.ts
@@ -1168,8 +1168,7 @@ function registerIpcHandlers(): void {
const mode = getSafeTheme(appearance.mode);
if (!mode) return;
nativeTheme.themeSource = mode;
- // themeId and accentHue are stored for future Electron shell styling
- // (title bar tint, vibrancy, etc.)
+ // themeId is available for future Electron shell styling work.
});
ipcMain.removeHandler(CONTEXT_MENU_CHANNEL);
diff --git a/apps/server/src/serverSettings.test.ts b/apps/server/src/serverSettings.test.ts
index f26fece246..d733b5ff21 100644
--- a/apps/server/src/serverSettings.test.ts
+++ b/apps/server/src/serverSettings.test.ts
@@ -179,4 +179,95 @@ it.layer(NodeServices.layer)("server settings", (it) => {
});
}).pipe(Effect.provide(makeServerSettingsLayer())),
);
+
+ it.effect("persists custom themes as part of server-authoritative appearance settings", () =>
+ Effect.gen(function* () {
+ const serverSettings = yield* ServerSettingsService;
+ const serverConfig = yield* ServerConfig;
+ const fileSystem = yield* FileSystem.FileSystem;
+
+ const next = yield* serverSettings.updateSettings({
+ activeLightThemeId: "custom-codex-light",
+ activeDarkThemeId: "custom-codex-dark",
+ customThemes: [
+ {
+ id: "custom-codex-light",
+ name: "Custom Codex Light",
+ version: 1,
+ origin: "custom",
+ mode: "light",
+ radius: "0.75rem",
+ fontSize: "15px",
+ accent: "#0169cc",
+ background: "#ffffff",
+ foreground: "#0d0d0d",
+ uiFontFamily: '"IBM Plex Sans", sans-serif',
+ codeFontFamily: '"IBM Plex Mono", monospace',
+ sidebarTranslucent: true,
+ contrast: 46,
+ },
+ {
+ id: "custom-codex-dark",
+ name: "Custom Codex Dark",
+ version: 1,
+ origin: "custom",
+ mode: "dark",
+ radius: "0.75rem",
+ fontSize: "15px",
+ accent: "#0169cc",
+ background: "#111111",
+ foreground: "#fcfcfc",
+ uiFontFamily: '"IBM Plex Sans", sans-serif',
+ codeFontFamily: '"IBM Plex Mono", monospace',
+ sidebarTranslucent: true,
+ contrast: 41,
+ },
+ ],
+ });
+
+ assert.equal(next.activeLightThemeId, "custom-codex-light");
+ assert.equal(next.activeDarkThemeId, "custom-codex-dark");
+ assert.equal(next.customThemes.length, 2);
+
+ const raw = yield* fileSystem.readFileString(serverConfig.settingsPath);
+ assert.deepEqual(JSON.parse(raw), {
+ activeLightThemeId: "custom-codex-light",
+ activeDarkThemeId: "custom-codex-dark",
+ customThemes: [
+ {
+ id: "custom-codex-light",
+ name: "Custom Codex Light",
+ version: 1,
+ origin: "custom",
+ mode: "light",
+ radius: "0.75rem",
+ fontSize: "15px",
+ accent: "#0169cc",
+ background: "#ffffff",
+ foreground: "#0d0d0d",
+ uiFontFamily: '"IBM Plex Sans", sans-serif',
+ codeFontFamily: '"IBM Plex Mono", monospace',
+ sidebarTranslucent: true,
+ contrast: 46,
+ },
+ {
+ id: "custom-codex-dark",
+ name: "Custom Codex Dark",
+ version: 1,
+ origin: "custom",
+ mode: "dark",
+ radius: "0.75rem",
+ fontSize: "15px",
+ accent: "#0169cc",
+ background: "#111111",
+ foreground: "#fcfcfc",
+ uiFontFamily: '"IBM Plex Sans", sans-serif',
+ codeFontFamily: '"IBM Plex Mono", monospace',
+ sidebarTranslucent: true,
+ contrast: 41,
+ },
+ ],
+ });
+ }).pipe(Effect.provide(makeServerSettingsLayer())),
+ );
});
diff --git a/apps/web/src/components/KeybindingsToast.browser.tsx b/apps/web/src/components/KeybindingsToast.browser.tsx
index db2498043c..19f162abe3 100644
--- a/apps/web/src/components/KeybindingsToast.browser.tsx
+++ b/apps/web/src/components/KeybindingsToast.browser.tsx
@@ -61,8 +61,9 @@ function createBaseServerConfig(): ServerConfig {
defaultThreadEnvMode: "local" as const,
textGenerationModelSelection: { provider: "codex" as const, model: "gpt-5.4-mini" },
colorMode: "system" as const,
- activeThemeId: "t3code",
- accentHue: null,
+ activeLightThemeId: "t3code-light",
+ activeDarkThemeId: "t3code-dark",
+ customThemes: [],
providers: {
codex: { enabled: true, binaryPath: "", homePath: "", customModels: [] },
claudeAgent: { enabled: true, binaryPath: "", customModels: [] },
diff --git a/apps/web/src/components/settings/AppearanceSettingsPanel.tsx b/apps/web/src/components/settings/AppearanceSettingsPanel.tsx
index 65a295c979..25c7569973 100644
--- a/apps/web/src/components/settings/AppearanceSettingsPanel.tsx
+++ b/apps/web/src/components/settings/AppearanceSettingsPanel.tsx
@@ -1,300 +1,798 @@
-import { CheckIcon } from "lucide-react";
-import { useCallback, useRef } from "react";
-import type { ColorMode } from "@t3tools/contracts/settings";
-import { useAppearance } from "../../hooks/useAppearance";
import {
- ACCENT_PRESETS,
- BUILT_IN_THEMES,
- DEFAULT_THEME_ID,
- type ThemeDefinition,
- type ThemeTokenMap,
-} from "../../lib/themes";
+ ChevronDownIcon,
+ CopyIcon,
+ MonitorIcon,
+ MoonIcon,
+ RotateCcwIcon,
+ SunIcon,
+ Trash2Icon,
+ UploadIcon,
+} from "lucide-react";
+import { Schema, SchemaIssue } from "effect";
+import { type ChangeEvent, useCallback, useMemo, useRef, useState } from "react";
+import {
+ ThemeDocumentSchema,
+ type ColorMode,
+ type ThemeDerivedOverrides,
+ type ThemeDocument,
+ type ThemeMode,
+} from "@t3tools/contracts";
+import {
+ BUILTIN_THEME_PRESETS,
+ canonicalizeThemeDocument,
+ getDefaultThemeId,
+ getThemeDocumentsForMode,
+ serializeThemeDocument,
+} from "@t3tools/shared/appearance/registry";
import { cn } from "../../lib/utils";
+import { useAppearance } from "../../hooks/useAppearance";
+import { useUpdateSettings } from "../../hooks/useSettings";
+import { toastManager } from "../ui/toast";
+import { Badge } from "../ui/badge";
import { Button } from "../ui/button";
-import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
+import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../ui/collapsible";
+import { Input } from "../ui/input";
+import { Switch } from "../ui/switch";
+import { SettingsPageContainer, SettingsSection } from "./SettingsPanels";
import {
- SettingResetButton,
- SettingsPageContainer,
- SettingsRow,
- SettingsSection,
-} from "./SettingsPanels";
-
-// ── Constants ────────────────────────────────────────────────────
+ createDuplicateTheme,
+ normalizeImportedThemeDocument,
+ replaceCustomTheme,
+ updateThemeDocument,
+} from "./appearance.logic";
const COLOR_MODE_OPTIONS = [
- { value: "system", label: "System" },
- { value: "light", label: "Light" },
- { value: "dark", label: "Dark" },
-] as const;
+ { value: "system", label: "System", icon: MonitorIcon },
+ { value: "light", label: "Light", icon: SunIcon },
+ { value: "dark", label: "Dark", icon: MoonIcon },
+] as const satisfies ReadonlyArray<{
+ value: ColorMode;
+ label: string;
+ icon: typeof MonitorIcon;
+}>;
-// ── Swatch preview ──────────────────────────────────────────────
-
-/** Render small color dots showing what the theme overrides. */
-function ThemeSwatch({ theme }: { theme: ThemeDefinition }) {
- // Show the tokens the theme actually overrides (merge light + dark for preview)
- const overrideTokens = Object.keys({ ...theme.light, ...theme.dark }) as Array<
- keyof ThemeTokenMap
- >;
-
- if (overrideTokens.length === 0) {
- // Default theme — show placeholder dots
- return (
-
- {Array.from({ length: 4 }, (_, i) => (
-
- ))}
-
- );
+const MODE_COPY = {
+ light: {
+ label: "Light Theme",
+ modeLabel: "Light",
+ importTitle: "Import Light Theme",
+ emptyDescription: "Imported or duplicated light theme.",
+ },
+ dark: {
+ label: "Dark Theme",
+ modeLabel: "Dark",
+ importTitle: "Import Dark Theme",
+ emptyDescription: "Imported or duplicated dark theme.",
+ },
+} as const satisfies Record<
+ ThemeMode,
+ {
+ label: string;
+ modeLabel: string;
+ importTitle: string;
+ emptyDescription: string;
}
+>;
- // For display, prefer light-mode values (more vivid), fall back to dark
- const displayTokens = overrideTokens.filter((t) => !t.endsWith("-foreground")).slice(0, 5);
-
- return (
-
- {displayTokens.map((token) => {
- const color = theme.light[token] ?? theme.dark[token];
- return color ? (
-
- ) : (
-
- );
- })}
-
- );
-}
-
-// ── Theme card ───────────────────────────────────────────────────
+const OVERRIDE_FIELDS: ReadonlyArray<{
+ key: keyof ThemeDerivedOverrides;
+ label: string;
+ placeholder: string;
+}> = [
+ { key: "background", label: "Background", placeholder: "Auto" },
+ { key: "foreground", label: "Foreground", placeholder: "Auto" },
+ { key: "card", label: "Card", placeholder: "Auto" },
+ { key: "cardForeground", label: "Card text", placeholder: "Auto" },
+ { key: "popover", label: "Popover", placeholder: "Auto" },
+ { key: "popoverForeground", label: "Popover text", placeholder: "Auto" },
+ { key: "primary", label: "Primary", placeholder: "Auto" },
+ { key: "primaryForeground", label: "Primary text", placeholder: "Auto" },
+ { key: "secondary", label: "Secondary", placeholder: "Auto" },
+ { key: "secondaryForeground", label: "Secondary text", placeholder: "Auto" },
+ { key: "muted", label: "Muted", placeholder: "Auto" },
+ { key: "mutedForeground", label: "Muted text", placeholder: "Auto" },
+ { key: "accentSurface", label: "Accent surface", placeholder: "Auto" },
+ { key: "accentForeground", label: "Accent text", placeholder: "Auto" },
+ { key: "border", label: "Border", placeholder: "Auto" },
+ { key: "input", label: "Input", placeholder: "Auto" },
+ { key: "ring", label: "Ring", placeholder: "Auto" },
+ { key: "destructive", label: "Destructive", placeholder: "Auto" },
+ { key: "destructiveForeground", label: "Destructive text", placeholder: "Auto" },
+ { key: "info", label: "Info", placeholder: "Auto" },
+ { key: "infoForeground", label: "Info text", placeholder: "Auto" },
+ { key: "success", label: "Success", placeholder: "Auto" },
+ { key: "successForeground", label: "Success text", placeholder: "Auto" },
+ { key: "warning", label: "Warning", placeholder: "Auto" },
+ { key: "warningForeground", label: "Warning text", placeholder: "Auto" },
+ { key: "diffAddition", label: "Diff addition", placeholder: "Auto" },
+ { key: "diffDeletion", label: "Diff deletion", placeholder: "Auto" },
+ { key: "sidebar", label: "Sidebar", placeholder: "Auto" },
+ { key: "sidebarForeground", label: "Sidebar text", placeholder: "Auto" },
+ { key: "sidebarAccent", label: "Sidebar accent", placeholder: "Auto" },
+ { key: "sidebarAccentForeground", label: "Sidebar accent text", placeholder: "Auto" },
+ { key: "sidebarBorder", label: "Sidebar border", placeholder: "Auto" },
+];
function ThemeCard({
theme,
+ description,
isSelected,
onSelect,
}: {
- theme: ThemeDefinition;
+ theme: ThemeDocument;
+ description: string;
isSelected: boolean;
onSelect: () => void;
}) {
return (