'use client'; import React, { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Card } from '@/components/ui/card'; import { Loader2, AlertCircle, RefreshCw } from 'lucide-react'; import { useVncPreloader } from '@/hooks/useVncPreloader'; interface HealthCheckedVncIframeProps { sandbox: { id: string; vnc_preview: string; pass: string; }; className?: string; } export function HealthCheckedVncIframe({ sandbox, className }: HealthCheckedVncIframeProps) { const [iframeKey, setIframeKey] = useState(0); // Use the enhanced VNC preloader hook const { status, retryCount, retry, isPreloaded } = useVncPreloader(sandbox, { maxRetries: 5, initialDelay: 1000, timeoutMs: 5000 }); // VNC URL received but preloading in progress if (status === 'loading') { return (
Connecting to browser...
Testing VNC connection
{retryCount > 0 && (🔄 Attempt {retryCount + 1}/5
)}Connection Failed
Unable to connect to VNC server after 5 attempts