mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-04-25 11:18:22 +00:00
fix(artifact): enhance artifact content loading to include URL for non-write files (#1678)
This commit is contained in:
parent
6ff60f2af1
commit
cf43584d24
@ -83,7 +83,7 @@ export function ArtifactFileDetail({
|
||||
const isSupportPreview = useMemo(() => {
|
||||
return language === "html" || language === "markdown";
|
||||
}, [language]);
|
||||
const { content } = useArtifactContent({
|
||||
const { content, url } = useArtifactContent({
|
||||
threadId,
|
||||
filepath: filepathFromProps,
|
||||
enabled: isCodeFile && !isWriteFile,
|
||||
@ -240,7 +240,9 @@ export function ArtifactFileDetail({
|
||||
(language === "markdown" || language === "html") && (
|
||||
<ArtifactFilePreview
|
||||
content={displayContent}
|
||||
isWriteFile={isWriteFile}
|
||||
language={language ?? "text"}
|
||||
url={url}
|
||||
/>
|
||||
)}
|
||||
{isCodeFile && viewMode === "code" && (
|
||||
@ -263,10 +265,14 @@ export function ArtifactFileDetail({
|
||||
|
||||
export function ArtifactFilePreview({
|
||||
content,
|
||||
isWriteFile,
|
||||
language,
|
||||
url,
|
||||
}: {
|
||||
content: string;
|
||||
isWriteFile: boolean;
|
||||
language: string;
|
||||
url?: string;
|
||||
}) {
|
||||
if (language === "markdown") {
|
||||
return (
|
||||
@ -286,8 +292,8 @@ export function ArtifactFilePreview({
|
||||
<iframe
|
||||
className="size-full"
|
||||
title="Artifact preview"
|
||||
srcDoc={content}
|
||||
sandbox="allow-scripts allow-forms"
|
||||
{...(isWriteFile ? { srcDoc: content } : url ? { src: url } : {})}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@ -34,5 +34,10 @@ export function useArtifactContent({
|
||||
// Cache artifact content for 5 minutes to avoid repeated fetches (especially for .skill ZIP extraction)
|
||||
staleTime: 5 * 60 * 1000,
|
||||
});
|
||||
return { content: isWriteFile ? content : data, isLoading, error };
|
||||
return {
|
||||
content: isWriteFile ? content : data?.content,
|
||||
url: isWriteFile ? undefined : data?.url,
|
||||
isLoading,
|
||||
error,
|
||||
};
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ export async function loadArtifactContent({
|
||||
const url = urlOfArtifact({ filepath: enhancedFilepath, threadId, isMock });
|
||||
const response = await fetch(url);
|
||||
const text = await response.text();
|
||||
return text;
|
||||
return { content: text, url };
|
||||
}
|
||||
|
||||
export function loadArtifactContentFromToolCall({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user