Roo-Code/apps/web-roo-code/src/lib/hooks/use-logo-src.ts
Murilo Pires c47de36b05
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
2025-07-23 16:41:02 -04:00

24 lines
755 B
TypeScript

"use client"
import { useTheme } from "next-themes"
import { useEffect, useState } from "react"
export function useLogoSrc(): string {
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"
}