diff --git a/src/routes/builder/$resumeId/-components/ai-chat.tsx b/src/routes/builder/$resumeId/-components/ai-chat.tsx index f6b4dc46a..6b36a1623 100644 --- a/src/routes/builder/$resumeId/-components/ai-chat.tsx +++ b/src/routes/builder/$resumeId/-components/ai-chat.tsx @@ -29,6 +29,8 @@ type AIChatResponse = { }; }; +const FAB_TIMEOUT_MS = 60_000; + export function AIChatPanel() { const aiEnabled = useAIStore((state) => state.enabled); const aiConfig = useAIStore((state) => ({ @@ -41,7 +43,7 @@ export function AIChatPanel() { const { resumeId } = useParams({ from: "/builder/$resumeId" }); const updateResumeData = useResumeStore((state) => state.updateResumeData); - const { isOpen, fabVisible, lastInteraction, messages, toggle, open, close, hideFab, addMessage, touch } = + const { isOpen, fabVisible, lastInteraction, messages, toggle, close, hideFab, addMessage, touch } = useAIChatStore(); const [input, setInput] = useState(""); @@ -76,7 +78,7 @@ export function AIChatPanel() { useEffect(() => { if (!fabVisible || isOpen) return; const last = lastInteraction ?? Date.now(); - const remaining = Math.max(0, 60_000 - (Date.now() - last)); + const remaining = Math.max(0, FAB_TIMEOUT_MS - (Date.now() - last)); const timer = setTimeout(() => { if (!useAIChatStore.getState().isOpen) hideFab(); }, remaining); @@ -173,7 +175,7 @@ export function AIChatPanel() { > ) : null} - - {!fabVisible && ( - - )} ); } diff --git a/src/routes/builder/$resumeId/-store/ai-chat.ts b/src/routes/builder/$resumeId/-store/ai-chat.ts index 6587d4123..75afa9054 100644 --- a/src/routes/builder/$resumeId/-store/ai-chat.ts +++ b/src/routes/builder/$resumeId/-store/ai-chat.ts @@ -25,7 +25,10 @@ type AIChatActions = { type AIChatStore = AIChatState & AIChatActions; -const createId = () => (crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(36).slice(2)); +const createId = () => + typeof crypto !== "undefined" && crypto.randomUUID + ? crypto.randomUUID() + : `${Date.now()}-${Math.random().toString(36).slice(2)}`; const initialMessages: AIChatMessage[] = [ {