High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
feat: show chart with server metrics even when no instances running
Bosch12a93d15891e
diff --git a/dashboard/src/components/molecules/TabsChart.test.tsx b/dashboard/src/components/molecules/TabsChart.test.tsxindex 31d49030..97e0b083 100644--- a/dashboard/src/components/molecules/TabsChart.test.tsx+++ b/dashboard/src/components/molecules/TabsChart.test.tsx@@ -26,23 +26,11 @@ const mockData: TabDataPoint[] = [describe("TabsChart", () => {describe("empty states", () => {- it('shows "No running instances" when instances array is empty', () => {- render(- <TabsChart- data={mockData}- instances={[]}- selectedInstanceId={null}- onSelectInstance={() => {}}- />,- );- expect(screen.getByText("No running instances")).toBeInTheDocument();- });-- it('shows "Collecting data..." when data array is empty', () => {+ it('shows "Collecting data..." when no data at all', () => {render(<TabsChartdata={[]}- instances={mockInstances}+ instances={[]}selectedInstanceId={null}onSelectInstance={() => {}}/>,@@ -50,16 +38,19 @@ describe("TabsChart", () => {expect(screen.getByText("Collecting data...")).toBeInTheDocument();});- it('shows "No running instances" when both are empty (instances takes priority)', () => {- render(+ it("renders chart even with no instances if data exists (e.g., server metrics)", () => {+ const { container } = render(<TabsChart- data={[]}+ data={mockData}instances={[]}selectedInstanceId={null}onSelectInstance={() => {}}/>,);- expect(screen.getByText("No running instances")).toBeInTheDocument();+ // Chart container should render, not empty state+ expect(+ container.querySelector(".recharts-responsive-container"),+ ).toBeInTheDocument();});});diff --git a/dashboard/src/components/molecules/TabsChart.tsx b/dashboard/src/components/molecules/TabsChart.tsxindex c648a21c..5bd1733c 100644--- a/dashboard/src/components/molecules/TabsChart.tsx+++ b/dashboard/src/components/molecules/TabsChart.tsx@@ -64,8 +64,21 @@ export default function TabsChart({(serverData || []).map((s) => [s.timestamp, s]),);- return data.map((d) => {- const merged: Record<string, number> = { ...d };+ // Use tab data as base, or server data if no tabs+ const baseData =+ data.length > 0+ ? data+ : (serverData || []).map((s) => ({ timestamp: s.timestamp }));++ return baseData.map((d) => {+ const merged: Record<string, number> = { timestamp: d.timestamp };++ // Add tab data if present+ for (const [key, val] of Object.entries(d)) {+ if (key !== "timestamp") {+ merged[key] = val as number;+ }+ }// Add memory keys with _mem suffixconst mem = memByTime.get(d.timestamp);@@ -87,10 +100,11 @@ export default function TabsChart({});}, [data, memoryData, serverData]);- if (data.length === 0 || instances.length === 0) {+ // Show empty state only if no data at all+ if (mergedData.length === 0) {return (<div className="flex h-[200px] items-center justify-center rounded-lg border border-border-subtle bg-bg-surface text-sm text-text-muted">- {instances.length === 0 ? "No running instances" : "Collecting data..."}+ Collecting data...</div>);}diff --git a/dashboard/src/pages/MonitoringPage.tsx b/dashboard/src/pages/MonitoringPage.tsxindex eb0d8077..9114ee33 100644--- a/dashboard/src/pages/MonitoringPage.tsx+++ b/dashboard/src/pages/MonitoringPage.tsx@@ -46,20 +46,32 @@ export default function MonitoringPage() {const fetchAllInstanceData = useCallback(async () => {const runningInstances = instances.filter((i) => i.status === "running");- if (runningInstances.length === 0) return;+ const timestamp = Date.now();try {- // Fetch tabs always, metrics only if enabled- const [allTabs, allMetrics, serverMetrics] = await Promise.all([+ // Always fetch server metrics+ const serverMetrics = await api.fetchServerMetrics().catch(() => null);+ if (serverMetrics) {+ addServerDataPoint({+ timestamp,+ goHeapMB: serverMetrics.goHeapAllocMB,+ goroutines: serverMetrics.goNumGoroutine,+ rateBucketHosts: serverMetrics.rateBucketHosts,+ });+ }++ // Skip instance data if no running instances+ if (runningInstances.length === 0) return;++ // Fetch tabs and instance metrics+ const [allTabs, allMetrics] = await Promise.all([api.fetchAllTabs().catch(() => []),memoryEnabled ? api.fetchAllMetrics().catch(() => []) : [],- api.fetchServerMetrics().catch(() => null),]);const tabsArray = Array.isArray(allTabs) ? allTabs : [];const metricsArray = Array.isArray(allMetrics) ? allMetrics : [];- const timestamp = Date.now();const tabDataPoint: Record<string, number> = { timestamp };const memDataPoint: Record<string, number> = { timestamp };const tabsByInstance: Record<string, InstanceTab[]> = {};@@ -89,14 +101,6 @@ export default function MonitoringPage() {memDataPoint as Parameters<typeof addMemoryDataPoint>[0],);}- if (serverMetrics) {- addServerDataPoint({- timestamp,- goHeapMB: serverMetrics.goHeapAllocMB,- goroutines: serverMetrics.goNumGoroutine,- rateBucketHosts: serverMetrics.rateBucketHosts,- });- }setCurrentTabs(tabsByInstance);setCurrentMemory(memoryByInstance);} catch (e) {