High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
feat: persist chart data, improve profile cards, add copy command
Boschc2c292b920c4
diff --git a/dashboard/src/components/molecules/ProfileCard.tsx b/dashboard/src/components/molecules/ProfileCard.tsxindex 90978931..4e09fddf 100644--- a/dashboard/src/components/molecules/ProfileCard.tsx+++ b/dashboard/src/components/molecules/ProfileCard.tsx@@ -5,57 +5,90 @@ interface Props {profile: Profileinstance?: InstanceonLaunch: () => void- onManage: () => void+ onStop?: () => void+ onDetails?: () => void}-export default function ProfileCard({ profile, instance, onLaunch, onManage }: Props) {- const isRunning = !!instance+function InfoRow({ label, value }: { label: string; value: string }) {+ return (+ <div className="flex justify-between text-xs">+ <span className="text-text-muted">{label}</span>+ <span className="text-text-secondary">{value}</span>+ </div>+ )+}++export default function ProfileCard({+ profile,+ instance,+ onLaunch,+ onStop,+ onDetails,+}: Props) {+ const isRunning = instance?.status === 'running'+ const isError = instance?.status === 'error'+ const accountText = profile.accountEmail || profile.accountName || '—'+ const sizeText = profile.sizeMB ? `${profile.sizeMB.toFixed(0)} MB` : '—'return (- <Card hover className="flex flex-col p-4">- <div className="mb-3 flex items-start justify-between">- <div className="flex items-center gap-2">- <span className="text-2xl">📁</span>- <div>- <div className="font-medium text-text-primary">{profile.name}</div>- {profile.useWhen && (- <div className="mt-0.5 text-xs text-text-muted line-clamp-1">- {profile.useWhen}- </div>- )}- </div>- </div>+ <Card hover className="flex flex-col">+ {/* Header */}+ <div className="flex items-center justify-between border-b border-border-subtle p-3">+ <span className="truncate font-medium text-text-primary">+ {profile.name}+ </span>{isRunning ? (- <Badge variant="success">Running</Badge>+ <Badge variant="success">:{instance.port}</Badge>+ ) : isError ? (+ <Badge variant="danger">error</Badge>) : (- <Badge>Stopped</Badge>+ <Badge>stopped</Badge>)}</div>- {isRunning && instance && (- <div className="mb-3 rounded bg-bg-elevated px-2 py-1.5 text-xs text-text-muted">- Port {instance.port}- </div>- )}+ {/* Body */}+ <div className="flex flex-1 flex-col gap-1.5 p-3">+ <InfoRow label="Size" value={sizeText} />+ <InfoRow label="Account" value={accountText} />+ {profile.useWhen && (+ <div className="mt-1">+ <div className="text-xs text-text-muted">Use when</div>+ <div className="mt-0.5 line-clamp-2 text-xs text-text-secondary">+ {profile.useWhen}+ </div>+ </div>+ )}+ {isError && instance?.error && (+ <div className="mt-1 text-xs text-destructive">{instance.error}</div>+ )}+ </div>- <div className="mt-auto flex gap-2">+ {/* Actions */}+ <div className="flex gap-2 border-t border-border-subtle p-3">+ {onDetails && (+ <Button size="sm" variant="ghost" onClick={onDetails}>+ Details+ </Button>+ )}{isRunning ? (<Buttonsize="sm"- variant="primary"+ variant="danger"className="flex-1"- onClick={() => window.open(`http://localhost:${instance.port}/dashboard`, '_blank')}+ onClick={onStop}>- Open+ Stop</Button>) : (- <Button size="sm" variant="primary" className="flex-1" onClick={onLaunch}>+ <Button+ size="sm"+ variant="primary"+ className="flex-1"+ onClick={onLaunch}+ >Launch</Button>)}- <Button size="sm" variant="ghost" onClick={onManage}>- ⋯- </Button></div></Card>)diff --git a/dashboard/src/components/molecules/TabsChart.tsx b/dashboard/src/components/molecules/TabsChart.tsxindex 2ca3beaa..832110eb 100644--- a/dashboard/src/components/molecules/TabsChart.tsx+++ b/dashboard/src/components/molecules/TabsChart.tsx@@ -6,13 +6,8 @@ import {YAxis,Tooltip,ResponsiveContainer,- Legend,} from 'recharts'--export interface TabDataPoint {- timestamp: number- [instanceId: string]: number // tab count per instance-}+import type { TabDataPoint } from '../../stores/useAppStore'interface Props {data: TabDataPoint[]@@ -54,29 +49,36 @@ export default function TabsChart({return colors}, [instances])- if (data.length === 0) {+ if (data.length === 0 || instances.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">- No data yet — waiting for instances...+ {instances.length === 0+ ? 'No running instances'+ : 'Collecting data...'}</div>)}return (- <div className="rounded-lg border border-border-subtle bg-bg-surface p-4">+ <div className="rounded-lg border border-border-subtle bg-bg-surface"><ResponsiveContainer width="100%" height={200}>- <LineChart data={data}>+ <LineChart data={data} margin={{ top: 16, right: 16, bottom: 8, left: 8 }}><XAxisdataKey="timestamp"tickFormatter={formatTime}stroke="#666"fontSize={11}+ tickLine={false}+ axisLine={false}/><YAxisstroke="#666"fontSize={11}allowDecimals={false}domain={[0, 'auto']}+ tickLine={false}+ axisLine={false}+ width={30}/><TooltipcontentStyle={{@@ -86,27 +88,28 @@ export default function TabsChart({fontSize: '12px',}}labelFormatter={(label) => formatTime(label as number)}- />- <Legend- onClick={(e) => {- const id = e.dataKey as string- onSelectInstance(id)+ formatter={(value, name) => {+ const inst = instances.find((i) => i.id === name)+ return [value ?? 0, inst?.profileName || name]}}- wrapperStyle={{ cursor: 'pointer', fontSize: '12px' }}/>{instances.map((inst) => (<Linekey={inst.id}type="monotone"dataKey={inst.id}- name={inst.profileName}+ name={inst.id}stroke={instanceColors[inst.id]}strokeWidth={selectedInstanceId === inst.id ? 3 : 1.5}strokeOpacity={selectedInstanceId && selectedInstanceId !== inst.id ? 0.3 : 1}dot={false}- activeDot={{ r: 4 }}+ activeDot={{+ r: 4,+ onClick: () => onSelectInstance(inst.id),+ style: { cursor: 'pointer' },+ }}/>))}</LineChart>diff --git a/dashboard/src/pages/MonitoringPage.tsx b/dashboard/src/pages/MonitoringPage.tsxindex d6adeda3..727d3e3c 100644--- a/dashboard/src/pages/MonitoringPage.tsx+++ b/dashboard/src/pages/MonitoringPage.tsx@@ -1,18 +1,23 @@import { useEffect, useState, useCallback, useRef } from 'react'import { useAppStore } from '../stores/useAppStore'import { Card, EmptyState, Badge, Button } from '../components/atoms'-import TabsChart, { type TabDataPoint } from '../components/molecules/TabsChart'+import TabsChart from '../components/molecules/TabsChart'import type { InstanceTab } from '../generated/types'import * as api from '../services/api'const POLL_INTERVAL = 30000 // 30 seconds-const MAX_DATA_POINTS = 60 // 30 minutes of dataexport default function MonitoringPage() {- const { instances, setInstances, setInstancesLoading } = useAppStore()+ const {+ instances,+ setInstances,+ setInstancesLoading,+ tabsChartData,+ currentTabs,+ addChartDataPoint,+ setCurrentTabs,+ } = useAppStore()const [selectedId, setSelectedId] = useState<string | null>(null)- const [tabsData, setTabsData] = useState<TabDataPoint[]>([])- const [currentTabs, setCurrentTabs] = useState<Record<string, InstanceTab[]>>({})const pollRef = useRef<ReturnType<typeof setInterval> | null>(null)const loadInstances = async () => {@@ -33,7 +38,7 @@ export default function MonitoringPage() {if (runningInstances.length === 0) returnconst timestamp = Date.now()- const dataPoint: TabDataPoint = { timestamp }+ const dataPoint: Record<string, number> = { timestamp }const tabsByInstance: Record<string, InstanceTab[]> = {}await Promise.all(@@ -51,9 +56,9 @@ export default function MonitoringPage() {}))- setTabsData((prev) => [...prev.slice(-MAX_DATA_POINTS + 1), dataPoint])+ addChartDataPoint(dataPoint as any)setCurrentTabs(tabsByInstance)- }, [instances])+ }, [instances, addChartDataPoint, setCurrentTabs])// Initial loaduseEffect(() => {@@ -106,7 +111,7 @@ export default function MonitoringPage() {<div className="flex flex-1 flex-col gap-4 overflow-auto p-4">{/* Chart */}<TabsChart- data={tabsData}+ data={tabsChartData}instances={runningInstances.map((i) => ({id: i.id,profileName: i.profileName,diff --git a/dashboard/src/pages/ProfilesPage.tsx b/dashboard/src/pages/ProfilesPage.tsxindex e140afba..896cfaa2 100644--- a/dashboard/src/pages/ProfilesPage.tsx+++ b/dashboard/src/pages/ProfilesPage.tsx@@ -1,11 +1,18 @@-import { useEffect, useState } from 'react'+import { useEffect, useState, useMemo } from 'react'import { useAppStore } from '../stores/useAppStore'import { Toolbar, EmptyState, Button, Modal, Input } from '../components/atoms'import { ProfileCard } from '../components/molecules'import * as api from '../services/api'export default function ProfilesPage() {- const { profiles, instances, profilesLoading, setProfiles, setProfilesLoading } = useAppStore()+ const {+ profiles,+ instances,+ profilesLoading,+ setProfiles,+ setProfilesLoading,+ setInstances,+ } = useAppStore()const [showCreate, setShowCreate] = useState(false)const [showLaunch, setShowLaunch] = useState<string | null>(null)@@ -17,6 +24,7 @@ export default function ProfilesPage() {// Launch formconst [launchPort, setLaunchPort] = useState('9868')const [launchHeadless, setLaunchHeadless] = useState(false)+ const [copyFeedback, setCopyFeedback] = useState('')const loadProfiles = async () => {setProfilesLoading(true)@@ -65,21 +73,57 @@ export default function ProfilesPage() {setShowLaunch(null)setLaunchPort('9868')setLaunchHeadless(false)- // Instances will refresh automatically} catch (e) {console.error('Failed to launch instance', e)}}- const instanceByProfile = new Map(- instances.map((i) => [i.profileName, i])- )+ const handleStop = async (profileName: string) => {+ const inst = instanceByProfile.get(profileName)+ if (!inst) return+ try {+ await api.stopInstance(inst.id)+ // Refresh instances+ const updated = await api.fetchInstances()+ setInstances(updated)+ } catch (e) {+ console.error('Failed to stop instance', e)+ }+ }++ // Generate launch command+ const launchCommand = useMemo(() => {+ if (!showLaunch) return ''+ const profile = profiles.find((p) => p.name === showLaunch)+ const profileId = profile?.id || showLaunch+ const mode = launchHeadless ? 'headless' : 'headed'+ const port = launchPort || 'auto'+ return `curl -X POST http://localhost:9867/instances/start -H "Content-Type: application/json" -d '{"profileId":"${profileId}","mode":"${mode}","port":"${port}"}'`+ }, [showLaunch, launchHeadless, launchPort, profiles])++ const handleCopyCommand = async () => {+ try {+ await navigator.clipboard.writeText(launchCommand)+ setCopyFeedback('Copied!')+ setTimeout(() => setCopyFeedback(''), 2000)+ } catch {+ setCopyFeedback('Failed to copy')+ setTimeout(() => setCopyFeedback(''), 2000)+ }+ }++ const instanceByProfile = new Map(instances.map((i) => [i.profileName, i]))return (<div className="flex flex-1 flex-col"><Toolbaractions={[- { key: 'new', label: '+ New Profile', onClick: () => setShowCreate(true), variant: 'primary' },+ {+ key: 'new',+ label: '+ New Profile',+ onClick: () => setShowCreate(true),+ variant: 'primary',+ },{ key: 'refresh', label: 'Refresh', onClick: loadProfiles },]}/>@@ -107,9 +151,7 @@ export default function ProfilesPage() {profile={p}instance={instanceByProfile.get(p.name)}onLaunch={() => setShowLaunch(p.name)}- onManage={() => {- // TODO: manage modal- }}+ onStop={() => handleStop(p.name)}/>))}</div>@@ -127,7 +169,11 @@ export default function ProfilesPage() {<Button variant="secondary" onClick={() => setShowCreate(false)}>Cancel</Button>- <Button variant="primary" onClick={handleCreate} disabled={!createName.trim()}>+ <Button+ variant="primary"+ onClick={handleCreate}+ disabled={!createName.trim()}+ >Create</Button></>@@ -187,6 +233,26 @@ export default function ProfilesPage() {/>Headless (best for Docker/VPS)</label>++ {/* Command */}+ <div>+ <label className="mb-1 block text-xs text-text-muted">+ Direct launch command (backup)+ </label>+ <textarea+ readOnly+ value={launchCommand}+ className="h-20 w-full resize-none rounded border border-border-subtle bg-bg-elevated px-3 py-2 font-mono text-xs text-text-secondary"+ />+ <div className="mt-2 flex items-center gap-2">+ <Button size="sm" variant="secondary" onClick={handleCopyCommand}>+ Copy Command+ </Button>+ {copyFeedback && (+ <span className="text-xs text-success">{copyFeedback}</span>+ )}+ </div>+ </div></div></Modal></div>diff --git a/dashboard/src/stores/useAppStore.ts b/dashboard/src/stores/useAppStore.tsindex e8750bfe..d0d53416 100644--- a/dashboard/src/stores/useAppStore.ts+++ b/dashboard/src/stores/useAppStore.ts@@ -2,12 +2,18 @@ import { create } from 'zustand'import type {Profile,Instance,+ InstanceTab,Agent,ActivityEvent,Settings,ServerInfo,} from '../generated/types'+export interface TabDataPoint {+ timestamp: number+ [instanceId: string]: number+}+interface AppState {// Profilesprofiles: Profile[]@@ -21,6 +27,12 @@ interface AppState {setInstances: (instances: Instance[]) => voidsetInstancesLoading: (loading: boolean) => void+ // Chart data (persists across navigation)+ tabsChartData: TabDataPoint[]+ currentTabs: Record<string, InstanceTab[]>+ addChartDataPoint: (point: TabDataPoint) => void+ setCurrentTabs: (tabs: Record<string, InstanceTab[]>) => void+// Agentsagents: Agent[]selectedAgentId: string | null@@ -62,6 +74,15 @@ export const useAppStore = create<AppState>((set) => ({setInstances: (instances) => set({ instances }),setInstancesLoading: (instancesLoading) => set({ instancesLoading }),+ // Chart data+ tabsChartData: [],+ currentTabs: {},+ addChartDataPoint: (point) =>+ set((state) => ({+ tabsChartData: [...state.tabsChartData.slice(-59), point], // Keep last 60 points+ })),+ setCurrentTabs: (currentTabs) => set({ currentTabs }),+// Agentsagents: [],selectedAgentId: null,