| 249 | }, []); |
| 250 | const pushStreaming = useCallback((text: string) => { |
| 251 | streamPendingRef.current = text; |
| 252 | if (streamTimerRef.current === null) { |
| 253 | streamTimerRef.current = setTimeout(flushStreaming, 50); |
| 254 | } |
| 255 | }, [flushStreaming]); |
| 256 | const clearStreaming = useCallback(() => { |
| 257 | if (streamTimerRef.current !== null) { |
| 258 | clearTimeout(streamTimerRef.current); |
| 259 | streamTimerRef.current = null; |
| 260 | } |
| 261 | streamPendingRef.current = null; |
| 262 | setStreamingText(''); |
| 263 | }, []); |
| 264 | |
| 265 | // Initialize agent |
| 266 | useEffect(() => { |