import { useState, useEffect } from 'react' const ACTIVE_KEY = 'homeai_active_character' export function useActiveCharacter() { const [character, setCharacter] = useState(null) useEffect(() => { const activeId = localStorage.getItem(ACTIVE_KEY) if (!activeId) return fetch(`/api/characters/${activeId}`) .then(r => r.ok ? r.json() : null) .then(profile => { if (profile) { setCharacter({ id: profile.id, name: profile.data.display_name || profile.data.name || 'AI', image: profile.image || null, tts: profile.data.tts || null, }) } }) .catch(() => {}) }, []) return character }