Skip to content

An open-source, faster Devin alternative

TypeScript

Add mission-control panels to the run board: stat strip, findings feed, dispatch

Mohamed Habib via Computerb783698b60d2
diff --git a/web/src/managed-agents/security/ProjectSwarm.tsx b/web/src/managed-agents/security/ProjectSwarm.tsx
index 8b510993..946abf0f 100644
--- a/web/src/managed-agents/security/ProjectSwarm.tsx
+++ b/web/src/managed-agents/security/ProjectSwarm.tsx
@@ -21,6 +21,7 @@ import {
} from './catalog'
import { RunReportCard, SwarmGrid } from './SwarmGrid'
import { SwarmMap } from './SwarmMap'
+import { CellDispatchPanel, FindingsPanel, StatBar } from './SwarmPanels'
import {
statesFromReport,
useSwarmRun,
@@ -226,9 +227,15 @@ function RunBody({
</div>
</div>
+ <StatBar states={states} counts={counts} />
+
{view === 'map' ? (
<div className="space-y-4">
<SwarmMap states={states} counts={counts} settled={settled} />
+ <div className="grid gap-4 lg:grid-cols-2">
+ <FindingsPanel states={states} projectId={projectId} />
+ <CellDispatchPanel states={states} projectId={projectId} />
+ </div>
{report ? (
<RunReportCard report={report} projectId={projectId} />
) : null}
diff --git a/web/src/managed-agents/security/SwarmMap.tsx b/web/src/managed-agents/security/SwarmMap.tsx
index efee818c..ee47d9e6 100644
--- a/web/src/managed-agents/security/SwarmMap.tsx
+++ b/web/src/managed-agents/security/SwarmMap.tsx
@@ -1,4 +1,5 @@
import { useEffect, useMemo, useRef } from 'react'
+import { PALETTE } from './palette'
import { cellPhase, type CellState, type SwarmCounts } from './useSwarmRun'
// The mission-control view of a run: a coordinator dispatches to a fan of cells,
@@ -7,18 +8,6 @@ import { cellPhase, type CellState, type SwarmCounts } from './useSwarmRun'
// a live map. Everything animated here (pulses, particles) is cosmetic; every
// position and color is derived from the actual cell states.
-const PALETTE = {
- bg: '#07080a',
- ink: '#8b9199',
- text: '#e8eaed',
- orange: '#ff7a18',
- red: '#ff4d4d',
- amber: '#f5b942',
- green: '#4ade80',
- grey: '#5b6066',
- purple: '#c084fc',
-} as const
-
type CellColor = keyof typeof PALETTE
// A cell's color is its phase, and for a settled cell its disposition. Running
diff --git a/web/src/managed-agents/security/SwarmPanels.tsx b/web/src/managed-agents/security/SwarmPanels.tsx
new file mode 100644
index 00000000..3ddc2c29
--- /dev/null
+++ b/web/src/managed-agents/security/SwarmPanels.tsx
@@ -0,0 +1,222 @@
+import { Link } from 'react-router-dom'
+import { PALETTE } from './palette'
+import { cellPhase, type CellState, type SwarmCounts } from './useSwarmRun'
+
+// The mission-control panels that sit under the map: a metric strip, a findings
+// feed, and the per-cell dispatch list. Everything here is derived from the cell
+// states the page already polls — no extra fetching — and drawn in the map's
+// dark terminal palette so the whole run reads as one board.
+
+// A cell's status word + color, shared by the feed and the dispatch list.
+function cellStatus(state: CellState): { label: string; color: string } {
+ const phase = cellPhase(state)
+ if (phase === 'running') return { label: 'running', color: PALETTE.orange }
+ if (phase === 'queued') return { label: 'queued', color: PALETTE.grey }
+ if (phase === 'failed') return { label: 'failed', color: PALETTE.red }
+ const d = state.finding?.disposition
+ if (d === 'exposed') return { label: 'exposed', color: PALETTE.red }
+ if (d === 'needs-review') return { label: 'review', color: PALETTE.amber }
+ return { label: 'ok', color: PALETTE.green }
+}
+
+function Panel({
+ title,
+ children,
+}: {
+ title: string
+ children: React.ReactNode
+}) {
+ return (
+ <div
+ className="flex flex-col overflow-hidden rounded-lg border border-white/10"
+ style={{ background: PALETTE.bg }}
+ >
+ <div
+ className="border-b border-white/10 px-4 py-2 font-mono text-[11px] font-bold tracking-wider"
+ style={{ color: PALETTE.orange }}
+ >
+ {title}
+ </div>
+ <div className="min-h-0 flex-1">{children}</div>
+ </div>
+ )
+}
+
+// The top metric strip: the run's numbers at a glance, each in its verdict color.
+export function StatBar({
+ states,
+ counts,
+}: {
+ states: CellState[]
+ counts: SwarmCounts
+}) {
+ const fixPrs = states.filter((s) => s.finding?.pullRequest).length
+ const items: { label: string; value: number; color: string }[] = [
+ { label: 'CELLS', value: states.length, color: PALETTE.text },
+ { label: 'LIVE', value: counts.pending, color: PALETTE.orange },
+ { label: 'EXPOSED', value: counts.exposed, color: PALETTE.red },
+ { label: 'NOT EXP', value: counts['not-exposed'], color: PALETTE.green },
+ { label: 'REVIEW', value: counts['needs-review'], color: PALETTE.amber },
+ { label: 'FAILED', value: counts.failed, color: PALETTE.grey },
+ { label: 'FIX PRs', value: fixPrs, color: PALETTE.purple },
+ ]
+ return (
+ <div
+ className="flex flex-wrap gap-x-8 gap-y-3 rounded-lg border border-white/10 px-4 py-3"
+ style={{ background: PALETTE.bg }}
+ >
+ {items.map((it) => (
+ <div key={it.label} className="font-mono">
+ <div className="text-[10px] tracking-wider" style={{ color: PALETTE.ink }}>
+ {it.label}
+ </div>
+ <div className="text-xl font-bold" style={{ color: it.color }}>
+ {it.value}
+ </div>
+ </div>
+ ))}
+ </div>
+ )
+}
+
+// The findings feed: the reportable cells — exposed, needs-review, or carrying a
+// fix PR — ranked most-actionable first. No timestamps, because a finding
+// document doesn't carry one; this is the ranked list, not a time-ordered log.
+export function FindingsPanel({
+ states,
+ projectId,
+}: {
+ states: CellState[]
+ projectId: string
+}) {
+ const rank: Record<string, number> = { exposed: 0, 'needs-review': 1 }
+ const reportable = states
+ .filter(
+ (s) =>
+ s.finding &&
+ (s.finding.disposition === 'exposed' ||
+ s.finding.disposition === 'needs-review' ||
+ Boolean(s.finding.pullRequest)),
+ )
+ .sort(
+ (a, b) =>
+ (rank[a.finding?.disposition ?? ''] ?? 2) -
+ (rank[b.finding?.disposition ?? ''] ?? 2),
+ )
+ return (
+ <Panel title="FINDINGS FEED">
+ {reportable.length === 0 ? (
+ <p
+ className="px-4 py-6 font-mono text-xs"
+ style={{ color: PALETTE.ink }}
+ >
+ No findings yet.
+ </p>
+ ) : (
+ <ul className="max-h-80 divide-y divide-white/5 overflow-y-auto">
+ {reportable.map((s) => {
+ const status = cellStatus(s)
+ return (
+ <li
+ key={`${s.cell.repository}__${s.cell.cveId}`}
+ className="px-4 py-2.5 font-mono text-xs"
+ >
+ <div className="flex items-center justify-between gap-2">
+ <span
+ className="font-bold uppercase tracking-wide"
+ style={{ color: status.color }}
+ >
+ {status.label}
+ </span>
+ {s.finding?.pullRequest ? (
+ <a
+ href={s.finding.pullRequest}
+ target="_blank"
+ rel="noreferrer"
+ className="hover:underline"
+ style={{ color: PALETTE.purple }}
+ >
+ fix PR
+ </a>
+ ) : null}
+ </div>
+ <div className="mt-1" style={{ color: PALETTE.text }}>
+ {s.cell.cveId}{' '}
+ <span style={{ color: PALETTE.ink }}>· {s.cell.repository}</span>
+ </div>
+ {s.sessionId ? (
+ <Link
+ to={`/projects/${encodeURIComponent(projectId)}/sessions/${encodeURIComponent(s.sessionId)}`}
+ className="mt-1 inline-block hover:underline"
+ style={{ color: PALETTE.ink }}
+ >
+ open session →
+ </Link>
+ ) : null}
+ </li>
+ )
+ })}
+ </ul>
+ )}
+ </Panel>
+ )
+}
+
+// The dispatch list: every cell and its live status, running ones first. This is
+// the "who is doing what" column of the board.
+export function CellDispatchPanel({
+ states,
+ projectId,
+}: {
+ states: CellState[]
+ projectId: string
+}) {
+ const order: Record<string, number> = {
+ running: 0,
+ queued: 1,
+ exposed: 2,
+ review: 3,
+ failed: 4,
+ ok: 5,
+ }
+ const rows = states
+ .map((s, i) => ({ s, i, status: cellStatus(s) }))
+ .sort((a, b) => (order[a.status.label] ?? 9) - (order[b.status.label] ?? 9))
+ return (
+ <Panel title="CELL DISPATCH">
+ <ul className="max-h-80 divide-y divide-white/5 overflow-y-auto">
+ {rows.map(({ s, i, status }) => {
+ const label = `cell-${String(i + 1).padStart(2, '0')}`
+ const inner = (
+ <div className="flex items-center gap-3 px-4 py-2 font-mono text-xs">
+ <span style={{ color: PALETTE.ink }}>{label}</span>
+ <span className="min-w-0 flex-1 truncate" style={{ color: PALETTE.text }}>
+ {s.cell.repository}
+ </span>
+ <span
+ className="shrink-0 font-bold uppercase tracking-wide"
+ style={{ color: status.color }}
+ >
+ {status.label}
+ </span>
+ </div>
+ )
+ return (
+ <li key={`${s.cell.repository}__${s.cell.cveId}`}>
+ {s.sessionId ? (
+ <Link
+ to={`/projects/${encodeURIComponent(projectId)}/sessions/${encodeURIComponent(s.sessionId)}`}
+ className="block hover:bg-white/5"
+ >
+ {inner}
+ </Link>
+ ) : (
+ inner
+ )}
+ </li>
+ )
+ })}
+ </ul>
+ </Panel>
+ )
+}
diff --git a/web/src/managed-agents/security/palette.ts b/web/src/managed-agents/security/palette.ts
new file mode 100644
index 00000000..34ca842f
--- /dev/null
+++ b/web/src/managed-agents/security/palette.ts
@@ -0,0 +1,13 @@
+// The run board's dark terminal palette, shared by the map canvas and the
+// mission-control panels so a cell is the same color everywhere.
+export const PALETTE = {
+ bg: '#07080a',
+ ink: '#8b9199',
+ text: '#e8eaed',
+ orange: '#ff7a18',
+ red: '#ff4d4d',
+ amber: '#f5b942',
+ green: '#4ade80',
+ grey: '#5b6066',
+ purple: '#c084fc',
+} as const