(textLength: number)
| 2863 | let msgCount = 0; |
| 2864 | |
| 2865 | const streamText = async (textLength: number) => { |
| 2866 | const targetIndex = msgCount - 1; |
| 2867 | const duration = 500 + textLength * 8; // Longer text = longer duration |
| 2868 | const startTime = Date.now(); |
| 2869 | |
| 2870 | const animate = () => { |
| 2871 | if (cancelled) return; |
| 2872 | const elapsed = Date.now() - startTime; |
| 2873 | const progress = Math.min(elapsed / duration, 1); |
| 2874 | // Ease out for smoother ending |
| 2875 | const easedProgress = 1 - Math.pow(1 - progress, 2); |
| 2876 | |
| 2877 | setMessages(prev => prev.map((m, idx) => |
| 2878 | idx === targetIndex ? { ...m, progress: easedProgress } : m |
| 2879 | )); |
| 2880 | |
| 2881 | if (progress < 1) { |
| 2882 | requestAnimationFrame(animate); |
| 2883 | } |
| 2884 | }; |
| 2885 | |
| 2886 | requestAnimationFrame(animate); |
| 2887 | await delay(duration); |
| 2888 | }; |
| 2889 | |
| 2890 | const runAnimation = async () => { |
| 2891 | setMessages([]); |
no test coverage detected
searching dependent graphs…