Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

feat: add ErrorBoundary component to catch crashes

Bosch7b806a3c69cc
diff --git a/dashboard/src/components/atoms/ErrorBoundary.tsx b/dashboard/src/components/atoms/ErrorBoundary.tsx
new file mode 100644
index 00000000..ac519dca
--- /dev/null
+++ b/dashboard/src/components/atoms/ErrorBoundary.tsx
@@ -0,0 +1,51 @@
+import { Component, type ReactNode } from "react";
+
+interface Props {
+ children: ReactNode;
+ fallback?: ReactNode;
+}
+
+interface State {
+ hasError: boolean;
+ error: Error | null;
+}
+
+export default class ErrorBoundary extends Component<Props, State> {
+ constructor(props: Props) {
+ super(props);
+ this.state = { hasError: false, error: null };
+ }
+
+ static getDerivedStateFromError(error: Error): State {
+ return { hasError: true, error };
+ }
+
+ componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
+ console.error("ErrorBoundary caught:", error, errorInfo);
+ }
+
+ render() {
+ if (this.state.hasError) {
+ return (
+ this.props.fallback || (
+ <div className="flex h-full items-center justify-center p-4">
+ <div className="rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-center">
+ <div className="mb-2 text-lg">⚠️ Something went wrong</div>
+ <div className="text-sm text-text-muted">
+ {this.state.error?.message || "Unknown error"}
+ </div>
+ <button
+ className="mt-3 rounded bg-primary px-3 py-1 text-sm text-white"
+ onClick={() => this.setState({ hasError: false, error: null })}
+ >
+ Try again
+ </button>
+ </div>
+ </div>
+ )
+ );
+ }
+
+ return this.props.children;
+ }
+}
diff --git a/dashboard/src/components/atoms/index.ts b/dashboard/src/components/atoms/index.ts
index bb306ef5..1e37dd85 100644
--- a/dashboard/src/components/atoms/index.ts
+++ b/dashboard/src/components/atoms/index.ts
@@ -6,3 +6,4 @@ export { default as StatusDot } from "./StatusDot";
export { default as Modal } from "./Modal";
export { default as Toolbar } from "./Toolbar";
export { default as EmptyState } from "./EmptyState";
+export { default as ErrorBoundary } from "./ErrorBoundary";
diff --git a/dashboard/src/pages/MonitoringPage.tsx b/dashboard/src/pages/MonitoringPage.tsx
index fd0f903a..16bdefdd 100644
--- a/dashboard/src/pages/MonitoringPage.tsx
+++ b/dashboard/src/pages/MonitoringPage.tsx
@@ -1,6 +1,6 @@
import { useEffect, useState, useCallback, useRef } from "react";
import { useAppStore } from "../stores/useAppStore";
-import { EmptyState, Button } from "../components/atoms";
+import { EmptyState, Button, ErrorBoundary } from "../components/atoms";
import { TabsChart, InstanceListItem, TabItem } from "../components/molecules";
import type { InstanceTab } from "../generated/types";
import * as api from "../services/api";
@@ -158,105 +158,109 @@ export default function MonitoringPage() {
instances?.filter((i) => i?.status === "running") || [];
return (
- <div className="flex flex-1 flex-col gap-4 overflow-auto p-4">
- {/* Chart - always show, even with no instances (displays server metrics) */}
- <TabsChart
- data={tabsChartData || []}
- memoryData={memoryEnabled ? memoryChartData : undefined}
- serverData={serverChartData || []}
- instances={runningInstances.map((i) => ({
- id: i.id,
- profileName: i.profileName || "Unknown",
- }))}
- selectedInstanceId={selectedId}
- onSelectInstance={setSelectedId}
- />
+ <ErrorBoundary>
+ <div className="flex flex-1 flex-col gap-4 overflow-auto p-4">
+ {/* Chart - always show, even with no instances (displays server metrics) */}
+ <TabsChart
+ data={tabsChartData || []}
+ memoryData={memoryEnabled ? memoryChartData : undefined}
+ serverData={serverChartData || []}
+ instances={runningInstances.map((i) => ({
+ id: i.id,
+ profileName: i.profileName || "Unknown",
+ }))}
+ selectedInstanceId={selectedId}
+ onSelectInstance={setSelectedId}
+ />
- {instances.length === 0 && (
- <div className="flex flex-1 items-center justify-center">
- <EmptyState
- title="No instances yet"
- description="Start a profile to see instance data"
- icon="📡"
- />
- </div>
- )}
+ {instances.length === 0 && (
+ <div className="flex flex-1 items-center justify-center">
+ <EmptyState
+ title="No instances yet"
+ description="Start a profile to see instance data"
+ icon="📡"
+ />
+ </div>
+ )}
- {/* Bottom section - only show when instances exist */}
- {instances.length > 0 && (
- <div className="flex flex-1 gap-4 overflow-hidden">
- {/* Instance list */}
- <div className="w-64 shrink-0 overflow-auto rounded-lg border border-border-subtle bg-bg-surface">
- <div className="border-b border-border-subtle p-3">
- <h3 className="text-sm font-semibold text-text-secondary">
- Instances ({instances.length})
- </h3>
- </div>
- <div className="p-2">
- {instances.map((inst) => (
- <InstanceListItem
- key={inst.id}
- instance={inst}
- tabCount={currentTabs[inst.id]?.length ?? 0}
- memoryMB={memoryEnabled ? currentMemory[inst.id] : undefined}
- selected={selectedId === inst.id}
- onClick={() => setSelectedId(inst.id)}
- />
- ))}
+ {/* Bottom section - only show when instances exist */}
+ {instances.length > 0 && (
+ <div className="flex flex-1 gap-4 overflow-hidden">
+ {/* Instance list */}
+ <div className="w-64 shrink-0 overflow-auto rounded-lg border border-border-subtle bg-bg-surface">
+ <div className="border-b border-border-subtle p-3">
+ <h3 className="text-sm font-semibold text-text-secondary">
+ Instances ({instances.length})
+ </h3>
+ </div>
+ <div className="p-2">
+ {instances.map((inst) => (
+ <InstanceListItem
+ key={inst.id}
+ instance={inst}
+ tabCount={currentTabs[inst.id]?.length ?? 0}
+ memoryMB={
+ memoryEnabled ? currentMemory[inst.id] : undefined
+ }
+ selected={selectedId === inst.id}
+ onClick={() => setSelectedId(inst.id)}
+ />
+ ))}
+ </div>
</div>
- </div>
- {/* Selected instance details */}
- <div className="flex flex-1 flex-col overflow-hidden rounded-lg border border-border-subtle bg-bg-surface">
- {selectedInstance ? (
- <>
- <div className="flex items-center justify-between border-b border-border-subtle p-3">
- <div>
- <h3 className="text-sm font-semibold text-text-primary">
- {selectedInstance.profileName}
- </h3>
- <div className="text-xs text-text-muted">
- Port {selectedInstance.port} ·{" "}
- {selectedInstance.headless ? "Headless" : "Headed"}
+ {/* Selected instance details */}
+ <div className="flex flex-1 flex-col overflow-hidden rounded-lg border border-border-subtle bg-bg-surface">
+ {selectedInstance ? (
+ <>
+ <div className="flex items-center justify-between border-b border-border-subtle p-3">
+ <div>
+ <h3 className="text-sm font-semibold text-text-primary">
+ {selectedInstance.profileName}
+ </h3>
+ <div className="text-xs text-text-muted">
+ Port {selectedInstance.port} ·{" "}
+ {selectedInstance.headless ? "Headless" : "Headed"}
+ </div>
</div>
+ {selectedInstance.status === "running" && (
+ <Button
+ size="sm"
+ variant="danger"
+ onClick={() => handleStop(selectedInstance.id)}
+ >
+ Stop
+ </Button>
+ )}
</div>
- {selectedInstance.status === "running" && (
- <Button
- size="sm"
- variant="danger"
- onClick={() => handleStop(selectedInstance.id)}
- >
- Stop
- </Button>
- )}
- </div>
- {/* Tabs list */}
- <div className="flex-1 overflow-auto p-3">
- <h4 className="mb-2 text-xs font-semibold uppercase tracking-wide text-text-muted">
- Open Tabs ({selectedTabs.length})
- </h4>
- {selectedTabs.length === 0 ? (
- <div className="py-8 text-center text-sm text-text-muted">
- No tabs open
- </div>
- ) : (
- <div className="space-y-1">
- {selectedTabs.map((tab) => (
- <TabItem key={tab.id} tab={tab} />
- ))}
- </div>
- )}
+ {/* Tabs list */}
+ <div className="flex-1 overflow-auto p-3">
+ <h4 className="mb-2 text-xs font-semibold uppercase tracking-wide text-text-muted">
+ Open Tabs ({selectedTabs.length})
+ </h4>
+ {selectedTabs.length === 0 ? (
+ <div className="py-8 text-center text-sm text-text-muted">
+ No tabs open
+ </div>
+ ) : (
+ <div className="space-y-1">
+ {selectedTabs.map((tab) => (
+ <TabItem key={tab.id} tab={tab} />
+ ))}
+ </div>
+ )}
+ </div>
+ </>
+ ) : (
+ <div className="flex flex-1 items-center justify-center text-sm text-text-muted">
+ Select an instance to view details
</div>
- </>
- ) : (
- <div className="flex flex-1 items-center justify-center text-sm text-text-muted">
- Select an instance to view details
- </div>
- )}
+ )}
+ </div>
</div>
- </div>
- )}
- </div>
+ )}
+ </div>
+ </ErrorBoundary>
);
}