Skip to content

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

feat: add memory metrics toggle (off by default)

Bosch22bdebca7398
diff --git a/dashboard/src/generated/types.ts b/dashboard/src/generated/types.ts
index 6b8b9ff4..9b4df3c8 100644
--- a/dashboard/src/generated/types.ts
+++ b/dashboard/src/generated/types.ts
@@ -89,6 +89,13 @@ export interface Settings {
screencast: ScreencastSettings;
stealth: string; // light/full
browser: BrowserSettings;
+ monitoring: MonitoringSettings;
+}
+/**
+ * MonitoringSettings controls dashboard monitoring features.
+ */
+export interface MonitoringSettings {
+ memoryMetrics: boolean; // Enable per-tab memory aggregation (can be heavy)
}
/**
* ServerInfo contains health/status information.
diff --git a/dashboard/src/pages/MonitoringPage.tsx b/dashboard/src/pages/MonitoringPage.tsx
index 6e873c68..a003c1c5 100644
--- a/dashboard/src/pages/MonitoringPage.tsx
+++ b/dashboard/src/pages/MonitoringPage.tsx
@@ -20,6 +20,7 @@ export default function MonitoringPage() {
addMemoryDataPoint,
setCurrentTabs,
setCurrentMemory,
+ settings,
} = useAppStore();
const [selectedId, setSelectedId] = useState<string | null>(null);
const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
@@ -36,16 +37,18 @@ export default function MonitoringPage() {
}
};
- // Fetch tabs and memory for all running instances
+ // Fetch tabs and optionally memory for all running instances
+ const memoryEnabled = settings.monitoring?.memoryMetrics ?? false;
+
const fetchAllInstanceData = useCallback(async () => {
const runningInstances = instances.filter((i) => i.status === "running");
if (runningInstances.length === 0) return;
try {
- // Fetch tabs and metrics in parallel
+ // Fetch tabs always, metrics only if enabled
const [allTabs, allMetrics] = await Promise.all([
api.fetchAllTabs().catch(() => []),
- api.fetchAllMetrics().catch(() => []),
+ memoryEnabled ? api.fetchAllMetrics().catch(() => []) : [],
]);
const tabsArray = Array.isArray(allTabs) ? allTabs : [];
@@ -63,20 +66,24 @@ export default function MonitoringPage() {
tabDataPoint[inst.id] = instTabs.length;
tabsByInstance[inst.id] = instTabs;
- // Find memory for this instance
- const instMem = metricsArray.find((m) => m.instanceId === inst.id);
- if (instMem) {
- memDataPoint[inst.id] = instMem.jsHeapUsedMB;
- memoryByInstance[inst.id] = instMem.jsHeapUsedMB;
+ // Find memory for this instance (if enabled)
+ if (memoryEnabled) {
+ const instMem = metricsArray.find((m) => m.instanceId === inst.id);
+ if (instMem) {
+ memDataPoint[inst.id] = instMem.jsHeapUsedMB;
+ memoryByInstance[inst.id] = instMem.jsHeapUsedMB;
+ }
}
}
addChartDataPoint(
tabDataPoint as Parameters<typeof addChartDataPoint>[0],
);
- addMemoryDataPoint(
- memDataPoint as Parameters<typeof addMemoryDataPoint>[0],
- );
+ if (memoryEnabled) {
+ addMemoryDataPoint(
+ memDataPoint as Parameters<typeof addMemoryDataPoint>[0],
+ );
+ }
setCurrentTabs(tabsByInstance);
setCurrentMemory(memoryByInstance);
} catch (e) {
@@ -84,6 +91,7 @@ export default function MonitoringPage() {
}
}, [
instances,
+ memoryEnabled,
addChartDataPoint,
addMemoryDataPoint,
setCurrentTabs,
@@ -140,7 +148,7 @@ export default function MonitoringPage() {
{/* Chart */}
<TabsChart
data={tabsChartData}
- memoryData={memoryChartData}
+ memoryData={memoryEnabled ? memoryChartData : undefined}
instances={runningInstances.map((i) => ({
id: i.id,
profileName: i.profileName,
@@ -164,7 +172,7 @@ export default function MonitoringPage() {
key={inst.id}
instance={inst}
tabCount={currentTabs[inst.id]?.length ?? 0}
- memoryMB={currentMemory[inst.id]}
+ memoryMB={memoryEnabled ? currentMemory[inst.id] : undefined}
selected={selectedId === inst.id}
onClick={() => setSelectedId(inst.id)}
/>
diff --git a/dashboard/src/pages/SettingsPage.tsx b/dashboard/src/pages/SettingsPage.tsx
index 5e2ecd65..8f9a1b4b 100644
--- a/dashboard/src/pages/SettingsPage.tsx
+++ b/dashboard/src/pages/SettingsPage.tsx
@@ -182,6 +182,39 @@ export default function SettingsPage() {
</div>
</Card>
+ {/* Monitoring */}
+ <Card className="p-4">
+ <h3 className="mb-4 text-sm font-semibold text-text-primary">
+ 📈 Monitoring
+ </h3>
+ <div className="space-y-3">
+ <label className="flex items-center justify-between">
+ <div>
+ <span className="text-sm text-text-secondary">
+ Memory Metrics
+ </span>
+ <p className="text-xs text-text-muted">
+ Aggregate JS heap usage across tabs (can be heavy)
+ </p>
+ </div>
+ <input
+ type="checkbox"
+ checked={local.monitoring?.memoryMetrics ?? false}
+ onChange={(e) =>
+ setLocal({
+ ...local,
+ monitoring: {
+ ...local.monitoring,
+ memoryMetrics: e.target.checked,
+ },
+ })
+ }
+ className="h-4 w-4"
+ />
+ </label>
+ </div>
+ </Card>
+
{/* Server Info */}
{serverInfo && (
<Card className="p-4">
diff --git a/dashboard/src/stores/useAppStore.test.ts b/dashboard/src/stores/useAppStore.test.ts
index dbefa58d..30474a03 100644
--- a/dashboard/src/stores/useAppStore.test.ts
+++ b/dashboard/src/stores/useAppStore.test.ts
@@ -138,6 +138,7 @@ describe("useAppStore", () => {
screencast: { fps: 5, quality: 50, maxWidth: 1024 },
stealth: "strict" as const,
browser: { blockImages: true, blockMedia: true, noAnimations: true },
+ monitoring: { memoryMetrics: true },
};
useAppStore.getState().setSettings(newSettings);
expect(useAppStore.getState().settings).toEqual(newSettings);
diff --git a/dashboard/src/stores/useAppStore.ts b/dashboard/src/stores/useAppStore.ts
index d552d719..56073f78 100644
--- a/dashboard/src/stores/useAppStore.ts
+++ b/dashboard/src/stores/useAppStore.ts
@@ -68,6 +68,7 @@ const defaultSettings: Settings = {
screencast: { fps: 1, quality: 30, maxWidth: 800 },
stealth: "light",
browser: { blockImages: false, blockMedia: false, noAnimations: false },
+ monitoring: { memoryMetrics: false },
};
export const useAppStore = create<AppState>((set) => ({
diff --git a/internal/api/types/types.go b/internal/api/types/types.go
index 09d98461..05cd6a0f 100644
--- a/internal/api/types/types.go
+++ b/internal/api/types/types.go
@@ -78,6 +78,12 @@ type Settings struct {
Screencast ScreencastSettings `json:"screencast"`
Stealth string `json:"stealth"` // light/full
Browser BrowserSettings `json:"browser"`
+ Monitoring MonitoringSettings `json:"monitoring"`
+}
+
+// MonitoringSettings controls dashboard monitoring features.
+type MonitoringSettings struct {
+ MemoryMetrics bool `json:"memoryMetrics"` // Enable per-tab memory aggregation (can be heavy)
}
// ServerInfo contains health/status information.