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
This commit is contained in:
Murilo Pires 2025-07-23 17:41:02 -03:00 committed by GitHub
parent bcad858b2f
commit c47de36b05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,8 +1,24 @@
"use client"
import { useTheme } from "next-themes"
import { useEffect, useState } from "react"
export function useLogoSrc(): string {
const { resolvedTheme } = useTheme()
return resolvedTheme === "light" ? "/Roo-Code-Logo-Horiz-blk.svg" : "/Roo-Code-Logo-Horiz-white.svg"
const { resolvedTheme, theme } = useTheme()
const [mounted, setMounted] = useState(false)
// Avoid hydration mismatch by waiting for client-side mount
useEffect(() => {
setMounted(true)
}, [])
// Before mounting, return a default logo (dark theme as specified in providers)
// This prevents the logo from flickering on initial load
if (!mounted) {
return "/Roo-Code-Logo-Horiz-white.svg"
}
// Use theme as fallback if resolvedTheme is not available yet
const currentTheme = resolvedTheme || theme
return currentTheme === "light" ? "/Roo-Code-Logo-Horiz-blk.svg" : "/Roo-Code-Logo-Horiz-white.svg"
}