High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
feat(dashboard): browser-style tab bar, interactive screencast, compact layout (#319)
luigiagentc78c589aa3e5
diff --git a/dashboard/src/components/instances/InstanceListItem.tsx b/dashboard/src/components/instances/InstanceListItem.tsxindex 330c0bbd..584d4520 100644--- a/dashboard/src/components/instances/InstanceListItem.tsx+++ b/dashboard/src/components/instances/InstanceListItem.tsx@@ -5,7 +5,10 @@ interface Props {tabCount: number;memoryMB?: number;selected: boolean;+ autoRestart?: boolean;onClick: () => void;+ onStop?: () => void;+ onOpenProfile?: () => void;}export default function InstanceListItem({@@ -13,7 +16,10 @@ export default function InstanceListItem({tabCount,memoryMB,selected,+ autoRestart = false,onClick,+ onStop,+ onOpenProfile,}: Props) {const statusColor =instance.status === "running"@@ -22,25 +28,75 @@ export default function InstanceListItem({? "bg-destructive": "bg-text-muted";+ const stopLabel = autoRestart ? "Restart" : "Stop";+ const stopStyle = autoRestart+ ? "rounded bg-warning/10 px-2 py-0.5 text-[10px] font-medium uppercase text-warning transition-colors hover:bg-warning/20"+ : "rounded bg-destructive/10 px-2 py-0.5 text-[10px] font-medium uppercase text-destructive transition-colors hover:bg-destructive/20";+return (<buttononClick={onClick}- className={`mb-2 flex w-full items-center gap-3 px-3 py-3 text-left ${+ className={`mb-2 flex w-full flex-col gap-1 px-3 py-2.5 text-left ${selected? "dashboard-panel dashboard-panel-selected border-primary": "dashboard-panel dashboard-panel-hover"}`}>- <div className={`h-2 w-2 rounded-full ${statusColor}`} />- <div className="min-w-0 flex-1">- <div className="truncate text-sm font-medium text-text-primary">- {instance.profileName}- </div>- <div className="dashboard-mono text-xs text-text-muted">- :{instance.port} · {tabCount} tabs- {memoryMB !== undefined && ` · ${memoryMB.toFixed(0)}MB`}+ <div className="flex w-full items-center gap-2">+ <div className={`h-2 w-2 shrink-0 rounded-full ${statusColor}`} />+ <div className="min-w-0 flex-1">+ <h3 className="truncate text-sm font-medium text-text-primary">+ {instance.profileName}+ </h3>+ <div className="dashboard-mono text-xs text-text-muted">+ :{instance.port} · {tabCount} tabs+ {memoryMB !== undefined && ` · ${memoryMB.toFixed(0)}MB`}+ </div></div></div>+ {selected && (+ <div className="flex gap-1 pl-4 pt-1">+ {onOpenProfile && (+ <span+ role="button"+ aria-label="Open Profile"+ tabIndex={0}+ onClick={(e) => {+ e.stopPropagation();+ onOpenProfile();+ }}+ onKeyDown={(e) => {+ if (e.key === "Enter") {+ e.stopPropagation();+ onOpenProfile();+ }+ }}+ className="rounded bg-bg-elevated px-2 py-0.5 text-[10px] font-medium uppercase text-text-muted transition-colors hover:bg-border-subtle hover:text-text-primary"+ >+ Open Profile+ </span>+ )}+ {onStop && instance.status === "running" && (+ <span+ role="button"+ tabIndex={0}+ onClick={(e) => {+ e.stopPropagation();+ onStop();+ }}+ onKeyDown={(e) => {+ if (e.key === "Enter") {+ e.stopPropagation();+ onStop();+ }+ }}+ className={stopStyle}+ >+ {stopLabel}+ </span>+ )}+ </div>+ )}</button>);}diff --git a/dashboard/src/components/molecules/TabsLayout.tsx b/dashboard/src/components/molecules/TabsLayout.tsxindex c146d6aa..4261cbf9 100644--- a/dashboard/src/components/molecules/TabsLayout.tsx+++ b/dashboard/src/components/molecules/TabsLayout.tsx@@ -12,6 +12,7 @@ interface Props<T extends string> {onChange: (id: T) => void;children: React.ReactNode;className?: string;+ rightSlot?: React.ReactNode;}export default function TabsLayout<T extends string>({@@ -20,11 +21,12 @@ export default function TabsLayout<T extends string>({onChange,children,className = "",+ rightSlot,}: Props<T>) {return (<div className={`flex h-full flex-col overflow-hidden ${className}`}><div className="border-b border-border-subtle px-4 py-2">- <div className="flex flex-wrap gap-1">+ <div className="flex items-center gap-1">{tabs.map((tab) => (<buttonkey={tab.id}@@ -44,9 +46,12 @@ export default function TabsLayout<T extends string>({)}</button>))}+ {rightSlot && (+ <div className="ml-auto min-w-0 shrink">{rightSlot}</div>+ )}</div></div>- <div className="min-h-0 flex-1 overflow-auto p-4">{children}</div>+ <div className="min-h-0 flex-1 overflow-auto">{children}</div></div>);}diff --git a/dashboard/src/components/profiles/InstanceLogsPanel.tsx b/dashboard/src/components/profiles/InstanceLogsPanel.tsxindex 978b0359..48fd9aba 100644--- a/dashboard/src/components/profiles/InstanceLogsPanel.tsx+++ b/dashboard/src/components/profiles/InstanceLogsPanel.tsx@@ -60,15 +60,15 @@ export default function InstanceLogsPanel({return (<div className="flex h-full min-h-0 flex-col">{loading && !logs ? (- <div className="flex h-full items-center justify-center rounded-xl border border-border-subtle bg-black/10 px-4 py-6 text-sm text-text-muted">+ <div className="flex h-full items-center justify-center border border-border-subtle bg-black/10 px-4 py-6 text-sm text-text-muted">Loading logs...</div>) : logs ? (- <pre className="h-full overflow-auto rounded-xl border border-border-subtle bg-black/10 p-3 font-mono text-[10px] leading-4 text-text-secondary">+ <pre className="h-full overflow-auto border border-border-subtle bg-black/10 p-3 font-mono text-[10px] leading-4 text-text-secondary">{logs}</pre>) : (- <div className="flex h-full items-center justify-center rounded-xl border border-border-subtle bg-black/10 px-4 py-6 text-sm text-text-muted">+ <div className="flex h-full items-center justify-center border border-border-subtle bg-black/10 px-4 py-6 text-sm text-text-muted">{emptyMessage}</div>)}diff --git a/dashboard/src/components/profiles/ProfileDetailsPanel.tsx b/dashboard/src/components/profiles/ProfileDetailsPanel.tsxindex c530d01b..d3efd30f 100644--- a/dashboard/src/components/profiles/ProfileDetailsPanel.tsx+++ b/dashboard/src/components/profiles/ProfileDetailsPanel.tsx@@ -113,7 +113,7 @@ export default function ProfileDetailsPanel({onChange={(id) => setActiveTab(id)}>{activeTab === "profile" && (- <div className="h-full overflow-auto">+ <div className="h-full overflow-auto p-4"><div className="grid gap-4 xl:grid-cols-2"><ProfileBasicInfoPanelprofile={profile}diff --git a/dashboard/src/components/profiles/ProfileLiveViewPanel.tsx b/dashboard/src/components/profiles/ProfileLiveViewPanel.tsxindex c3aefb71..301c213d 100644--- a/dashboard/src/components/profiles/ProfileLiveViewPanel.tsx+++ b/dashboard/src/components/profiles/ProfileLiveViewPanel.tsx@@ -19,7 +19,7 @@ export default function ProfileLiveViewPanel({tabs.length === 0 ? (<EmptyView message="No tabs open" />) : (- <div className="grid grid-cols-1 gap-4 lg:grid-cols-2">+ <div className="p-4 grid grid-cols-1 gap-4 lg:grid-cols-2">{tabs.map((tab) => (<div key={tab.id} className="aspect-video"><ScreencastTilediff --git a/dashboard/src/components/screencast/ScreencastStatusBar.tsx b/dashboard/src/components/screencast/ScreencastStatusBar.tsxnew file mode 100644index 00000000..0ebde4a1--- /dev/null+++ b/dashboard/src/components/screencast/ScreencastStatusBar.tsx@@ -0,0 +1,124 @@+import { useState } from "react";+import * as api from "../../services/api";++export type ScreencastStatus = "connecting" | "streaming" | "error";++interface Props {+ tabId: string;+ status: ScreencastStatus;+ localFps: number;+ setLocalFps: (fps: number | ((prev: number) => number)) => void;+ fpsDisplay: string;+ sizeDisplay: string;+}++export default function ScreencastStatusBar({+ tabId,+ status,+ localFps,+ setLocalFps,+ fpsDisplay,+ sizeDisplay,+}: Props) {+ const [isCapturing, setIsCapturing] = useState(false);+ const [isPdfGenerating, setIsPdfGenerating] = useState(false);++ const takeScreenshot = async () => {+ if (isCapturing) return;+ setIsCapturing(true);++ try {+ const blob = await api.fetchTabScreenshot(tabId, "png");+ const url = URL.createObjectURL(blob);+ const link = document.createElement("a");+ link.href = url;+ link.download = `screenshot-${tabId}-${Date.now()}.png`;+ document.body.appendChild(link);+ link.click();+ document.body.removeChild(link);+ URL.revokeObjectURL(url);+ } catch (e) {+ console.error("Screenshot capture failed", e);+ } finally {+ setIsCapturing(false);+ }+ };++ const downloadPdf = async () => {+ if (isPdfGenerating) return;+ setIsPdfGenerating(true);++ try {+ const blob = await api.fetchTabPdf(tabId);+ const url = URL.createObjectURL(blob);+ const link = document.createElement("a");+ link.href = url;+ link.download = `page-${tabId}-${Date.now()}.pdf`;+ document.body.appendChild(link);+ link.click();+ document.body.removeChild(link);+ URL.revokeObjectURL(url);+ } catch (e) {+ console.error("PDF generation failed", e);+ } finally {+ setIsPdfGenerating(false);+ }+ };++ return (+ <div className="flex shrink-0 items-center justify-between border-t border-border-subtle px-3 py-1 text-xs text-text-muted">+ <div className="flex items-center gap-3">+ <div className="flex items-center overflow-hidden rounded border border-border-subtle bg-black/20">+ <button+ onClick={() => setLocalFps((prev) => Math.max(1, prev - 1))}+ className="flex h-5 w-5 items-center justify-center hover:bg-white/5 active:bg-white/10"+ title="Decrease FPS"+ >+ -+ </button>+ <div className="min-w-16 px-1.5 text-center font-mono text-[10px] text-text-secondary">+ {localFps} FPS ({fpsDisplay})+ </div>+ <button+ onClick={() => setLocalFps((prev) => Math.min(30, prev + 1))}+ className="flex h-5 w-5 items-center justify-center hover:bg-white/5 active:bg-white/10"+ title="Increase FPS"+ >+ ++ </button>+ </div>++ <button+ onClick={takeScreenshot}+ disabled={isCapturing || status !== "streaming"}+ className={`flex h-6 w-6 items-center justify-center rounded-md border border-border-subtle transition-colors hover:bg-white/5 disabled:opacity-50 ${+ isCapturing ? "bg-primary/20" : "bg-black/20"+ }`}+ title="Take full quality screenshot (PNG)"+ >+ {isCapturing ? (+ <span className="animate-pulse">⌛</span>+ ) : (+ <span>📸</span>+ )}+ </button>++ <button+ onClick={downloadPdf}+ disabled={isPdfGenerating || status !== "streaming"}+ className={`flex h-6 w-6 items-center justify-center rounded-md border border-border-subtle transition-colors hover:bg-white/5 disabled:opacity-50 ${+ isPdfGenerating ? "bg-primary/20" : "bg-black/20"+ }`}+ title="Download as PDF"+ >+ {isPdfGenerating ? (+ <span className="animate-pulse">⌛</span>+ ) : (+ <span>📄</span>+ )}+ </button>+ </div>+ <span>{sizeDisplay}</span>+ </div>+ );+}diff --git a/dashboard/src/components/screencast/ScreencastTile.tsx b/dashboard/src/components/screencast/ScreencastTile.tsxindex ff2733cb..3aa78ee6 100644--- a/dashboard/src/components/screencast/ScreencastTile.tsx+++ b/dashboard/src/components/screencast/ScreencastTile.tsx@@ -1,6 +1,9 @@import { useCallback, useEffect, useRef, useState } from "react";import { addTokenToUrl } from "../../services/auth";import * as api from "../../services/api";+import ScreencastStatusBar, {+ type ScreencastStatus,+} from "./ScreencastStatusBar";interface Props {instanceId: string;@@ -13,8 +16,6 @@ interface Props {showTitle?: boolean;}-type Status = "connecting" | "streaming" | "error";-export default function ScreencastTile({instanceId,tabId,@@ -27,16 +28,80 @@ export default function ScreencastTile({}: Props) {const canvasRef = useRef<HTMLCanvasElement>(null);const socketRef = useRef<WebSocket | null>(null);- const [status, setStatus] = useState<Status>("connecting");+ const [status, setStatus] = useState<ScreencastStatus>("connecting");const [fpsDisplay, setFpsDisplay] = useState("—");const [sizeDisplay, setSizeDisplay] = useState("—");const [localFps, setLocalFps] = useState(fps);- const [isCapturing, setIsCapturing] = useState(false);- const [isPdfGenerating, setIsPdfGenerating] = useState(false);const [hasFrame, setHasFrame] = useState(false);const [fallbackUrl, setFallbackUrl] = useState<string | null>(null);const [retryKey, setRetryKey] = useState(0);+ // ── Interactive click & scroll on the screencast canvas ──++ const getPageCoords = useCallback(+ (e: React.MouseEvent<HTMLCanvasElement>) => {+ const canvas = canvasRef.current;+ if (!canvas) return null;+ const rect = canvas.getBoundingClientRect();+ // canvas.width/height = actual CDP viewport pixels+ // rect.width/height = CSS display size+ return {+ x: ((e.clientX - rect.left) / rect.width) * canvas.width,+ y: ((e.clientY - rect.top) / rect.height) * canvas.height,+ };+ },+ [],+ );++ const handleCanvasClick = useCallback(+ async (e: React.MouseEvent<HTMLCanvasElement>) => {+ if (status !== "streaming") return;+ const coords = getPageCoords(e);+ if (!coords) return;+ try {+ await api.sendAction({+ kind: "click",+ tabId,+ x: Math.round(coords.x),+ y: Math.round(coords.y),+ hasXY: true,+ });+ } catch (err) {+ console.error("click failed", err);+ }+ },+ [status, tabId, getPageCoords],+ );++ const handleCanvasWheel = useCallback(+ async (e: React.WheelEvent<HTMLCanvasElement>) => {+ if (status !== "streaming") return;+ const coords = getPageCoords(e);+ if (!coords) return;+ try {+ await api.sendAction({+ kind: "scroll",+ tabId,+ x: Math.round(coords.x),+ y: Math.round(coords.y),+ deltaY: Math.round(e.deltaY),+ });+ } catch (err) {+ console.error("scroll failed", err);+ }+ },+ [status, tabId, getPageCoords],+ );++ // Prevent default wheel behavior on the canvas so the page doesn't scroll+ useEffect(() => {+ const canvas = canvasRef.current;+ if (!canvas) return;+ const prevent = (e: WheelEvent) => e.preventDefault();+ canvas.addEventListener("wheel", prevent, { passive: false });+ return () => canvas.removeEventListener("wheel", prevent);+ }, []);+// Reset local FPS when the tab changes to match the new tab's initial requestuseEffect(() => {setLocalFps(fps);@@ -54,48 +119,6 @@ export default function ScreencastTile({};}, [fallbackUrl]);- const takeScreenshot = async () => {- if (isCapturing) return;- setIsCapturing(true);-- try {- const blob = await api.fetchTabScreenshot(tabId, "png");- const url = URL.createObjectURL(blob);- const link = document.createElement("a");- link.href = url;- link.download = `screenshot-${tabId}-${Date.now()}.png`;- document.body.appendChild(link);- link.click();- document.body.removeChild(link);- URL.revokeObjectURL(url);- } catch (e) {- console.error("Screenshot capture failed", e);- } finally {- setIsCapturing(false);- }- };-- const downloadPdf = async () => {- if (isPdfGenerating) return;- setIsPdfGenerating(true);-- try {- const blob = await api.fetchTabPdf(tabId);- const url = URL.createObjectURL(blob);- const link = document.createElement("a");- link.href = url;- link.download = `page-${tabId}-${Date.now()}.pdf`;- document.body.appendChild(link);- link.click();- document.body.removeChild(link);- URL.revokeObjectURL(url);- } catch (e) {- console.error("PDF generation failed", e);- } finally {- setIsPdfGenerating(false);- }- };-const captureFallback = useCallback(async () => {try {const blob = await api.fetchTabScreenshot(tabId, "png");@@ -222,7 +245,7 @@ export default function ScreencastTile({? "bg-warning": "bg-destructive";return (- <div className="flex h-full flex-col overflow-hidden rounded-lg border border-border-subtle bg-bg-elevated">+ <div className="flex h-full flex-col overflow-hidden border border-border-subtle bg-bg-elevated">{/* Header */}{showTitle && (<div className="flex shrink-0 items-center justify-between border-b border-border-subtle px-3 py-2">@@ -248,9 +271,11 @@ export default function ScreencastTile({) : (<canvasref={canvasRef}- className="max-h-full max-w-full object-contain"+ className="max-h-full max-w-full cursor-pointer object-contain"width={800}height={600}+ onClick={handleCanvasClick}+ onWheel={handleCanvasWheel}/>)}@@ -282,60 +307,14 @@ export default function ScreencastTile({</div>)}</div>- <div className="flex shrink-0 items-center justify-between border-t border-border-subtle px-3 py-1 text-xs text-text-muted">- <div className="flex items-center gap-3">- <div className="flex items-center overflow-hidden rounded border border-border-subtle bg-black/20">- <button- onClick={() => setLocalFps((prev) => Math.max(1, prev - 1))}- className="flex h-5 w-5 items-center justify-center hover:bg-white/5 active:bg-white/10"- title="Decrease FPS"- >- -- </button>- <div className="min-w-16 px-1.5 text-center font-mono text-[10px] text-text-secondary">- {localFps} FPS ({fpsDisplay})- </div>- <button- onClick={() => setLocalFps((prev) => Math.min(30, prev + 1))}- className="flex h-5 w-5 items-center justify-center hover:bg-white/5 active:bg-white/10"- title="Increase FPS"- >- +- </button>- </div>-- <button- onClick={takeScreenshot}- disabled={isCapturing || status !== "streaming"}- className={`flex h-6 w-6 items-center justify-center rounded-md border border-border-subtle transition-colors hover:bg-white/5 disabled:opacity-50 ${- isCapturing ? "bg-primary/20" : "bg-black/20"- }`}- title="Take full quality screenshot (PNG)"- >- {isCapturing ? (- <span className="animate-pulse">⌛</span>- ) : (- <span>📸</span>- )}- </button>-- <button- onClick={downloadPdf}- disabled={isPdfGenerating || status !== "streaming"}- className={`flex h-6 w-6 items-center justify-center rounded-md border border-border-subtle transition-colors hover:bg-white/5 disabled:opacity-50 ${- isPdfGenerating ? "bg-primary/20" : "bg-black/20"- }`}- title="Download as PDF"- >- {isPdfGenerating ? (- <span className="animate-pulse">⌛</span>- ) : (- <span>📄</span>- )}- </button>- </div>- <span>{sizeDisplay}</span>- </div>+ <ScreencastStatusBar+ tabId={tabId}+ status={status}+ localFps={localFps}+ setLocalFps={setLocalFps}+ fpsDisplay={fpsDisplay}+ sizeDisplay={sizeDisplay}+ /></div>);}diff --git a/dashboard/src/components/tabs/InstanceTabsPanel.test.tsx b/dashboard/src/components/tabs/InstanceTabsPanel.test.tsxindex 6dd14095..ee989b27 100644--- a/dashboard/src/components/tabs/InstanceTabsPanel.test.tsx+++ b/dashboard/src/components/tabs/InstanceTabsPanel.test.tsx@@ -42,9 +42,9 @@ describe("InstanceTabsPanel", () => {render(<InstanceTabsPanel tabs={tabs} />);// Select Beta tab from list- const betaTabItem = screen- .getByText("Beta Tab")- .closest('[role="button"]')!;+ const betaTabItem = screen.getByRole("button", {+ name: /Beta Tab.*tab_beta/,+ });await user.click(betaTabItem);// Find heading for beta tab titlediff --git a/dashboard/src/components/tabs/InstanceTabsPanel.tsx b/dashboard/src/components/tabs/InstanceTabsPanel.tsxindex 2c56ed30..6b083d3e 100644--- a/dashboard/src/components/tabs/InstanceTabsPanel.tsx+++ b/dashboard/src/components/tabs/InstanceTabsPanel.tsx@@ -1,6 +1,6 @@import { useEffect, useMemo, useState } from "react";import type { InstanceTab } from "../../generated/types";-import TabItem from "./TabItem";+import TabBar from "./TabBar";import SelectedTabPanel from "./SelectedTabPanel";interface Props {@@ -32,51 +32,32 @@ export default function InstanceTabsPanel({[selectedTabId, tabs],);- return (- <div className="flex flex-1 min-h-0 flex-col p-3">- <h4 className="mb-2 text-xs font-semibold uppercase tracking-wide text-text-muted">- Open Tabs ({tabs.length})- </h4>+ const heading = `Open Tabs (${tabs.length})`;- {tabs.length === 0 ? (- <div className="py-8 text-center text-sm text-text-muted">+ if (tabs.length === 0) {+ return (+ <div className="flex min-h-0 flex-1 flex-col">+ <div className="border-b border-border-subtle px-4 py-3">+ <h2 className="text-sm font-medium text-text-primary">{heading}</h2>+ </div>+ <div className="flex flex-1 items-center justify-center py-8 text-sm text-text-muted">{emptyMessage}</div>- ) : (- <div className="flex min-h-0 flex-1 flex-col gap-3 xl:flex-row">- <div className="min-h-0 overflow-auto xl:w-80 xl:shrink-0">- <div className="space-y-1">- {tabs.map((tab) => {- const isSelected = tab.id === selectedTabId;-- return (- <div- key={tab.id}- role="button"- tabIndex={0}- onClick={() => setSelectedTabId(tab.id)}- onKeyDown={(event) => {- if (event.key === "Enter" || event.key === " ") {- event.preventDefault();- setSelectedTabId(tab.id);- }- }}- className={`w-full rounded-xl border text-left transition ${- isSelected- ? "border-primary bg-primary/10"- : "border-border-subtle bg-white/2 hover:border-border-default hover:bg-white/3"- }`}- >- <TabItem tab={tab} />- </div>- );- })}- </div>- </div>+ </div>+ );+ }- <SelectedTabPanel selectedTab={selectedTab} instanceId={instanceId} />- </div>- )}+ return (+ <div className="flex min-h-0 flex-1 flex-col">+ <div className="border-b border-border-subtle px-4 py-3">+ <h2 className="text-sm font-medium text-text-primary">{heading}</h2>+ </div>+ <TabBar+ tabs={tabs}+ selectedTabId={selectedTabId}+ onSelect={setSelectedTabId}+ />+ <SelectedTabPanel selectedTab={selectedTab} instanceId={instanceId} /></div>);}diff --git a/dashboard/src/components/tabs/SelectedTabPanel.tsx b/dashboard/src/components/tabs/SelectedTabPanel.tsxindex a5f5476c..3829f7c5 100644--- a/dashboard/src/components/tabs/SelectedTabPanel.tsx+++ b/dashboard/src/components/tabs/SelectedTabPanel.tsx@@ -12,6 +12,20 @@ interface Props {type SubTabId = "actions" | "live" | "console" | "errors";+function TabInfo({ tab }: { tab: InstanceTab }) {+ return (+ <div className="flex flex-col gap-0.5 text-right">+ <div className="flex items-center justify-end gap-1.5">+ <h3 className="truncate text-xs font-medium text-text-secondary">+ {tab.title || "Untitled"}+ </h3>+ <IdBadge id={tab.id} />+ </div>+ <div className="truncate text-[10px] text-text-muted">{tab.url}</div>+ </div>+ );+}+export default function SelectedTabPanel({ selectedTab, instanceId }: Props) {const [activeSubTab, setActiveSubTab] = useState<SubTabId>("live");@@ -24,39 +38,27 @@ export default function SelectedTabPanel({ selectedTab, instanceId }: Props) {if (!selectedTab) {return (- <div className="flex flex-1 rounded-xl border border-border-subtle bg-white/2">- <EmptyView message="Select a tab to view details" />+ <div className="flex flex-1 items-center justify-center text-sm text-text-muted">+ Select a tab to view details</div>);}return (- <div className="flex min-h-48 flex-1 flex-col rounded-xl border border-border-subtle bg-white/2 relative overflow-hidden">- <div className="border-b border-border-subtle bg-black/5 p-4">- <div className="flex items-center justify-between gap-4">- <div className="min-w-0 flex-1">- <h5 className="truncate text-base font-semibold text-text-primary">- {selectedTab.title || "Untitled"}- </h5>- <div className="mt-1 truncate text-xs text-text-muted">- {selectedTab.url}- </div>- </div>- <IdBadge id={selectedTab.id} />- </div>- </div>+ <div className="flex min-h-48 flex-1 flex-col overflow-hidden rounded-xl"><div className="flex-1 min-h-0"><TabsLayouttabs={subTabs}activeTab={activeSubTab}onChange={(id) => setActiveSubTab(id)}+ rightSlot={<TabInfo tab={selectedTab} />}>{activeSubTab === "actions" && (- <div className="h-full p-3">+ <div className="h-full"><ActivityExplorerembeddedshowFilterMenu={false}- title="Tab activity"+ title=""summaryLabel="Actions"initialFilters={{instanceId: instanceId || "",@@ -71,18 +73,14 @@ export default function SelectedTabPanel({ selectedTab, instanceId }: Props) {{activeSubTab === "live" && (<div className="h-full">{instanceId ? (- <div className="flex h-full items-center justify-center">- <div className="h-full w-full">- <ScreencastTile- key={selectedTab.id}- instanceId={instanceId}- tabId={selectedTab.id}- label={selectedTab.title || selectedTab.id.slice(0, 8)}- url={selectedTab.url}- showTitle={false}- />- </div>- </div>+ <ScreencastTile+ key={selectedTab.id}+ instanceId={instanceId}+ tabId={selectedTab.id}+ label={selectedTab.title || selectedTab.id.slice(0, 8)}+ url={selectedTab.url}+ showTitle={false}+ />) : (<EmptyView message="No instance ID provided for live view." />)}diff --git a/dashboard/src/components/tabs/TabBar.tsx b/dashboard/src/components/tabs/TabBar.tsxnew file mode 100644index 00000000..c3e3e141--- /dev/null+++ b/dashboard/src/components/tabs/TabBar.tsx@@ -0,0 +1,69 @@+import type { InstanceTab } from "../../generated/types";+import * as api from "../../services/api";++interface Props {+ tabs: InstanceTab[];+ selectedTabId: string | null;+ onSelect: (id: string) => void;+ onTabClosed?: () => void;+}++export default function TabBar({+ tabs,+ selectedTabId,+ onSelect,+ onTabClosed,+}: Props) {+ const handleClose = async (e: React.MouseEvent, tabId: string) => {+ e.stopPropagation();+ try {+ await api.closeTab(tabId);+ onTabClosed?.();+ } catch (err) {+ console.error("Failed to close tab", err);+ }+ };+ if (tabs.length === 0) return null;++ return (+ <div className="flex min-h-0 items-end gap-px overflow-x-auto border-b border-border-subtle bg-black/10 px-1 pt-1">+ {tabs.map((tab) => {+ const isSelected = tab.id === selectedTabId;+ const title = tab.title || "Untitled";+ const shortId = tab.id.substring(0, 8);++ return (+ <button+ key={tab.id}+ onClick={() => onSelect(tab.id)}+ title={`${title}\n${tab.url}\n${tab.id}`}+ className={`group relative flex max-w-52 min-w-0 items-center gap-1 rounded-t-md pl-3 pr-1.5 py-1.5 text-left transition-colors ${+ isSelected+ ? "bg-bg-surface text-text-primary border-x border-t border-border-subtle"+ : "text-text-muted hover:bg-white/5 hover:text-text-secondary"+ }`}+ >+ <span className="truncate text-xs font-medium">{title}</span>+ <span+ className={`shrink-0 font-mono text-[9px] ${isSelected ? "text-text-muted" : "text-text-muted/50"}`}+ >+ {shortId}+ </span>+ <span+ role="button"+ tabIndex={0}+ onClick={(e) => handleClose(e, tab.id)}+ onKeyDown={(e) => {+ if (e.key === "Enter")+ handleClose(e as unknown as React.MouseEvent, tab.id);+ }}+ className="ml-0.5 shrink-0 rounded p-0.5 text-[10px] leading-none text-text-muted/40 opacity-0 transition-all hover:bg-white/10 hover:text-text-primary group-hover:opacity-100"+ >+ ✕+ </span>+ </button>+ );+ })}+ </div>+ );+}diff --git a/dashboard/src/components/tabs/index.ts b/dashboard/src/components/tabs/index.tsindex 92948ece..0d693424 100644--- a/dashboard/src/components/tabs/index.ts+++ b/dashboard/src/components/tabs/index.ts@@ -1,4 +1,5 @@export { default as InstanceTabsPanel } from "./InstanceTabsPanel";export { default as SelectedTabPanel } from "./SelectedTabPanel";+export { default as TabBar } from "./TabBar";export { default as TabItem } from "./TabItem";export { default as IdBadge } from "./IdBadge";diff --git a/dashboard/src/pages/MonitoringPage.tsx b/dashboard/src/pages/MonitoringPage.tsxindex def8fc5e..2bdb7a4e 100644--- a/dashboard/src/pages/MonitoringPage.tsx+++ b/dashboard/src/pages/MonitoringPage.tsx@@ -1,7 +1,7 @@import { useEffect, useState } from "react";import { useNavigate } from "react-router-dom";import { useAppStore } from "../stores/useAppStore";-import { EmptyState, Button, ErrorBoundary } from "../components/atoms";+import { EmptyState, ErrorBoundary } from "../components/atoms";import { TabsChart } from "../components/molecules";import InstanceListItem from "../components/instances/InstanceListItem";import InstanceTabsPanel from "../components/tabs/InstanceTabsPanel";@@ -19,8 +19,22 @@ export default function MonitoringPage() {} = useAppStore();const navigate = useNavigate();const [selectedId, setSelectedId] = useState<string | null>(null);+ const [strategy, setStrategy] = useState<string>("always-on");const memoryEnabled = settings.monitoring?.memoryMetrics ?? false;+ // Fetch backend strategy once+ useEffect(() => {+ const load = async () => {+ try {+ const cfg = await api.fetchBackendConfig();+ setStrategy(cfg.config.multiInstance.strategy);+ } catch {+ // ignore — default to always-on+ }+ };+ load();+ }, []);+// Auto-select first running instanceuseEffect(() => {if (!selectedId) {@@ -88,7 +102,21 @@ export default function MonitoringPage() {memoryEnabled ? currentMemory[inst.id] : undefined}selected={selectedId === inst.id}+ autoRestart={+ inst.profileName === "default" &&+ (strategy === "always-on" ||+ strategy === "simple-autorestart")+ }onClick={() => setSelectedId(inst.id)}+ onStop={() => handleStop(inst.id)}+ onOpenProfile={() =>+ navigate("/dashboard/profiles", {+ state: {+ selectedProfileKey:+ inst.profileId || inst.profileName,+ },+ })+ }/>))}</div>@@ -97,52 +125,10 @@ export default function MonitoringPage() {{/* Selected instance details */}<div className="dashboard-panel flex flex-1 flex-col overflow-hidden">{selectedInstance ? (- <>- <div className="flex items-center justify-between border-b border-border-subtle px-4 py-3">- <div>- <div className="dashboard-section-title mb-1">- Active instance- </div>- <h3 className="text-sm font-semibold text-text-primary">- {selectedInstance.profileName}- </h3>- <div className="dashboard-mono text-xs text-text-muted">- Port {selectedInstance.port} ·{" "}- {selectedInstance.headless ? "Headless" : "Headed"}- </div>- </div>- <div className="flex items-center gap-2">- <Button- size="sm"- variant="secondary"- onClick={() =>- navigate("/dashboard/profiles", {- state: {- selectedProfileKey:- selectedInstance.profileId ||- selectedInstance.profileName,- },- })- }- >- Open Profile- </Button>- {selectedInstance.status === "running" && (- <Button- size="sm"- variant="danger"- onClick={() => handleStop(selectedInstance.id)}- >- Stop- </Button>- )}- </div>- </div>- <InstanceTabsPanel- tabs={selectedTabs}- instanceId={selectedId || undefined}- />- </>+ <InstanceTabsPanel+ tabs={selectedTabs}+ instanceId={selectedId || undefined}+ />) : (<div className="flex flex-1 items-center justify-center text-sm text-text-muted">Select an instance to view detailsdiff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.tsindex eb0de6b0..db811f74 100644--- a/dashboard/src/services/api.ts+++ b/dashboard/src/services/api.ts@@ -213,6 +213,31 @@ export async function fetchTabPdf(tabId: string): Promise<Blob> {return requestBlob(`/tabs/${encodeURIComponent(tabId)}/pdf?raw=true`);}+export async function closeTab(tabId: string): Promise<void> {+ await request(`/tabs/${encodeURIComponent(tabId)}`, { method: "DELETE" });+}++export async function navigateTab(+ tabId: string,+ url: string,+): Promise<unknown> {+ return request("/navigate", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ tabId, url }),+ });+}++export async function sendAction(+ body: Record<string, unknown>,+): Promise<unknown> {+ return request("/action", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify(body),+ });+}+export function subscribeToInstanceLogs(id: string,handlers: { onLogs?: (logs: string) => void },diff --git a/dashboard/vite.config.ts b/dashboard/vite.config.tsindex 3f0c6af1..3a7074fd 100644--- a/dashboard/vite.config.ts+++ b/dashboard/vite.config.ts@@ -3,16 +3,28 @@ import { defineConfig } from 'vite'import react from '@vitejs/plugin-react'import tailwindcss from '@tailwindcss/vite'-export default defineConfig({+export default defineConfig(() => {+ const backendPort = process.env.PINCHTAB_DEV_PORT || '9867'+ const backendUrl = `http://localhost:${backendPort}`++ // In dev mode, proxy all API routes to the Go backend.+ // Add new top-level API paths here as they're created.+ const apiPaths = [+ '/api', '/health', '/metrics', '/instances', '/profiles', '/tabs',+ '/navigate', '/action', '/screenshot', '/evaluate', '/find', '/text',+ '/snapshot', '/download', '/upload', '/cookies', '/fingerprint', '/scheduler',+ ]+ const proxy: Record<string, string> = {}+ for (const path of apiPaths) {+ proxy[path] = backendUrl+ }++ return {plugins: [react(), tailwindcss()],base: '/dashboard/', // Served at /dashboard by Goserver: {port: 5173,- proxy: {- '/api': 'http://localhost:9867',- '/health': 'http://localhost:9867',- '/metrics': 'http://localhost:9867',- },+ proxy,},build: {outDir: 'dist',@@ -31,4 +43,5 @@ export default defineConfig({setupFiles: ['./src/test/setup.ts'],include: ['src/**/*.test.{ts,tsx}'],},+ }})diff --git a/scripts/dev-dashboard.sh b/scripts/dev-dashboard.shindex 6d2fcec1..b9e61336 100755--- a/scripts/dev-dashboard.sh+++ b/scripts/dev-dashboard.sh@@ -5,7 +5,9 @@# 1. pinchtab backend (Go) on port 9867# 2. Vite dev server (React) on port 5173 with proxy to backend#-# Access the dashboard at: http://localhost:5173/dashboard/+# Access the dashboard at:+# - http://localhost:5173/dashboard/ (hot reload via Vite)+# - http://localhost:9867/dashboard/ (backend-served build, no hot reload)# Changes to dashboard/src/* will hot-reload instantly.## Usage: ./scripts/dev-dashboard.sh [pinchtab args...]@@ -25,6 +27,7 @@ cleanup() {echo " ${MUTED}Shutting down...${NC}"kill $BACKEND_PID 2>/dev/null || truekill $VITE_PID 2>/dev/null || true+ [ -n "${DEV_CONFIG:-}" ] && rm -f "$DEV_CONFIG" 2>/dev/nullexit 0}@@ -38,21 +41,24 @@ echo ""echo " ${MUTED}Building Go backend...${NC}"go build -o pinchtab ./cmd/pinchtab-# Start backend-echo " ${MUTED}Starting pinchtab backend on :9867...${NC}"-./pinchtab server "$@" &+# Start backend on port 9867 (matches Vite proxy target)+DEV_PORT=${PINCHTAB_DEV_PORT:-9867}+DEV_CONFIG=$(mktemp -d)/pinchtab.json+echo "{\"server\":{\"port\":\"${DEV_PORT}\"}}" > "$DEV_CONFIG"+echo " ${MUTED}Starting pinchtab backend on :${DEV_PORT}...${NC}"+PINCHTAB_CONFIG="$DEV_CONFIG" ./pinchtab server "$@" &BACKEND_PID=$!# Wait for backend to be readyecho " ${MUTED}Waiting for backend...${NC}"for i in {1..30}; do- if curl -s http://localhost:9867/health >/dev/null 2>&1; then+ if curl -s http://localhost:${DEV_PORT}/health >/dev/null 2>&1; thenbreakfisleep 0.5done-if ! curl -s http://localhost:9867/health >/dev/null 2>&1; then+if ! curl -s http://localhost:${DEV_PORT}/health >/dev/null 2>&1; thenecho " ${BOLD}Backend failed to start${NC}"kill $BACKEND_PID 2>/dev/null || trueexit 1@@ -80,10 +86,11 @@ sleep 3echo ""echo " ${SUCCESS}${BOLD}✓ Ready!${NC}"echo ""-echo " ${BOLD}Dashboard:${NC} ${ACCENT}http://localhost:5173/dashboard/${NC}"-echo " ${BOLD}Backend:${NC} http://localhost:9867"+echo " ${BOLD}Hot reload at:${NC} ${ACCENT}http://localhost:5173/dashboard/${NC}"+echo " ${BOLD}Dashboard:${NC} ${ACCENT}http://localhost:${DEV_PORT}/dashboard/${NC}"+echo " ${BOLD}Backend:${NC} http://localhost:${DEV_PORT}"echo ""-echo " ${MUTED}Edit dashboard/src/* and changes will hot-reload.${NC}"+echo " ${MUTED}Edit dashboard/src/* and use the Vite URL above for live updates.${NC}"echo " ${MUTED}Press Ctrl+C to stop.${NC}"echo ""