From aa8db2f61dfd1f4fa0011d53f344dbb5d0f882b3 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Fri, 21 Nov 2025 19:16:03 +0000 Subject: [PATCH 1/2] fix: auto-fix CI failures in PR Build Check - Fix Prettier formatting issue in CHANGELOG.md (add trailing newline) - Fix React Hooks violation in theme-switcher.tsx (useTheme called conditionally) - Remove try-catch wrapper around useTheme() to comply with Rules of Hooks - Hooks must be called unconditionally at the top level of components - Remove graceful degradation fallback UI (not needed) --- CHANGELOG.md | 1 + src/components/ui/theme-switcher.tsx | 32 ++-------------------------- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a3bf2ba9..ca8d00dd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,3 +7,4 @@ All notable changes to this project will be documented in this file. ### Added - Add dark mode support with theme switcher in Dashboard and settings pages (#171) @ding113 + diff --git a/src/components/ui/theme-switcher.tsx b/src/components/ui/theme-switcher.tsx index 1d0b75afb..fdee95b11 100644 --- a/src/components/ui/theme-switcher.tsx +++ b/src/components/ui/theme-switcher.tsx @@ -32,41 +32,13 @@ export function ThemeSwitcher({ const t = useTranslations("common"); const [mounted, setMounted] = useState(false); - // Wrap useTheme in try-catch for localStorage error handling - let themeHook: ReturnType | null = null; - try { - themeHook = useTheme(); - } catch (error) { - console.error("Failed to initialize theme:", error); - } + // Always call useTheme unconditionally (Rules of Hooks requirement) + const { theme, setTheme } = useTheme(); useEffect(() => { setMounted(true); }, []); - // Graceful degradation if theme system unavailable - if (!themeHook) { - return ( - - ); - } - - const { theme, setTheme } = themeHook; - // Simplified theme options with better type inference const options = [ { value: "light" as ThemeValue, icon: Sun }, From 284080da5a0454a668618dd6d36dc041ed7eb7fa Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 21 Nov 2025 19:16:45 +0000 Subject: [PATCH 2/2] chore: format code (claude-fix-pr-170-19580916774-aa8db2f) --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca8d00dd7..2a3bf2ba9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,4 +7,3 @@ All notable changes to this project will be documented in this file. ### Added - Add dark mode support with theme switcher in Dashboard and settings pages (#171) @ding113 -