diff --git a/frontend/src/app/workspace/agents/new/page.tsx b/frontend/src/app/workspace/agents/new/page.tsx index 67ec49315..e006cf88a 100644 --- a/frontend/src/app/workspace/agents/new/page.tsx +++ b/frontend/src/app/workspace/agents/new/page.tsx @@ -45,6 +45,7 @@ import { type HumanInputResponse, } from "@/core/messages/human-input"; import { isHiddenFromUIMessage } from "@/core/messages/utils"; +import { safeLocalStorage } from "@/core/settings/local"; import { useThreadStream } from "@/core/threads/hooks"; import { uuid } from "@/core/utils/uuid"; import { isIMEComposing } from "@/lib/ime"; @@ -130,11 +131,11 @@ export default function NewAgentPage() { if (typeof window === "undefined" || step !== "chat") { return; } - if (window.localStorage.getItem(SAVE_HINT_STORAGE_KEY) === "1") { + if (safeLocalStorage.getItem(SAVE_HINT_STORAGE_KEY) === "1") { return; } setShowSaveHint(true); - window.localStorage.setItem(SAVE_HINT_STORAGE_KEY, "1"); + safeLocalStorage.setItem(SAVE_HINT_STORAGE_KEY, "1"); }, [step]); const handleConfirmName = useCallback(async () => { diff --git a/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx b/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx index 546a9d8a5..d77d75031 100644 --- a/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx +++ b/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx @@ -129,7 +129,13 @@ export function ArtifactFileDetail({ }, [filepath]); const { isCodeFile, language } = useMemo(() => { if (isWriteFile) { - let language = checkCodeFile(filepath).language; + const codeResult = checkCodeFile(filepath); + // Non-code browser-previewable files (PDF, images, audio, video) + // should render in the sandboxed iframe, not the code editor. + if (!codeResult.isCodeFile && canBrowserPreviewFile(filepath)) { + return codeResult; + } + let language = codeResult.language; language ??= "text"; return { isCodeFile: true, language }; } @@ -360,6 +366,7 @@ export function ArtifactFileDetail({ {!isCodeFile && canPreviewInBrowser && (