The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 12:15 UTC
fix(web): preserve published theme IDs during alias lookup (#31318)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Johan Vaz committed
Nov 15, 2026 at 09:38 UTC
01c8e59f1489a1c89848541ec3ed9ccfefa30a25
2 files changed
+26
-2
apps/web/src/themePalette.test.ts
+23
-1
@@ -3,10 +3,13 @@ import { converter } from "culori/fn";
3
import { BUILT_IN_THEMES } from "@t3tools/shared/themePalettes";
4
5
import { CONTEXT_CHIP_ACCENTS, contextChipColorVariable } from "./lib/contextChipAccents";
6
+import { appAtomRegistry } from "./rpc/atomRegistry";
7
8
import {
9
applyThemePalette,
10
+ canonicalThemePreference,
11
contextChipVariables,
12
+ getThemeDefinition,
13
getThemeColorsForMode,
14
getThemeModes,
15
getCustomThemes,
@@ -15,6 +18,8 @@ import {
18
invalidateCustomThemes,
19
installCustomTheme,
20
parseThemeFile,
21
+ parseThemeHalves,
22
+ publishedThemeDefinitions,
23
removeCustomTheme,
24
replaceCustomThemeCollection,
25
resolveDesktopTheme,
@@ -704,7 +709,7 @@ describe("context chip colors", () => {
709
});
710
711
describe("stored theme preferences", () => {
707
- it("lets a configured half unlock an appearance the base theme lacks", () => {
712
+ it("lets built-in and published halves unlock an appearance the base theme lacks", () => {
713
const lightOnly = parseThemeFile({
714
version: THEME_FILE_VERSION,
715
id: "paper",
@@ -712,6 +717,17 @@ describe("stored theme preferences", () => {
717
appearance: "light",
718
colors: { canvas: "#f8fbff" },
719
});
720
+ const [publishedTheme] = publishedThemeDefinitions([
721
+ {
722
+ id: "constructor",
723
+ name: "Constructor",
724
+ appearance: "dark",
725
+ canvas: "#1a1b26",
726
+ accent: "#7aa2f7",
727
+ },
728
+ ]);
729
+ expect(publishedTheme).toBeDefined();
730
+ using _environmentThemes = vi.spyOn(appAtomRegistry, "get").mockReturnValue([publishedTheme]);
731
vi.stubGlobal("window", {
732
localStorage: {
733
getItem: (key: string) =>
@@ -725,6 +741,12 @@ describe("stored theme preferences", () => {
741
expect(resolveThemeAppearance("paper", true, true, undefined, halves)).toBe("dark");
742
expect(resolveThemeAppearance("paper", false, false, "dark", halves)).toBe("dark");
743
expect(resolveDesktopTheme("paper", true, undefined, halves)).toBe("system");
744
+
745
+ expect(getThemeDefinition("constructor")).toEqual(publishedTheme);
746
+ expect(canonicalThemePreference("constructor")).toBe("constructor");
747
+ const publishedHalves = parseThemeHalves(JSON.stringify({ dark: "constructor" }));
748
+ expect(publishedHalves).toEqual({ dark: "constructor" });
749
+ expect(resolveThemeAppearance("paper", true, true, undefined, publishedHalves)).toBe("dark");
750
} finally {
751
vi.unstubAllGlobals();
752
invalidateCustomThemes();
apps/web/src/themePalette.ts
+3
-1
@@ -412,7 +412,9 @@ const LEGACY_THEME_ID_ALIASES: Readonly<Record<string, string>> = {
412
};
413
414
function normalizeThemeId(themeId: string): string {
415
- return LEGACY_THEME_ID_ALIASES[themeId] ?? themeId;
415
+ return Object.hasOwn(LEGACY_THEME_ID_ALIASES, themeId)
416
+ ? (LEGACY_THEME_ID_ALIASES[themeId] ?? themeId)
417
+ : themeId;
418
}
419
420
export function canonicalThemePreference(theme: string): string {