feat(圆桌): Step3 三产物并行 + 大屏多页模式 + 后台挂起查看恢复流程

后台挂起 Step3:
- engine 总结报告/结果绘制/大屏数据 asyncio.gather 三流并行,故障隔离
- request.state 回归修复(进程内虚拟 request 补 state),恢复后台报告
- ROUNDTABLE_JOB_GATEWAY 默认 inprocess;产物自愈重试(截断/缺失纠偏)
- 大屏后端只产 report-json(dashboardJson),前端按当前主题渲染

结果绘制大屏多页模式(模式二):
- report-template 模板渲染(report-json→大屏HTML),零截断、主题跟随
- 与模式一同款交互(流式+沙箱+可修改);沙箱新窗口打开按钮

最终方案展示:左侧席位栏+总控头像、交付/文件合并、收展动画、内联沙箱

后台挂起查看=恢复实时流程:
- handleLoadDraft 返回 Promise,await hydrate 后订阅 streamJob SSE 跟随
- saveDraftNow 强制存(发起前+查看前各一次)防丢

第二步优化:总控判断串/并行(并行单列可写)、席位上下文+交付模板、
peerDeliveries、失败重试、共识标记、流程图小窗(缩放/拖动/并行批)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@
This commit is contained in:
董宏凯 committed 2026-06-13 10:36:46 +08:00
1 parent a7596001c5
commit d5f319d9cb
51 files changed
+5016 -1186

No files matched your search

@@ -1,19 +1,30 @@
import React, { useCallback, useEffect, useMemo, useState } from "react";
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
import {
CheckCircle,
ChevronDown,
ChevronRight,
ChevronsLeft,
ChevronsRight,
Download,
Eye,
FileText,
Loader2,
RefreshCw,
Sparkles,
Users,
} from "lucide-react";
import { useArtifacts } from "@/components/workspace/artifacts";
import type { BaseStream } from "@langchain/langgraph-sdk/react";
import { ArtifactFileDetail, useArtifacts } from "@/components/workspace/artifacts";
import { ThreadContext } from "@/components/workspace/messages/context";
import { apiFetch } from "@/core/api";
import type { AgentThreadState } from "@/core/threads";
import { cn } from "@/lib/utils";
import { getAvatar } from "@/roundtable-planning/components/Avatars";
import { getAvatarTypeFor } from "@/roundtable-planning/lib/roundtable-constants";
import {
buildArtifactDownloadUrl,
listSessionArtifacts,
@@ -21,7 +32,6 @@ import {
type ThreadIdMap,
} from "@/roundtable-planning/api/multi-agent";
import { ConsensusDocxDownloadButton } from "@/roundtable-planning/components/ConsensusDocxDownloadButton";
import { Step3FileBrowseMode } from "@/roundtable-planning/components/Step3FileBrowseMode";
import { markdownComponents } from "@/roundtable-planning/components/markdown-components";
import {
Step3ReportMode,
@@ -32,7 +42,9 @@ import type {
DraftStep3Snapshot,
DraftStep3SummarySnapshot,
} from "@/roundtable-planning/api/drafts";
import type { ReportIntent } from "@/roundtable-planning/hooks/useStep3Report";
import type { UseStep3DashboardReturn } from "@/roundtable-planning/hooks/useStep3Dashboard";
import type { ReportIntent, UseStep3ReportReturn } from "@/roundtable-planning/hooks/useStep3Report";
import type { UseStep3SummaryReturn } from "@/roundtable-planning/hooks/useStep3Summary";
interface SeatDelivery {
/** Display name of the seat (e.g. "情报收集"). */
@@ -72,6 +84,10 @@ interface HighFidelityReportProps {
savedSummary?: DraftStep3SummarySnapshot | null;
/** 一次总结完成时回调,把结果交给上层存进草稿 step3.summaryReport。 */
onSummarySaved?: (snapshot: DraftStep3SummarySnapshot) => void;
/** 页面层常驻的三个 Step3 生成流(切走不断流,进入续看)。 */
summaryFlow: UseStep3SummaryReturn;
reportFlow: UseStep3ReportReturn;
dashboardFlow: UseStep3DashboardReturn;
/** Resets state and navigates back to Step 1. */
onReset: () => void;
openArtifactPreview: (threadId: string, path: string) => void;
@@ -116,6 +132,9 @@ export const HighFidelityReport: React.FC<HighFidelityReportProps> = ({
coordinatorPrompt,
savedSummary,
onSummarySaved,
summaryFlow,
reportFlow,
dashboardFlow,
onReset,
openArtifactPreview,
seatStubMessages,
@@ -132,7 +151,9 @@ export const HighFidelityReport: React.FC<HighFidelityReportProps> = ({
// 用户点「最终方案展示」切到静态页(summaryMode=false),再从静态页可进「结果绘制」HTML。
const [summaryMode, setSummaryMode] = useState(true);
const [drawMode, setDrawMode] = useState(false);
const [fileSandboxMode, setFileSandboxMode] = useState(false);
// 文件沙箱(2026-06-13 改内联):点文件卡片在右侧滑入沙箱面板、左侧席位栏收起
// (不再整页切走)。target 在关闭后保留,供退出过渡动画期间继续渲染。
const [fileSandboxOpen, setFileSandboxOpen] = useState(false);
const [fileSandboxTarget, setFileSandboxTarget] = useState<{
threadId: string;
file: SessionArtifactFile;
@@ -225,17 +246,77 @@ export const HighFidelityReport: React.FC<HighFidelityReportProps> = ({
};
}, [seatThreadEntries, reloadKey]);
const totalFileCount = useMemo(
() => artifactsBySeat.reduce((sum, s) => sum + s.files.length, 0),
[artifactsBySeat],
);
// ── 统一席位总览(2026-06-13 大改):交付内容 + 该席位生成的报告文件合并到一起 ──
// 以「有线程的席位」为主(带文件清单),无线程时回退到交付列表;key = displayName。
const seatOverviews = useMemo(() => {
const avatarByDisplay = new Map<string, string>();
for (const d of seatDeliveries) {
if (!avatarByDisplay.has(d.sender)) avatarByDisplay.set(d.sender, d.avatarType);
}
type Overview = {
key: string;
displayName: string;
avatarType: string;
delivery: string | null;
threadId: string | null;
files: SessionArtifactFile[];
loading: boolean;
error: string | null;
};
const out: Overview[] = [];
const seen = new Set<string>();
artifactsBySeat.forEach((s, i) => {
seen.add(s.displayName);
out.push({
key: s.displayName,
displayName: s.displayName,
avatarType:
avatarByDisplay.get(s.displayName) ?? getAvatarTypeFor(s.agentName, i),
delivery: deliveryByDisplay.get(s.displayName) ?? null,
threadId: s.threadId,
files: s.files,
loading: s.loading,
error: s.error,
});
});
// 没有线程映射(恢复的旧草稿等)时,纯交付席位也要出现在列表里。
seatDeliveries.forEach((d, i) => {
if (seen.has(d.sender)) return;
seen.add(d.sender);
out.push({
key: d.sender,
displayName: d.sender,
avatarType: d.avatarType || getAvatarTypeFor(d.sender, i),
delivery: d.content,
threadId: null,
files: [],
loading: false,
error: null,
});
});
return out;
}, [artifactsBySeat, seatDeliveries, deliveryByDisplay]);
// 只保留「有产出文件」的席位;加载中 / 出错的席位仍保留以展示其状态。
// 全部席位都没有文件(且都已加载完成、无错误)时,整块「生成的报告文件」隐藏。
const seatsWithFiles = useMemo(
() => artifactsBySeat.filter((s) => s.loading || s.error || s.files.length > 0),
[artifactsBySeat],
);
// 左侧席位栏(像第二步的参与角色栏):可收起成头像列;点卡片/头像 → 展开右侧
// 对应区块并平滑滚动过去(短暂高亮提示落点)。
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
const [focusedSeat, setFocusedSeat] = useState<string | null>(null);
const seatSectionRefs = useRef<Map<string, HTMLElement>>(new Map());
// 总控最终结论:支持展开/收起(默认展开);左侧总控头像点击 → 展开并滚动到这里。
const CONSENSUS_KEY = "__consensus__";
const [consensusExpanded, setConsensusExpanded] = useState(true);
const consensusSectionRef = useRef<HTMLElement | null>(null);
const focusConsensus = useCallback(() => {
setConsensusExpanded(true);
setFocusedSeat(CONSENSUS_KEY);
requestAnimationFrame(() => {
requestAnimationFrame(() => {
consensusSectionRef.current?.scrollIntoView({ behavior: "smooth", block: "start" });
});
});
window.setTimeout(() => setFocusedSeat((cur) => (cur === CONSENSUS_KEY ? null : cur)), 1800);
}, []);
const toggleSeat = useCallback((key: string) => {
setExpandedSeats((prev) => {
@@ -246,16 +327,94 @@ export const HighFidelityReport: React.FC<HighFidelityReportProps> = ({
});
}, []);
const handleViewInSandbox = useCallback((threadId: string, file: SessionArtifactFile) => {
setFileSandboxTarget({ threadId, file });
setFileSandboxMode(true);
const focusSeat = useCallback((key: string) => {
setExpandedSeats((prev) => new Set(prev).add(key));
setFocusedSeat(key);
// 等展开渲染完成后再滚动,落点更准。
requestAnimationFrame(() => {
requestAnimationFrame(() => {
seatSectionRefs.current
.get(key)
?.scrollIntoView({ behavior: "smooth", block: "start" });
});
});
window.setTimeout(
() => setFocusedSeat((cur) => (cur === key ? null : cur)),
1800,
);
}, []);
const handleBackFromFileSandbox = useCallback(() => {
setFileSandboxMode(false);
setFileSandboxTarget(null);
deselectArtifact();
}, [deselectArtifact]);
// 文本类扩展名 → 拉文本走虚拟 stub 预览;其余(图片/PDF 等二进制)直接 iframe。
const TEXT_FILE_RE = /\.(md|markdown|html?|txt|csv|json|js|ts|tsx|py|xml|yml|yaml|log|mmd|css)$/i;
const [fileSandboxContent, setFileSandboxContent] = useState<string | null>(null);
const [fileSandboxIsText, setFileSandboxIsText] = useState(true);
const fileFetchSeqRef = useRef(0);
// 点文件卡片:右侧滑入内联沙箱 + 左侧席位栏收起(不消失),页面不切走。
// 内容**不走** threads artifacts hook(这些圆桌线程在那条路由上 404,曾表现为
// 预览区只显示 {"detail":"Not Found"})——改用与「下载」同源、已验证可用的
// buildArtifactDownloadUrl 自取文本,再以 write_file 虚拟 stub 喂给预览组件。
const handleViewInSandbox = useCallback((threadId: string, file: SessionArtifactFile) => {
setFileSandboxTarget({ threadId, file });
setFileSandboxOpen(true);
setSidebarCollapsed(true);
const isText = TEXT_FILE_RE.test(file.name);
setFileSandboxIsText(isText);
setFileSandboxContent(null);
if (!isText) return; // 二进制走 iframe(src 即下载路由),无需取文本
const seq = ++fileFetchSeqRef.current;
void apiFetch(buildArtifactDownloadUrl(threadId, file.path))
.then(async (res) => {
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const text = await res.text();
if (fileFetchSeqRef.current === seq) setFileSandboxContent(text);
})
.catch((err) => {
if (fileFetchSeqRef.current === seq) {
setFileSandboxContent(`> 读取文件失败:${(err as Error).message}`);
}
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const handleCloseFileSandbox = useCallback(() => {
setFileSandboxOpen(false); // target 保留到过渡结束,面板滑出更顺
}, []);
// 虚拟 stub(write-file URL → 预览组件直接读 tool_call.args.content,零 HTTP)。
const fileSandboxStubPath = fileSandboxTarget
? fileSandboxTarget.file.path.startsWith("/")
? fileSandboxTarget.file.path
: `/${fileSandboxTarget.file.path}`
: "";
const fileSandboxVirtualUrl = fileSandboxTarget
? `write-file:${fileSandboxStubPath}?message_id=hfr-file-stub&tool_call_id=tc-hfr-0`
: "";
const fileSandboxThreadStub = useMemo(() => {
const messages =
fileSandboxTarget && fileSandboxContent != null
? [
{
id: "hfr-file-stub",
type: "ai",
content: "",
tool_calls: [
{
id: "tc-hfr-0",
name: "write_file",
args: { path: fileSandboxStubPath, content: fileSandboxContent },
},
],
},
]
: [];
return {
messages,
isLoading: false,
isThreadLoading: false,
values: { title: "", messages, artifacts: [] },
} as unknown as BaseStream<AgentThreadState>;
}, [fileSandboxTarget, fileSandboxContent, fileSandboxStubPath]);
const handleDownload = useCallback(
(threadId: string, file: SessionArtifactFile) => {
@@ -283,28 +442,12 @@ export const HighFidelityReport: React.FC<HighFidelityReportProps> = ({
setSelectedModel={setSelectedModel}
coordinatorPrompt={coordinatorPrompt}
savedSummary={savedSummary}
onSummarySaved={onSummarySaved}
summary={summaryFlow}
onViewStatic={() => setSummaryMode(false)}
/>
);
}
if (fileSandboxMode && fileSandboxTarget) {
return (
<Step3FileBrowseMode
consensusText={consensusText}
hasConsensus={hasConsensus}
consensusDocTitle={consensusDocTitle}
seatDeliveries={seatDeliveries}
artifactsBySeat={artifactsBySeat}
seatStubMessages={seatStubMessages}
openArtifactPreview={openArtifactPreview}
initialFile={fileSandboxTarget}
onBack={handleBackFromFileSandbox}
/>
);
}
if (drawMode) {
return (
<Step3ReportMode
@@ -320,14 +463,15 @@ export const HighFidelityReport: React.FC<HighFidelityReportProps> = ({
modelsLoading={modelsLoading}
setSelectedModel={setSelectedModel}
savedReport={savedReport}
onReportSaved={onReportSaved}
report={reportFlow}
dashboard={dashboardFlow}
onBack={() => setDrawMode(false)}
/>
);
}
return (
<div className="flex-1 flex flex-col min-h-0 overflow-y-auto text-slate-800">
<div className="flex-1 flex flex-col min-h-0 text-slate-800">
{/* Header */}
<div className="shrink-0 px-6 py-4.5 border-b border-slate-100 flex items-center justify-between bg-gradient-to-r from-slate-50 to-white flex-wrap gap-3">
<div className="flex flex-wrap items-center gap-2.5">
@@ -402,179 +546,476 @@ export const HighFidelityReport: React.FC<HighFidelityReportProps> = ({
</div>
</div>
<div className="p-6 space-y-6">
{/* Section 1: Coordinator consensus conclusion */}
<section className="bg-white border border-slate-200 rounded-2xl p-5 shadow-[0_2px_8px_rgba(0,0,0,0.02)]">
<div className="mb-3 flex items-center justify-between gap-2">
<h4 className="text-xs font-black text-slate-900 uppercase tracking-widest flex items-center gap-2 min-w-0">
<CheckCircle className="w-4 h-4 text-emerald-500 shrink-0" />
<span className="truncate">总控最终结论</span>
</h4>
<ConsensusDocxDownloadButton
markdown={consensusText}
title={consensusDocTitle}
className="shrink-0"
/>
</div>
{consensusText ? (
<div className="text-xs text-slate-700 leading-relaxed">
<ReactMarkdown remarkPlugins={[remarkGfm]} components={markdownComponents}>
{consensusText}
</ReactMarkdown>
</div>
) : (
<p className="text-[11px] text-slate-400 italic">
暂无总控结论。返回 Step 2 完成至少一轮研讨后再查看此页。
</p>
{/* 主体:左侧参与席位栏(像第二步) + 右侧滚动内容(2026-06-13 大改) */}
<div className="flex flex-1 min-h-0">
{/* ── 左侧参与席位栏:可收起成头像列;有交付内容的席位头像点亮 ── */}
<aside
className={cn(
"shrink-0 flex flex-col border-r border-slate-100 bg-slate-50/50 transition-all",
sidebarCollapsed ? "w-14" : "w-52",
)}
</section>
{/* Section 2: Per-seat deliveries (collapsible) */}
<section className="bg-white border border-slate-200 rounded-2xl p-5 shadow-[0_2px_8px_rgba(0,0,0,0.02)]">
<h4 className="text-xs font-black text-slate-900 uppercase tracking-widest mb-3 flex items-center gap-2">
<FileText className="w-4 h-4 text-primary" />
各席位最终交付
<span className="text-[10px] font-mono font-semibold text-slate-400 bg-slate-100 px-1.5 py-0.5 rounded">
{seatDeliveries.length}
</span>
</h4>
{seatDeliveries.length === 0 ? (
<p className="text-[11px] text-slate-400 italic">
本次研讨尚未产生子智能体交付。Leader 派活并收到子智能体回复后,该区块会自动填充。
</p>
) : (
<div className="space-y-2">
{seatDeliveries.map((seat, idx) => {
const key = `${seat.sender}-${idx}`;
const expanded = expandedSeats.has(key);
return (
<div key={key} className="border border-slate-150 rounded-xl overflow-hidden">
<button
type="button"
onClick={() => toggleSeat(key)}
className="w-full flex items-center justify-between gap-2 px-3 py-2.5 bg-slate-50 hover:bg-slate-100 transition text-left"
>
<div className="flex items-center gap-2 min-w-0">
{expanded ? (
<ChevronDown className="w-3.5 h-3.5 text-slate-500 shrink-0" />
) : (
<ChevronRight className="w-3.5 h-3.5 text-slate-500 shrink-0" />
)}
<span className="text-[11.5px] font-bold text-slate-800 truncate">{seat.sender}</span>
</div>
<span className="text-[10px] text-slate-400 font-mono shrink-0">
{seat.content.length} 字
</span>
</button>
{expanded && (
<div className="px-4 py-3 text-xs text-slate-700 leading-relaxed border-t border-slate-100 bg-white">
<ReactMarkdown remarkPlugins={[remarkGfm]} components={markdownComponents}>
{seat.content || "(空)"}
</ReactMarkdown>
</div>
)}
</div>
);
})}
</div>
)}
</section>
{/* Section 3: Generated files per seat —— 点击「查看」进入沙箱分栏预览。
仅当存在「有产出文件 / 加载中 / 出错」的席位时才渲染;全部席位无文件则整块隐藏。 */}
{seatsWithFiles.length > 0 && (
<section className="bg-white border border-slate-200 rounded-2xl p-5 shadow-[0_2px_8px_rgba(0,0,0,0.02)]">
<h4 className="text-xs font-black text-slate-900 uppercase tracking-widest mb-3 flex items-center gap-2">
<Download className="w-4 h-4 text-primary" />
生成的报告文件
<span className="text-[10px] font-mono font-semibold text-slate-400 bg-slate-100 px-1.5 py-0.5 rounded">
{totalFileCount}
>
<div
className={cn(
"flex shrink-0 items-center border-b border-slate-100 px-2 py-2",
sidebarCollapsed ? "justify-center" : "justify-between",
)}
>
{!sidebarCollapsed && (
<span className="inline-flex items-center gap-1.5 text-[11px] font-black uppercase tracking-widest text-slate-500">
<Users className="w-3.5 h-3.5 text-primary" />
参与席位
<span className="rounded bg-slate-100 px-1 py-px font-mono text-[9px] font-semibold text-slate-400">
{seatOverviews.length}
</span>
</span>
</h4>
)}
<button
type="button"
onClick={() => setSidebarCollapsed((v) => !v)}
title={sidebarCollapsed ? "展开席位栏" : "收起席位栏"}
className="rounded-md p-1 text-slate-400 transition hover:bg-slate-100 hover:text-slate-600"
>
{sidebarCollapsed ? (
<ChevronsRight className="w-3.5 h-3.5" />
) : (
<ChevronsLeft className="w-3.5 h-3.5" />
)}
</button>
</div>
<div className="space-y-3">
{seatsWithFiles.map((seat) => (
<div key={seat.agentName} className="border border-slate-150 rounded-xl">
<div className="flex items-center justify-between gap-2 px-3 py-2 bg-slate-50 border-b border-slate-150 rounded-t-xl">
<span className="text-[11.5px] font-bold text-slate-800 truncate">{seat.displayName}</span>
<span className="text-[10px] text-slate-400 font-mono shrink-0">
{seat.loading ? "加载中…" : `${seat.files.length} 个文件`}
<div className="custom-scrollbar min-h-0 flex-1 overflow-y-auto px-2 py-2 space-y-1.5">
{/* 总控协调(顶置):点击 → 展开「总控最终结论」并滚动过去 */}
{sidebarCollapsed ? (
<button
type="button"
onClick={focusConsensus}
title={`总控协调${consensusText ? "(点击查看最终结论)" : "(暂无结论)"}`}
className="mx-auto block rounded-full transition hover:scale-105"
>
<span
className={cn(
"relative flex size-9 items-center justify-center rounded-full border-2 bg-white",
consensusText
? "border-emerald-400/70"
: "border-slate-200 opacity-45 grayscale",
)}
>
{getAvatar("human", "h-7 w-7")}
{!!consensusText && (
<span className="absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-white bg-emerald-500" />
)}
</span>
</button>
) : (
<button
type="button"
onClick={focusConsensus}
className={cn(
"w-full flex items-center gap-2 rounded-xl border px-2 py-1.5 text-left transition",
consensusText
? "border-emerald-200/70 bg-emerald-50/40 hover:border-emerald-400/60 hover:bg-emerald-50"
: "border-slate-150 bg-slate-50/60 hover:bg-slate-100",
)}
title={consensusText ? "点击查看总控最终结论" : "暂无总控结论"}
>
<span
className={cn(
"relative flex size-9 shrink-0 items-center justify-center rounded-full border-2 bg-white",
consensusText
? "border-emerald-400/70"
: "border-slate-200 opacity-45 grayscale",
)}
>
{getAvatar("human", "h-7 w-7")}
{!!consensusText && (
<span className="absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-white bg-emerald-500" />
)}
</span>
<span className="min-w-0 flex-1">
<span
className={cn(
"block truncate text-[11.5px] font-bold",
consensusText ? "text-slate-800" : "text-slate-400",
)}
>
总控协调
</span>
<span className="block truncate text-[9.5px] font-mono text-slate-400">
{consensusText ? "最终结论" : "无结论"}
</span>
</span>
</button>
)}
{seatOverviews.map((seat) => {
const lit = !!seat.delivery?.trim();
return sidebarCollapsed ? (
// 收起态:只剩头像列;点头像同样展开右侧对应交付并滚过去。
<button
key={seat.key}
type="button"
onClick={() => focusSeat(seat.key)}
title={`${seat.displayName}${lit ? "(点击查看交付与文件)" : "(暂无交付)"}`}
className="mx-auto block rounded-full transition hover:scale-105"
>
<span
className={cn(
"relative flex size-9 items-center justify-center rounded-full border-2 bg-white",
lit
? "border-emerald-400/70"
: "border-slate-200 opacity-45 grayscale",
)}
>
{getAvatar(seat.avatarType, "h-7 w-7")}
{lit && (
<span className="absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-white bg-emerald-500" />
)}
</span>
</button>
) : (
// 展开态:席位卡片(头像 + 名称 + 交付/文件徽标)。
<button
key={seat.key}
type="button"
onClick={() => focusSeat(seat.key)}
className={cn(
"w-full flex items-center gap-2 rounded-xl border px-2 py-1.5 text-left transition",
lit
? "border-slate-200 bg-white hover:border-primary/40 hover:bg-primary/5"
: "border-slate-150 bg-slate-50/60 hover:bg-slate-100",
)}
title={lit ? "点击查看该席位的交付与文件" : "该席位暂无交付"}
>
<span
className={cn(
"relative flex size-9 shrink-0 items-center justify-center rounded-full border-2 bg-white",
lit
? "border-emerald-400/70"
: "border-slate-200 opacity-45 grayscale",
)}
>
{getAvatar(seat.avatarType, "h-7 w-7")}
{lit && (
<span className="absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-white bg-emerald-500" />
)}
</span>
<span className="min-w-0 flex-1">
<span
className={cn(
"block truncate text-[11.5px] font-bold",
lit ? "text-slate-800" : "text-slate-400",
)}
>
{seat.displayName}
</span>
</div>
<span className="block truncate text-[9.5px] font-mono text-slate-400">
{lit ? `${seat.delivery!.length} 字` : "无交付"}
{seat.files.length > 0 ? ` · ${seat.files.length} 文件` : ""}
</span>
</span>
</button>
);
})}
{seatOverviews.length === 0 && !sidebarCollapsed && (
<p className="px-1 pt-2 text-[10px] italic text-slate-400">
暂无参与席位
</p>
)}
</div>
</aside>
{seat.loading ? (
<div className="flex items-center gap-2 px-3 py-3 text-[11px] text-slate-500">
<Loader2 className="w-3 h-3 animate-spin text-primary" />
<span>正在查询 outputs 目录…</span>
</div>
) : seat.error ? (
<div className="px-3 py-3 text-[11px] text-rose-600">
读取失败:{seat.error}
</div>
) : seat.files.length === 0 ? (
<div className="px-3 py-3 text-[11px] text-slate-400 italic">
该席位未产生输出文件
{/* ── 右侧内容:总控结论 + 每席位一个区块(交付内容 + 报告文件卡片合并) ── */}
<div className="custom-scrollbar flex-1 min-h-0 overflow-y-auto p-6 space-y-5">
{/* Section 1: Coordinator consensus conclusion(可收起,带过渡动画) */}
<section
ref={consensusSectionRef}
className={cn(
"scroll-mt-4 bg-white border rounded-2xl shadow-[0_2px_8px_rgba(0,0,0,0.02)] overflow-hidden transition-shadow",
focusedSeat === CONSENSUS_KEY
? "border-primary/50 ring-2 ring-primary/30"
: "border-slate-200",
)}
>
<div className="flex items-center justify-between gap-2 px-5 py-3.5 bg-slate-50/40">
<button
type="button"
onClick={() => setConsensusExpanded((v) => !v)}
className="flex min-w-0 flex-1 items-center gap-2 text-left"
title={consensusExpanded ? "收起结论" : "展开结论"}
>
{consensusExpanded ? (
<ChevronDown className="w-3.5 h-3.5 text-slate-500 shrink-0" />
) : (
<ChevronRight className="w-3.5 h-3.5 text-slate-500 shrink-0" />
)}
<CheckCircle className="w-4 h-4 text-emerald-500 shrink-0" />
<span className="truncate text-xs font-black text-slate-900 uppercase tracking-widest">
总控最终结论
</span>
</button>
<ConsensusDocxDownloadButton
markdown={consensusText}
title={consensusDocTitle}
className="shrink-0"
/>
</div>
<div
className={cn(
"grid transition-[grid-template-rows] duration-300 ease-out",
consensusExpanded ? "grid-rows-[1fr]" : "grid-rows-[0fr]",
)}
>
<div className="overflow-hidden">
<div className="border-t border-slate-100 px-5 py-4">
{consensusText ? (
<div className="text-xs text-slate-700 leading-relaxed">
<ReactMarkdown remarkPlugins={[remarkGfm]} components={markdownComponents}>
{consensusText}
</ReactMarkdown>
</div>
) : (
<ul className="divide-y divide-slate-100">
{seat.files.map((f) => (
<li
key={f.path}
className="px-3 py-2 flex items-center justify-between gap-2 hover:bg-slate-50/60"
>
<div className="flex items-center gap-2 min-w-0">
<FileText className="w-3.5 h-3.5 text-slate-400 shrink-0" />
<span className="text-[11.5px] font-medium text-slate-800 truncate" title={f.name}>
{f.name}
</span>
</div>
<div className="flex items-center gap-2 shrink-0">
<span className="text-[10px] font-mono text-slate-400">
{formatBytes(f.sizeBytes)}
</span>
<button
type="button"
onClick={() => handleViewInSandbox(seat.threadId, f)}
className="text-slate-600 hover:text-primary transition p-1 rounded hover:bg-slate-100"
title="在沙箱中查看"
>
<Eye className="w-3.5 h-3.5" />
</button>
<button
type="button"
onClick={() => handleDownload(seat.threadId, f)}
className="text-slate-600 hover:text-primary transition p-1 rounded hover:bg-slate-100"
title="下载"
>
<Download className="w-3.5 h-3.5" />
</button>
</div>
</li>
))}
</ul>
<p className="text-[11px] text-slate-400 italic">
暂无总控结论。返回 Step 2 完成至少一轮研讨后再查看此页。
</p>
)}
</div>
))}
</div>
</div>
</section>
)}
{/* Footer */}
<div className="pt-2 border-t border-slate-100 flex items-center justify-between flex-wrap gap-4">
<span className="text-xs text-slate-400 font-medium">
如需重新立项,可清空当前研讨,回到任务理解阶段重新起草。
</span>
<button
type="button"
onClick={onReset}
className="border border-slate-700 text-slate-700 hover:text-slate-900 hover:bg-slate-50 text-[10.5px] font-bold px-4 py-3 rounded-2xl transition cursor-pointer select-none"
>
重新起草新规划
</button>
{/* Section 2: 每席位一个区块 —— 交付内容 + 该席位生成的报告文件(卡片,点击开沙箱) */}
{seatOverviews.length === 0 ? (
<section className="bg-white border border-slate-200 rounded-2xl p-5 shadow-[0_2px_8px_rgba(0,0,0,0.02)]">
<p className="text-[11px] text-slate-400 italic">
本次研讨尚未产生子智能体交付。Leader 派活并收到子智能体回复后,这里会按席位展示交付与产出文件。
</p>
</section>
) : (
seatOverviews.map((seat) => {
const expanded = expandedSeats.has(seat.key);
const lit = !!seat.delivery?.trim();
return (
<section
key={seat.key}
ref={(el) => {
if (el) seatSectionRefs.current.set(seat.key, el);
else seatSectionRefs.current.delete(seat.key);
}}
className={cn(
"scroll-mt-4 bg-white border rounded-2xl shadow-[0_2px_8px_rgba(0,0,0,0.02)] overflow-hidden transition-shadow",
focusedSeat === seat.key
? "border-primary/50 ring-2 ring-primary/30"
: "border-slate-200",
)}
>
{/* 区块头:头像 + 席位名 + 徽标,点击折叠/展开 */}
<button
type="button"
onClick={() => toggleSeat(seat.key)}
className="w-full flex items-center justify-between gap-2 px-4 py-3 bg-slate-50/70 hover:bg-slate-100/70 transition text-left"
>
<div className="flex items-center gap-2.5 min-w-0">
{expanded ? (
<ChevronDown className="w-3.5 h-3.5 text-slate-500 shrink-0" />
) : (
<ChevronRight className="w-3.5 h-3.5 text-slate-500 shrink-0" />
)}
<span
className={cn(
"flex size-7 shrink-0 items-center justify-center rounded-full border-2 bg-white",
lit ? "border-emerald-400/70" : "border-slate-200 opacity-50 grayscale",
)}
>
{getAvatar(seat.avatarType, "h-5.5 w-5.5")}
</span>
<span className="text-xs font-black text-slate-800 truncate">
{seat.displayName}
</span>
</div>
<span className="text-[10px] text-slate-400 font-mono shrink-0">
{lit ? `${seat.delivery!.length} 字` : "无交付"}
{seat.loading
? " · 文件加载中…"
: seat.files.length > 0
? ` · ${seat.files.length} 个文件`
: ""}
</span>
</button>
<div
className={cn(
"grid transition-[grid-template-rows] duration-300 ease-out",
expanded ? "grid-rows-[1fr]" : "grid-rows-[0fr]",
)}
>
<div className="overflow-hidden">
<div className="border-t border-slate-100">
{/* 交付内容 */}
<div className="px-5 py-4 text-xs text-slate-700 leading-relaxed">
{lit ? (
<ReactMarkdown
remarkPlugins={[remarkGfm]}
components={markdownComponents}
>
{seat.delivery!}
</ReactMarkdown>
) : (
<p className="text-[11px] text-slate-400 italic">该席位暂无交付内容。</p>
)}
</div>
{/* 该席位生成的报告文件 —— 卡片,点击在沙箱中打开 */}
{(seat.loading || seat.error || seat.files.length > 0) && (
<div className="border-t border-slate-100 bg-slate-50/40 px-5 py-3">
<div className="mb-2 flex items-center gap-1.5 text-[10px] font-black uppercase tracking-widest text-slate-500">
<Download className="w-3 h-3 text-primary" />
生成的报告文件
</div>
{seat.loading ? (
<div className="flex items-center gap-2 text-[11px] text-slate-500">
<Loader2 className="w-3 h-3 animate-spin text-primary" />
<span>正在查询 outputs 目录…</span>
</div>
) : seat.error ? (
<div className="text-[11px] text-rose-600">读取失败:{seat.error}</div>
) : (
<div className="grid grid-cols-1 gap-2 sm:grid-cols-2">
{seat.files.map((f) => (
<div
key={f.path}
role="button"
tabIndex={0}
onClick={() =>
seat.threadId && handleViewInSandbox(seat.threadId, f)
}
onKeyDown={(e) => {
if ((e.key === "Enter" || e.key === " ") && seat.threadId) {
e.preventDefault();
handleViewInSandbox(seat.threadId, f);
}
}}
title="点击在沙箱中查看"
className="group flex cursor-pointer items-center justify-between gap-2 rounded-xl border border-slate-200 bg-white px-3 py-2.5 transition hover:border-primary/40 hover:bg-primary/5 hover:shadow-sm"
>
<div className="flex items-center gap-2 min-w-0">
<span className="flex size-7 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary">
<FileText className="w-3.5 h-3.5" />
</span>
<div className="min-w-0">
<span
className="block truncate text-[11.5px] font-bold text-slate-800"
title={f.name}
>
{f.name}
</span>
<span className="block text-[9.5px] font-mono text-slate-400">
{formatBytes(f.sizeBytes)}
</span>
</div>
</div>
<div className="flex items-center gap-1 shrink-0">
<Eye className="w-3.5 h-3.5 text-slate-300 transition group-hover:text-primary" />
<button
type="button"
onClick={(e) => {
e.stopPropagation();
if (seat.threadId) handleDownload(seat.threadId, f);
}}
className="rounded p-1 text-slate-400 transition hover:bg-slate-100 hover:text-primary"
title="下载"
>
<Download className="w-3.5 h-3.5" />
</button>
</div>
</div>
))}
</div>
)}
</div>
)}
</div>
</div>
</div>
</section>
);
})
)}
{/* Footer */}
<div className="pt-2 border-t border-slate-100 flex items-center justify-between flex-wrap gap-4">
<span className="text-xs text-slate-400 font-medium">
如需重新立项,可清空当前研讨,回到任务理解阶段重新起草。
</span>
<button
type="button"
onClick={onReset}
className="border border-slate-700 text-slate-700 hover:text-slate-900 hover:bg-slate-50 text-[10.5px] font-bold px-4 py-3 rounded-2xl transition cursor-pointer select-none"
>
重新起草新规划
</button>
</div>
</div>
{/* ── 内联文件沙箱(2026-06-13):点文件卡片从右侧滑入,左侧席位栏只收起不消失。
width 0↔46% 过渡 + 面板内容平移,关闭后 target 保留到动画结束。 ── */}
<div
className={cn(
"shrink-0 min-h-0 overflow-hidden transition-all duration-300 ease-in-out",
fileSandboxOpen && fileSandboxTarget ? "w-[46%]" : "w-0",
)}
>
{fileSandboxTarget && (
<div
className={cn(
"h-full w-full border-l border-slate-100 bg-[#fffdfa] p-3 transition-transform duration-300 ease-in-out",
fileSandboxOpen ? "translate-x-0" : "translate-x-full",
)}
>
{!fileSandboxIsText ? (
// 二进制(图片 / PDF 等):直接 iframe 下载路由(浏览器原生渲染)。
<div className="flex h-full flex-col overflow-hidden rounded-xl border border-slate-200 bg-white">
<div className="flex shrink-0 items-center justify-between gap-2 border-b border-slate-100 px-3 py-2">
<span className="truncate text-xs font-bold text-slate-700">
{fileSandboxTarget.file.name}
</span>
<button
type="button"
onClick={handleCloseFileSandbox}
className="rounded-md p-1 text-slate-400 transition hover:bg-slate-100 hover:text-slate-600"
title="关闭预览"
>
×
</button>
</div>
<iframe
title={fileSandboxTarget.file.name}
src={buildArtifactDownloadUrl(
fileSandboxTarget.threadId,
fileSandboxTarget.file.path,
)}
className="min-h-0 flex-1 w-full border-0 bg-white"
/>
</div>
) : fileSandboxContent == null ? (
<div className="flex h-full items-center justify-center gap-2 rounded-xl border border-slate-200 bg-white text-xs text-slate-400">
<Loader2 className="w-4 h-4 animate-spin text-primary" />
正在读取文件内容…
</div>
) : (
<ThreadContext.Provider value={{ thread: fileSandboxThreadStub, isMock: false }}>
<ArtifactFileDetail
className="size-full"
filepath={fileSandboxVirtualUrl}
threadId={fileSandboxTarget.threadId}
onClose={handleCloseFileSandbox}
/>
</ThreadContext.Provider>
)}
</div>
)}
</div>
</div>
</div>
);
};