This commit is contained in:
fengxiangdebaozi committed 2026-06-23 21:52:27 +08:00
commit e3631a9fd6
2 files changed
+173 -9

No files matched your search

@@ -837,12 +837,22 @@ export function useStep2Orchestration(
const findSeatArtifactSource = useCallback(
(
rawPath: string,
): { seatThreadId: string; messageId: string; toolCallId: string } | null => {
): {
seatThreadId: string;
messageId: string;
toolCallId: string;
/** stub 里捕获的文件内容(仅 write_file 有;str_replace / 跨账号草稿恢复时常为 undefined)。 */
content?: string;
} | null => {
const target = rawPath.trim();
if (!target) return null;
const targetBase = target.split("/").pop() ?? target;
const readContent = (tc: { args?: unknown }): string | undefined => {
const c = (tc.args as { content?: unknown })?.content;
return typeof c === "string" ? c : undefined;
};
let basenameMatch:
| { seatThreadId: string; messageId: string; toolCallId: string }
| { seatThreadId: string; messageId: string; toolCallId: string; content?: string }
| null = null;
for (const [seatThreadId, msgs] of Object.entries(
seatStubMessagesRef.current,
@@ -857,10 +867,10 @@ export function useStep2Orchestration(
: "";
if (!p) continue;
if (p === target) {
return { seatThreadId, messageId: msg.id, toolCallId: tc.id };
return { seatThreadId, messageId: msg.id, toolCallId: tc.id, content: readContent(tc) };
}
if (!basenameMatch && (p.split("/").pop() ?? p) === targetBase) {
basenameMatch = { seatThreadId, messageId: msg.id, toolCallId: tc.id };
basenameMatch = { seatThreadId, messageId: msg.id, toolCallId: tc.id, content: readContent(tc) };
}
}
}
@@ -879,10 +889,11 @@ export function useStep2Orchestration(
if (!normalized) return;
// present_files 呈现的文件多半是子智能体 write_file 写入的:真实内容/thread 在 stub 里。
// 先反查 stub 走虚拟预览(内存内容)—— 关闭沙箱后再点文件卡也能显示,且不受
// 总控 coordinator thread 在后端 artifacts 路由下 not found 的影响。
// 先反查 stub:**仅当 stub 内存里确有内容**(流式期间 / 草稿恢复时捕获了 write_file content)
// 才走虚拟预览——关闭沙箱后再点也能显示,且不受总控 coordinator thread 在 artifacts 路由
// not found 的影响。
const seatSource = findSeatArtifactSource(normalized);
if (seatSource) {
if (seatSource && typeof seatSource.content === "string" && seatSource.content.length > 0) {
const virtualUrl = buildWriteFileVirtualUrl(
normalized,
seatSource.messageId,
@@ -896,9 +907,14 @@ export function useStep2Orchestration(
return;
}
if (!threadId) return;
// stub 无内容(str_replace、或**别的账号**打开共享任务会商草稿时 stub 没带上内容)→ 落 HTTP
// artifacts 接口拉取。优先用真实「子席位 thread」(present_files 的文件物理落在子席位、且
// 是 thread_type=roundtable 线程,后端按对话创建者解析路径 + 放行跨账号访问),它比 coordinator
// thread 更可能命中(coordinator 没有该文件 → 404)。这是修复「跨账号看不到第二步文件产物」的关键。
const effectiveThreadId = seatSource?.seatThreadId || threadId;
if (!effectiveThreadId) return;
setActiveArtifactThreadId(threadId);
setActiveArtifactThreadId(effectiveThreadId);
const prev = artifactPathsRef.current;
if (!prev.includes(normalized)) {
const next = [...prev, normalized];