Skip to content

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

feat: add ProfileDetailsModal with 3 tabs (Profile/Live/Logs)

Bosch884f48407d9b
diff --git a/dashboard/src/components/molecules/ProfileDetailsModal.tsx b/dashboard/src/components/molecules/ProfileDetailsModal.tsx
new file mode 100644
index 00000000..1ae0e9a7
--- /dev/null
+++ b/dashboard/src/components/molecules/ProfileDetailsModal.tsx
@@ -0,0 +1,298 @@
+import { useState, useEffect, useCallback } from 'react'
+import { Modal, Button, Input } from '../atoms'
+import type { Profile, Instance, InstanceTab, Agent } from '../../generated/types'
+import * as api from '../../services/api'
+
+interface Props {
+ profile: Profile | null
+ instance?: Instance
+ onClose: () => void
+ onSave?: (name: string, useWhen: string) => void
+ onDelete?: () => void
+}
+
+type TabId = 'profile' | 'live' | 'logs'
+
+function InfoRow({ label, value }: { label: string; value: string }) {
+ return (
+ <div className="flex justify-between py-1 text-sm">
+ <span className="text-text-muted">{label}</span>
+ <span className="text-text-primary">{value}</span>
+ </div>
+ )
+}
+
+export default function ProfileDetailsModal({
+ profile,
+ instance,
+ onClose,
+ onSave,
+ onDelete,
+}: Props) {
+ const [activeTab, setActiveTab] = useState<TabId>('profile')
+ const [name, setName] = useState('')
+ const [useWhen, setUseWhen] = useState('')
+ const [tabs, setTabs] = useState<InstanceTab[]>([])
+ const [agents, setAgents] = useState<Agent[]>([])
+ const [logs] = useState('') // TODO: fetch from /instances/{id}/logs
+ const [copyFeedback, setCopyFeedback] = useState('')
+
+ const isRunning = instance?.status === 'running'
+
+ // Initialize form values
+ useEffect(() => {
+ if (profile) {
+ setName(profile.name)
+ setUseWhen(profile.useWhen || '')
+ }
+ }, [profile])
+
+ // Load live data when switching to live/logs tab
+ const loadLiveData = useCallback(async () => {
+ if (!instance?.id) return
+
+ try {
+ const [tabsData, agentsData] = await Promise.all([
+ api.fetchInstanceTabs(instance.id).catch(() => []),
+ api.fetchAgents().catch(() => []),
+ ])
+ setTabs(Array.isArray(tabsData) ? tabsData : [])
+ setAgents(agentsData.filter((a) => a.name === profile?.name))
+ } catch (e) {
+ console.error('Failed to load live data', e)
+ }
+ }, [instance?.id, profile?.name])
+
+ useEffect(() => {
+ if (activeTab === 'live' || activeTab === 'logs') {
+ loadLiveData()
+ }
+ }, [activeTab, loadLiveData])
+
+ const handleCopyId = async () => {
+ if (!profile?.id) return
+ try {
+ await navigator.clipboard.writeText(profile.id)
+ setCopyFeedback('Copied!')
+ setTimeout(() => setCopyFeedback(''), 2000)
+ } catch {
+ setCopyFeedback('Failed')
+ setTimeout(() => setCopyFeedback(''), 2000)
+ }
+ }
+
+ const handleSave = () => {
+ onSave?.(name, useWhen)
+ }
+
+ if (!profile) return null
+
+ const tabClasses = (id: TabId) =>
+ `flex-1 py-2 text-sm font-medium border-b-2 transition-colors ${
+ activeTab === id
+ ? 'border-primary text-text-primary'
+ : 'border-transparent text-text-muted hover:text-text-secondary'
+ }`
+
+ return (
+ <Modal open={!!profile} onClose={onClose} title={profile.name} wide>
+ {/* Tabs */}
+ <div className="-mx-4 -mt-2 mb-4 flex border-b border-border-subtle px-4">
+ <button className={tabClasses('profile')} onClick={() => setActiveTab('profile')}>
+ Profile
+ </button>
+ <button className={tabClasses('live')} onClick={() => setActiveTab('live')}>
+ Live
+ </button>
+ <button className={tabClasses('logs')} onClick={() => setActiveTab('logs')}>
+ Logs
+ </button>
+ </div>
+
+ {/* Tab Content */}
+ <div className="min-h-[400px]">
+ {activeTab === 'profile' && (
+ <div className="flex flex-col gap-4">
+ {/* Profile ID */}
+ <div>
+ <label className="mb-1 block text-xs text-text-muted">Profile ID</label>
+ <div className="flex gap-2">
+ <input
+ readOnly
+ value={profile.id || '—'}
+ className="flex-1 rounded border border-border-subtle bg-bg-elevated px-3 py-2 font-mono text-xs text-text-secondary"
+ />
+ <Button size="sm" variant="secondary" onClick={handleCopyId}>
+ {copyFeedback || 'Copy'}
+ </Button>
+ </div>
+ </div>
+
+ {/* Name */}
+ <Input
+ label="Name"
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ />
+
+ {/* Use When */}
+ <div>
+ <label className="mb-1 block text-xs text-text-muted">
+ Use this profile when
+ </label>
+ <textarea
+ value={useWhen}
+ onChange={(e) => setUseWhen(e.target.value)}
+ className="min-h-[80px] w-full resize-y rounded border border-border-subtle bg-bg-elevated px-3 py-2 text-sm text-text-primary"
+ />
+ </div>
+
+ {/* Status */}
+ <div className="rounded border border-border-subtle bg-bg-elevated p-3">
+ <h4 className="mb-2 text-xs font-semibold uppercase tracking-wide text-text-muted">
+ Status
+ </h4>
+ <div className="space-y-1">
+ <InfoRow label="State" value={instance?.status || 'stopped'} />
+ <InfoRow label="Port" value={instance?.port || '—'} />
+ <InfoRow label="Size" value={profile.sizeMB ? `${profile.sizeMB.toFixed(0)} MB` : '—'} />
+ <InfoRow label="Source" value={profile.source || '—'} />
+ {profile.chromeProfileName && (
+ <InfoRow label="Chrome" value={profile.chromeProfileName} />
+ )}
+ {(profile.accountEmail || profile.accountName) && (
+ <InfoRow label="Account" value={profile.accountEmail || profile.accountName || ''} />
+ )}
+ </div>
+ </div>
+
+ {/* Path */}
+ {profile.path && (
+ <div className="rounded border border-border-subtle bg-bg-elevated p-3">
+ <h4 className="mb-1 text-xs font-semibold uppercase tracking-wide text-text-muted">
+ Path
+ </h4>
+ <code className={`text-xs ${profile.pathExists ? 'text-text-secondary' : 'text-destructive'}`}>
+ {profile.path}
+ {!profile.pathExists && ' (not found)'}
+ </code>
+ </div>
+ )}
+ </div>
+ )}
+
+ {activeTab === 'live' && (
+ <div>
+ {isRunning ? (
+ <div>
+ <div className="mb-3 flex items-center justify-between">
+ <span className="text-sm text-text-muted">{tabs.length} tab(s)</span>
+ <Button size="sm" variant="secondary" onClick={loadLiveData}>
+ Refresh
+ </Button>
+ </div>
+ {tabs.length === 0 ? (
+ <div className="flex h-[300px] items-center justify-center text-sm text-text-muted">
+ No tabs open
+ </div>
+ ) : (
+ <div className="grid gap-3 sm:grid-cols-2">
+ {tabs.map((tab) => (
+ <div
+ key={tab.id}
+ className="rounded border border-border-subtle bg-bg-elevated p-3"
+ >
+ <div className="truncate text-sm font-medium text-text-primary">
+ {tab.title || 'Untitled'}
+ </div>
+ <div className="truncate text-xs text-text-muted">{tab.url}</div>
+ </div>
+ ))}
+ </div>
+ )}
+ </div>
+ ) : (
+ <div className="flex h-[300px] items-center justify-center text-sm text-text-muted">
+ Instance not running. Launch the profile to see live view.
+ </div>
+ )}
+ </div>
+ )}
+
+ {activeTab === 'logs' && (
+ <div className="space-y-4">
+ {/* Tabs */}
+ <div>
+ <h4 className="mb-2 text-xs font-semibold uppercase tracking-wide text-text-muted">
+ Tabs ({tabs.length})
+ </h4>
+ {tabs.length === 0 ? (
+ <p className="text-sm text-text-muted">
+ {isRunning ? 'No tabs open.' : 'Instance not running.'}
+ </p>
+ ) : (
+ <div className="space-y-1">
+ {tabs.map((tab) => (
+ <div key={tab.id} className="border-b border-border-subtle py-2">
+ <div className="truncate text-sm text-text-primary">
+ {tab.title || 'Untitled'}
+ </div>
+ <div className="truncate text-xs text-text-muted">{tab.url}</div>
+ </div>
+ ))}
+ </div>
+ )}
+ </div>
+
+ {/* Agents */}
+ <div>
+ <h4 className="mb-2 text-xs font-semibold uppercase tracking-wide text-text-muted">
+ Agents ({agents.length})
+ </h4>
+ {agents.length === 0 ? (
+ <p className="text-sm text-text-muted">No agents connected.</p>
+ ) : (
+ <div className="space-y-1">
+ {agents.map((agent) => (
+ <div key={agent.id} className="text-sm text-text-secondary">
+ {agent.id}
+ </div>
+ ))}
+ </div>
+ )}
+ </div>
+
+ {/* Logs placeholder */}
+ <div>
+ <h4 className="mb-2 text-xs font-semibold uppercase tracking-wide text-text-muted">
+ Logs
+ </h4>
+ {logs ? (
+ <pre className="max-h-[200px] overflow-auto rounded bg-bg-elevated p-3 font-mono text-xs text-text-secondary">
+ {logs}
+ </pre>
+ ) : (
+ <p className="text-sm text-text-muted">No instance logs available.</p>
+ )}
+ </div>
+ </div>
+ )}
+ </div>
+
+ {/* Footer */}
+ <div className="-mx-4 -mb-4 mt-4 flex items-center justify-between border-t border-border-subtle px-4 pt-4">
+ <Button variant="danger" onClick={onDelete}>
+ Delete
+ </Button>
+ <div className="flex gap-2">
+ <Button variant="primary" onClick={handleSave}>
+ Save
+ </Button>
+ <Button variant="secondary" onClick={onClose}>
+ Close
+ </Button>
+ </div>
+ </div>
+ </Modal>
+ )
+}
diff --git a/dashboard/src/components/molecules/index.ts b/dashboard/src/components/molecules/index.ts
index e280953a..29dc0a0f 100644
--- a/dashboard/src/components/molecules/index.ts
+++ b/dashboard/src/components/molecules/index.ts
@@ -1,5 +1,6 @@
export { default as NavBar } from './NavBar'
export { default as ProfileCard } from './ProfileCard'
+export { default as ProfileDetailsModal } from './ProfileDetailsModal'
export { default as InstanceCard } from './InstanceCard'
export { default as AgentItem } from './AgentItem'
export { default as ActivityLine } from './ActivityLine'
diff --git a/dashboard/src/pages/ProfilesPage.tsx b/dashboard/src/pages/ProfilesPage.tsx
index 896cfaa2..7df59daf 100644
--- a/dashboard/src/pages/ProfilesPage.tsx
+++ b/dashboard/src/pages/ProfilesPage.tsx
@@ -1,8 +1,9 @@
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 { ProfileCard, ProfileDetailsModal } from '../components/molecules'
import * as api from '../services/api'
+import type { Profile } from '../generated/types'
export default function ProfilesPage() {
const {
@@ -15,6 +16,7 @@ export default function ProfilesPage() {
} = useAppStore()
const [showCreate, setShowCreate] = useState(false)
const [showLaunch, setShowLaunch] = useState<string | null>(null)
+ const [showDetails, setShowDetails] = useState<Profile | null>(null)
// Create form
const [createName, setCreateName] = useState('')
@@ -83,7 +85,6 @@ export default function ProfilesPage() {
if (!inst) return
try {
await api.stopInstance(inst.id)
- // Refresh instances
const updated = await api.fetchInstances()
setInstances(updated)
} catch (e) {
@@ -91,6 +92,17 @@ export default function ProfilesPage() {
}
}
+ const handleDelete = async () => {
+ if (!showDetails?.id) return
+ try {
+ await api.deleteProfile(showDetails.id)
+ setShowDetails(null)
+ loadProfiles()
+ } catch (e) {
+ console.error('Failed to delete profile', e)
+ }
+ }
+
// Generate launch command
const launchCommand = useMemo(() => {
if (!showLaunch) return ''
@@ -152,6 +164,7 @@ export default function ProfilesPage() {
instance={instanceByProfile.get(p.name)}
onLaunch={() => setShowLaunch(p.name)}
onStop={() => handleStop(p.name)}
+ onDetails={() => setShowDetails(p)}
/>
))}
</div>
@@ -255,6 +268,14 @@ export default function ProfilesPage() {
</div>
</div>
</Modal>
+
+ {/* Profile Details Modal */}
+ <ProfileDetailsModal
+ profile={showDetails}
+ instance={showDetails ? instanceByProfile.get(showDetails.name) : undefined}
+ onClose={() => setShowDetails(null)}
+ onDelete={handleDelete}
+ />
</div>
)
}