- 区域级脱敏 Hook useDesensitizeSubtree:对左右侧面板、顶部标题、 业务链条选择器/列表弹窗/列表页/配置页/映射页整片脱敏(文本节点, 跳过 input/textarea 等可编辑控件) - 消息列表正文保持原文,仅智能体名称脱敏(senderName / 席位名 / 流程图节点) - Step3 总结/报告/大屏、推荐弹窗等结果面板脱敏 - 沙箱产物预览不脱敏:ArtifactFileDetail 加 disableDesensitize,会商沙箱传入 - desensitize.ts 新增 desensitizeDeep 递归脱敏结构化数据 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1024 lines
47 KiB
TypeScript
1024 lines
47 KiB
TypeScript
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 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,
|
||
type SessionArtifactFile,
|
||
type ThreadIdMap,
|
||
} from "@/roundtable-planning/api/multi-agent";
|
||
import { ConsensusDocxDownloadButton } from "@/roundtable-planning/components/ConsensusDocxDownloadButton";
|
||
import { desensitize } from "@/lib/desensitize";
|
||
import { markdownComponents } from "@/roundtable-planning/components/markdown-components";
|
||
import {
|
||
Step3ReportMode,
|
||
type ModelOption,
|
||
} from "@/roundtable-planning/components/Step3ReportMode";
|
||
import { Step3SummaryMode } from "@/roundtable-planning/components/Step3SummaryMode";
|
||
import type {
|
||
DraftStep3Snapshot,
|
||
DraftStep3SummarySnapshot,
|
||
} from "@/roundtable-planning/api/drafts";
|
||
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. "情报收集"). */
|
||
sender: string;
|
||
/** Avatar color hint inherited from the dialogue card. Unused for layout right now. */
|
||
avatarType: string;
|
||
/** The seat's final markdown delivery from Step 2. */
|
||
content: string;
|
||
}
|
||
|
||
interface HighFidelityReportProps {
|
||
threadIds: ThreadIdMap | null;
|
||
coordinatorName: string | null;
|
||
/** The most recent leader-agent text — rendered as the final consensus. */
|
||
consensusText: string;
|
||
/** True once leader.dispatched === [] was observed (natural convergence). */
|
||
hasConsensus: boolean;
|
||
/** Each sub-agent's final delivery, filtered out of step2 dialogues. */
|
||
seatDeliveries: SeatDelivery[];
|
||
/** lowercase agent name → display name (e.g. "roundtable-intelligence" → "情报收集"). */
|
||
seatNameMap: Record<string, string>;
|
||
/** Step 1 整理出的结构化意图 —— 喂给「结果绘制」的方案可视化智能体。 */
|
||
intentReady: ReportIntent | null;
|
||
/** 当前推理模型 —— 跑可视化智能体用。 */
|
||
selectedModel: string;
|
||
/** 可选模型列表 + 加载态 + 切换器 —— 结果绘制右侧的模型选择(对齐第 2 步)。 */
|
||
availableModels: ReadonlyArray<ModelOption>;
|
||
modelsLoading: boolean;
|
||
setSelectedModel: (model: string) => void;
|
||
/** 草稿里已存的上次绘制结果 —— 透传给「结果绘制」恢复展示。 */
|
||
savedReport?: DraftStep3Snapshot | null;
|
||
/** 一次绘制完成时回调,把结果交给上层存进草稿 step3。 */
|
||
onReportSaved?: (snapshot: DraftStep3Snapshot) => void;
|
||
/** 业务链写给总控的编排提示 —— 注入「总结报告」智能体作为最高优先级口径。 */
|
||
coordinatorPrompt?: string | null;
|
||
/** 草稿里已存的上次总结结果 —— 透传给「总结报告」恢复展示。 */
|
||
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;
|
||
seatStubMessages: Record<string, unknown[]>;
|
||
}
|
||
|
||
interface SeatArtifacts {
|
||
agentName: string;
|
||
displayName: string;
|
||
threadId: string;
|
||
files: SessionArtifactFile[];
|
||
loading: boolean;
|
||
error: string | null;
|
||
}
|
||
|
||
function formatBytes(n: number): string {
|
||
if (n < 1024) return `${n} B`;
|
||
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
|
||
if (n < 1024 * 1024 * 1024) return `${(n / (1024 * 1024)).toFixed(1)} MB`;
|
||
return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
||
}
|
||
|
||
function formatGeneratedAt(d: Date): string {
|
||
const pad = (n: number) => n.toString().padStart(2, "0");
|
||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
||
}
|
||
|
||
export const HighFidelityReport: React.FC<HighFidelityReportProps> = ({
|
||
threadIds,
|
||
coordinatorName,
|
||
consensusText,
|
||
hasConsensus,
|
||
seatDeliveries,
|
||
seatNameMap,
|
||
intentReady,
|
||
selectedModel,
|
||
availableModels,
|
||
modelsLoading,
|
||
setSelectedModel,
|
||
savedReport,
|
||
onReportSaved,
|
||
coordinatorPrompt,
|
||
savedSummary,
|
||
onSummarySaved,
|
||
summaryFlow,
|
||
reportFlow,
|
||
dashboardFlow,
|
||
onReset,
|
||
openArtifactPreview,
|
||
seatStubMessages,
|
||
}) => {
|
||
// 「结果绘制」模式:把现有报告内容收起到左栏,右侧由方案可视化智能体绘制图表 HTML。
|
||
const consensusDocTitle = useMemo(() => {
|
||
const objective = intentReady?.objective?.trim();
|
||
if (!objective) return "圆桌总控最终结论";
|
||
const short = objective.length > 40 ? `${objective.slice(0, 40)}…` : objective;
|
||
return `圆桌总控结论-${short}`;
|
||
}, [intentReady?.objective]);
|
||
|
||
// 第 3 步**主页** = 总结报告(进第三步默认自动跑「方案总结报告智能体」)。
|
||
// 用户点「最终方案展示」切到静态页(summaryMode=false),再从静态页可进「结果绘制」HTML。
|
||
const [summaryMode, setSummaryMode] = useState(true);
|
||
const [drawMode, setDrawMode] = useState(false);
|
||
// 文件沙箱(2026-06-13 改内联):点文件卡片在右侧滑入沙箱面板、左侧席位栏收起
|
||
// (不再整页切走)。target 在关闭后保留,供退出过渡动画期间继续渲染。
|
||
const [fileSandboxOpen, setFileSandboxOpen] = useState(false);
|
||
const [fileSandboxTarget, setFileSandboxTarget] = useState<{
|
||
threadId: string;
|
||
file: SessionArtifactFile;
|
||
} | null>(null);
|
||
|
||
// 进入第三步即关闭并清空第二步遗留的沙箱(artifacts 面板全局共享,第二步打开后
|
||
// 不会自动关)。点「结果绘制」后 Step3ReportMode 会按需开自己的沙箱,互不串扰。
|
||
const { deselect: deselectArtifact } = useArtifacts();
|
||
useEffect(() => {
|
||
// 总结报告主页(summaryMode)由 Step3SummaryMode 自管沙箱——这里不 deselect,
|
||
// 否则会盖掉它在恢复草稿时同步打开的 md 预览。切到静态页时才清空第二步遗留沙箱。
|
||
if (summaryMode) return;
|
||
deselectArtifact();
|
||
}, [deselectArtifact, summaryMode]);
|
||
// Build the per-seat list (excludes the coordinator). useMemo so the file
|
||
// fetch effect doesn't re-fire on every parent render.
|
||
const seatThreadEntries = useMemo(() => {
|
||
if (!threadIds) return [] as Array<{ agentName: string; threadId: string; displayName: string }>;
|
||
return Object.entries(threadIds)
|
||
.filter(([name]) => !coordinatorName || name !== coordinatorName)
|
||
.map(([agentName, threadId]) => ({
|
||
agentName,
|
||
threadId,
|
||
displayName: seatNameMap[agentName.toLowerCase()] ?? agentName,
|
||
}));
|
||
}, [threadIds, coordinatorName, seatNameMap]);
|
||
|
||
// Map sender display name → its delivery content for the accordion rows.
|
||
// Built once per seatDeliveries change; later entries with the same sender
|
||
// win so the *latest* delivery wins.
|
||
const deliveryByDisplay = useMemo(() => {
|
||
const m = new Map<string, string>();
|
||
for (const d of seatDeliveries) m.set(d.sender, d.content);
|
||
return m;
|
||
}, [seatDeliveries]);
|
||
|
||
const [artifactsBySeat, setArtifactsBySeat] = useState<SeatArtifacts[]>([]);
|
||
const [expandedSeats, setExpandedSeats] = useState<Set<string>>(new Set());
|
||
const [reloadKey, setReloadKey] = useState(0);
|
||
const generatedAt = useMemo(() => formatGeneratedAt(new Date()), []);
|
||
|
||
// Fetch artifact listings for every seat thread in parallel. Re-runs when
|
||
// the user clicks "刷新文件清单" (reloadKey ticks) or when the thread set
|
||
// changes (rare — only on a true re-init).
|
||
useEffect(() => {
|
||
if (seatThreadEntries.length === 0) {
|
||
setArtifactsBySeat([]);
|
||
return;
|
||
}
|
||
|
||
const initial: SeatArtifacts[] = seatThreadEntries.map((s) => ({
|
||
...s,
|
||
files: [],
|
||
loading: true,
|
||
error: null,
|
||
}));
|
||
setArtifactsBySeat(initial);
|
||
|
||
const abort = new AbortController();
|
||
let cancelled = false;
|
||
|
||
(async () => {
|
||
const results = await Promise.all(
|
||
seatThreadEntries.map(async (seat) => {
|
||
try {
|
||
const res = await listSessionArtifacts(seat.threadId, { signal: abort.signal });
|
||
return { seat, files: res.files, error: null as string | null };
|
||
} catch (err) {
|
||
if ((err as Error).name === "AbortError") {
|
||
return { seat, files: [] as SessionArtifactFile[], error: null };
|
||
}
|
||
return { seat, files: [] as SessionArtifactFile[], error: (err as Error).message };
|
||
}
|
||
}),
|
||
);
|
||
if (cancelled) return;
|
||
setArtifactsBySeat(
|
||
results.map(({ seat, files, error }) => ({
|
||
...seat,
|
||
files,
|
||
loading: false,
|
||
error,
|
||
})),
|
||
);
|
||
})();
|
||
|
||
return () => {
|
||
cancelled = true;
|
||
abort.abort();
|
||
};
|
||
}, [seatThreadEntries, reloadKey]);
|
||
|
||
// ── 统一席位总览(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 [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) => {
|
||
const next = new Set(prev);
|
||
if (next.has(key)) next.delete(key);
|
||
else next.add(key);
|
||
return next;
|
||
});
|
||
}, []);
|
||
|
||
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,
|
||
);
|
||
}, []);
|
||
|
||
// 文本类扩展名 → 拉文本走虚拟 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) => {
|
||
const url = buildArtifactDownloadUrl(threadId, file.path, { download: true });
|
||
if (typeof window !== "undefined") {
|
||
window.open(url, "_blank", "noopener,noreferrer");
|
||
}
|
||
},
|
||
[],
|
||
);
|
||
|
||
if (summaryMode) {
|
||
return (
|
||
<Step3SummaryMode
|
||
threadIds={threadIds}
|
||
coordinatorName={coordinatorName}
|
||
consensusText={consensusText}
|
||
hasConsensus={hasConsensus}
|
||
seatDeliveries={seatDeliveries}
|
||
seatNameMap={seatNameMap}
|
||
intentReady={intentReady}
|
||
selectedModel={selectedModel}
|
||
availableModels={availableModels}
|
||
modelsLoading={modelsLoading}
|
||
setSelectedModel={setSelectedModel}
|
||
coordinatorPrompt={coordinatorPrompt}
|
||
savedSummary={savedSummary}
|
||
summary={summaryFlow}
|
||
onViewStatic={() => setSummaryMode(false)}
|
||
/>
|
||
);
|
||
}
|
||
|
||
if (drawMode) {
|
||
return (
|
||
<Step3ReportMode
|
||
threadIds={threadIds}
|
||
coordinatorName={coordinatorName}
|
||
consensusText={consensusText}
|
||
hasConsensus={hasConsensus}
|
||
seatDeliveries={seatDeliveries}
|
||
seatNameMap={seatNameMap}
|
||
intentReady={intentReady}
|
||
selectedModel={selectedModel}
|
||
availableModels={availableModels}
|
||
modelsLoading={modelsLoading}
|
||
setSelectedModel={setSelectedModel}
|
||
savedReport={savedReport}
|
||
report={reportFlow}
|
||
dashboard={dashboardFlow}
|
||
onBack={() => setDrawMode(false)}
|
||
/>
|
||
);
|
||
}
|
||
|
||
return (
|
||
<div className="flex-1 flex flex-col min-h-0 text-slate-800 dark:text-foreground">
|
||
{/* 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 dark:border-border dark:from-card dark:to-card">
|
||
<div className="flex flex-wrap items-center gap-2.5">
|
||
<div className="flex items-center gap-2">
|
||
<CheckCircle className="w-5 h-5 text-emerald-500" />
|
||
<h3 className="text-sm font-black text-slate-900 tracking-tight dark:text-foreground">最终方案展示</h3>
|
||
</div>
|
||
<div className="flex items-center gap-1.5 shrink-0">
|
||
{hasConsensus && (
|
||
<span className="text-[10px] font-black text-emerald-700 bg-emerald-50 border border-emerald-200 px-2 py-0.5 rounded-full shadow-sm dark:text-emerald-300 dark:bg-emerald-500/10 dark:border-emerald-500/30 dark:shadow-none">
|
||
● 已达成共识
|
||
</span>
|
||
)}
|
||
<span className="text-[10px] font-mono text-slate-400 font-semibold bg-slate-100/80 px-2 py-0.5 rounded-lg dark:text-muted-foreground dark:bg-muted">
|
||
生成时间:{generatedAt}
|
||
</span>
|
||
</div>
|
||
</div>
|
||
|
||
<div className="flex items-center gap-2">
|
||
<select
|
||
id="step3-report-model-select-entry"
|
||
value={selectedModel}
|
||
onChange={(e) => setSelectedModel(e.target.value)}
|
||
disabled={modelsLoading || availableModels.length === 0}
|
||
title={
|
||
modelsLoading
|
||
? "正在加载模型列表…"
|
||
: availableModels.length === 0
|
||
? "未在 config.yaml 中配置任何模型"
|
||
: "切换结果绘制使用的推理模型"
|
||
}
|
||
className="shrink-0 max-w-[180px] bg-slate-50/50 border border-slate-200 rounded-xl px-2.5 py-1.5 text-[10.5px] font-bold text-slate-700 cursor-pointer focus:outline-none focus:border-primary focus:ring-1 focus:ring-[var(--brand-200)]/50 disabled:opacity-50 disabled:cursor-not-allowed dark:bg-secondary dark:text-foreground dark:border-border"
|
||
>
|
||
{availableModels.length === 0 && (
|
||
<option value="">{modelsLoading ? "加载中…" : "未配置模型"}</option>
|
||
)}
|
||
{availableModels.map((m) => (
|
||
<option key={m.name} value={m.name}>
|
||
{m.display_name && m.display_name !== m.name
|
||
? `${m.display_name} (${m.name})`
|
||
: m.name}
|
||
</option>
|
||
))}
|
||
</select>
|
||
<button
|
||
type="button"
|
||
onClick={() => setSummaryMode(true)}
|
||
title="返回「方案总结报告」(Markdown 总结 + 问答/修改)"
|
||
className="bg-white border border-slate-200 text-slate-700 hover:bg-slate-50 text-[10.5px] font-bold px-3 py-1.5 rounded-xl flex items-center gap-1 transition cursor-pointer dark:bg-secondary dark:border-border dark:text-foreground dark:hover:bg-accent"
|
||
>
|
||
<FileText className="w-3.5 h-3.5 text-slate-500" />
|
||
总结报告
|
||
</button>
|
||
<button
|
||
type="button"
|
||
onClick={() => setDrawMode(true)}
|
||
title="把研讨成果交给方案可视化智能体,绘制带图表的可视化看板"
|
||
className="bg-primary text-white hover:bg-[var(--brand-900)] text-[10.5px] font-bold px-3 py-1.5 rounded-xl flex items-center gap-1 transition cursor-pointer shadow-sm shadow-primary/10"
|
||
>
|
||
<Sparkles className="w-3.5 h-3.5" />
|
||
结果绘制
|
||
</button>
|
||
<button
|
||
type="button"
|
||
onClick={() => setReloadKey((k) => k + 1)}
|
||
className="bg-white border border-slate-200 text-slate-700 hover:bg-slate-50 text-[10.5px] font-bold px-3 py-1.5 rounded-xl flex items-center gap-1 transition cursor-pointer dark:bg-secondary dark:border-border dark:text-foreground dark:hover:bg-accent"
|
||
>
|
||
<RefreshCw className="w-3.5 h-3.5 text-slate-500" />
|
||
刷新文件清单
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
{/* 主体:左侧参与席位栏(像第二步) + 右侧滚动内容(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 dark:border-border dark:bg-card",
|
||
sidebarCollapsed ? "w-14" : "w-52",
|
||
)}
|
||
>
|
||
<div
|
||
className={cn(
|
||
"flex shrink-0 items-center border-b border-slate-100 px-2 py-2 dark:border-border",
|
||
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 dark:text-muted-foreground">
|
||
<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 dark:bg-muted dark:text-muted-foreground">
|
||
{seatOverviews.length}
|
||
</span>
|
||
</span>
|
||
)}
|
||
<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 dark:text-muted-foreground dark:hover:bg-accent dark:hover:text-foreground"
|
||
>
|
||
{sidebarCollapsed ? (
|
||
<ChevronsRight className="w-3.5 h-3.5" />
|
||
) : (
|
||
<ChevronsLeft className="w-3.5 h-3.5" />
|
||
)}
|
||
</button>
|
||
</div>
|
||
|
||
<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 dark:bg-secondary",
|
||
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 dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:hover:border-emerald-500/50 dark:hover:bg-emerald-500/15"
|
||
: "border-slate-150 bg-slate-50/60 hover:bg-slate-100 dark:border-border dark:bg-white/5 dark:hover:bg-accent",
|
||
)}
|
||
title={consensusText ? "点击查看总控最终结论" : "暂无总控结论"}
|
||
>
|
||
<span
|
||
className={cn(
|
||
"relative flex size-9 shrink-0 items-center justify-center rounded-full border-2 bg-white dark:bg-secondary",
|
||
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 dark:text-foreground" : "text-slate-400 dark:text-muted-foreground",
|
||
)}
|
||
>
|
||
总控协调
|
||
</span>
|
||
<span className="block truncate text-[9.5px] font-mono text-slate-400 dark:text-muted-foreground">
|
||
{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 dark:bg-secondary",
|
||
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 dark:border-border dark:bg-secondary dark:hover:border-primary/50 dark:hover:bg-accent"
|
||
: "border-slate-150 bg-slate-50/60 hover:bg-slate-100 dark:border-border dark:bg-white/5 dark:hover:bg-accent",
|
||
)}
|
||
title={lit ? "点击查看该席位的交付与文件" : "该席位暂无交付"}
|
||
>
|
||
<span
|
||
className={cn(
|
||
"relative flex size-9 shrink-0 items-center justify-center rounded-full border-2 bg-white dark:bg-secondary",
|
||
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 dark:text-foreground" : "text-slate-400 dark:text-muted-foreground",
|
||
)}
|
||
>
|
||
{desensitize(seat.displayName)}
|
||
</span>
|
||
<span className="block truncate text-[9.5px] font-mono text-slate-400 dark:text-muted-foreground">
|
||
{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 dark:text-muted-foreground">
|
||
暂无参与席位
|
||
</p>
|
||
)}
|
||
</div>
|
||
</aside>
|
||
|
||
{/* ── 右侧内容:总控结论 + 每席位一个区块(交付内容 + 报告文件卡片合并) ── */}
|
||
<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 dark:bg-card dark:shadow-none",
|
||
focusedSeat === CONSENSUS_KEY
|
||
? "border-primary/50 ring-2 ring-primary/30"
|
||
: "border-slate-200 dark:border-border",
|
||
)}
|
||
>
|
||
<div className="flex items-center justify-between gap-2 px-5 py-3.5 bg-slate-50/40 dark:bg-white/5">
|
||
<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 dark:text-muted-foreground" />
|
||
) : (
|
||
<ChevronRight className="w-3.5 h-3.5 text-slate-500 shrink-0 dark:text-muted-foreground" />
|
||
)}
|
||
<CheckCircle className="w-4 h-4 text-emerald-500 shrink-0" />
|
||
<span className="truncate text-xs font-black text-slate-900 uppercase tracking-widest dark:text-foreground">
|
||
总控最终结论
|
||
</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 dark:border-border">
|
||
{consensusText ? (
|
||
<div className="text-xs text-slate-700 leading-relaxed dark:text-foreground/80">
|
||
<ReactMarkdown remarkPlugins={[remarkGfm]} components={markdownComponents}>
|
||
{desensitize(consensusText)}
|
||
</ReactMarkdown>
|
||
</div>
|
||
) : (
|
||
<p className="text-[11px] text-slate-400 italic dark:text-muted-foreground">
|
||
暂无总控结论。返回 Step 2 完成至少一轮研讨后再查看此页。
|
||
</p>
|
||
)}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
{/* 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)] dark:bg-card dark:border-border dark:shadow-none">
|
||
<p className="text-[11px] text-slate-400 italic dark:text-muted-foreground">
|
||
本次研讨尚未产生子智能体交付。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 dark:bg-card dark:shadow-none",
|
||
focusedSeat === seat.key
|
||
? "border-primary/50 ring-2 ring-primary/30"
|
||
: "border-slate-200 dark:border-border",
|
||
)}
|
||
>
|
||
{/* 区块头:头像 + 席位名 + 徽标,点击折叠/展开 */}
|
||
<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 dark:bg-white/5 dark:hover:bg-accent"
|
||
>
|
||
<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 dark:text-muted-foreground" />
|
||
) : (
|
||
<ChevronRight className="w-3.5 h-3.5 text-slate-500 shrink-0 dark:text-muted-foreground" />
|
||
)}
|
||
<span
|
||
className={cn(
|
||
"flex size-7 shrink-0 items-center justify-center rounded-full border-2 bg-white dark:bg-secondary",
|
||
lit ? "border-emerald-400/70" : "border-slate-200 opacity-50 grayscale dark:border-border",
|
||
)}
|
||
>
|
||
{getAvatar(seat.avatarType, "h-5.5 w-5.5")}
|
||
</span>
|
||
<span className="text-xs font-black text-slate-800 truncate dark:text-foreground">
|
||
{desensitize(seat.displayName)}
|
||
</span>
|
||
</div>
|
||
<span className="text-[10px] text-slate-400 font-mono shrink-0 dark:text-muted-foreground">
|
||
{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 dark:border-border">
|
||
{/* 交付内容 */}
|
||
<div className="px-5 py-4 text-xs text-slate-700 leading-relaxed dark:text-foreground/80">
|
||
{lit ? (
|
||
<ReactMarkdown
|
||
remarkPlugins={[remarkGfm]}
|
||
components={markdownComponents}
|
||
>
|
||
{desensitize(seat.delivery!)}
|
||
</ReactMarkdown>
|
||
) : (
|
||
<p className="text-[11px] text-slate-400 italic dark:text-muted-foreground">该席位暂无交付内容。</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 dark:border-border dark:bg-white/5">
|
||
<div className="mb-2 flex items-center gap-1.5 text-[10px] font-black uppercase tracking-widest text-slate-500 dark:text-muted-foreground">
|
||
<Download className="w-3 h-3 text-primary" />
|
||
生成的报告文件
|
||
</div>
|
||
{seat.loading ? (
|
||
<div className="flex items-center gap-2 text-[11px] text-slate-500 dark:text-muted-foreground">
|
||
<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 dark:border-border dark:bg-secondary dark:hover:border-primary/50 dark:hover:bg-accent dark:hover:shadow-none"
|
||
>
|
||
<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 dark:text-foreground"
|
||
title={f.name}
|
||
>
|
||
{f.name}
|
||
</span>
|
||
<span className="block text-[9.5px] font-mono text-slate-400 dark:text-muted-foreground">
|
||
{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 dark:text-muted-foreground" />
|
||
<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 dark:text-muted-foreground dark:hover:bg-accent"
|
||
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 dark:border-border">
|
||
<span className="text-xs text-slate-400 font-medium dark:text-muted-foreground">
|
||
如需重新立项,可清空当前研讨,回到任务理解阶段重新起草。
|
||
</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 dark:border-border dark:text-foreground dark:hover:bg-accent dark:hover:text-foreground"
|
||
>
|
||
重新起草新规划
|
||
</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 dark:border-border dark:bg-card",
|
||
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 dark:border-border dark:bg-secondary">
|
||
<div className="flex shrink-0 items-center justify-between gap-2 border-b border-slate-100 px-3 py-2 dark:border-border">
|
||
<span className="truncate text-xs font-bold text-slate-700 dark:text-foreground">
|
||
{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 dark:text-muted-foreground dark:hover:bg-accent dark:hover:text-foreground"
|
||
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 dark:border-border dark:bg-secondary dark:text-muted-foreground">
|
||
<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}
|
||
allowVirtualMarkdownEdit
|
||
/>
|
||
</ThreadContext.Provider>
|
||
)}
|
||
</div>
|
||
)}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
);
|
||
};
|