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(downloads): a bundle with cancelled files no longer reads as complete
purple0598e8901d2e
diff --git a/src/api/model-bundles.ts b/src/api/model-bundles.tsindex b1f1c7c3..ff978341 100644--- a/src/api/model-bundles.ts+++ b/src/api/model-bundles.ts@@ -1206,7 +1206,7 @@ export function getVideoBundles(): ModelBundle[] {},{name: 'LTX 2.5 · Small (GGUF Q4)',- description: 'The same video with sound model in a smaller 4 bit version for 16 GB graphics cards. Needs the ComfyUI-GGUF node pack, the install offers it. Slightly softer detail than the full version.',+ description: 'The same video with sound model in a smaller 4 bit version for 16 GB graphics cards. The ComfyUI-GGUF node pack it needs is installed with it. Slightly softer detail than the full version.',tags: ['LTX 2.5', 'Audio', 'GGUF'],totalSizeGB: 28.4,vramRequired: '16 GB',diff --git a/src/components/layout/DownloadBadge.tsx b/src/components/layout/DownloadBadge.tsxindex 763d3c09..00dc276a 100644--- a/src/components/layout/DownloadBadge.tsx+++ b/src/components/layout/DownloadBadge.tsx@@ -8,9 +8,9 @@ import { useDownloadStore } from '../../stores/downloadStore'import { isPermanentDownloadError } from '../../api/discover'import { useMlxInstallStore } from '../../stores/mlxInstallStore'import { isMlxImageHost } from '../../api/mlx-image'-import { formatBytes, countLabel } from '../../lib/formatters'+import { formatBytes } from '../../lib/formatters'import { HINWEIS_TEXT, PUNKT_FARBE } from '../../lib/hinweis'-import { trayAfterPulse, TRAY_CLOSED, NO_PULSE } from '../../lib/download-tray'+import { trayAfterPulse, trayBundles, bundleVerdict, TRAY_CLOSED, NO_PULSE } from '../../lib/download-tray'function ProgressBar({ progress }: { progress: number }) {return (@@ -44,13 +44,10 @@ export function DownloadBadge() {)const comfyActiveCount = comfyEntries.filter(([, d]) => d.status === 'downloading' || d.status === 'connecting').length- // Group comfyUI downloads by bundle name- const comfyBundles = new Map<string, { id: string; d: typeof comfyDownloads[string] }[]>()- for (const [id, d] of comfyEntries) {- const bundleName = bundleMap[id] || id // Ungrouped files show as individual- if (!comfyBundles.has(bundleName)) comfyBundles.set(bundleName, [])- comfyBundles.get(bundleName)!.push({ id, d })- }+ // Grouped by bundle, each bundle with the files the user cancelled+ // (lib/download-tray). Ungrouped files show as individual rows.+ const cancelledFiles = useDownloadStore(s => s.cancelled)+ const comfyBundles = trayBundles(Object.fromEntries(comfyEntries), bundleMap, cancelledFiles)// MLX installs (macOS image/video engines + models), fed by the Rust// install slots via mlxInstallStore.@@ -153,6 +150,10 @@ export function DownloadBadge() {onClick={() => {textEntries.filter(([, s]) => s.complete).forEach(([n]) => dismissPull(n))comfyEntries.filter(([, d]) => d.status === 'complete').forEach(([id]) => useDownloadStore.getState().dismiss(id))+ // A bundle that is over takes its cancelled files with it.+ useDownloadStore.getState().forgetCancelled(+ comfyBundles.filter(b => bundleVerdict(b).state !== 'running').flatMap(b => b.cancelled),+ )mlxEntries.filter(e => e.status === 'complete').forEach(e => useMlxInstallStore.getState().dismiss(e.kind))}}className="text-[0.6rem] text-gray-500 hover:text-gray-300 transition-colors"@@ -210,13 +211,18 @@ export function DownloadBadge() {})}{/* ComfyUI downloads (image/video models) — grouped by bundle */}- {Array.from(comfyBundles.entries()).map(([bundleName, files]) => {- const allComplete = files.every(f => f.d.status === 'complete')+ {comfyBundles.map((bundle) => {+ const { name: bundleName, files, cancelled } = bundle+ // 'partial' is a bundle whose remaining files all finished+ // while others were cancelled: nothing runs any more, and it+ // is not complete either.+ const verdict = bundleVerdict(bundle)+ const settled = verdict.state !== 'running'const totalBytes = files.reduce((s, f) => s + f.d.total, 0)const doneBytes = files.reduce((s, f) => s + f.d.progress, 0)const bundleProg = totalBytes > 0 ? (doneBytes / totalBytes) * 100 : 0const bundleSpeed = files.reduce((s, f) => s + (f.d.status === 'downloading' ? (f.d.speed || 0) : 0), 0)- const isBundle = files.length > 1+ const isBundle = files.length + cancelled.length > 1const failed = files.filter(f => f.d.status === 'error')// Der Grund, aus dem ein Download stehen blieb, in Worten. Eine// abgelehnte Uebertragung zeigte frueher nur einen Retry-Knopf,@@ -252,16 +258,42 @@ export function DownloadBadge() {{retryable.length > 0 && (<button onClick={() => retryable.forEach(f => useDownloadStore.getState().retry(f.id))} className="p-0.5 rounded hover:bg-red-500/20 text-red-400 hover:text-red-300 transition-colors" title="Retry failed"><RotateCcw size={11} /></button>)}- {allComplete ? (- <button onClick={() => files.forEach(f => useDownloadStore.getState().dismiss(f.id))} className="p-0.5 rounded hover:bg-white/10 text-gray-500 hover:text-gray-300 transition-colors" title={files.length === 1 ? 'Dismiss' : 'Dismiss all'}><X size={11} /></button>+ {settled ? (+ <button+ onClick={() => {+ files.forEach(f => useDownloadStore.getState().dismiss(f.id))+ useDownloadStore.getState().forgetCancelled(cancelled)+ }}+ className="p-0.5 rounded hover:bg-white/10 text-gray-500 hover:text-gray-300 transition-colors" title={isBundle ? 'Dismiss all' : 'Dismiss'}+ ><X size={11} /></button>) : (<button onClick={() => files.forEach(f => useDownloadStore.getState().cancel(f.id))} className="p-0.5 rounded hover:bg-white/10 text-gray-500 hover:text-gray-300 transition-colors" title={files.length === 1 ? 'Cancel' : 'Cancel all'}><X size={11} /></button>)}</div></div>- {allComplete ? (- <div className="flex items-center gap-1.5 text-green-400"><CheckCircle size={11} /><span className="text-[0.65rem]">Complete ({countLabel(files.length, 'file')})</span></div>+ {verdict.state === 'complete' ? (+ <div className="flex items-center gap-1.5 text-green-400"><CheckCircle size={11} /><span className="text-[0.65rem]">{verdict.line}</span></div>+ ) : verdict.state === 'partial' ? (+ // No check and no green: files of this bundle are+ // missing, and its card offers the download again.+ <>+ <p className={`text-[0.65rem] ${HINWEIS_TEXT.ruhig}`}>{verdict.line}</p>+ <div className="mt-1.5 space-y-0.5">+ {files.map(({ id, d }) => (+ <div key={id} className="flex items-center justify-between text-[0.55rem] text-gray-500">+ <span className="truncate flex-1 font-mono">{d.filename || id}</span>+ <span className="shrink-0 ml-2 text-green-400">Done</span>+ </div>+ ))}+ {cancelled.map((id) => (+ <div key={id} className="flex items-center justify-between text-[0.55rem] text-gray-500">+ <span className="truncate flex-1 font-mono">{id}</span>+ <span className="shrink-0 ml-2">Cancelled</span>+ </div>+ ))}+ </div>+ </>) : (<>{totalBytes > 0 && <ProgressBar progress={bundleProg} />}@@ -329,6 +361,12 @@ export function DownloadBadge() {</span></div>))}+ {cancelled.map((id) => (+ <div key={id} className="flex items-center justify-between text-[0.55rem] text-gray-500">+ <span className="truncate flex-1 font-mono">{id}</span>+ <span className="shrink-0 ml-2">Cancelled</span>+ </div>+ ))}</div>)}</>diff --git a/src/lib/__tests__/download-tray-cancelled-bundle.test.ts b/src/lib/__tests__/download-tray-cancelled-bundle.test.tsnew file mode 100644index 00000000..b022b3e9--- /dev/null+++ b/src/lib/__tests__/download-tray-cancelled-bundle.test.ts@@ -0,0 +1,63 @@+/**+ * The box, 03.10.2026: three of the five files of "LTX 2.5 · Small (GGUF Q4)"+ * were cancelled, and the tray then said "Complete (2 files)" with a green+ * check. The two finished files were all the tray still knew of the bundle, so+ * "every row is complete" was true and meant nothing. The tray now keeps the+ * cancelled files with their bundle and says what is done and what is not.+ *+ * Run: npx vitest run src/lib/__tests__/download-tray-cancelled-bundle.test.ts+ */+import { describe, it, expect } from 'vitest'+import { trayBundles, bundleVerdict } from '../download-tray'++const LTX = 'LTX 2.5 · Small (GGUF Q4)'+const FILES = [+ 'ltx-2.5-22b-distilled-transformer-bf16-Q4_K_M.gguf',+ 'gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors',+ 'ltx-2.5-video-vae-bf16.safetensors',+ 'ltx-2.5-audio-vae-bf16.safetensors',+ 'ltx-2.5-latent-spatial-upscaler-x2-bf16-1.0.safetensors',+]+const bundleMap = Object.fromEntries(FILES.map((f) => [f, LTX]))+const row = (filename: string, status: string) => ({ progress: 1, total: 1, speed: 0, filename, status })++describe('a bundle with cancelled files', () => {+ it('is not complete: the tray says what finished and what was cancelled', () => {+ const rows = { [FILES[3]]: row(FILES[3], 'complete'), [FILES[4]]: row(FILES[4], 'complete') }+ const [group] = trayBundles(rows, bundleMap, FILES.slice(0, 3))+ expect(group.name).toBe(LTX)+ expect(group.files.map((f) => f.id)).toEqual([FILES[3], FILES[4]])+ expect(group.cancelled).toEqual(FILES.slice(0, 3))+ expect(bundleVerdict(group)).toEqual({ state: 'partial', line: '2 of 5 files downloaded, 3 cancelled' })+ })++ it('one finished file and one cancelled reads in the singular', () => {+ const rows = { 'a.safetensors': row('a.safetensors', 'complete') }+ const [group] = trayBundles(rows, { 'a.safetensors': 'Pair', 'b.safetensors': 'Pair' }, ['b.safetensors'])+ expect(bundleVerdict(group).line).toBe('1 of 2 files downloaded, 1 cancelled')+ })++ it('a bundle whose files all finished is complete, as before', () => {+ const rows = Object.fromEntries(FILES.map((f) => [f, row(f, 'complete')]))+ const [group] = trayBundles(rows, bundleMap, [])+ expect(bundleVerdict(group)).toEqual({ state: 'complete', line: 'Complete (5 files)' })+ })++ it('a cancelled file that was started again is no longer cancelled', () => {+ const rows = { [FILES[0]]: row(FILES[0], 'downloading'), [FILES[3]]: row(FILES[3], 'complete') }+ const [group] = trayBundles(rows, bundleMap, [FILES[0]])+ expect(group.cancelled).toEqual([])+ expect(bundleVerdict(group).state).toBe('running')+ })++ it('a bundle with nothing left but cancelled files has no row at all', () => {+ expect(trayBundles({}, bundleMap, FILES)).toEqual([])+ })++ it('a single file outside any bundle keeps its own row', () => {+ const rows = { 'lora.safetensors': row('lora.safetensors', 'complete') }+ const [group] = trayBundles(rows, {}, [])+ expect(group.name).toBe('lora.safetensors')+ expect(bundleVerdict(group)).toEqual({ state: 'complete', line: 'Complete (1 file)' })+ })+})diff --git a/src/lib/download-tray.ts b/src/lib/download-tray.tsindex b042e4e3..56b76e05 100644--- a/src/lib/download-tray.ts+++ b/src/lib/download-tray.ts@@ -16,6 +16,8 @@* harness (vitest runs in `node`, there is no @testing-library).*/+import { countLabel } from './formatters'+/** Is the tray open, and was it the tray or the user that opened it. */export interface TrayState {open: boolean@@ -64,3 +66,57 @@ export const TRAY_CLOSED: TrayState = { open: false, auto: false }* auto-open effect did.*/export const NO_PULSE: DownloadPulse = { active: 0, any: false }++/** One row of the ComfyUI download list, as the tray reads it. */+interface TrayRow {+ status: string+}++/** The files of one bundle as the tray shows them: the rows that exist, and+ * the files the user cancelled. */+export interface TrayBundle<R extends TrayRow> {+ name: string+ files: { id: string; d: R }[]+ /** Cancelled by the user and not started again. */+ cancelled: string[]+}++/**+ * Group the download rows by bundle and keep each bundle's cancelled files+ * with it.+ *+ * The box, 03.10.2026: after "Cancel all" on a bundle with two finished and+ * three running files, the two finished rows were all that was left of it, and+ * "every row is complete" turned the group into "Complete (2 files)" with a+ * green check. A cancelled file has no row, so the group has to be told about+ * it. A file that has a row again (started once more) is not cancelled, and a+ * bundle with nothing but cancelled files is not listed: there is nothing to+ * show, and its card offers the download again.+ */+export function trayBundles<R extends TrayRow>(+ rows: Record<string, R>,+ bundleMap: Record<string, string>,+ cancelled: string[],+): TrayBundle<R>[] {+ const groups = new Map<string, TrayBundle<R>>()+ for (const [id, d] of Object.entries(rows)) {+ const name = bundleMap[id] || id+ if (!groups.has(name)) groups.set(name, { name, files: [], cancelled: [] })+ groups.get(name)!.files.push({ id, d })+ }+ for (const id of cancelled) {+ if (rows[id]) continue+ groups.get(bundleMap[id] || id)?.cancelled.push(id)+ }+ return [...groups.values()]+}++/** What the tray says about a bundle as a whole. `complete` is the only state+ * that gets the green check. */+export function bundleVerdict(bundle: TrayBundle<TrayRow>): { state: 'complete' | 'partial' | 'running'; line: string } {+ const done = bundle.files.filter((f) => f.d.status === 'complete').length+ if (done < bundle.files.length) return { state: 'running', line: '' }+ if (bundle.cancelled.length === 0) return { state: 'complete', line: `Complete (${countLabel(done, 'file')})` }+ const total = done + bundle.cancelled.length+ return { state: 'partial', line: `${done} of ${countLabel(total, 'file')} downloaded, ${bundle.cancelled.length} cancelled` }+}diff --git a/src/stores/__tests__/downloadStore-cancel-remembers.test.ts b/src/stores/__tests__/downloadStore-cancel-remembers.test.tsnew file mode 100644index 00000000..f1a01571--- /dev/null+++ b/src/stores/__tests__/downloadStore-cancel-remembers.test.ts@@ -0,0 +1,65 @@+/**+ * The other half of the cancelled bundle (lib/download-tray): the store+ * remembers which files the user cancelled, until they are started again or+ * the user clears the row. A finished file is never "cancelled": cancelling it+ * only made its row flicker out and back with the next poll.+ *+ * Run: npx vitest run src/stores/__tests__/downloadStore-cancel-remembers.test.ts+ */+import { describe, it, expect, vi, beforeEach } from 'vitest'++const cancelDownload = vi.fn(async () => {})++vi.mock('../../api/discover', async () => {+ const actual = await vi.importActual<typeof import('../../api/discover')>('../../api/discover')+ return {+ ...actual,+ getDownloadProgress: vi.fn(async () => ({})),+ cancelDownload: (...a: unknown[]) => cancelDownload(...(a as [])),+ clearDownloadEntry: vi.fn(async () => {}),+ }+})++import { useDownloadStore } from '../downloadStore'++const row = (filename: string, status: string) => ({ progress: 1, total: 2, speed: 0, filename, status })++beforeEach(() => {+ cancelDownload.mockClear()+ useDownloadStore.setState({+ downloads: {+ 'model.gguf': row('model.gguf', 'downloading'),+ 'vae.safetensors': row('vae.safetensors', 'complete'),+ },+ cancelled: [],+ bundleMap: { 'model.gguf': 'Bundle', 'vae.safetensors': 'Bundle' },+ } as never)+})++describe('cancel', () => {+ it('remembers the file it stopped', async () => {+ await useDownloadStore.getState().cancel('model.gguf')+ expect(cancelDownload).toHaveBeenCalledWith('model.gguf')+ expect(useDownloadStore.getState().downloads['model.gguf']).toBeUndefined()+ expect(useDownloadStore.getState().cancelled).toEqual(['model.gguf'])+ })++ it('leaves a finished file alone', async () => {+ await useDownloadStore.getState().cancel('vae.safetensors')+ expect(cancelDownload).not.toHaveBeenCalled()+ expect(useDownloadStore.getState().downloads['vae.safetensors']?.status).toBe('complete')+ expect(useDownloadStore.getState().cancelled).toEqual([])+ })++ it('starting the file again forgets the cancel', async () => {+ await useDownloadStore.getState().cancel('model.gguf')+ useDownloadStore.getState().setMeta('model.gguf', 'https://example.com/model.gguf', 'diffusion_models')+ expect(useDownloadStore.getState().cancelled).toEqual([])+ })++ it('clearing the bundle row forgets its cancelled files', async () => {+ await useDownloadStore.getState().cancel('model.gguf')+ useDownloadStore.getState().forgetCancelled(['model.gguf'])+ expect(useDownloadStore.getState().cancelled).toEqual([])+ })+})diff --git a/src/stores/downloadStore.ts b/src/stores/downloadStore.tsindex 0e7fe94a..9c445abd 100644--- a/src/stores/downloadStore.ts+++ b/src/stores/downloadStore.ts@@ -121,6 +121,10 @@ interface DownloadStoreState {bundleMap: BundleMap // filename → bundle name/** Partials found on disk with no transfer behind them, keyed by stem. */orphans: Record<string, OrphanEntry>+ /** Files the user cancelled and has not started again. The tray keeps them+ * with their bundle, so a bundle with cancelled files never reads as+ * complete (lib/download-tray). This session only. */+ cancelled: string[]polling: booleanpollInterval: ReturnType<typeof setInterval> | nullpollCount: number@@ -137,6 +141,8 @@ interface DownloadStoreState {resume: (id: string) => Promise<void>retry: (id: string) => Promise<void>dismiss: (id: string) => void+ /** The user cleared the bundle's row: its cancelled files go with it. */+ forgetCancelled: (ids: string[]) => voidscanOrphans: () => Promise<void>resumeOrphan: (stem: string) => Promise<void>discardOrphan: (stem: string) => Promise<void>@@ -229,6 +235,7 @@ export const useDownloadStore = create<DownloadStoreState>()(persist((set, get)downloadMeta: {},bundleMap: {},orphans: {},+ cancelled: [],polling: false,pollInterval: null,@@ -308,7 +315,9 @@ export const useDownloadStore = create<DownloadStoreState>()(persist((set, get)// entries that matter are the ones just started.for (const k of keys.slice(0, keys.length - META_LIMIT)) delete next[k]}- return { downloadMeta: next }+ // Every start goes through here first, so a file that is started+ // again stops counting as cancelled.+ return { downloadMeta: next, cancelled: s.cancelled.filter((f) => f !== filename) }})},@@ -349,13 +358,20 @@ export const useDownloadStore = create<DownloadStoreState>()(persist((set, get)/** The user aborting: the transfer stops AND the partial file goes. The one* path that is allowed to throw bytes away. */cancel: async (id: string) => {+ // A finished file has nothing to cancel. "Cancel all" on a bundle used to+ // drop its row too, and the next poll brought it straight back.+ if (get().downloads[id]?.status === 'complete') returnawait cancelDownload(id)set(s => {const updated = { ...s.downloads }delete updated[id]// An adopted orphan must go from BOTH places or the next poll re-adopts// the row the user just cancelled.- return { downloads: updated, orphans: withoutFilename(s.orphans, id) }+ return {+ downloads: updated,+ orphans: withoutFilename(s.orphans, id),+ cancelled: s.cancelled.includes(id) ? s.cancelled : [...s.cancelled, id],+ }})},@@ -435,6 +451,10 @@ export const useDownloadStore = create<DownloadStoreState>()(persist((set, get)})},+ forgetCancelled: (ids: string[]) => {+ set(s => ({ cancelled: s.cancelled.filter((f) => !ids.includes(f)) }))+ },+/*** Find `.download` files left behind by an earlier run and make them* reachable again.