refactor(01-06): decompose social.tsx and runs.tsx into focused sub-components

- social.tsx (541 lines) -> 5 files: SocialPanel, AccountCard, AddAccountDialog, ActionHistory, social-config
- runs.tsx (506 lines) -> 4 files: RunCenter, RunQueue, RunDetail, run-helpers
- All sub-component files under 300 lines
- Backward-compatible re-export barrels preserve existing App.tsx imports
This commit is contained in:
ZacharyZhang-NY committed 2026-03-22 02:54:02 -04:00
1 parent d77486504d
commit 93e599befd
11 files changed
+1147 -1047

No files matched your search

+104
View File
@@ -0,0 +1,104 @@
import type { AgentRecord, RunRecord, TaskRecord, WorkspaceRecord } from "@shared/types";
import { timeAgo } from "../../lib/formatters";
import { EmptyState, Input, ListFrame, ListRow, Panel, Select, StatusPill } from "../ui";
import type { TranslationFn } from "../../i18n";
interface RunQueueProps {
filteredRuns: RunRecord[];
selectedRun: RunRecord | null;
taskMap: Map<string, TaskRecord>;
agentMap: Map<string, AgentRecord>;
workspaceMap: Map<string, WorkspaceRecord>;
statusFilter: "all" | RunRecord["status"];
setStatusFilter: (value: "all" | RunRecord["status"]) => void;
search: string;
setSearch: (value: string) => void;
onSelectRun: (runId: string) => void;
t: TranslationFn;
}
export function RunQueue({
filteredRuns,
selectedRun,
taskMap,
agentMap,
workspaceMap,
statusFilter,
setStatusFilter,
search,
setSearch,
onSelectRun,
t,
}: RunQueueProps) {
return (
<div className="space-y-5">
<Panel
title={t("runs.runQueue")}
action={(
<Select
compact
value={statusFilter}
onChange={(value) => setStatusFilter(value as "all" | RunRecord["status"])}
options={[
{ value: "all", label: "All" },
{ value: "queued", label: "Queued" },
{ value: "running", label: "Running" },
{ value: "succeeded", label: "Succeeded" },
{ value: "failed", label: "Failed" },
{ value: "timed_out", label: "Timed out" },
{ value: "cancelled", label: "Cancelled" },
{ value: "interrupted", label: "Interrupted" },
]}
/>
)}
>
<div className="mb-4">
<Input
ariaLabel="Search runs"
value={search}
onChange={setSearch}
placeholder={t("runs.searchRuns")}
/>
</div>
<ListFrame>
{filteredRuns.map((run) => {
const task = taskMap.get(run.taskId);
const agent = agentMap.get(run.agentId);
const workspace = run.workspaceId ? workspaceMap.get(run.workspaceId) : null;
const title = task?.title ?? (run.summary || `Run ${run.id.slice(0, 8)}`);
const supportingText = run.errorMessage || run.summary || "No summary yet";
return (
<ListRow
key={run.id}
onClick={() => onSelectRun(run.id)}
className={selectedRun?.id === run.id ? "bg-[color:var(--accent-soft)]" : "hover:bg-[color:var(--panel-soft)]"}
>
<div className="space-y-1.5">
<div className="flex items-center justify-between gap-3">
<div className="min-w-0">
<div className="truncate text-[13px] font-semibold text-[color:var(--text)]">{title}</div>
<div className="mt-0.5 truncate text-[11px] text-[color:var(--muted)]">
{agent?.name ?? "Unknown agent"} via {run.connectorId} {workspace ? `\u00B7 ${workspace.name}` : ""}
</div>
</div>
<StatusPill status={run.status} />
</div>
<div className="flex items-center justify-between gap-3 text-[11px] text-[color:var(--muted)]">
<span className="truncate">{supportingText}</span>
<span className="shrink-0">{timeAgo(run.updatedAt)}</span>
</div>
</div>
</ListRow>
);
})}
</ListFrame>
{filteredRuns.length === 0 ? (
<EmptyState
title={t("runs.noRunsMatch")}
detail={t("runs.noRunsMatchDetail")}
/>
) : null}
</Panel>
</div>
);
}