The best way to control Claude Code, Codex and more from any computer or phone
feat(web): make sidebar artwork theme-aware (#5636)
maria committed
Aug 7, 2026 at 15:41 UTC
f0fb406acf419c1ab3d37d5f42093c07921484b2
5 files changed
+185
-6
apps/web/src/components/settings/ThemeEditorPanel.tsx
+39
-2
@@ -165,6 +165,7 @@ export function ThemeEditorPanel({
165
const isEditing = editingTheme !== null;
166
const [name, setName] = useState("");
167
const [activeAppearance, setActiveAppearance] = useState<ThemeAppearance>(initialAppearance);
168
+ const [sidebarArtwork, setSidebarArtwork] = useState(false);
169
const [isAdvanced, setIsAdvanced] = useState(false);
170
const [colorsByAppearance, setColorsByAppearance] = useState<ThemeEditorColorsByAppearance>(() =>
171
getThemeEditorColorsByAppearance(),
@@ -178,6 +179,7 @@ export function ThemeEditorPanel({
179
const [isInspecting, setIsInspecting] = useState(false);
180
const [selectedRole, setSelectedRole] = useState<ThemeColorRole | null>(null);
181
const [usageCount, setUsageCount] = useState<number | null>(null);
182
+ const previousMergeTargetIdRef = useRef<string | null>(null);
183
// Null parks the panel at its default corner; a value is a dragged spot,
184
// kept clamped so the header can always be grabbed again.
185
const [position, setPosition] = useState<{ x: number; y: number } | null>(null);
@@ -259,6 +261,9 @@ export function ThemeEditorPanel({
261
262
setName(editingTheme?.label ?? seedName ?? "");
263
setActiveAppearance(nextAppearance);
264
+ // Artwork is opt-in for new themes, including duplicates. Editing keeps
265
+ // the theme's existing choice.
266
+ setSidebarArtwork(editingTheme?.sidebarArtwork === true);
267
// Themes saved by the guided editor carry the managed flag; anything
268
// else (imports, hand-edited files, older saves) opens in advanced mode
269
// so guided regeneration cannot silently discard hand-tuned colors. A
@@ -315,6 +320,18 @@ export function ThemeEditorPanel({
320
// an explanation instead.
321
const mergeTargetId = mergeTarget?.id ?? null;
322
const takenAppearancesKey = takenAppearances.join(",");
323
+ useEffect(() => {
324
+ if (previousMergeTargetIdRef.current === mergeTargetId) return;
325
+ previousMergeTargetIdRef.current = mergeTargetId;
326
+ // A matching name makes that existing theme the surviving merge target.
327
+ // Seed theme-level options from it so adding a palette or renaming onto it
328
+ // does not silently reset them. Leaving the merge restores the edited
329
+ // theme's option (or the off-by-default choice for a new theme).
330
+ setSidebarArtwork(
331
+ mergeTarget ? mergeTarget.sidebarArtwork === true : editingTheme?.sidebarArtwork === true,
332
+ );
333
+ }, [editingTheme, mergeTarget, mergeTargetId]);
334
+
335
useEffect(() => {
336
if (isEditing || mergeTargetId === null) return;
337
const taken = takenAppearancesKey.split(",").filter(Boolean) as ThemeAppearance[];
@@ -330,8 +347,8 @@ export function ThemeEditorPanel({
347
// comes back when the editor closes, including on cancel.
348
useEffect(() => {
349
if (!open || !isDraftSeeded) return;
333
- applyThemeColorPreview(colorsByAppearance[activeAppearance], activeAppearance);
334
- }, [activeAppearance, colorsByAppearance, isDraftSeeded, open]);
350
+ applyThemeColorPreview(colorsByAppearance[activeAppearance], activeAppearance, sidebarArtwork);
351
+ }, [activeAppearance, colorsByAppearance, isDraftSeeded, open, sidebarArtwork]);
352
353
useEffect(() => {
354
if (!open) return;
@@ -657,6 +674,7 @@ export function ThemeEditorPanel({
674
...mergeTarget.variants,
675
...Object.fromEntries(editedModes.map((mode) => [mode, colorsForSave[mode]])),
676
},
677
+ ...(sidebarArtwork ? { sidebarArtwork: true } : {}),
678
...(mergeTarget.managed === true && !isAdvanced ? { managed: true } : {}),
679
}),
680
);
@@ -687,6 +705,7 @@ export function ThemeEditorPanel({
705
...(getThemeModes(editingTheme).length > 1
706
? { variants: { [variantAppearance]: colorsForSave[variantAppearance] } }
707
: {}),
708
+ ...(sidebarArtwork ? { sidebarArtwork: true } : {}),
709
...(isAdvanced ? {} : { managed: true }),
710
}),
711
);
@@ -713,6 +732,7 @@ export function ThemeEditorPanel({
732
...mergeTarget.variants,
733
[activeAppearance]: colorsForSave[activeAppearance],
734
},
735
+ ...(sidebarArtwork ? { sidebarArtwork: true } : {}),
736
...(mergeTarget.managed === true && !isAdvanced ? { managed: true } : {}),
737
}),
738
);
@@ -723,6 +743,7 @@ export function ThemeEditorPanel({
743
name,
744
appearance: activeAppearance,
745
colors: colorsForSave[activeAppearance],
746
+ ...(sidebarArtwork ? { sidebarArtwork: true } : {}),
747
...(isAdvanced ? {} : { managed: true }),
748
}),
749
);
@@ -773,6 +794,7 @@ export function ThemeEditorPanel({
794
name,
795
onOpenChange,
796
onSaved,
797
+ sidebarArtwork,
798
simpleColorsDirtyByAppearance,
799
takenAppearances,
800
]);
@@ -832,6 +854,20 @@ export function ThemeEditorPanel({
854
</div>
855
);
856
857
+ const renderSidebarArtworkToggle = () => (
858
+ <label className="grid cursor-pointer grid-cols-[minmax(0,1fr)_minmax(0,2fr)] items-center gap-3">
859
+ <span className="text-sm font-medium">Sidebar artwork</span>
860
+ <span className="flex items-center justify-between gap-3 text-xs text-muted-foreground">
861
+ <span>Show T3 Code environment artwork</span>
862
+ <Switch
863
+ aria-label="Allow sidebar artwork with this theme"
864
+ checked={sidebarArtwork}
865
+ onCheckedChange={(checked) => setSidebarArtwork(Boolean(checked))}
866
+ />
867
+ </span>
868
+ </label>
869
+ );
870
+
871
const renderColorsHeader = () => (
872
<div className="grid grid-cols-[minmax(0,1fr)_minmax(0,2fr)] items-start gap-3">
873
<div>
@@ -1088,6 +1124,7 @@ export function ThemeEditorPanel({
1124
</p>
1125
) : null}
1126
{renderAppearanceButtons()}
1127
+ {renderSidebarArtworkToggle()}
1128
<div className="space-y-3">
1129
{renderColorsHeader()}
1130
{renderColorFields()}
apps/web/src/hooks/useSettings.test.ts
+31
@@ -17,6 +17,37 @@ describe("resolveEnvironmentIdentificationMode", () => {
17
"pill",
18
);
19
});
20
+
21
+ it("uses a pill instead of artwork with a palette theme", () => {
22
+ expect(
23
+ resolveEnvironmentIdentificationMode({
24
+ mode: "artwork",
25
+ settingsHydrated: true,
26
+ paletteThemeActive: true,
27
+ }),
28
+ ).toBe("pill");
29
+ });
30
+
31
+ it("respects none with a palette theme", () => {
32
+ expect(
33
+ resolveEnvironmentIdentificationMode({
34
+ mode: "none",
35
+ settingsHydrated: true,
36
+ paletteThemeActive: true,
37
+ }),
38
+ ).toBe("none");
39
+ });
40
+
41
+ it("keeps artwork when the palette theme opts into it", () => {
42
+ expect(
43
+ resolveEnvironmentIdentificationMode({
44
+ mode: "artwork",
45
+ settingsHydrated: true,
46
+ paletteThemeActive: true,
47
+ paletteThemeAllowsArtwork: true,
48
+ }),
49
+ ).toBe("artwork");
50
+ });
51
});
52
53
describe("mergeEnvironmentSettings", () => {
apps/web/src/hooks/useSettings.ts
+30
-2
@@ -28,10 +28,17 @@ import { safeErrorLogAttributes } from "@t3tools/client-runtime/errors";
28
import { APP_STAGE_LABEL } from "~/branding";
29
import { resolveSidebarV2Enabled } from "~/branding.logic";
30
import { ensureLocalApi } from "~/localApi";
31
+import {
32
+ getThemeDefinition,
33
+ getThemePreviewSidebarArtwork,
34
+ resolveThemeHalf,
35
+ subscribeToThemePreview,
36
+} from "~/themePalette";
37
import * as Struct from "effect/Struct";
38
import { primaryServerSettingsAtom, serverEnvironment } from "~/state/server";
39
import { usePrimaryEnvironment } from "~/state/environments";
40
import { useAtomCommand } from "~/state/use-atom-command";
41
+import { useTheme } from "./useTheme";
42
43
const CLIENT_SETTINGS_PERSISTENCE_ERROR_SCOPE = "[CLIENT_SETTINGS]";
44
@@ -226,15 +233,36 @@ export function useClientSettings<T = ClientSettings>(
233
export function resolveEnvironmentIdentificationMode(input: {
234
mode: EnvironmentIdentificationMode;
235
settingsHydrated: boolean;
236
+ paletteThemeActive?: boolean;
237
+ paletteThemeAllowsArtwork?: boolean;
238
}): EnvironmentIdentificationMode {
239
// Avoid briefly rendering the default artwork before a persisted pill/none choice loads.
231
- return input.settingsHydrated ? input.mode : "none";
240
+ if (!input.settingsHydrated) return "none";
241
+ // Stage artwork has fixed colors that can clash with palette themes. Keep an
242
+ // explicit "none", but use the theme-aware pill in place of artwork.
243
+ return input.paletteThemeActive && !input.paletteThemeAllowsArtwork && input.mode === "artwork"
244
+ ? "pill"
245
+ : input.mode;
246
}
247
248
export function useEnvironmentIdentificationMode(): EnvironmentIdentificationMode {
249
const settingsHydrated = useClientSettingsHydrated();
250
const mode = useClientSettingsValue().environmentIdentificationMode;
237
- return resolveEnvironmentIdentificationMode({ mode, settingsHydrated });
251
+ const { resolvedTheme, theme, themeHalves } = useTheme();
252
+ const previewSidebarArtwork = useSyncExternalStore(
253
+ subscribeToThemePreview,
254
+ getThemePreviewSidebarArtwork,
255
+ () => null,
256
+ );
257
+ const activeTheme = resolveThemeHalf(theme, themeHalves, resolvedTheme);
258
+ const activeThemeDefinition = getThemeDefinition(activeTheme);
259
+ return resolveEnvironmentIdentificationMode({
260
+ mode,
261
+ settingsHydrated,
262
+ paletteThemeActive: previewSidebarArtwork !== null || activeThemeDefinition !== null,
263
+ paletteThemeAllowsArtwork:
264
+ previewSidebarArtwork ?? activeThemeDefinition?.sidebarArtwork === true,
265
+ });
266
}
267
268
/**
apps/web/src/themePalette.test.ts
+55
-1
@@ -1,9 +1,12 @@
1
import { describe, expect, it, vi } from "vite-plus/test";
2
3
import {
4
+ applyThemeColorPreview,
5
+ applyThemePalette,
6
getThemeColorsForMode,
7
getThemeDefinition,
8
getThemeModes,
9
+ getThemePreviewSidebarArtwork,
10
getThemePreferenceMode,
11
isKnownThemePreference,
12
getCustomThemes,
@@ -15,6 +18,7 @@ import {
18
resolveDesktopTheme,
19
resolveThemeAppearance,
20
serializeThemeFile,
21
+ subscribeToThemePreview,
22
subscribeToCustomThemes,
23
T3_CHAT_THEME,
24
EMBER_THEME,
@@ -200,6 +204,49 @@ describe("theme files", () => {
204
});
205
});
206
207
+ it("keeps sidebar artwork opt-in through theme files", () => {
208
+ const withoutArtwork = parseThemeFile({
209
+ version: THEME_FILE_VERSION,
210
+ name: "Plain sidebar",
211
+ appearance: "light",
212
+ colors: { accent: "#5b6cff" },
213
+ });
214
+ const withArtwork = parseThemeFile({
215
+ version: THEME_FILE_VERSION,
216
+ name: "Art sidebar",
217
+ appearance: "light",
218
+ colors: { accent: "#5b6cff" },
219
+ sidebarArtwork: true,
220
+ });
221
+
222
+ expect(withoutArtwork.sidebarArtwork).toBeUndefined();
223
+ expect(withArtwork.sidebarArtwork).toBe(true);
224
+ expect(JSON.parse(serializeThemeFile(withArtwork)).sidebarArtwork).toBe(true);
225
+ });
226
+
227
+ it("publishes sidebar artwork changes from the live theme preview", () => {
228
+ const listener = vi.fn();
229
+ const unsubscribe = subscribeToThemePreview(listener);
230
+ vi.stubGlobal("document", {
231
+ documentElement: {
232
+ classList: { toggle: vi.fn() },
233
+ dataset: {},
234
+ style: { removeProperty: vi.fn(), setProperty: vi.fn() },
235
+ },
236
+ });
237
+
238
+ applyThemeColorPreview(T3_CHAT_THEME.colors, "light", true);
239
+ expect(getThemePreviewSidebarArtwork()).toBe(true);
240
+ expect(listener).toHaveBeenCalledTimes(1);
241
+
242
+ applyThemePalette("system");
243
+ expect(getThemePreviewSidebarArtwork()).toBeNull();
244
+ expect(listener).toHaveBeenCalledTimes(2);
245
+
246
+ unsubscribe();
247
+ vi.unstubAllGlobals();
248
+ });
249
+
250
it("keeps optional light and dark palettes under one theme id", () => {
251
const theme = parseThemeFile({
252
version: THEME_FILE_VERSION,
@@ -387,6 +434,7 @@ describe("theme files", () => {
434
name: "Aurora",
435
appearance: "light",
436
colors: { canvas: "#f8fbff", accent: "#5b6cff" },
437
+ sidebarArtwork: true,
438
}),
439
);
440
const updatedTheme = updateCustomTheme({
@@ -395,11 +443,17 @@ describe("theme files", () => {
443
colors: { ...createdTheme.colors, accent: "#7c3aed" },
444
});
445
398
- expect(updatedTheme).toMatchObject({ id: "aurora", label: "Aurora Night" });
446
+ expect(updatedTheme).toMatchObject({
447
+ id: "aurora",
448
+ label: "Aurora Night",
449
+ sidebarArtwork: true,
450
+ });
451
+ invalidateCustomThemes();
452
expect(getCustomThemes()).toEqual([updatedTheme]);
453
expect(JSON.parse(stored.get(CUSTOM_THEMES_STORAGE_KEY) ?? "[]")[0]).toMatchObject({
454
id: "aurora",
455
label: "Aurora Night",
456
+ sidebarArtwork: true,
457
});
458
459
vi.unstubAllGlobals();
apps/web/src/themePalette.ts
+30
-1
@@ -96,6 +96,8 @@ export type ThemeDefinition = Readonly<{
96
appearance: ThemeAppearance;
97
colors: ThemeColors;
98
variants?: ThemeVariants;
99
+ /** Allows fixed Dev/Nightly artwork to render over this theme's sidebar. */
100
+ sidebarArtwork?: boolean;
101
/** True when the palette was generated by the guided editor from its
102
* canvas and accent; such themes reopen in guided mode. */
103
managed?: boolean;
@@ -107,6 +109,7 @@ export type ThemeFile = Readonly<{
109
appearance: ThemeAppearance;
110
colors: ThemeColorOverrides;
111
variants?: ThemeVariantOverrides;
112
+ sidebarArtwork?: boolean;
113
managed?: boolean;
114
}>;
115
@@ -128,6 +131,23 @@ const RESERVED_THEME_IDS = new Set([
131
132
const customThemeListeners = new Set<() => void>();
133
let customThemesSnapshot: ReadonlyArray<ThemeDefinition> | null = null;
134
+const themePreviewListeners = new Set<() => void>();
135
+let themePreviewSidebarArtwork: boolean | null = null;
136
+
137
+export function getThemePreviewSidebarArtwork(): boolean | null {
138
+ return themePreviewSidebarArtwork;
139
+}
140
+
141
+export function subscribeToThemePreview(listener: () => void): () => void {
142
+ themePreviewListeners.add(listener);
143
+ return () => themePreviewListeners.delete(listener);
144
+}
145
+
146
+function setThemePreviewSidebarArtwork(next: boolean | null): void {
147
+ if (themePreviewSidebarArtwork === next) return;
148
+ themePreviewSidebarArtwork = next;
149
+ for (const listener of themePreviewListeners) listener();
150
+}
151
152
function isRecord(value: unknown): value is Record<string, unknown> {
153
return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -203,6 +223,7 @@ function parseStoredTheme(value: unknown): ThemeDefinition | null {
223
appearance: value.appearance,
224
colors,
225
...(variants ? { variants } : {}),
226
+ ...(value.sidebarArtwork === true ? { sidebarArtwork: true } : {}),
227
...(value.managed === true ? { managed: true } : {}),
228
};
229
}
@@ -1541,6 +1562,7 @@ export function parseThemeFile(value: unknown): ThemeDefinition {
1562
appearance,
1563
colors: { ...fallback, ...overrides },
1564
...(Object.keys(variants).length > 0 ? { variants } : {}),
1565
+ ...(value.sidebarArtwork === true ? { sidebarArtwork: true } : {}),
1566
...(value.managed === true ? { managed: true } : {}),
1567
};
1568
}
@@ -1553,6 +1575,7 @@ export function serializeThemeFile(theme: ThemeDefinition): string {
1575
appearance: theme.appearance,
1576
colors: theme.colors,
1577
...(theme.variants ? { variants: theme.variants } : {}),
1578
+ ...(theme.sidebarArtwork ? { sidebarArtwork: true } : {}),
1579
...(theme.managed ? { managed: true } : {}),
1580
};
1581
return `${JSON.stringify(file, null, 2)}\n`;
@@ -1630,11 +1653,16 @@ export const THEME_PREVIEW_ID = "__preview";
1653
* can be judged against the real interface instead of a miniature. Callers
1654
* restore the stored theme (refreshTheme) when the draft goes away.
1655
*/
1633
-export function applyThemeColorPreview(colors: ThemeColors, appearance: ThemeAppearance): void {
1656
+export function applyThemeColorPreview(
1657
+ colors: ThemeColors,
1658
+ appearance: ThemeAppearance,
1659
+ sidebarArtwork = false,
1660
+): void {
1661
if (typeof document === "undefined") return;
1662
const root = document.documentElement;
1663
if (!root?.style) return;
1664
1665
+ setThemePreviewSidebarArtwork(sidebarArtwork);
1666
root.dataset.themeId = THEME_PREVIEW_ID;
1667
root.classList.toggle("dark", appearance === "dark");
1668
for (const [role, value] of Object.entries(colors) as Array<[ThemeColorRole, string]>) {
@@ -1649,6 +1677,7 @@ export function applyThemePalette(theme: ThemePreference, appearance?: ThemeAppe
1677
const root = document.documentElement;
1678
if (!root?.style) return;
1679
1680
+ setThemePreviewSidebarArtwork(null);
1681
const palette = getThemeDefinition(theme);
1682
1683
if (palette) {