From f8e916bec98398c3bc3ff38c2a036fbfacc40b86 Mon Sep 17 00:00:00 2001 From: liyp Date: Sat, 15 Aug 2026 12:28:30 +0800 Subject: [PATCH 1/2] feat: add SVG preview and download to artifact panel --- .../components/sections/chat-artifact.tsx | 16 ++++++- .../features/chat/model/chat-artifacts.ts | 43 +++++++++++++++++-- frontend/i18n/messages/en-US/chat.json | 1 + frontend/i18n/messages/zh-CN/chat.json | 1 + frontend/shared/lib/artifact-preview.ts | 7 ++- 5 files changed, 60 insertions(+), 8 deletions(-) diff --git a/frontend/features/chat/components/sections/chat-artifact.tsx b/frontend/features/chat/components/sections/chat-artifact.tsx index 6bb9a2f0..65969261 100644 --- a/frontend/features/chat/components/sections/chat-artifact.tsx +++ b/frontend/features/chat/components/sections/chat-artifact.tsx @@ -177,8 +177,16 @@ function ChatArtifactPanel({ const handleDownload = React.useCallback(() => { if (!canPreview) return; + if (artifact.kind === "svg") { + downloadArtifactHTML( + resolveArtifactDownloadName(artifact.kind), + artifact.code, + "image/svg+xml;charset=utf-8", + ); + return; + } downloadArtifactHTML(resolveArtifactDownloadName(artifact.kind), previewHTML); - }, [artifact.kind, canPreview, previewHTML]); + }, [artifact.kind, artifact.code, canPreview, previewHTML]); return (