Skip to content

Commit c47de36

Browse files
authored
Fix/website logo theme persistence (#6040)
* feat: add Issue Fixer Orchestrator mode * fix: persist logo theme state on page navigation and refresh - Add mounted state to prevent hydration mismatch - Use theme as fallback when resolvedTheme is not available - Ensure logo matches the persisted theme on initial page load Fixes issue where logo would revert to dark version after page refresh even when light theme was selected
1 parent bcad858 commit c47de36

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
"use client"
22

33
import { useTheme } from "next-themes"
4+
import { useEffect, useState } from "react"
45

56
export function useLogoSrc(): string {
6-
const { resolvedTheme } = useTheme()
7-
return resolvedTheme === "light" ? "/Roo-Code-Logo-Horiz-blk.svg" : "/Roo-Code-Logo-Horiz-white.svg"
7+
const { resolvedTheme, theme } = useTheme()
8+
const [mounted, setMounted] = useState(false)
9+
10+
// Avoid hydration mismatch by waiting for client-side mount
11+
useEffect(() => {
12+
setMounted(true)
13+
}, [])
14+
15+
// Before mounting, return a default logo (dark theme as specified in providers)
16+
// This prevents the logo from flickering on initial load
17+
if (!mounted) {
18+
return "/Roo-Code-Logo-Horiz-white.svg"
19+
}
20+
21+
// Use theme as fallback if resolvedTheme is not available yet
22+
const currentTheme = resolvedTheme || theme
23+
return currentTheme === "light" ? "/Roo-Code-Logo-Horiz-blk.svg" : "/Roo-Code-Logo-Horiz-white.svg"
824
}

0 commit comments

Comments
 (0)