feat(roundtable): 增强多智能体 Step2 流式推理与产物展示

提交内容:将 roundtable 的流式消息拆分为文本与 think 推理,支持思考内容以 <think> 形式内联渲染,解决仅返回 reasoning token 时的内容空洞问题。新增 stream-reasoning 工具与单元测试,保证 reasoning 首包到正文的闭合行为稳定。

交互与预览修正:write_file/str_replace 工具的沙箱打开策略改为更接近实时席位行为,不再因为文件后缀限制阻塞临时脚本写入可视化;通过新增 streaming-artifacts 工具统一处理可预览路径、最终交付产物过滤与目录快照比对,支持 bash/脚本直接落盘场景在流式阶段自动发现新增文档。

体验细节:步骤面板文件卡片从工具路径与最终 artifact 统一收敛,避免 read_file 点击误触发;自动滚动逻辑新增布局高度抖动识别,防止模型推理渲染导致的误判向上滚动。
This commit is contained in:
董宏凯 committed 2026-08-31 16:45:01 +08:00
1 parent fbf9031e25
commit f0ddade8a7
9 files changed
+600 -106

No files matched your search

@@ -43,7 +43,7 @@ const SHOW_BACKGROUND_SUSPEND = true;
import { AutoGrowTextarea } from "@/components/ui/auto-grow-textarea";
import { PositionIntentInput } from "@/position-roundtable/components/PositionIntentInput";
import { useLocalSettings } from "@/core/settings";
import { languageOfStreamingArtifact } from "@/core/artifacts/streaming-write-preview";
import { collectRoundtableDeliverablePaths } from "@/roundtable-planning/lib/streaming-artifacts";
import { cn } from "@/lib/utils";
import type { MessageMetric } from "@/components/workspace/messages/use-message-metrics";
@@ -1086,7 +1086,7 @@ export function Step2Message({
const rawContent = msg.content ?? "";
const { content, reasoning } = splitInlineReasoning(rawContent);
const hasContent = content.length > 0;
const presentedFiles = collectPresentedFiles(msg.steps);
const presentedFiles = collectPresentedFiles(msg.steps, msg.artifactPaths);
const avatarInner = getAvatar(msg.avatarType, "h-9 w-9 shrink-0");
// 传了 onAvatarClick → 头像变成「按席位筛选」开关:点亮当前筛选席位,带光圈高亮。
@@ -1193,23 +1193,25 @@ function RoundtableSubtaskCard({
* 只能 write_file 写文件,单文件 path 在 args.path —— 也聚合进卡片,保证"凡是写了
* 成品文件就出可点的卡片"。
*
* write_file/str_replace 的 path 需过 `languageOfStreamingArtifact`(只认 .md/.html/
* write_file/str_replace 的 path 需过同一套交付物门槛(只认 .md/.html/
* .mermaid 等可预览产物,与主聊天 `ArtifactWriteToolCall` 的流式预览门槛同一套):
* 席位在沙箱里写的过程文件(fetch.py / r1.txt 等)与无扩展名的畸形路径不再出卡。
*/
function collectPresentedFiles(
steps: Step2Dialogue["steps"],
settledArtifactPaths?: string[],
): string[] {
if (!Array.isArray(steps) || steps.length === 0) return [];
const toolSteps = Array.isArray(steps) ? steps : [];
if (toolSteps.length === 0 && (!settledArtifactPaths || settledArtifactPaths.length === 0)) return [];
const out: string[] = [];
const seen = new Set<string>();
const add = (fp: unknown, requirePreviewable = false) => {
if (typeof fp !== "string" || !fp || seen.has(fp)) return;
if (requirePreviewable && !languageOfStreamingArtifact(fp)) return;
if (requirePreviewable && collectRoundtableDeliverablePaths([fp]).length === 0) return;
seen.add(fp);
out.push(fp);
};
for (const step of steps) {
for (const step of toolSteps) {
if (step.key === "tool_calling:present_files") {
const fps = step.args?.filepaths;
if (Array.isArray(fps)) fps.forEach((fp) => add(fp));
@@ -1222,6 +1224,9 @@ function collectPresentedFiles(
add(step.args?.path, true);
}
}
// A weak model may create a report through bash rather than present_files;
// the completed dialogue adds only real, user-facing document paths here.
settledArtifactPaths?.forEach((path) => add(path, true));
return out;
}