import { useState, useEffect } from 'react'; import Clock from './components/Clock'; import BackgroundScene from './components/BackgroundScene'; import MusicPlayer from './components/MusicPlayer'; import Timer from './components/Timer'; import Notes from './components/Notes'; import KiraAvatar from './components/KiraAvatar'; import ChatBubble from './components/ChatBubble'; import PetZone from './components/PetZone'; import Wardrobe from './components/Wardrobe'; import Toolbar from './components/Toolbar'; import Particles from './components/Particles'; import WelcomeScreen from './components/WelcomeScreen'; import { SCENES, type Scene } from './components/scenes'; import { useConversation } from './hooks/useConversation'; export default function App() { const { messages, isConnected, isKiraSpeaking, isRecording, identified, preferences, loadingPrefs, identify, setPreference, sendText, startRecording, stopRecording, } = useConversation(); const [currentSceneId, setCurrentSceneId] = useState('cozy-room'); const [currentOutfit, setCurrentOutfit] = useState('cozy-hoodie'); const [currentAcc, setCurrentAcc] = useState(null); const [textInput, setTextInput] = useState(''); // Apply saved preferences once they load useEffect(() => { if (preferences.scene) setCurrentSceneId(preferences.scene); if (preferences.outfit) setCurrentOutfit(preferences.outfit); if (preferences.accessory) setCurrentAcc(preferences.accessory); }, [preferences.scene, preferences.outfit, preferences.accessory]); const currentScene: Scene = SCENES.find((s) => s.id === currentSceneId) ?? SCENES[0]; const handleSceneChange = (id: string) => { setCurrentSceneId(id); setPreference('scene', id); }; const handleOutfitChange = (id: string) => { setCurrentOutfit(id); setPreference('outfit', id); }; const handleAccessoryChange = (id: string | null) => { setCurrentAcc(id); setPreference('accessory', id || ''); }; const handleTalkToggle = () => { if (isRecording) stopRecording(); else startRecording(); }; const handleTextSend = () => { if (!textInput.trim()) return; sendText(textInput.trim()); setTextInput(''); }; const handleWelcome = (name: string) => { identify(name); }; // Show WelcomeScreen for first-time users if (!identified && !loadingPrefs) { const savedId = localStorage.getItem('kira-user-id'); if (!savedId) { return ; } // Has saved ID but not identified yet — show welcome with their name return (
🌸

coming back? say your name to pick up where you left off

); } // Main app with user's name in the greeting const userName = preferences.name || 'there'; return (
{/* Top toolbar */}
{/* Main grid */}
{/* Column 1: Kira + Clock */}
{/* Column 2: Timer + Music */}
{/* Column 3: Chat + Text Input */}
{/* Text input fallback */}
{/* Subtle greeting */}
hey {userName} ✨
setTextInput(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && handleTextSend()} placeholder={`what's up, ${userName}?`} className="flex-1 bg-white/60 rounded-xl px-3 py-2 text-sm text-kira-plum placeholder-kira-plum/30 border border-kira-pink/20 focus:outline-none focus:border-kira-pink/50" />
{isConnected ? 'connected' : 'connecting...'}
{/* Column 4: Cats + Wardrobe */}
{/* Bottom bar */}
{isRecording ? 'listening...' : isKiraSpeaking ? 'kira speaking' : `kira's here for you, ${userName}`}
{identified ? `hi ${userName}` : 'body double mode'} 🌸
); }