The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(mac): Download on a local render saves the file instead of failing quietly
purple2ff97bd8a1bc
diff --git a/src/components/create/experimental/OutputView.tsx b/src/components/create/experimental/OutputView.tsxindex 0e5c9452..37becb5d 100644--- a/src/components/create/experimental/OutputView.tsx+++ b/src/components/create/experimental/OutputView.tsx@@ -1,7 +1,7 @@import { motion } from 'framer-motion'import { Cpu, Sparkles, ImageDown, Maximize2, Download, Wand2, MonitorOff, AudioLines } from 'lucide-react'import { useCreateStore, type GalleryItem, type ProgressPhase } from '../../../stores/createStore'-import { downloadComfyFile, isTauri } from '../../../api/backend'+import { backendCall, downloadComfyFile, isTauri } from '../../../api/backend'import { refreshResultUrl } from '../../../api/cloud/jobs'import { markGalleryItemAvailable } from './galleryUrl'import { useComfyMedia } from './useComfyMedia'@@ -81,7 +81,50 @@ function extFor(contentType: string, kind: 'image' | 'video' | 'audio'): string// after the last read); dataUrl items decode in place. Tauri gets the native// Save-As dialog (WebView2 blob-anchors are unreliable); failures surface via// setError instead of a silent no-op.+/** Hand bytes to the user. Tauri gets the native Save-As dialog (WebView2+ * blob-anchors are unreliable); the browser build gets an anchor click. */+async function saveBytes(bytes: Uint8Array, name: string, ext: string): Promise<void> {+ if (!isTauri()) {+ const blobUrl = URL.createObjectURL(new Blob([bytes as BlobPart]))+ const a = document.createElement('a')+ a.href = blobUrl+ a.download = name+ document.body.appendChild(a)+ a.click()+ document.body.removeChild(a)+ URL.revokeObjectURL(blobUrl)+ return+ }+ const { invoke } = await import('@tauri-apps/api/core')+ // Returns the chosen path, or null if the user cancelled — nothing to do then.+ await invoke('save_binary_file_dialog', {+ bytes: Array.from(bytes),+ defaultName: name,+ extension: ext,+ extLabel: ext.toUpperCase(),+ })+}+async function downloadGalleryItem(item: GalleryItem): Promise<void> {+ // A local MLX render (Mac) carries BOTH a filename and a real file on disk.+ // The filename is ours, not a ComfyUI output name — routing on its mere+ // presence sent every Mac render into the ComfyUI proxy below, which cannot+ // answer here, and downloadComfyFile swallows the failure. Disk first.+ if (item.localPath) {+ try {+ const b64 = await backendCall<string>('read_media_file', { path: item.localPath })+ const binary = atob(b64)+ const bytes = new Uint8Array(binary.length)+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i)+ const ext = item.localPath.toLowerCase().endsWith('.mp4') ? 'mp4' : 'png'+ await saveBytes(bytes, `lu-${item.id}.${ext}`, ext)+ } catch (err) {+ useCreateStore+ .getState()+ .setError(`Download failed: ${err instanceof Error ? err.message : String(err)}`)+ }+ return+ }if (item.filename && item.unavailable) {// The item's media already failed to load — the ComfyUI fetch would only// fail again (and downloadComfyFile swallows its errors). Be honest.@@ -101,27 +144,8 @@ async function downloadGalleryItem(item: GalleryItem): Promise<void> {const res = await fetch(url)if (!res.ok) throw new Error(`fetch failed (${res.status})`)const ext = extFor(res.headers.get('content-type') ?? '', item.type)- const name = `lu-${item.id}.${ext}`const bytes = new Uint8Array(await res.arrayBuffer())- if (!isTauri()) {- const blobUrl = URL.createObjectURL(new Blob([bytes]))- const a = document.createElement('a')- a.href = blobUrl- a.download = name- document.body.appendChild(a)- a.click()- document.body.removeChild(a)- URL.revokeObjectURL(blobUrl)- return- }- const { invoke } = await import('@tauri-apps/api/core')- // Returns the chosen path, or null if the user cancelled — nothing to do then.- await invoke('save_binary_file_dialog', {- bytes: Array.from(bytes),- defaultName: name,- extension: ext,- extLabel: ext.toUpperCase(),- })+ await saveBytes(bytes, `lu-${item.id}.${ext}`, ext)} catch (err) {useCreateStore.getState()