feat: initial conversational flow #37

Merged
talksik merged 39 commits from 33-conversational-flow-for-streams---story-mode into master 2026-03-19 23:29:41 +00:00
Showing only changes of commit aa2e2bc424 - Show all commits
+14 -7
View File
@@ -1,4 +1,4 @@
import { useState, useEffect, useCallback, useReducer, useRef } from "react";
import { useState, useEffect, useEffectEvent, useCallback, useReducer, useRef } from "react";
import { useNavigate } from "react-router-dom";
import { useAuthStore } from "@/stores/auth-store";
import type { Particle } from "@/api/types";
@@ -102,6 +102,10 @@ function useExitCountdown(
) {
const [exitProgress, setExitProgress] = useState<number | null>(null);
const handleExit = useEffectEvent(() => {
onExit();
});
// Start/cancel countdown based on playback status
useEffect(() => {
if (status === "ended") {
@@ -119,16 +123,19 @@ function useExitCountdown(
setExitProgress((prev) => {
if (prev === null) return null;
const next = prev + EXIT_TICK_MS / EXIT_DELAY_MS;
if (next >= 1) {
onExit();
return 1;
}
return next;
return next >= 1 ? 1 : next;
});
}, EXIT_TICK_MS);
return () => clearInterval(interval);
}, [exitProgress !== null, composeActive, onExit]);
}, [exitProgress !== null, composeActive]);
// Navigate once countdown completes
useEffect(() => {
if (exitProgress !== null && exitProgress >= 1) {
handleExit();
}
}, [exitProgress]);
return exitProgress;
}