diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index 0fd5dc39..4409078b 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -117,6 +117,7 @@ export const ChatPane = forwardRef(({ const [isDragOver, setIsDragOver] = useState(false); const [scrolledProjects] = useState(() => new Set()); const [showOnboarding, setShowOnboarding] = useState(false); + const [isStuck, setIsStuck] = useState(false); // Use external state if provided, otherwise default to false const isBuildLoading = externalIsBuildLoading || false; @@ -240,6 +241,19 @@ export const ChatPane = forwardRef(({ } }, [internalIsLoading, onLoadingChange]); + // Timer to detect when AI appears stuck during tool generation + useEffect(() => { + // Start a 2-second timer + const timer = streamingMessage + ? setTimeout(() => setIsStuck(true), 2000) + : undefined; + + return () => { + setIsStuck(false); + clearTimeout(timer); + }; + }, [streamingMessage]); + // Function to scroll to bottom const scrollToBottom = useCallback(() => { if (scrollAreaRef.current) { @@ -581,11 +595,23 @@ export const ChatPane = forwardRef(({ })} {streamingMessage && ( streamingMessage.content || streamingMessage.reasoning_content ? ( - + <> + + {/* Show loading skeleton if AI appears stuck generating tools */} + {isStuck && ( +
+
+
+ +
+
+
+ )} + ) : ( !(streamingMessage?.tool_calls?.[0]?.type === 'function') && (