@devries-cameron20 / t3code-1 / commits / a9fb6087ea
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

perf(web): the theme library compiles with the React Compiler (#20655)

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

Julius Marminge committed Oct 16, 2026 at 21:56 UTC a9fb6087ead0af57fbf6ee6c3f9137c7943da747
1 file changed +40 -64
apps/web/src/components/settings/ThemeSettings.tsx
+40 -64
@@ -9,7 +9,7 @@ import {
9 Trash2Icon,
10 UploadIcon,
11 } from "lucide-react";
12 -import { useCallback, useEffect, useState, type ReactElement } from "react";
12 +import { useState, type ReactElement } from "react";
13 import { useEnvironmentThemeDefinitions } from "../../hooks/useEnvironmentTheme";
14 import { readThemeHalvesRaw } from "../../hooks/useTheme";
15 import { cn } from "../../lib/utils";
@@ -442,9 +442,7 @@ function CustomThemeCollectionCard({
442 const safeIndex = Math.min(variantIndex, themes.length - 1);
443 const theme = themes[safeIndex];
444
445 - useEffect(() => {
446 - if (variantIndex !== safeIndex) setVariantIndex(safeIndex);
447 - }, [safeIndex, variantIndex]);
445 + if (variantIndex !== safeIndex) setVariantIndex(safeIndex);
446
447 if (!theme) return null;
448 const collectionLabel = theme.collection?.label ?? theme.label;
@@ -537,7 +535,7 @@ export function ThemeLibrary({
535 const removeDialogCollectionLabel =
536 removeDialogTheme?.collection?.label ?? removeDialogTheme?.label;
537
540 - const notifyThemeSaveFailure = useCallback(() => {
538 + const notifyThemeSaveFailure = () => {
539 toastManager.add(
540 stackedThreadToast({
541 type: "error",
@@ -545,9 +543,9 @@ export function ThemeLibrary({
543 description: "Try again.",
544 }),
545 );
548 - }, []);
546 + };
547
550 - const notifyThemeRemovalFailure = useCallback(() => {
548 + const notifyThemeRemovalFailure = () => {
549 toastManager.add(
550 stackedThreadToast({
551 type: "error",
@@ -555,27 +553,24 @@ export function ThemeLibrary({
553 description: "Try again.",
554 }),
555 );
558 - }, []);
556 + };
557
560 - const persistTheme = useCallback(
561 - (nextTheme: string) => {
562 - const didSave = setTheme(nextTheme);
563 - if (!didSave) notifyThemeSaveFailure();
564 - return didSave;
565 - },
566 - [notifyThemeSaveFailure, setTheme],
567 - );
558 + const persistTheme = (nextTheme: string) => {
559 + const didSave = setTheme(nextTheme);
560 + if (!didSave) notifyThemeSaveFailure();
561 + return didSave;
562 + };
563
569 - const handleRemoveTheme = useCallback(
570 - (customTheme: ThemeDefinition, collectionThemes: ReadonlyArray<ThemeDefinition>) => {
571 - setThemeRemovalTarget({ theme: customTheme, collectionThemes });
572 - setThemeIdsToRemove(collectionThemes.length > 1 ? [] : [customTheme.id]);
573 - setIsThemeRemovalOpen(true);
574 - },
575 - [],
576 - );
564 + const handleRemoveTheme = (
565 + customTheme: ThemeDefinition,
566 + collectionThemes: ReadonlyArray<ThemeDefinition>,
567 + ) => {
568 + setThemeRemovalTarget({ theme: customTheme, collectionThemes });
569 + setThemeIdsToRemove(collectionThemes.length > 1 ? [] : [customTheme.id]);
570 + setIsThemeRemovalOpen(true);
571 + };
572
578 - const handleConfirmRemoveTheme = useCallback(() => {
573 + const handleConfirmRemoveTheme = () => {
574 if (!themeRemovalTarget) return;
575 const removedIds = new Set(themeIdsToRemove);
576 if (removedIds.size === 0) return;
@@ -603,52 +598,33 @@ export function ThemeLibrary({
598 return;
599 }
600 setIsThemeRemovalOpen(false);
606 - }, [
607 - appearanceMode,
608 - notifyThemeRemovalFailure,
609 - persistTheme,
610 - setThemeHalf,
611 - theme,
612 - themeIdsToRemove,
613 - themeRemovalTarget,
614 - ]);
601 + };
602
603 const baseCardId = getThemeDefinition(theme)?.id ?? null;
604 const lightOwner = themeHalves?.light ?? baseCardId;
605 const darkOwner = themeHalves?.dark ?? baseCardId;
606
620 - const assignHalf = useCallback(
621 - (appearance: ThemeAppearance, cardId: string | null) => {
622 - const otherAppearance = appearance === "light" ? "dark" : "light";
623 - // Picking the default over a themed base cannot be stored as a half:
624 - // the base would still own that appearance. Convert the base into an
625 - // explicit half on the other side so this side falls back to default.
626 - if (cardId === null && baseCardId !== null) {
627 - // Read raw, before persistTheme clears the mix: the other half may
628 - // name a published theme that has not streamed in yet, and falling
629 - // back to the base would silently rewrite it.
630 - const otherOwner = readThemeHalvesRaw()[otherAppearance] ?? baseCardId;
631 - if (!persistTheme(appearanceMode === "system" ? "system" : appearanceMode)) return;
632 - if (!setThemeHalf(otherAppearance, otherOwner)) {
633 - setTheme(theme);
634 - notifyThemeSaveFailure();
635 - }
636 - return;
637 - }
638 - if (!setThemeHalf(appearance, cardId)) {
607 + const assignHalf = (appearance: ThemeAppearance, cardId: string | null) => {
608 + const otherAppearance = appearance === "light" ? "dark" : "light";
609 + // Picking the default over a themed base cannot be stored as a half:
610 + // the base would still own that appearance. Convert the base into an
611 + // explicit half on the other side so this side falls back to default.
612 + if (cardId === null && baseCardId !== null) {
613 + // Read raw, before persistTheme clears the mix: the other half may
614 + // name a published theme that has not streamed in yet, and falling
615 + // back to the base would silently rewrite it.
616 + const otherOwner = readThemeHalvesRaw()[otherAppearance] ?? baseCardId;
617 + if (!persistTheme(appearanceMode === "system" ? "system" : appearanceMode)) return;
618 + if (!setThemeHalf(otherAppearance, otherOwner)) {
619 + setTheme(theme);
620 notifyThemeSaveFailure();
621 }
641 - },
642 - [
643 - appearanceMode,
644 - baseCardId,
645 - notifyThemeSaveFailure,
646 - persistTheme,
647 - setTheme,
648 - setThemeHalf,
649 - theme,
650 - ],
651 - );
622 + return;
623 + }
624 + if (!setThemeHalf(appearance, cardId)) {
625 + notifyThemeSaveFailure();
626 + }
627 + };
628
629 const activeThemeForAppearance =
630 getThemeDefinition((initialAppearance === "light" ? lightOwner : darkOwner) ?? "") ?? null;