import { ArrowSquareOut } from "@phosphor-icons/react" import type { AgentRecord, DocumentRecord, ProjectRecord, RunRecord, TaskRecord, WorkspaceRecord } from "@shared/types" import { useT } from "../../i18n" import { formatTime } from "../../lib/formatters" import { ActionButton, EmptyState, StatusPill } from "../ui" import { PriorityDot, WorkspaceStatePill } from "./execution-utils" export function WorkspaceInspector({ workspace, agents, tasks, runs, documents, project, onOpen }: { workspace: WorkspaceRecord | null; agents: AgentRecord[]; tasks: TaskRecord[]; runs: RunRecord[]; documents: DocumentRecord[]; project: ProjectRecord | null; onOpen: (path: string) => Promise }) { const t = useT() if (!workspace) return const wAgents = agents.filter((a) => a.workspaceId === workspace.id); const wTasks = tasks.filter((tk) => tk.workspaceId === workspace.id) const wRuns = runs.filter((r) => r.workspaceId === workspace.id); const wDocs = documents.filter((d) => d.projectId && project && d.projectId === project.id) return (
{workspace.name}
{workspace.localPath}
{project ? <>Project: {project.name} : "No linked project"}{workspace.repoUrl ? · Repo: {workspace.repoUrl} : null}{workspace.repoRef ? · Ref: {workspace.repoRef} : null}
void onOpen(workspace.localPath)} icon={ArrowSquareOut} />
{[{ label: t("exec.agents"), val: wAgents.length }, { label: t("exec.tasks"), val: wTasks.length }, { label: t("exec.runs"), val: wRuns.length }, { label: t("exec.docs"), val: wDocs.length }].map((s) => (
{s.label}
{s.val}
))}
{t("exec.assignedAgents")}
{wAgents.length === 0 ?
{t("exec.noAgentsBound")}
:
{wAgents.map((a) =>
{a.name}
{a.role}
)}
}
{t("exec.openTasks")}
{wTasks.length === 0 ?
{t("exec.noTasksTarget")}
:
{wTasks.slice(0, 6).map((tk) =>
{tk.title}
{tk.status.replaceAll("_"," ")}
)}
}
{t("exec.recentRuns")}
{wRuns.length === 0 ?
{t("exec.noRunsExecuted")}
:
{wRuns.slice(0, 6).map((r) =>
{r.summary || `Run ${r.id.slice(0, 8)}`}
{formatTime(r.startedAt)} → {formatTime(r.finishedAt)}
)}
}
) }