import { useState } from "react"; import { Layout } from "./components/Layout"; import { CaseSelector } from "./components/CaseSelector"; import { NiiVueViewer } from "./components/NiiVueViewer"; import { MetricsPanel } from "./components/MetricsPanel"; import { ProgressIndicator } from "./components/ProgressIndicator"; import { ErrorBoundary } from "./components/ErrorBoundary"; import { useSegmentation } from "./hooks/useSegmentation"; function AppContent() { const [selectedCase, setSelectedCase] = useState(null); const { result, isLoading, error, jobStatus, progress, progressMessage, elapsedSeconds, runSegmentation, cancelJob, } = useSegmentation(); const handleRunSegmentation = async () => { if (selectedCase) { await runSegmentation(selectedCase); } }; // Show progress indicator when job is active const showProgress = isLoading && jobStatus && jobStatus !== "completed"; return (
{/* Left Panel: Controls */}
{/* Cancel button when processing */} {isLoading && ( )} {/* Progress indicator */} {showProgress && ( )} {/* Error display */} {error && !isLoading && (

Error

{error}

)} {/* Results metrics */} {result && }
{/* Right Panel: Viewer */}
{result ? ( ) : (

{isLoading ? "Processing segmentation..." : "Select a case and run segmentation to view results"}

)}
); } /** * Main App component wrapped in ErrorBoundary. * * The ErrorBoundary catches React rendering errors (e.g., WebGL failures * in NiiVueViewer) and displays a user-friendly error message instead * of crashing to a white screen. */ export default function App() { return ( ); }