feat(frontend): 支持 Roundtable 写文件流式预览与消息流聚合展示
功能说明:\n- 为写文件工具链增加流式预览状态模型(in-flight、chunk 归并、已完成)\n- 在消息面板中支持 write_file 流式 artifact 的动态插入/更新与完成态呈现\n- 优化 artifact 详情页的文件名与来源显示,兼容流式生成中文件路径\n- 在 Roundtable 工作流 step2 流程中注入与监听 write_file 事件,支持多阶段消息统一展示\n- 补充单测覆盖:streaming-write-preview、write-file-in-flight、streaming-artifacts 等关键路径
This commit is contained in:
1 parent
553f72604a
commit
f5bf7897b9
11 files changed
+266
-44
No files matched your search
@@ -42,6 +42,37 @@ export function resolveRoundtableStreamingWritePreview(
|
||||
return languageOfStreamingArtifact(path) ? path : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge successive snapshots of one streaming tool call without losing bytes
|
||||
* that arrived in an earlier SSE frame.
|
||||
*
|
||||
* LangChain's partial JSON snapshots frequently contain only `path` while the
|
||||
* complete `content` has already been received (and the inverse can happen
|
||||
* while the path key is still incomplete). A click on a progress step also
|
||||
* carries the deliberately compact `{ path }` payload. Blindly replacing the
|
||||
* prior args with either shape empties the virtual write_file preview.
|
||||
*/
|
||||
export function mergeRoundtableStreamingToolArgs(
|
||||
previous: Record<string, unknown> | undefined,
|
||||
incoming: Record<string, unknown>,
|
||||
): Record<string, unknown> {
|
||||
if (!previous) return { ...incoming };
|
||||
|
||||
const merged = { ...previous, ...incoming };
|
||||
for (const key of ["path", "content"] as const) {
|
||||
const prior = previous[key];
|
||||
const next = incoming[key];
|
||||
if (
|
||||
typeof prior === "string" &&
|
||||
prior.length > 0 &&
|
||||
!(typeof next === "string" && next.length > 0)
|
||||
) {
|
||||
merged[key] = prior;
|
||||
}
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
|
||||
/** Final artifact cards intentionally expose only user-facing deliverables. */
|
||||
export function collectRoundtableDeliverablePaths(values: Iterable<unknown>): string[] {
|
||||
const seen = new Set<string>();
|
||||
|
||||
Reference in new issue
Block a user