diff --git a/src/components/TypingIndicator.tsx b/src/components/TypingIndicator.tsx index 652a066..c513e26 100644 --- a/src/components/TypingIndicator.tsx +++ b/src/components/TypingIndicator.tsx @@ -1,6 +1,28 @@ +import { useState, useEffect, useRef } from 'react'; import { Bot } from 'lucide-react'; +import { useT } from '../hooks/useLocale'; + +function formatElapsed(seconds: number): string { + if (seconds < 60) return `${seconds}s`; + const m = Math.floor(seconds / 60); + const s = seconds % 60; + return `${m}m ${s.toString().padStart(2, '0')}s`; +} export function TypingIndicator() { + const t = useT(); + const [elapsed, setElapsed] = useState(0); + const startRef = useRef(Date.now()); + + useEffect(() => { + startRef.current = Date.now(); + setElapsed(0); + const interval = setInterval(() => { + setElapsed(Math.floor((Date.now() - startRef.current) / 1000)); + }, 1000); + return () => clearInterval(interval); + }, []); + return (