@devries-cameron20 / t3code Mirror · read-only / commits / 0fdbb37478
Fork 0

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 23, 06:45 UTC

perf(web): the theme editor host compiles without manual memoization (#20638)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 16, 2026 at 21:58 UTC 0fdbb37478dedd328bfb908e9b20bb3b2061d5dc
1 file changed +47 -50
apps/web/src/components/settings/ThemeEditorHost.tsx
+47 -50
@@ -1,4 +1,4 @@
1 -import { lazy, Suspense, useCallback, useSyncExternalStore } from "react";
1 +import { lazy, Suspense, useSyncExternalStore } from "react";
2
3 import { useTheme } from "../../hooks/useTheme";
4 import {
@@ -29,50 +29,11 @@ export function ThemeEditorHost() {
29 const editingTheme = useThemeDefinition(session?.editingThemeId);
30 const seedTheme = useThemeDefinition(session?.seedThemeId);
31
32 - const handleSaved = useCallback(
33 - (
34 - savedTheme: ThemeDefinition,
35 - { created, mergedAppearance }: { created: boolean; mergedAppearance?: ThemeAppearance },
36 - ) => {
37 - if (mergedAppearance) {
38 - if (!setTheme(savedTheme.id)) {
39 - toastManager.add(
40 - stackedThreadToast({
41 - type: "error",
42 - title: "Could not save your theme",
43 - description: "Browser storage is unavailable, so the change was not kept.",
44 - }),
45 - );
46 - return false;
47 - }
48 - toastManager.add(
49 - stackedThreadToast({
50 - type: "success",
51 - title: `${savedTheme.label} updated`,
52 - description: `Its ${mergedAppearance} palette was added.`,
53 - }),
54 - );
55 - return true;
56 - }
57 - if (!created) {
58 - // The edited theme may be showing through the base preference or either
59 - // half of the mix; the preference itself is untouched (a setTheme here
60 - // would clear the mix), the palette just needs re-applying.
61 - const wasActive =
62 - getThemeDefinition(theme)?.id === savedTheme.id ||
63 - themeHalves?.light === savedTheme.id ||
64 - themeHalves?.dark === savedTheme.id;
65 - if (wasActive) refreshTheme();
66 - toastManager.add(
67 - stackedThreadToast({
68 - type: "success",
69 - title: `${savedTheme.label} saved`,
70 - description: wasActive ? "Your changes are now active." : "Your changes are saved.",
71 - }),
72 - );
73 - return true;
74 - }
75 -
32 + const handleSaved = (
33 + savedTheme: ThemeDefinition,
34 + { created, mergedAppearance }: { created: boolean; mergedAppearance?: ThemeAppearance },
35 + ) => {
36 + if (mergedAppearance) {
37 if (!setTheme(savedTheme.id)) {
38 toastManager.add(
39 stackedThreadToast({
@@ -86,14 +47,50 @@ export function ThemeEditorHost() {
47 toastManager.add(
48 stackedThreadToast({
49 type: "success",
89 - title: `${savedTheme.label} created`,
90 - description: "It’s now active.",
50 + title: `${savedTheme.label} updated`,
51 + description: `Its ${mergedAppearance} palette was added.`,
52 }),
53 );
54 return true;
94 - },
95 - [refreshTheme, setTheme, theme, themeHalves],
96 - );
55 + }
56 + if (!created) {
57 + // The edited theme may be showing through the base preference or either
58 + // half of the mix; the preference itself is untouched (a setTheme here
59 + // would clear the mix), the palette just needs re-applying.
60 + const wasActive =
61 + getThemeDefinition(theme)?.id === savedTheme.id ||
62 + themeHalves?.light === savedTheme.id ||
63 + themeHalves?.dark === savedTheme.id;
64 + if (wasActive) refreshTheme();
65 + toastManager.add(
66 + stackedThreadToast({
67 + type: "success",
68 + title: `${savedTheme.label} saved`,
69 + description: wasActive ? "Your changes are now active." : "Your changes are saved.",
70 + }),
71 + );
72 + return true;
73 + }
74 +
75 + if (!setTheme(savedTheme.id)) {
76 + toastManager.add(
77 + stackedThreadToast({
78 + type: "error",
79 + title: "Could not save your theme",
80 + description: "Browser storage is unavailable, so the change was not kept.",
81 + }),
82 + );
83 + return false;
84 + }
85 + toastManager.add(
86 + stackedThreadToast({
87 + type: "success",
88 + title: `${savedTheme.label} created`,
89 + description: "It’s now active.",
90 + }),
91 + );
92 + return true;
93 + };
94
95 if (!session) return null;
96