mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-09-11 06:28:58 +00:00
fix(front): stabilize artifact paths during streaming (#4094)
This commit is contained in:
parent
88b0484898
commit
7bdf9412cc
@ -691,6 +691,8 @@ export function MessageList({
|
|||||||
return <MessageListSkeleton />;
|
return <MessageListSkeleton />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const artifactPaths = extractArtifactsFromThread(thread);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Conversation
|
<Conversation
|
||||||
@ -731,7 +733,7 @@ export function MessageList({
|
|||||||
groupIndex === groupedMessages.length - 1
|
groupIndex === groupedMessages.length - 1
|
||||||
}
|
}
|
||||||
threadId={threadId}
|
threadId={threadId}
|
||||||
artifactPaths={extractArtifactsFromThread(thread)}
|
artifactPaths={artifactPaths}
|
||||||
runId={
|
runId={
|
||||||
group.type === "assistant"
|
group.type === "assistant"
|
||||||
? (msg as { run_id?: string }).run_id
|
? (msg as { run_id?: string }).run_id
|
||||||
|
|||||||
@ -2,6 +2,8 @@ import { getBackendBaseURL } from "../config";
|
|||||||
import { isStaticWebsiteOnly } from "../static-mode";
|
import { isStaticWebsiteOnly } from "../static-mode";
|
||||||
import type { AgentThreadState } from "../threads";
|
import type { AgentThreadState } from "../threads";
|
||||||
|
|
||||||
|
const EMPTY_ARTIFACT_PATHS: readonly string[] = [];
|
||||||
|
|
||||||
export function urlOfArtifact({
|
export function urlOfArtifact({
|
||||||
filepath,
|
filepath,
|
||||||
threadId,
|
threadId,
|
||||||
@ -25,7 +27,7 @@ export function urlOfArtifact({
|
|||||||
export function extractArtifactsFromThread(thread: {
|
export function extractArtifactsFromThread(thread: {
|
||||||
values: Pick<AgentThreadState, "artifacts">;
|
values: Pick<AgentThreadState, "artifacts">;
|
||||||
}) {
|
}) {
|
||||||
return thread.values.artifacts ?? [];
|
return thread.values.artifacts ?? EMPTY_ARTIFACT_PATHS;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resolveArtifactURL(absolutePath: string, threadId: string) {
|
export function resolveArtifactURL(absolutePath: string, threadId: string) {
|
||||||
|
|||||||
@ -74,6 +74,19 @@ describe("artifact URL helpers", () => {
|
|||||||
).toBe("/demo/threads/thread-1/user-data/outputs/style.css");
|
).toBe("/demo/threads/thread-1/user-data/outputs/style.css");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("returns stable artifact path references", async () => {
|
||||||
|
const { extractArtifactsFromThread } = await loadFreshArtifactUtils();
|
||||||
|
const threadWithoutArtifacts = { values: {} };
|
||||||
|
const artifacts = ["/mnt/user-data/outputs/chart.png"];
|
||||||
|
|
||||||
|
expect(extractArtifactsFromThread(threadWithoutArtifacts)).toBe(
|
||||||
|
extractArtifactsFromThread(threadWithoutArtifacts),
|
||||||
|
);
|
||||||
|
expect(extractArtifactsFromThread({ values: { artifacts } })).toBe(
|
||||||
|
artifacts,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test("resolves a relative message image when it uniquely matches an artifact", async () => {
|
test("resolves a relative message image when it uniquely matches an artifact", async () => {
|
||||||
const { resolveMessageImageURL } = await loadFreshArtifactUtils();
|
const { resolveMessageImageURL } = await loadFreshArtifactUtils();
|
||||||
const artifacts = [
|
const artifacts = [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user