diff --git a/frontend/src/components/thread/tool-views/BrowserToolView.tsx b/frontend/src/components/thread/tool-views/BrowserToolView.tsx index 8bb1a6b5..25fe4a4b 100644 --- a/frontend/src/components/thread/tool-views/BrowserToolView.tsx +++ b/frontend/src/components/thread/tool-views/BrowserToolView.tsx @@ -124,6 +124,15 @@ export function BrowserToolView({ const isRunning = isStreaming || agentStatus === 'running'; const isLastToolCall = currentIndex === totalCalls - 1; + const [isIframeLoading, setIsIframeLoading] = React.useState(true); + + // Reset loading state when VNC URL changes + React.useEffect(() => { + if (vncPreviewUrl) { + setIsIframeLoading(true); + } + }, [vncPreviewUrl]); + const vncIframe = useMemo(() => { if (!vncPreviewUrl) return null; @@ -133,6 +142,7 @@ export function BrowserToolView({ title="Browser preview" className="w-full h-full border-0 min-h-[600px]" style={{ width: '100%', height: '100%', minHeight: '600px' }} + onLoad={() => setIsIframeLoading(false)} /> ); }, [vncPreviewUrl]); @@ -157,24 +167,53 @@ export function BrowserToolView({ } }, [isRunning]); + const [isScreenshotLoading, setIsScreenshotLoading] = React.useState(true); + + // Reset screenshot loading state when screenshot data changes + React.useEffect(() => { + if (screenshotUrl || screenshotBase64) { + setIsScreenshotLoading(true); + } + }, [screenshotUrl, screenshotBase64]); + const renderScreenshot = () => { if (screenshotUrl) { return ( -
Loading screenshot...
+Loading screenshot...
+Loading browser preview...
+Loading browser preview...
+Loading screenshot...
+