智能体列表
This commit is contained in:
1 parent
6cf4404243
commit
45eb46c3f3
11 files changed
+1457
-171
No files matched your search
@@ -44,6 +44,13 @@ import remarkGfm from "remark-gfm";
|
||||
import { HighFidelityReport } from "@/roundtable-planning/components/HighFidelityReport";
|
||||
import { ScrollToBottomButton } from "@/roundtable-planning/components/ScrollToBottomButton";
|
||||
import { useAutoScroll } from "@/roundtable-planning/hooks/useAutoScroll";
|
||||
import {
|
||||
ChainOfThought,
|
||||
ChainOfThoughtContent,
|
||||
ChainOfThoughtHeader,
|
||||
ChainOfThoughtSearchResult,
|
||||
ChainOfThoughtStep,
|
||||
} from "@/components/ai-elements/chain-of-thought";
|
||||
import { useTheme } from "@/contexts/ThemeContext";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useModels } from "@/core/models/hooks";
|
||||
@@ -111,6 +118,15 @@ import {
|
||||
Loader2,
|
||||
History,
|
||||
Trash2,
|
||||
// 步骤折叠卡的图标 —— 跟 chats/new 的 message-group ToolCall 用的一套保持一致,
|
||||
// 让圆桌 Step 2 与主聊天里的"步骤"视觉语义统一。
|
||||
Wrench as WrenchIcon,
|
||||
Search as SearchIcon,
|
||||
Lightbulb as LightbulbIcon,
|
||||
FolderOpen as FolderOpenIcon,
|
||||
BookOpenText as BookOpenTextIcon,
|
||||
MessageCircleQuestionMark as MessageCircleQuestionMarkIcon,
|
||||
Dot as DotIcon,
|
||||
Pencil,
|
||||
Upload,
|
||||
} from "lucide-react";
|
||||
@@ -251,6 +267,108 @@ function getDisplayNameFor(agent: SelectedAgent): string {
|
||||
return BUILTIN_AGENT_META[agent.agent_id]?.displayName ?? agent.name;
|
||||
}
|
||||
|
||||
/** 根据工具名 + args 渲染 ChainOfThoughtStep 的子节点(路径 chip / 命令代码块等)。
|
||||
* 数据来自前端 streamMultiAgent 解析 LangGraph messages-tuple 帧的 tool_calls[0].args。
|
||||
* 与 chats/new 的 message-group ToolCall 子节点保持一致风格。 */
|
||||
function renderStepArgs(key: string, args?: Record<string, unknown>): React.ReactNode {
|
||||
if (!args) return null;
|
||||
const [, toolName] = key.split(":");
|
||||
if (!toolName) return null;
|
||||
switch (toolName) {
|
||||
case "agent_orchestration": {
|
||||
const agentName = typeof args.agent_name === "string" ? args.agent_name : "";
|
||||
const task = typeof args.task === "string" ? args.task : "";
|
||||
if (!agentName && !task) return null;
|
||||
return (
|
||||
<>
|
||||
{agentName && (
|
||||
<ChainOfThoughtSearchResult>{agentName}</ChainOfThoughtSearchResult>
|
||||
)}
|
||||
{task && (
|
||||
<span className="block text-[11px] text-slate-600 line-clamp-3 mt-0.5">
|
||||
{task}
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
case "web_search": {
|
||||
const query = typeof args.query === "string" ? args.query : "";
|
||||
return query ? <ChainOfThoughtSearchResult>{query}</ChainOfThoughtSearchResult> : null;
|
||||
}
|
||||
case "read_file":
|
||||
case "ls":
|
||||
case "write_file":
|
||||
case "str_replace": {
|
||||
const path = typeof args.path === "string" ? args.path : "";
|
||||
return path ? <ChainOfThoughtSearchResult>{path}</ChainOfThoughtSearchResult> : null;
|
||||
}
|
||||
case "bash": {
|
||||
const command = typeof args.command === "string" ? args.command : "";
|
||||
return command ? (
|
||||
<code className="block bg-slate-100 rounded px-2 py-1 text-[11px] font-mono text-slate-800 mt-0.5 line-clamp-2 break-all">
|
||||
{command}
|
||||
</code>
|
||||
) : null;
|
||||
}
|
||||
case "ask_clarification": {
|
||||
const question = typeof args.question === "string" ? args.question : "";
|
||||
return question ? (
|
||||
<span className="block text-[11px] text-slate-600 line-clamp-2 mt-0.5">
|
||||
{question}
|
||||
</span>
|
||||
) : null;
|
||||
}
|
||||
default: {
|
||||
// 兜底:把 args 紧凑展示为 key=value chip
|
||||
const entries = Object.entries(args).filter(
|
||||
([, v]) => v !== null && v !== undefined && v !== "",
|
||||
);
|
||||
if (entries.length === 0) return null;
|
||||
return (
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{entries.slice(0, 4).map(([k, v]) => (
|
||||
<ChainOfThoughtSearchResult key={k}>
|
||||
<span className="opacity-60">{k}:</span>{" "}
|
||||
{typeof v === "string" ? v : JSON.stringify(v)}
|
||||
</ChainOfThoughtSearchResult>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 根据 step.key(格式 `phase:toolName`)给出 ChainOfThoughtStep 的图标 + 文案,
|
||||
* 与 chats/new 的 message-group ToolCall 视觉语义对齐 —— 工具调用走 WrenchIcon
|
||||
* + 「使用 "X" 工具」;特殊工具按截图风格特化(搜索 → SearchIcon、文件 → 文件夹图标…)。
|
||||
* 非工具阶段(connecting / streaming 等)走 fallback label + 简洁的指示点/灯泡图标。 */
|
||||
function getStepDisplay(
|
||||
key: string,
|
||||
fallbackLabel: string,
|
||||
): { icon: typeof DotIcon; label: string } {
|
||||
const [phase, toolName] = key.split(":");
|
||||
if (phase === "tool_calling" && toolName) {
|
||||
switch (toolName) {
|
||||
case "ask_clarification":
|
||||
return { icon: MessageCircleQuestionMarkIcon, label: "需要你的协助" };
|
||||
case "present_files":
|
||||
return { icon: FolderOpenIcon, label: "展示文件" };
|
||||
case "web_search":
|
||||
return { icon: SearchIcon, label: "搜索相关信息" };
|
||||
case "read_file":
|
||||
return { icon: BookOpenTextIcon, label: "读取文件" };
|
||||
default:
|
||||
return { icon: WrenchIcon, label: `使用 "${toolName}" 工具` };
|
||||
}
|
||||
}
|
||||
if (phase === "streaming") {
|
||||
return { icon: LightbulbIcon, label: fallbackLabel };
|
||||
}
|
||||
// connecting / connected / tool_result / 其它 — 一律用小点 + fallback 文案
|
||||
return { icon: DotIcon, label: fallbackLabel };
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the seat-template list shown in the right-rail role panel.
|
||||
* The commander always sits at id=1; agents take id=2..N+1, in the order
|
||||
@@ -490,6 +608,10 @@ export default function RoundtablePlanningPage() {
|
||||
// Step 2 dialogue list — populated by the real orchestration loop once the
|
||||
// user enters the roundtable. Starts empty so we never flash mock content.
|
||||
const [step2RoundtableDialogues, setStep2RoundtableDialogues] = useState<any[]>([]);
|
||||
// 步骤折叠卡的展开覆盖 dict —— key 是 dialogue.id,value 是用户手动设置的展开状态。
|
||||
// 未设置(undefined)时由「msg.streaming」决定:streaming 中默认展开,完成后自动收起。
|
||||
// 用户点击 header 后写入 true/false,从此覆盖默认行为(用户的偏好优先)。
|
||||
const [openSteps, setOpenSteps] = useState<Record<string | number, boolean>>({});
|
||||
|
||||
// Inputs for Step 2 conversation simulation controls
|
||||
const [isRoundTableRunning, setIsRoundTableRunning] = useState<boolean>(true);
|
||||
@@ -689,6 +811,49 @@ export default function RoundtablePlanningPage() {
|
||||
);
|
||||
}, []);
|
||||
|
||||
// 把一条新 phase 步骤追加到 dialogue 的 steps 历史里(参考 chats/new 的
|
||||
// ChainOfThought 折叠卡)。key 由 phase + toolName 组合,**连续重复时不重复 push**,
|
||||
// 避免 streaming 帧每来一次都重新打点产生同一行噪声。
|
||||
// args 是 tool_calling 阶段携带的工具入参(来自上游 LangGraph 的 tool_calls[0].args),
|
||||
// 渲染层根据工具类型展示路径 chip / 命令代码块 / 搜索词等子节点。
|
||||
const appendStepIfNew = useCallback((
|
||||
bubbleId: number,
|
||||
label: string,
|
||||
key: string,
|
||||
args?: Record<string, unknown>,
|
||||
) => {
|
||||
setStep2RoundtableDialogues(prev =>
|
||||
prev.map(d => {
|
||||
if (d.id !== bubbleId) return d;
|
||||
const steps: Array<{
|
||||
id: string;
|
||||
key: string;
|
||||
label: string;
|
||||
ts: string;
|
||||
args?: Record<string, unknown>;
|
||||
}> = d.steps ?? [];
|
||||
const last = steps[steps.length - 1];
|
||||
// 同 key 已存在 —— 但如果 args 是新拿到的(之前可能只有 toolName,这次有了完整 args),
|
||||
// 还是要更新这一行;否则直接跳过。
|
||||
if (last && last.key === key) {
|
||||
if (args && !last.args) {
|
||||
const next = [...steps];
|
||||
next[next.length - 1] = { ...last, args };
|
||||
return { ...d, steps: next };
|
||||
}
|
||||
return d;
|
||||
}
|
||||
return {
|
||||
...d,
|
||||
steps: [
|
||||
...steps,
|
||||
{ id: `${bubbleId}-${steps.length}`, key, label, ts: nowTime(), args },
|
||||
],
|
||||
};
|
||||
}),
|
||||
);
|
||||
}, []);
|
||||
|
||||
// Streaming variant: append a placeholder card and return its id so subsequent
|
||||
// text deltas can be appended in-place via appendToDialogue.
|
||||
const appendStreamingDialogue = useCallback((card: {
|
||||
@@ -708,6 +873,8 @@ export default function RoundtablePlanningPage() {
|
||||
time: nowTime(),
|
||||
confidence: card.confidence ?? "正在输出…",
|
||||
streaming: true,
|
||||
// ChainOfThought 折叠卡用 —— phase 改变时 appendStepIfNew 往里塞。
|
||||
steps: [] as Array<{ id: string; key: string; label: string; ts: string }>,
|
||||
},
|
||||
]);
|
||||
return id;
|
||||
@@ -875,8 +1042,10 @@ export default function RoundtablePlanningPage() {
|
||||
model: selectedModel || undefined,
|
||||
signal: leaderAborter.signal,
|
||||
onTextDelta: (text) => appendToDialogue(leaderBubbleId, text),
|
||||
onPhaseChange: (phase, toolName) => {
|
||||
setDialogueConfidence(leaderBubbleId, phaseLabel(phase, "leader", toolName));
|
||||
onPhaseChange: (phase, toolName, args) => {
|
||||
const label = phaseLabel(phase, "leader", toolName);
|
||||
setDialogueConfidence(leaderBubbleId, label);
|
||||
appendStepIfNew(leaderBubbleId, label, `${phase}:${toolName ?? ""}`, args);
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
@@ -952,13 +1121,19 @@ export default function RoundtablePlanningPage() {
|
||||
agentType: "special",
|
||||
dAgentThreadId: ids,
|
||||
agentName: subName,
|
||||
// 把中文显示名一起传后端,广播回 coordinator thread 时拼进
|
||||
// 「子智能体X完成...」让 LLM 易识别 —— 非内置 agent 的 id 是
|
||||
// UUID,只用 id 时总控认不出已完成的人,会无限循环派活。
|
||||
displayName: meta?.displayName,
|
||||
newMessage: task,
|
||||
// 优先级: 席位 Persona 覆盖 → 全局选中模型 → 让后端回退到 config.yaml models[0]
|
||||
model: perSeatModel || selectedModel || undefined,
|
||||
signal: subAborter.signal,
|
||||
onTextDelta: (text) => appendToDialogue(subBubbleId, text),
|
||||
onPhaseChange: (phase, toolName) => {
|
||||
setDialogueConfidence(subBubbleId, phaseLabel(phase, "special", toolName));
|
||||
onPhaseChange: (phase, toolName, args) => {
|
||||
const label = phaseLabel(phase, "special", toolName);
|
||||
setDialogueConfidence(subBubbleId, label);
|
||||
appendStepIfNew(subBubbleId, label, `${phase}:${toolName ?? ""}`, args);
|
||||
},
|
||||
});
|
||||
if (orchestrationCancelRef.current) {
|
||||
@@ -1001,23 +1176,28 @@ export default function RoundtablePlanningPage() {
|
||||
clearAllStreamingSpeakers();
|
||||
setIsOrchestrating(false);
|
||||
}
|
||||
}, [appendStreamingDialogue, appendToDialogue, finalizeDialogue, highlightSpeaker, markSpeakerStreaming, markSpeakerIdle, clearAllStreamingSpeakers, isOrchestrating, agentConfigs, agentNameToRole]);
|
||||
}, [appendStreamingDialogue, appendToDialogue, appendStepIfNew, setDialogueConfidence, phaseLabel, finalizeDialogue, highlightSpeaker, markSpeakerStreaming, markSpeakerIdle, clearAllStreamingSpeakers, isOrchestrating, agentConfigs, agentNameToRole]);
|
||||
|
||||
// Called by RecommendAgentsDialog onConfirm: update the participant roster,
|
||||
// reset step-2 init so the new coordinator is created for the new roster,
|
||||
// then navigate to Step 2.
|
||||
const handleConfirmAgents = useCallback((agentIds: string[]) => {
|
||||
setSelectedAgents(
|
||||
agentIds.map((id) => ({
|
||||
agent_id: id,
|
||||
name: BUILTIN_AGENT_META[id]?.displayName ?? id,
|
||||
})),
|
||||
);
|
||||
step2InitRef.current = false;
|
||||
setIsRecommendDialogOpen(false);
|
||||
setCurrentStep(2);
|
||||
setShowToast("成功确认!已切换至第二阶段圆桌研讨系统");
|
||||
}, []);
|
||||
const handleConfirmAgents = useCallback(
|
||||
(agents: Array<{ agent_id: string; name: string }>) => {
|
||||
setSelectedAgents(
|
||||
agents.map(({ agent_id, name }) => ({
|
||||
agent_id,
|
||||
// 内置 agent 的中文显示名固定在 BUILTIN_AGENT_META 里(SOUL 也是按这个名);
|
||||
// 非内置走对话框传过来的 name —— 来自候选池 agent.name,与 /api/agents 一致。
|
||||
name: BUILTIN_AGENT_META[agent_id]?.displayName ?? name ?? agent_id,
|
||||
})),
|
||||
);
|
||||
step2InitRef.current = false;
|
||||
setIsRecommendDialogOpen(false);
|
||||
setCurrentStep(2);
|
||||
setShowToast("成功确认!已切换至第二阶段圆桌研讨系统");
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
// Public stop handler used by the pause/stop button and the step-2 teardown.
|
||||
// Sets the cancel flag and aborts every in-flight stream so the loop can
|
||||
@@ -2154,8 +2334,8 @@ export default function RoundtablePlanningPage() {
|
||||
|
||||
{currentStep === 3 ? (
|
||||
<>
|
||||
{/* Panel 1: 任务成果概览 (Task Outcomes Overview) */}
|
||||
<div className="bg-white border border-slate-200/50 rounded-2xl p-4.5 shadow-[0_2px_8px_rgba(0,0,0,0.015)] transition hover:shadow-md">
|
||||
{/* Panel 1: 任务成果概览 —— 暂时隐藏(数据仍是写死示例,等真实统计接入后再恢复) */}
|
||||
<div className="hidden bg-white border border-slate-200/50 rounded-2xl p-4.5 shadow-[0_2px_8px_rgba(0,0,0,0.015)] transition hover:shadow-md">
|
||||
<div className="flex items-center gap-2 border-b border-slate-100 pb-2.5 mb-2.5">
|
||||
<Clipboard className="w-4 h-4 text-primary" strokeWidth={2.5} />
|
||||
<h2 className="text-xs font-black text-slate-900 uppercase tracking-widest">任务成果概览</h2>
|
||||
@@ -2195,13 +2375,25 @@ export default function RoundtablePlanningPage() {
|
||||
</div>
|
||||
|
||||
<div className="space-y-2 overflow-y-auto flex-1 pr-1 custom-scrollbar">
|
||||
{/* 第一项固定是用户(指挥官);后面动态读 selectedAgents —— 这是用户在
|
||||
推荐弹窗确认后选定的圆桌席位,跟第二步左侧角色面板一致。
|
||||
内置 agent 用 BUILTIN_AGENT_META 的中文名 + 颜色;非内置(用户自建)
|
||||
用 agent.name + FALLBACK_AVATAR_TYPES 轮换上色。 */}
|
||||
{[
|
||||
{ id: "human", name: "用户 (指挥官)", role: "人类介入协调", icon: <Man1Avatar size="h-7 w-7" /> },
|
||||
{ id: "agent2", name: "任务理解与前置专家", role: "理解专家 (Gemini)", icon: <RobotAvatar headColor="#f5222d" size="h-7 w-7" /> },
|
||||
{ id: "agent3", name: "极端条件信息情报专家", role: "情报情报 (Gemini)", icon: <PurpleRobotAvatar size="h-7 w-7" /> },
|
||||
{ id: "agent4", name: "算力与热力调度专家", role: "算力评估 (Gemini)", icon: <EmeraldRobotAvatar size="h-7 w-7" /> },
|
||||
{ id: "agent6", name: "安全合规及风控大管家", role: "安全主管 (Gemini)", icon: <AmberRobotAvatar size="h-7 w-7" /> },
|
||||
{ id: "agent7", name: "执行序列和路径规划专家", role: "执行规划 (Gemini)", icon: <PinkRobotAvatar size="h-7 w-7" /> },
|
||||
{
|
||||
id: "human",
|
||||
name: "用户 (指挥官)",
|
||||
role: "人类介入协调",
|
||||
icon: <Man1Avatar size="h-7 w-7" />,
|
||||
},
|
||||
...selectedAgents.map((agent, i) => ({
|
||||
id: agent.agent_id,
|
||||
name: getDisplayNameFor(agent),
|
||||
role: BUILTIN_AGENT_META[agent.agent_id]
|
||||
? `${BUILTIN_AGENT_META[agent.agent_id].displayName} 席位`
|
||||
: "圆桌席位",
|
||||
icon: getAvatar(getAvatarTypeFor(agent.agent_id, i), "h-7 w-7"),
|
||||
})),
|
||||
].map((contrib, idx) => (
|
||||
<div key={idx} className="flex items-center justify-between p-2 rounded-xl bg-slate-50 border border-slate-100 transition hover:border-emerald-100 hover:bg-emerald-50/10">
|
||||
<div className="flex items-center gap-2.5">
|
||||
@@ -2224,8 +2416,8 @@ export default function RoundtablePlanningPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Panel 3: 版本记录 (Version History) */}
|
||||
<div className="bg-white border border-slate-200/50 rounded-2xl p-4.5 shadow-[0_2px_8px_rgba(0,0,0,0.015)] shrink-0">
|
||||
{/* Panel 3: 版本记录 —— 暂时隐藏(无真实版本数据接入) */}
|
||||
<div className="hidden bg-white border border-slate-200/50 rounded-2xl p-4.5 shadow-[0_2px_8px_rgba(0,0,0,0.015)] shrink-0">
|
||||
<div className="flex items-center gap-2 border-b border-slate-100 pb-2.5 mb-2.5">
|
||||
<Clock className="w-4 h-4 text-primary" strokeWidth={2.5} />
|
||||
<h2 className="text-xs font-black text-slate-900 uppercase tracking-widest">版本记录</h2>
|
||||
@@ -2427,8 +2619,10 @@ export default function RoundtablePlanningPage() {
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Chat list viewport */}
|
||||
<div className="flex-1 overflow-y-auto p-6 space-y-4 font-normal">
|
||||
{/* Chat list viewport —— 与第二步消息列表同构:
|
||||
外层 relative + flex-col 给 ScrollToBottomButton 浮在右下;
|
||||
内层 step1ScrollRef 直接占满高度滚动,不再嵌套"问答交互区"卡片。 */}
|
||||
<div className="relative flex-1 min-h-0 flex flex-col font-normal">
|
||||
|
||||
{/* Step 1 dialogue is rendered by `interactiveMessages.map()`
|
||||
inside the 问答交互区 sub-block below. The static demo
|
||||
@@ -2439,7 +2633,7 @@ export default function RoundtablePlanningPage() {
|
||||
structured summary; otherwise shows a placeholder with
|
||||
a disabled "进入下一步" button so the user knows what they
|
||||
need to wait for. */}
|
||||
{intentReady ? (
|
||||
{/* {intentReady ? (
|
||||
<div className="border border-emerald-200 bg-[#f0fdf4]/60 rounded-2xl p-4.5 shadow-[0_2px_12px_rgba(16,185,129,0.04)]">
|
||||
<div className="flex items-center justify-between gap-3 border-b border-emerald-100 pb-3 mb-3.5">
|
||||
<div className="flex items-center gap-2">
|
||||
@@ -2535,28 +2729,14 @@ export default function RoundtablePlanningPage() {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
)} */}
|
||||
|
||||
{/* --- Q&A INTERACTION AREA (问答交互区) --- */}
|
||||
<div className="border border-red-100 rounded-2xl bg-slate-50/20 shadow-[0_2px_12px_rgba(245,34,45,0.01)] overflow-hidden">
|
||||
|
||||
{/* Inside header banner */}
|
||||
<div className="px-4 py-2.5 bg-[var(--brand-200)]/40 border-b border-red-100/50 flex items-center justify-between">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<HelpCircle className="h-4 w-4 text-primary" strokeWidth={2.5} />
|
||||
<span className="text-xs font-extrabold text-[var(--brand-950)]">
|
||||
问答交互区
|
||||
</span>
|
||||
</div>
|
||||
<span className="text-[10px] text-slate-400 font-medium">持续沟通可有效提供细节决策</span>
|
||||
</div>
|
||||
|
||||
{/* Content dialogue lines inside interaction */}
|
||||
<div className="relative">
|
||||
<div
|
||||
ref={step1ScrollRef}
|
||||
className="p-4.5 space-y-3.5 max-h-[280px] overflow-y-auto"
|
||||
>
|
||||
{/* Step 1 消息列表 —— 直接铺在主视区,样式与第二步一致(满高 + 滚动 + 大间距)。
|
||||
原"问答交互区"外框 + header banner 已移除。 */}
|
||||
<div
|
||||
ref={step1ScrollRef}
|
||||
className="flex-1 min-h-0 overflow-y-auto p-6 space-y-4 bg-white"
|
||||
>
|
||||
{interactiveMessages.map((msg) => {
|
||||
const isStreaming = (msg as { streaming?: boolean }).streaming === true;
|
||||
const hasContent = (msg.content ?? "").length > 0;
|
||||
@@ -2581,28 +2761,48 @@ export default function RoundtablePlanningPage() {
|
||||
parts.before.trim() === (clarification.question || "").trim()
|
||||
? ""
|
||||
: parts.before;
|
||||
const phaseLabel = (msg as { phase?: string }).phase;
|
||||
return (
|
||||
<div key={msg.id} className="flex items-start justify-between gap-3 border-b border-slate-100/50 pb-2.5 last:border-0 last:pb-0">
|
||||
<div className="flex items-start gap-2.5 min-w-0">
|
||||
{msg.sender === "user" ? (
|
||||
<Man1Avatar size="h-6 w-6" />
|
||||
) : (
|
||||
<RobotAvatar bg="bg-[var(--brand-200)]/50" size="h-6 w-6" />
|
||||
)}
|
||||
<div className="min-w-0">
|
||||
<span className={`text-[10.5px] font-bold block mb-0.5 ${msg.sender === 'user' ? 'text-primary' : 'text-slate-700'}`}>
|
||||
{msg.senderName}
|
||||
</span>
|
||||
{/* Pre-text spinner: shown only when streaming AND no content has arrived.
|
||||
Caption reflects the inferred SSE phase so users see what the
|
||||
backend is doing during the first-token wait. */}
|
||||
{isStreaming && !hasContent ? (
|
||||
<span className="inline-flex items-center gap-1.5 text-[11px] text-slate-400 italic">
|
||||
<Loader2 className="w-3 h-3 animate-spin text-primary" />
|
||||
{(msg as { phase?: string }).phase ?? "正在连接智能体..."}
|
||||
<div
|
||||
key={msg.id}
|
||||
className="flex gap-4 items-start"
|
||||
>
|
||||
{msg.sender === "user" ? (
|
||||
<Man1Avatar size="h-9 w-9 shrink-0" />
|
||||
) : (
|
||||
<RobotAvatar bg="bg-[var(--brand-200)]/50" size="h-9 w-9 shrink-0" />
|
||||
)}
|
||||
<div className="flex-1 min-w-0 space-y-1">
|
||||
{/* Header 行:发言人 + 阶段标签 + 时间 —— 与第二步气泡一致。 */}
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className={`text-xs font-extrabold ${msg.sender === 'user' ? 'text-primary' : 'text-slate-900'}`}>
|
||||
{msg.senderName}
|
||||
</span>
|
||||
) : isAgent ? (
|
||||
<div className="text-xs text-slate-700 leading-normal font-normal break-words space-y-2">
|
||||
{isStreaming && phaseLabel && (
|
||||
<span className="text-[9px] font-mono font-black uppercase text-[var(--brand-900)] bg-[var(--brand-200)] border border-red-200 px-1.5 py-0.2 rounded">
|
||||
{phaseLabel}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<span className="text-[10px] text-slate-400 font-mono font-medium shrink-0">
|
||||
{msg.time}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* 内容区:streaming + 无内容 → 大 spinner + 三点动画;有内容 → markdown / 用户文本。 */}
|
||||
{isStreaming && !hasContent ? (
|
||||
<div className="flex items-center gap-2 py-1.5 text-xs text-slate-600">
|
||||
<Loader2 className="w-4 h-4 animate-spin text-primary" />
|
||||
<span className="font-medium">{phaseLabel ?? "正在连接智能体..."}</span>
|
||||
<span className="inline-flex items-center gap-0.5">
|
||||
<span className="w-1 h-1 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.3s]" />
|
||||
<span className="w-1 h-1 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.15s]" />
|
||||
<span className="w-1 h-1 rounded-full bg-primary/70 animate-bounce" />
|
||||
</span>
|
||||
</div>
|
||||
) : isAgent ? (
|
||||
<div className="text-xs text-slate-700 leading-relaxed font-medium break-words space-y-2 roundtable-md">
|
||||
{introText && (
|
||||
<ReactMarkdown
|
||||
remarkPlugins={[remarkGfm]}
|
||||
@@ -2705,22 +2905,16 @@ export default function RoundtablePlanningPage() {
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<span className="text-xs text-slate-700 leading-normal font-normal whitespace-pre-wrap break-words">
|
||||
<div className="text-xs text-slate-700 leading-relaxed font-medium whitespace-pre-wrap break-words roundtable-md">
|
||||
{msg.content}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<span className="text-[9px] text-slate-400 font-mono shrink-0">{msg.time}</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{!step1AtBottom && <ScrollToBottomButton onClick={scrollStep1ToBottom} />}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{!step1AtBottom && <ScrollToBottomButton onClick={scrollStep1ToBottom} />}
|
||||
</div>
|
||||
|
||||
{/* Botton Input Drawer Area (Ask/Reply Box) */}
|
||||
@@ -2897,7 +3091,7 @@ export default function RoundtablePlanningPage() {
|
||||
{/* Collapsed handle: when the upper panel is hidden, show a thin
|
||||
bar at the top of the conversation area so the user can bring
|
||||
it back. */}
|
||||
{isUpperPanelCollapsed && (
|
||||
{false && isUpperPanelCollapsed && (
|
||||
<div className="shrink-0 px-6 py-2 border-b border-slate-100 bg-white flex items-center justify-center">
|
||||
<button
|
||||
onClick={() => setIsUpperPanelCollapsed(false)}
|
||||
@@ -2911,7 +3105,7 @@ export default function RoundtablePlanningPage() {
|
||||
)}
|
||||
|
||||
{/* Split layout: Roundtable visualizer and Interactive Controllers */}
|
||||
{!isUpperPanelCollapsed && (
|
||||
{false && !isUpperPanelCollapsed && (
|
||||
<div className="shrink-0 px-6 py-5 bg-gradient-to-b from-[var(--brand-200)]/10 to-transparent border-b border-slate-100 bg-white relative">
|
||||
{/* Close button — collapses this whole upper panel so the
|
||||
conversation log takes the freed vertical space. */}
|
||||
@@ -3252,6 +3446,17 @@ export default function RoundtablePlanningPage() {
|
||||
ref={step2ScrollRef}
|
||||
className="flex-1 min-h-0 overflow-y-auto p-6 space-y-4 bg-white border-t border-slate-150 border-b border-slate-150 shadow-inner"
|
||||
>
|
||||
{/* 初始化期间(创建协调智能体 + 各席位 thread)对话列表是空的,
|
||||
会有 1-3 秒 UI 空白让用户感觉卡住 —— 加居中加载占位,
|
||||
用文案告诉用户后端正在做什么。dialogues.length === 0 收紧条件,
|
||||
避免后续 reset 时短暂闪过(reset 完会立即 init,有覆盖期)。 */}
|
||||
{isInitializing && step2RoundtableDialogues.length === 0 && (
|
||||
<div className="flex h-full flex-col items-center justify-center gap-3 py-12 text-slate-500">
|
||||
<Loader2 className="w-8 h-8 animate-spin text-primary" />
|
||||
<div className="text-sm font-medium text-slate-700">正在初始化圆桌...</div>
|
||||
<div className="text-xs text-slate-400">正在为各席位建立独立线程,请稍候</div>
|
||||
</div>
|
||||
)}
|
||||
{step2RoundtableDialogues.map((msg) => (
|
||||
<div
|
||||
key={msg.id}
|
||||
@@ -3270,16 +3475,100 @@ export default function RoundtablePlanningPage() {
|
||||
</div>
|
||||
<span className="text-[10px] text-slate-400 font-mono font-medium">{msg.time}</span>
|
||||
</div>
|
||||
|
||||
{/* 步骤折叠卡(视觉 + 文案与 chats/new 消息列表的 ChainOfThought 对齐):
|
||||
位于生成内容**上方**;**始终默认收起**(避免抢占注意力),
|
||||
收起 header 上显示最新一步的图标 + 文案作为预览。
|
||||
openSteps[msg.id] 用户手动覆盖优先。
|
||||
每一步根据 step.key(`phase:toolName`)分配工具图标 + 中文化文案,
|
||||
例如 `tool_calling:agent_orchestration` → 扳手 + 「使用 "..." 工具」。 */}
|
||||
{Array.isArray(msg.steps) && msg.steps.length > 0 && (() => {
|
||||
const stepsOpen = openSteps[msg.id] ?? false;
|
||||
const lastStep = msg.steps[msg.steps.length - 1];
|
||||
const lastDisplay = lastStep
|
||||
? getStepDisplay(lastStep.key, lastStep.label)
|
||||
: null;
|
||||
const LastIcon = lastDisplay?.icon;
|
||||
return (
|
||||
<ChainOfThought
|
||||
className="rounded-md border border-slate-200 bg-slate-50/60 px-3 py-2"
|
||||
open={stepsOpen}
|
||||
onOpenChange={(v) => setOpenSteps((prev) => ({ ...prev, [msg.id]: v }))}
|
||||
>
|
||||
<ChainOfThoughtHeader
|
||||
className="text-[11px]"
|
||||
icon={
|
||||
// 仅在「生成中 + 收起」时显示最新一步的工具图标(作进度预览);
|
||||
// 完成后用默认脑子图标 + 「步骤列表」标题,提示这是历史时间线。
|
||||
!stepsOpen && msg.streaming && LastIcon ? (
|
||||
<LastIcon className="size-3.5 text-slate-500" />
|
||||
) : undefined
|
||||
}
|
||||
>
|
||||
{stepsOpen
|
||||
? "步骤"
|
||||
: msg.streaming
|
||||
? (lastDisplay?.label ?? `查看 ${msg.steps.length} 个步骤`)
|
||||
: "步骤列表"}
|
||||
</ChainOfThoughtHeader>
|
||||
<ChainOfThoughtContent>
|
||||
{msg.steps.map(
|
||||
(
|
||||
s: {
|
||||
id: string;
|
||||
key: string;
|
||||
label: string;
|
||||
ts: string;
|
||||
args?: Record<string, unknown>;
|
||||
},
|
||||
i: number,
|
||||
) => {
|
||||
const display = getStepDisplay(s.key, s.label);
|
||||
const argNode = renderStepArgs(s.key, s.args);
|
||||
return (
|
||||
<ChainOfThoughtStep
|
||||
key={s.id}
|
||||
icon={display.icon}
|
||||
label={
|
||||
<span className="text-[12px] text-slate-700">
|
||||
<span className="font-medium">{display.label}</span>
|
||||
<span className="ml-2 text-[10px] text-slate-400 font-mono">{s.ts}</span>
|
||||
</span>
|
||||
}
|
||||
status={
|
||||
msg.streaming && i === msg.steps.length - 1
|
||||
? "active"
|
||||
: "complete"
|
||||
}
|
||||
>
|
||||
{argNode}
|
||||
</ChainOfThoughtStep>
|
||||
);
|
||||
},
|
||||
)}
|
||||
</ChainOfThoughtContent>
|
||||
</ChainOfThought>
|
||||
);
|
||||
})()}
|
||||
|
||||
<div className="text-xs text-slate-700 leading-relaxed font-medium break-words roundtable-md">
|
||||
{/* Pre-streaming hint — when the bubble is created but
|
||||
no AI token has arrived yet, show a small spinner
|
||||
+ the current phase label so the user can see the
|
||||
backend is doing something (调度中 → 已连接 →
|
||||
正在派活/调用工具 → 流式输出). */}
|
||||
{/* 气泡刚创建、token 还没到 —— 显示更显眼的"思考中"动画。
|
||||
首字节通常 1-2s,之前是 12px 行内小 spinner,用户感受不到
|
||||
后端在工作。换成稍大 spinner + 跳动点,与气泡正文同色阶。 */}
|
||||
{msg.streaming && !msg.content && (
|
||||
<div className="flex items-center gap-2 py-1 text-[11px] text-slate-500 italic">
|
||||
<Loader2 className="w-3 h-3 animate-spin text-primary" />
|
||||
<span>{msg.confidence}</span>
|
||||
<div className="flex items-center gap-2 py-1.5 text-xs text-slate-600">
|
||||
<Loader2 className="w-4 h-4 animate-spin text-primary" />
|
||||
<span className="font-medium">{msg.confidence}</span>
|
||||
<span className="inline-flex items-center gap-0.5">
|
||||
<span className="w-1 h-1 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.3s]" />
|
||||
<span className="w-1 h-1 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.15s]" />
|
||||
<span className="w-1 h-1 rounded-full bg-primary/70 animate-bounce" />
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
<ReactMarkdown
|
||||
@@ -3510,8 +3799,8 @@ export default function RoundtablePlanningPage() {
|
||||
|
||||
{currentStep === 3 ? (
|
||||
<>
|
||||
{/* Panel 1: 最终共识结论 (Final Consensus Conclusion) */}
|
||||
<div className="bg-white border border-slate-200/50 rounded-2xl p-4.5 shadow-[0_2px_8px_rgba(0,0,0,0.015)] transition hover:shadow-md">
|
||||
{/* Panel 1: 最终共识结论 —— 暂时隐藏(等真实研讨结论接入后再恢复) */}
|
||||
<div className="hidden bg-white border border-slate-200/50 rounded-2xl p-4.5 shadow-[0_2px_8px_rgba(0,0,0,0.015)] transition hover:shadow-md">
|
||||
<div className="flex items-center gap-2 border-b border-slate-100 pb-2.5 mb-3.5">
|
||||
<CheckCircle className="w-4 h-4 text-emerald-500" strokeWidth={2.5} />
|
||||
<h2 className="text-xs font-black text-slate-900 uppercase tracking-widest">最终共识结论</h2>
|
||||
@@ -3559,8 +3848,8 @@ export default function RoundtablePlanningPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Panel 2: 风险与预算摘要 (Risks & Budget Summary) */}
|
||||
<div className="bg-white border border-slate-200/50 rounded-2xl p-4.5 shadow-[0_2px_8px_rgba(0,0,0,0.015)] transition hover:shadow-md flex-1 flex flex-col min-h-[300px]">
|
||||
{/* Panel 2: 风险与预算摘要 —— 暂时隐藏(写死示例,等真实风险/预算数据接入再恢复) */}
|
||||
<div className="hidden bg-white border border-slate-200/50 rounded-2xl p-4.5 shadow-[0_2px_8px_rgba(0,0,0,0.015)] transition hover:shadow-md flex-1 flex flex-col min-h-[300px]">
|
||||
<div className="flex items-center gap-2 border-b border-slate-100 pb-2.5 mb-3 shrink-0">
|
||||
<AlertTriangle className="w-4 h-4 text-amber-500" strokeWidth={2.5} />
|
||||
<h2 className="text-xs font-black text-slate-900 uppercase tracking-widest">风险与预算摘要</h2>
|
||||
@@ -3626,8 +3915,8 @@ export default function RoundtablePlanningPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Panel 3: 导出与交付 (Export and Delivery) */}
|
||||
<div className="bg-white border border-slate-200/50 rounded-2xl p-4.5 shadow-[0_2px_8px_rgba(0,0,0,0.015)] shrink-0">
|
||||
{/* Panel 3: 导出与交付 —— 暂时隐藏(无真实导出能力接入) */}
|
||||
<div className="hidden bg-white border border-slate-200/50 rounded-2xl p-4.5 shadow-[0_2px_8px_rgba(0,0,0,0.015)] shrink-0">
|
||||
<div className="flex items-center gap-2 border-b border-slate-100 pb-2.5 mb-2.5">
|
||||
<Share2 className="w-4 h-4 text-primary" strokeWidth={2.5} />
|
||||
<h2 className="text-xs font-black text-slate-900 uppercase tracking-widest">导出与交付</h2>
|
||||
|
||||
Reference in new issue
Block a user