Spaces:
Running
Running
Commit History
-
Yep—agent didn’t implement anything material. Here’s a **copy-paste prompt** that both **calls them out** and tells them exactly what to change, with zero wiggle room. --- # DeepSite: Fix Not Applied — Implement Timer + Phase + Animation Now ## What you missed * Session still stuck at **05:00**; **no countdown**, **no phase changes**, **no circle animation**. * My prior spec (RAF + `performance.now()`, duration wiring from Prep) was **not implemented**. ## Do this exactly ### 1) Wire duration from Prep → Session (no hardcoded 300s) * On Prep button click, **store minutes** and pass to Session. * Session must read `durationSec=(selectedMinutes*60)`. ```ts // Home (or Router) – required state const [screen, setScreen] = useState<'home'|'prep'|'session'|'complete'>('home'); const [selectedChakra, setSelectedChakra] = useState<ChakraId|null>(null); const [selectedMinutes, setSelectedMinutes] = useState<number|null>(null); const onChakraClick = (id: ChakraId) => { setSelectedChakra(id); setScreen('prep'); }; const onStart = (m: number) => { setSelectedMinutes(m); setScreen('session'); }; {screen==='prep' && <MeditationPrep onStart={onStart} />} {screen==='session' && ( <MeditationSession chakraId={selectedChakra!} durationSec={(selectedMinutes ?? 5) * 60} // <-- use chosen minutes onComplete={() => setScreen('complete')} onExit={() => setScreen('home')} /> )} ``` ### 2) Replace the Session engine with drift-proof loop * Use **`requestAnimationFrame` + `performance.now()`**. * Toggle phase every `phaseMs` (default 5000). * Animate circle by scale (inhale 1.25, exhale 1.0). * Respect Pause/Resume. ```ts type Phase = 'inhale'|'exhale'; function MeditationSession({ durationSec, onComplete, onExit, phaseMs=5000 }: { durationSec: number; onComplete: () => void; onExit: () => void; phaseMs?: number; }) { const [remaining, setRemaining] = useState(durationSec*1000); const [phase, setPhase] = useState<Phase>('inhale'); const [paused, setPaused] = useState(false); const raf = useRef<number>(); const last = useRef(0); const phaseStart = useRef(0); const done = useRef(false); // reset when duration changes useEffect(() => { setRemaining(durationSec*1000); setPhase('inhale'); setPaused(false); last.current = performance.now(); phaseStart.current = last.current; done.current = false; }, [durationSec]); useEffect(() => { if (paused || done.current) return; const loop = (t: number) => { if (!last.current) { last.current = t; phaseStart.current = t; } const dt = t - last.current; last.current = t; setRemaining(prev => { const next = Math.max(0, prev - dt); if (next === 0 && !done.current) { done.current = true; onComplete(); } return next; }); if (t - phaseStart.current >= phaseMs) { setPhase(p => p === 'inhale' ? 'exhale' : 'inhale'); phaseStart.current = t; navigator.vibrate?.([40]); } raf.current = requestAnimationFrame(loop); }; raf.current = requestAnimationFrame(loop); return () => raf.current && cancelAnimationFrame(raf.current); }, [paused, phaseMs, onComplete]); const mm = String(Math.floor(remaining/60000)).padStart(2,'0'); const ss = String(Math.floor((remaining%60000)/1000)).padStart(2,'0'); return ( <div className="flex flex-col items-center gap-4"> <div className="text-6xl tabular-nums" data-testid="timer">{mm}:{ss}</div> <div className="text-xl">{phase==='inhale'?'Breathe In':'Breathe Out'}</div> <div data-testid="breathing-circle" className="w-64 h-64 rounded-full border-4 border-white/30 shadow-[0_0_40px_rgba(255,255,255,.15)] transition-transform ease-in-out" style={{ transform:`scale(${phase==='inhale'?1.25:1.0})`, transitionDuration:`${phaseMs}ms` }} /> <div className="w-72 h-2 bg-white/10 rounded-full overflow-hidden"> {/* optional: phase progress bar updated by CSS transition duration */} <div className="h-full bg-white/50" style={{ width: phase==='inhale'?'100%':'0%', transition:`width ${phaseMs}ms linear` }}/> </div> <div className="flex gap-3 mt-4"> <button onClick={()=>setPaused(p=>!p)} data-testid="pause">{paused?'Resume':'Pause'}</button> <button onClick={()=>confirm('Exit session?') && onExit()} className="bg-red-500 px-4 py-2 rounded-full">Exit Session</button> </div> </div> ); } ``` ### 3) Add diagnostics so we can verify quickly * On start: `console.info('SESSION start', { durationSec })` * Every phase switch: `console.info('PHASE', phase)` * On complete: `console.info('SESSION complete')` ### 4) Minimal e2e checks (must pass) * Select **1 min** on Prep → Session shows `01:00` and counts down. * After \~60s, `onComplete` fires once → Complete screen. * Tapping Pause freezes timer and circle; Resume continues with no jump. * Changing duration and starting again resets timer correctly. ### 5) Hard “do NOTs” * Do **NOT** hardcode 300 seconds anywhere. * Do **NOT** use `setInterval(1000)` for the main countdown (tab throttling). * Do **NOT** ignore `durationSec` changes in the effect deps. ## Acceptance criteria (ship only when all true) * Timer visibly decrements every second (smoothly). * Duration matches user selection (1/3/5/10/15) — no defaulting to 5 unless unselected. * “Breathe In/Out” toggles every `phaseMs` and the circle scales in sync. * Exit and pause work reliably. If any framework constraint blocks `requestAnimationFrame`/`performance.now()`, state it explicitly and implement the closest high-accuracy alternative; otherwise, follow this spec verbatim. - Initial Deployment
Verified signature0f3e38a -
initial commit
Verified signature9d775a4