mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-07-21 10:15:47 +00:00
fix(front): stabilize artifact paths during streaming (#4094)
This commit is contained in:
@@ -691,6 +691,8 @@ export function MessageList({
|
||||
return <MessageListSkeleton />;
|
||||
}
|
||||
|
||||
const artifactPaths = extractArtifactsFromThread(thread);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Conversation
|
||||
@@ -731,7 +733,7 @@ export function MessageList({
|
||||
groupIndex === groupedMessages.length - 1
|
||||
}
|
||||
threadId={threadId}
|
||||
artifactPaths={extractArtifactsFromThread(thread)}
|
||||
artifactPaths={artifactPaths}
|
||||
runId={
|
||||
group.type === "assistant"
|
||||
? (msg as { run_id?: string }).run_id
|
||||
|
||||
@@ -2,6 +2,8 @@ import { getBackendBaseURL } from "../config";
|
||||
import { isStaticWebsiteOnly } from "../static-mode";
|
||||
import type { AgentThreadState } from "../threads";
|
||||
|
||||
const EMPTY_ARTIFACT_PATHS: readonly string[] = [];
|
||||
|
||||
export function urlOfArtifact({
|
||||
filepath,
|
||||
threadId,
|
||||
@@ -25,7 +27,7 @@ export function urlOfArtifact({
|
||||
export function extractArtifactsFromThread(thread: {
|
||||
values: Pick<AgentThreadState, "artifacts">;
|
||||
}) {
|
||||
return thread.values.artifacts ?? [];
|
||||
return thread.values.artifacts ?? EMPTY_ARTIFACT_PATHS;
|
||||
}
|
||||
|
||||
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");
|
||||
});
|
||||
|
||||
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 () => {
|
||||
const { resolveMessageImageURL } = await loadFreshArtifactUtils();
|
||||
const artifacts = [
|
||||
|
||||
Reference in New Issue
Block a user