From 7bdf9412cc3db4696b5fcc6a3122d6f7202e5696 Mon Sep 17 00:00:00 2001 From: Huixin615 Date: Sun, 12 Jul 2026 09:00:12 +0800 Subject: [PATCH] fix(front): stabilize artifact paths during streaming (#4094) --- .../components/workspace/messages/message-list.tsx | 4 +++- frontend/src/core/artifacts/utils.ts | 4 +++- frontend/tests/unit/core/artifacts/utils.test.ts | 13 +++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/workspace/messages/message-list.tsx b/frontend/src/components/workspace/messages/message-list.tsx index 83e783cbb..d03ef19dc 100644 --- a/frontend/src/components/workspace/messages/message-list.tsx +++ b/frontend/src/components/workspace/messages/message-list.tsx @@ -691,6 +691,8 @@ export function MessageList({ return ; } + const artifactPaths = extractArtifactsFromThread(thread); + return ( <> ; }) { - return thread.values.artifacts ?? []; + return thread.values.artifacts ?? EMPTY_ARTIFACT_PATHS; } export function resolveArtifactURL(absolutePath: string, threadId: string) { diff --git a/frontend/tests/unit/core/artifacts/utils.test.ts b/frontend/tests/unit/core/artifacts/utils.test.ts index 091f652f2..29377bac9 100644 --- a/frontend/tests/unit/core/artifacts/utils.test.ts +++ b/frontend/tests/unit/core/artifacts/utils.test.ts @@ -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 = [