Skip to content

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.

fix(create): keep the sha256 on retry and resume, exact size check, per-subcategory op pick

purplef5a02eb04e23
diff --git a/src/api/__tests__/jsdoc-sits-on-its-own-function.test.ts b/src/api/__tests__/jsdoc-sits-on-its-own-function.test.ts
new file mode 100644
index 00000000..5708e809
--- /dev/null
+++ b/src/api/__tests__/jsdoc-sits-on-its-own-function.test.ts
@@ -0,0 +1,48 @@
+/**
+ * Der Kommentar "MiniMax H3's audio autoencoder" stand ueber isLtx25File
+ * (Opus-Endpruefung 02.10.2026). Jede dieser Funktionen traegt den Kommentar,
+ * der von ihr handelt, und keinen fremden.
+ *
+ * Run: npx vitest run src/api/__tests__/jsdoc-sits-on-its-own-function.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { join } from 'node:path'
+
+const src = readFileSync(join(process.cwd(), 'src/api/comfyui.ts'), 'utf8')
+
+/** The JSDoc block(s) directly above `export ... name(`. */
+function docAbove(name: string): string {
+ const at = src.search(new RegExp(`export (async )?function ${name}\\b`))
+ expect(at, name).toBeGreaterThan(0)
+ let end = at
+ let out = ''
+ // Walk upwards over the comment blocks that touch the function.
+ for (;;) {
+ const before = src.slice(0, end).trimEnd()
+ if (!before.endsWith('*/')) break
+ const start = before.lastIndexOf('/**')
+ if (start < 0) break
+ out = before.slice(start) + out
+ end = start
+ }
+ return out
+}
+
+describe('JSDoc in comfyui.ts', () => {
+ it('isLtx25File traegt nur seinen eigenen Kommentar', () => {
+ const d = docAbove('isLtx25File')
+ expect(d).toMatch(/LTX 2\.5/)
+ expect(d).not.toMatch(/MiniMax/)
+ })
+
+ it('findMiniMaxAudioVAE traegt den MiniMax-Kommentar', () => {
+ expect(docAbove('findMiniMaxAudioVAE')).toMatch(/MiniMax H3's audio autoencoder/)
+ })
+
+ it('findLtx25AudioVAE traegt den LTX-Kommentar', () => {
+ const d = docAbove('findLtx25AudioVAE')
+ expect(d).toMatch(/LTX 2\.5/)
+ expect(d).not.toMatch(/MiniMax/)
+ })
+})
diff --git a/src/api/__tests__/same-name-other-size-is-not-installed.test.ts b/src/api/__tests__/same-name-other-size-is-not-installed.test.ts
new file mode 100644
index 00000000..02b85016
--- /dev/null
+++ b/src/api/__tests__/same-name-other-size-is-not-installed.test.ts
@@ -0,0 +1,93 @@
+/**
+ * Eine gleichnamige Datei in anderer Groesse ist nicht das Modell (Opus-
+ * Endpruefung 02.10.2026). comfyicu's Kopie des Gemma-Encoders heisst wie das
+ * Original und ist 2412 Byte groesser. check_model_sizes meldet "vollstaendig"
+ * ab 50 % der Katalogschaetzung, und der Install ueberspringt jede Datei, die
+ * so gemeldet wird. Dort, wo der Katalog die Bytes genau kennt (sizeBytes),
+ * zaehlt nur die genaue Groesse.
+ *
+ * Run: npx vitest run src/api/__tests__/same-name-other-size-is-not-installed.test.ts
+ */
+import { describe, it, expect, vi, beforeAll, beforeEach } from 'vitest'
+
+const backendCall = vi.fn<(cmd: string, args?: unknown) => Promise<unknown>>()
+
+vi.mock('../backend', () => ({
+ backendCall: (...a: unknown[]) => backendCall(...(a as [string, unknown])),
+ fetchExternal: vi.fn(),
+}))
+vi.mock('../comfyui', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('../comfyui')>()),
+ readComfyFolderLists: async () => ({}),
+ filterPartialFiles: async (names: string[]) => new Set(names),
+ refreshComfyModels: async () => true,
+}))
+
+import { getVideoBundles } from '../model-bundles'
+
+let d: typeof import('../discover')
+beforeAll(async () => {
+ ;(globalThis as unknown as { window: EventTarget }).window = new EventTarget()
+ d = await import('../discover')
+})
+
+const bundle = () => getVideoBundles().find((b) => b.name === 'LTX 2.5 · Video with Sound')!
+const encoder = () => bundle().files.find((f) => f.subfolder === 'text_encoders')!
+
+/** What the disk holds: every file at its exact size, except the ones overridden. */
+function disk(override: Record<string, number> = {}) {
+ backendCall.mockImplementation(async (cmd, args) => {
+ if (cmd !== 'check_model_sizes') return { status: 'started', id: 'x', fits: true }
+ const files = (args as { files: Array<{ filename: string; expectedBytes: number }> }).files
+ return files.map((f) => {
+ const actual = override[f.filename] ?? bundle().files.find((b) => b.filename === f.filename)?.sizeBytes ?? f.expectedBytes
+ return { filename: f.filename, exists: true, actualBytes: actual, complete: actual >= f.expectedBytes * 0.5 }
+ })
+ })
+}
+
+beforeEach(() => { backendCall.mockReset() })
+
+describe('onDiskMatchesCatalog', () => {
+ it('ohne genaue Katalogzahl gilt die bisherige Meldung, mit ihr nur die genaue Groesse', () => {
+ expect(d.onDiskMatchesCatalog({}, { complete: true, actualBytes: 1 })).toBe(true)
+ expect(d.onDiskMatchesCatalog({ sizeBytes: 100 }, { complete: true, actualBytes: 100 })).toBe(true)
+ expect(d.onDiskMatchesCatalog({ sizeBytes: 100 }, { complete: true, actualBytes: 102 })).toBe(false)
+ expect(d.onDiskMatchesCatalog({ sizeBytes: 100 }, { complete: false, actualBytes: 100 })).toBe(false)
+ expect(d.onDiskMatchesCatalog({ sizeBytes: 100 }, undefined)).toBe(false)
+ })
+
+ it('jede LTX-2.5-Datei des Katalogs kennt ihre Bytes', () => {
+ for (const f of bundle().files) expect(f.sizeBytes, f.filename).toBeGreaterThan(0)
+ })
+})
+
+describe('die Karte', () => {
+ it('steht auf "installiert", wenn jede Datei genau stimmt', async () => {
+ disk()
+ expect((await d.checkBundlesInstalled([bundle()]))[bundle().name]).toBe(true)
+ expect(await d.checkBundleInstalled(bundle())).toBe(true)
+ })
+
+ it('bietet Get wieder an, wenn der Encoder 2412 Byte zu gross ist (comfyicu-Kopie)', async () => {
+ disk({ [encoder().filename!]: encoder().sizeBytes! + 2412 })
+ expect((await d.checkBundlesInstalled([bundle()]))[bundle().name]).toBe(false)
+ expect(await d.checkBundleInstalled(bundle())).toBe(false)
+ })
+})
+
+describe('der Install', () => {
+ it('ueberspringt die genaue Datei und holt die gleichnamige fremde neu (mit Pruefsumme)', async () => {
+ disk({ [encoder().filename!]: encoder().sizeBytes! + 2412 })
+ await d.installBundleComplete(bundle()).catch(() => { /* node packs, restart: not under test */ })
+ const started = backendCall.mock.calls.filter((c) => c[0] === 'download_model').map((c) => c[1] as Record<string, unknown>)
+ expect(started.map((s) => s.filename)).toEqual([encoder().filename])
+ expect(started[0].expectedSha256).toBe(encoder().sha256)
+ })
+
+ it('startet nichts, wenn alle Dateien genau stimmen', async () => {
+ disk()
+ await d.installBundleComplete(bundle()).catch(() => {})
+ expect(backendCall.mock.calls.filter((c) => c[0] === 'download_model')).toHaveLength(0)
+ })
+})
diff --git a/src/api/comfyui.ts b/src/api/comfyui.ts
index ee30aa1c..f5592dd4 100644
--- a/src/api/comfyui.ts
+++ b/src/api/comfyui.ts
@@ -1779,8 +1779,6 @@ export async function findFramePackCLIPPair(): Promise<{ clipL: string; llavaLla
return { clipL, llavaLlama3 }
}
-/** MiniMax H3's audio autoencoder. The model writes picture and sound into
- * one latent and decodes the sound half with this file. */
/** A file that says it is an LTX 2.5 one (ltx-2.5-..., gemma4-...-ltx-2.5-...). */
export function isLtx25File(name: string): boolean {
return /ltx[._\- ]?2[._\- ]?5/.test(name.toLowerCase())
@@ -1795,6 +1793,8 @@ export async function findLtx25AudioVAE(): Promise<string> {
throw new Error(`No LTX 2.5 audio VAE found. Download "ltx-2.5-audio-vae-bf16.safetensors" from the Model Manager.`)
}
+/** MiniMax H3's audio autoencoder. The model writes picture and sound into
+ * one latent and decodes the sound half with this file. */
export async function findMiniMaxAudioVAE(): Promise<string> {
const vaes = await getVAEModels()
const match = vaes.find(v => v.toLowerCase().includes('minimax_h3_audio_vae'))
diff --git a/src/api/discover.ts b/src/api/discover.ts
index 6ffbeda5..fac5760d 100644
--- a/src/api/discover.ts
+++ b/src/api/discover.ts
@@ -297,6 +297,16 @@ export function remoteBundleNotice(bundleName: string, r: RemoteBundleReport): s
// ─── Custom Node Installation ───
+/** Is the file on disk the catalog's file? `check_model_sizes` only says "plausibly
+ * there" (50 % of the catalog estimate). Where the catalog knows the byte count
+ * exactly (`sizeBytes`), a file of the same name and another size is a repack from
+ * another mirror, not this model, so it must not count as installed: Get is
+ * offered again and the downloader's own size check fetches the right file. */
+export function onDiskMatchesCatalog(file: { sizeBytes?: number }, check: { complete: boolean; actualBytes?: number } | undefined): boolean {
+ if (!check?.complete) return false
+ return file.sizeBytes == null || check.actualBytes === file.sizeBytes
+}
+
/** Check if ALL files in a bundle are completely downloaded (size validated) */
export async function checkBundleInstalled(bundle: ModelBundle): Promise<boolean> {
try {
@@ -310,7 +320,8 @@ export async function checkBundleInstalled(bundle: ModelBundle): Promise<boolean
if (files.length === 0) return false
const results: Array<{ filename: string; exists: boolean; actualBytes: number; complete: boolean }> =
await backendCall('check_model_sizes', { files })
- return results.every(r => r.complete)
+ const byName = new Map(results.map(r => [r.filename, r]))
+ return bundle.files.filter(f => f.subfolder && f.filename).every(f => onDiskMatchesCatalog(f, byName.get(f.filename!)))
} catch {
return false
}
@@ -340,10 +351,10 @@ export async function checkBundlesInstalled(bundles: ModelBundle[]): Promise<Rec
await backendCall('check_model_sizes', { files: checkFiles })
// Map results back to bundles
- const fileStatus = new Map(results.map(r => [r.filename, r.complete]))
+ const fileStatus = new Map(results.map(r => [r.filename, r]))
for (const bundle of bundles) {
const bundleFiles = bundle.files.filter(f => f.filename)
- result[bundle.name] = bundleFiles.length > 0 && bundleFiles.every(f => fileStatus.get(f.filename!) === true)
+ result[bundle.name] = bundleFiles.length > 0 && bundleFiles.every(f => onDiskMatchesCatalog(f, fileStatus.get(f.filename!)))
}
} catch {
// If check fails (e.g. no ComfyUI), all bundles are not installed
@@ -702,10 +713,14 @@ export async function installBundleComplete(bundle: ModelBundle): Promise<{ remo
.filter(f => f.subfolder && f.filename)
.map(f => ({ subfolder: f.subfolder!, filename: f.filename!, expectedBytes: f.sizeGB ? Math.round(f.sizeGB * 1_073_741_824) : 0 }))
if (checkFiles.length > 0) {
- const results: Array<{ filename: string; exists: boolean; complete: boolean }> =
+ const results: Array<{ filename: string; exists: boolean; actualBytes?: number; complete: boolean }> =
await backendCall('check_model_sizes', { files: checkFiles })
+ const byName = new Map(bundle.files.map(f => [f.filename, f]))
for (const r of results) {
- if (r.complete) installedFiles.add(r.filename)
+ // A same-named file of another size is not ours: leave it out of the set
+ // so the download starts, and download_model refetches on the size
+ // mismatch (judge_existing).
+ if (onDiskMatchesCatalog(byName.get(r.filename) ?? {}, r)) installedFiles.add(r.filename)
}
}
} catch { /* can't check · download everything */ }
@@ -1651,6 +1666,14 @@ export function lookupFileMeta(filename: string): FileMeta | null {
return null
}
+/** The catalog's digest and byte count for `filename`, but only when the catalog
+ * names the SAME address. For callers that build a download from a registry
+ * entry and would otherwise start it without the digest. */
+export function catalogDigestFor(filename: string, url: string): { sha256?: string; expectedBytes?: number } {
+ const cat = lookupFileMeta(filename)
+ return cat && cat.url === url ? { sha256: cat.sha256, expectedBytes: cat.expectedBytes } : {}
+}
+
/** Every filename the catalog can name. Used to turn an orphaned partial's
* stem back into a real download id — see `orphanFilename`. */
export function catalogFilenames(): string[] {
diff --git a/src/api/model-bundles.ts b/src/api/model-bundles.ts
index 840d22bd..fb1691b6 100644
--- a/src/api/model-bundles.ts
+++ b/src/api/model-bundles.ts
@@ -34,6 +34,9 @@ export interface DiscoverModel {
filename?: string
subfolder?: string // ComfyUI models subfolder: checkpoints, diffusion_models, vae, text_encoders
sizeGB?: number
+ /** Exact byte count, when the catalog knows it to the byte. A file of the same name
+ * and another size is NOT this file (a mirror's repack), so it never counts as installed. */
+ sizeBytes?: number
// Vision projector that belongs to `downloadUrl`. A text GGUF carries no
// image tower: llama.cpp keeps it in a separate mmproj file and only sees
// images when the server is started with `--mmproj`. When this is set the
@@ -941,6 +944,7 @@ export function getVideoBundles(): ModelBundle[] {
pulls: '', tags: ['Model', '21.5 GB'], updated: 'New',
downloadUrl: 'https://huggingface.co/comfyicu/LTX-2.5/resolve/main/diffusion_models/ltx-2.5-22b-distilled-transformer-comfy-int8-convrot.safetensors',
filename: 'ltx-2.5-22b-distilled-transformer-comfy-int8-convrot.safetensors', subfolder: 'diffusion_models', sizeGB: 20.03,
+ sizeBytes: 21504034224,
sha256: 'c4279eeff115cbeaca494bd2183e7d768c38fe85a184dc6afbb7159157c44334',
},
{
@@ -949,6 +953,7 @@ export function getVideoBundles(): ModelBundle[] {
pulls: '', tags: ['Text Encoder', '15.4 GB'], updated: 'New',
downloadUrl: 'https://huggingface.co/deAPI-ai/ltx2-5-22b-dist-int8/resolve/main/text_encoders/gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors',
filename: 'gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors', subfolder: 'text_encoders', sizeGB: 14.32,
+ sizeBytes: 15372969374,
sha256: '6ce688a0aa98a5fa36a9f1e6c3f42152a498cc2b53ee8c15674c64244f91487f',
},
{
@@ -957,6 +962,7 @@ export function getVideoBundles(): ModelBundle[] {
pulls: '', tags: ['VAE', '1.5 GB'], updated: 'New',
downloadUrl: 'https://huggingface.co/comfyicu/LTX-2.5/resolve/main/vae/ltx-2.5-video-vae-bf16.safetensors',
filename: 'ltx-2.5-video-vae-bf16.safetensors', subfolder: 'vae', sizeGB: 1.37,
+ sizeBytes: 1472223346,
sha256: '847e14ca7f3355debca0cea4eaa24ac0fbcdf0061da054ac89ca638a869ddba3',
},
{
@@ -965,6 +971,7 @@ export function getVideoBundles(): ModelBundle[] {
pulls: '', tags: ['VAE', '365 MB'], updated: 'New',
downloadUrl: 'https://huggingface.co/comfyicu/LTX-2.5/resolve/main/vae/ltx-2.5-audio-vae-bf16.safetensors',
filename: 'ltx-2.5-audio-vae-bf16.safetensors', subfolder: 'vae', sizeGB: 0.34,
+ sizeBytes: 364866540,
sha256: 'c52733d37f6a7fb7949c3dc0fb468c6cb2169e4d836983a73babb9f0d54837a5',
},
{
@@ -973,6 +980,7 @@ export function getVideoBundles(): ModelBundle[] {
pulls: '', tags: ['Upscaler', '996 MB'], updated: 'New',
downloadUrl: 'https://huggingface.co/comfyicu/LTX-2.5/resolve/main/latent_upscale_models/ltx-2.5-latent-spatial-upscaler-x2-bf16-1.0.safetensors',
filename: 'ltx-2.5-latent-spatial-upscaler-x2-bf16-1.0.safetensors', subfolder: 'latent_upscale_models', sizeGB: 0.93,
+ sizeBytes: 995778752,
sha256: 'eb5a71fe4068ee87ccdb1c3aa635e547ca76bd2d30ae20ae889f2c325c0677e8',
},
],
@@ -994,6 +1002,7 @@ export function getVideoBundles(): ModelBundle[] {
pulls: '', tags: ['Model', '12.2 GB', 'GGUF'], updated: 'New',
downloadUrl: 'https://huggingface.co/agosh/LTX-2.5-Comfy-GGUF/resolve/main/ltx-2.5-22b-distilled-transformer-bf16-Q4_K_M.gguf',
filename: 'ltx-2.5-22b-distilled-transformer-bf16-Q4_K_M.gguf', subfolder: 'diffusion_models', sizeGB: 11.38,
+ sizeBytes: 12220864608,
sha256: '0b1bca38240087117bb0d1379fdaf1bcdb53c40e63f5f9bcb1a7e793f9520cfb',
},
{
@@ -1002,6 +1011,7 @@ export function getVideoBundles(): ModelBundle[] {
pulls: '', tags: ['Text Encoder', '15.4 GB'], updated: 'New',
downloadUrl: 'https://huggingface.co/deAPI-ai/ltx2-5-22b-dist-int8/resolve/main/text_encoders/gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors',
filename: 'gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors', subfolder: 'text_encoders', sizeGB: 14.32,
+ sizeBytes: 15372969374,
sha256: '6ce688a0aa98a5fa36a9f1e6c3f42152a498cc2b53ee8c15674c64244f91487f',
},
{
@@ -1010,6 +1020,7 @@ export function getVideoBundles(): ModelBundle[] {
pulls: '', tags: ['VAE', '1.5 GB'], updated: 'New',
downloadUrl: 'https://huggingface.co/comfyicu/LTX-2.5/resolve/main/vae/ltx-2.5-video-vae-bf16.safetensors',
filename: 'ltx-2.5-video-vae-bf16.safetensors', subfolder: 'vae', sizeGB: 1.37,
+ sizeBytes: 1472223346,
sha256: '847e14ca7f3355debca0cea4eaa24ac0fbcdf0061da054ac89ca638a869ddba3',
},
{
@@ -1018,6 +1029,7 @@ export function getVideoBundles(): ModelBundle[] {
pulls: '', tags: ['VAE', '365 MB'], updated: 'New',
downloadUrl: 'https://huggingface.co/comfyicu/LTX-2.5/resolve/main/vae/ltx-2.5-audio-vae-bf16.safetensors',
filename: 'ltx-2.5-audio-vae-bf16.safetensors', subfolder: 'vae', sizeGB: 0.34,
+ sizeBytes: 364866540,
sha256: 'c52733d37f6a7fb7949c3dc0fb468c6cb2169e4d836983a73babb9f0d54837a5',
},
{
@@ -1026,6 +1038,7 @@ export function getVideoBundles(): ModelBundle[] {
pulls: '', tags: ['Upscaler', '996 MB'], updated: 'New',
downloadUrl: 'https://huggingface.co/comfyicu/LTX-2.5/resolve/main/latent_upscale_models/ltx-2.5-latent-spatial-upscaler-x2-bf16-1.0.safetensors',
filename: 'ltx-2.5-latent-spatial-upscaler-x2-bf16-1.0.safetensors', subfolder: 'latent_upscale_models', sizeGB: 0.93,
+ sizeBytes: 995778752,
sha256: 'eb5a71fe4068ee87ccdb1c3aa635e547ca76bd2d30ae20ae889f2c325c0677e8',
},
],
diff --git a/src/components/create/experimental/CreateContext.tsx b/src/components/create/experimental/CreateContext.tsx
index c00b047d..fc9b20a1 100644
--- a/src/components/create/experimental/CreateContext.tsx
+++ b/src/components/create/experimental/CreateContext.tsx
@@ -462,12 +462,17 @@ export function CreateExpProvider({ children }: { children: ReactNode }) {
const dl = useDownloadStore.getState()
const files = bundle.files.filter((f) => f.downloadUrl && f.filename && f.subfolder)
if (files.length > 1) dl.setBundleGroup(bundle.name, files.map((f) => f.filename!))
- for (const f of files) dl.setMeta(f.filename!, f.downloadUrl!, f.subfolder!)
+ for (const f of files) {
+ dl.setMeta(f.filename!, f.downloadUrl!, f.subfolder!, undefined, {
+ expectedBytes: f.sizeGB ? Math.round(f.sizeGB * 1_073_741_824) : undefined,
+ sha256: f.sha256,
+ })
+ }
dl.startPolling()
await downloadBundleFiles(
files.map((f) => ({
- filename: f.filename!, subfolder: f.subfolder!, downloadUrl: f.downloadUrl!, sizeGB: f.sizeGB,
+ filename: f.filename!, subfolder: f.subfolder!, downloadUrl: f.downloadUrl!, sizeGB: f.sizeGB, sha256: f.sha256,
})),
{
start: startModelDownload,
diff --git a/src/components/create/experimental/SpecialIntentControls.tsx b/src/components/create/experimental/SpecialIntentControls.tsx
index 75a1411d..d1a73529 100644
--- a/src/components/create/experimental/SpecialIntentControls.tsx
+++ b/src/components/create/experimental/SpecialIntentControls.tsx
@@ -18,7 +18,7 @@ import {
characterTrainerStatus, installCharacterTrainer, parseLocalCharacterLora,
TRAINER_BASE_FILES, baseDownloadRunning, baseDownloadPercent, type TrainerStatus,
} from '../../../api/trainer'
-import { startModelDownload, getDownloadProgress } from '../../../api/discover'
+import { startModelDownload, getDownloadProgress, catalogDigestFor } from '../../../api/discover'
import { useDownloadStore } from '../../../stores/downloadStore'
import { getLoraModels } from '../../../api/comfyui'
import { isWindows, isMacOS } from '../../../api/backend'
@@ -506,7 +506,7 @@ function LocalTrainControls() {
if (missing.length > 1) dl.setBundleGroup('Character Studio base models', missing.map((f) => f.filename))
for (const f of missing) {
dl.setMeta(f.filename, f.url, f.subfolder)
- try { await startModelDownload(f.url, f.subfolder, f.filename) } catch (e) {
+ try { const d = catalogDigestFor(f.filename, f.url); await startModelDownload(f.url, f.subfolder, f.filename, d.expectedBytes, d.sha256) } catch (e) {
setNote(e instanceof Error ? e.message : `Could not start ${f.filename}.`)
}
dl.startPolling()
diff --git a/src/components/models/DiscoverModels.tsx b/src/components/models/DiscoverModels.tsx
index 20b70497..1c9005cd 100644
--- a/src/components/models/DiscoverModels.tsx
+++ b/src/components/models/DiscoverModels.tsx
@@ -468,7 +468,10 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:
const filenames: string[] = []
for (const file of bundle.files) {
if (file.downloadUrl && file.filename && file.subfolder) {
- dlStore.getState().setMeta(file.filename, file.downloadUrl, file.subfolder)
+ dlStore.getState().setMeta(file.filename, file.downloadUrl, file.subfolder, undefined, {
+ expectedBytes: file.sizeGB ? Math.round(file.sizeGB * 1_073_741_824) : undefined,
+ sha256: file.sha256,
+ })
filenames.push(file.filename)
}
}
@@ -527,8 +530,9 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:
dlStore.getState().retry(f.filename)
} else if (!dl || (dl.status !== 'complete' && dl.status !== 'downloading' && dl.status !== 'connecting')) {
// File has no active download — start fresh
- dlStore.getState().setMeta(f.filename, f.downloadUrl, f.subfolder)
- startModelDownload(f.downloadUrl, f.subfolder, f.filename, f.sizeGB ? Math.round(f.sizeGB * 1_073_741_824) : undefined)
+ const expectedBytes = f.sizeGB ? Math.round(f.sizeGB * 1_073_741_824) : undefined
+ dlStore.getState().setMeta(f.filename, f.downloadUrl, f.subfolder, undefined, { expectedBytes, sha256: f.sha256 })
+ startModelDownload(f.downloadUrl, f.subfolder, f.filename, expectedBytes, f.sha256)
dlStore.getState().startPolling()
}
}
diff --git a/src/components/models/__tests__/die-loras-haben-einen-eigenen-reiter.test.tsx b/src/components/models/__tests__/die-loras-haben-einen-eigenen-reiter.test.tsx
index c701ecc7..61f543af 100644
--- a/src/components/models/__tests__/die-loras-haben-einen-eigenen-reiter.test.tsx
+++ b/src/components/models/__tests__/die-loras-haben-einen-eigenen-reiter.test.tsx
@@ -44,6 +44,7 @@ vi.mock('../../../api/backend', () => ({
isMacOS: () => false,
}))
vi.mock('../../../api/discover', () => ({
+ lookupFileMeta: () => null,
searchCivitaiModels: (query: string, type: string, key?: string, host?: string) =>
searchCivitaiModels(query, type, key, host),
// The panel downloads through startCivitaiDownload; for a safetensors LoRA
diff --git a/src/components/onboarding/__tests__/staerkeres-modell-aktiv-bei-zwei-wahlen.test.tsx b/src/components/onboarding/__tests__/staerkeres-modell-aktiv-bei-zwei-wahlen.test.tsx
index 64363313..988ac045 100644
--- a/src/components/onboarding/__tests__/staerkeres-modell-aktiv-bei-zwei-wahlen.test.tsx
+++ b/src/components/onboarding/__tests__/staerkeres-modell-aktiv-bei-zwei-wahlen.test.tsx
@@ -42,6 +42,7 @@ vi.mock('../../../api/backend', () => ({
secretDelete: vi.fn(),
}))
vi.mock('../../../api/discover', () => ({
+ lookupFileMeta: () => null,
detectProviderModelPath: vi.fn(async () => ''),
startModelDownloadToPath: (url: string, dir: string, filename: string, bytes?: number, sha?: string) =>
startModelDownloadToPath(url, dir, filename, bytes, sha),
diff --git a/src/hooks/useCreate.ts b/src/hooks/useCreate.ts
index 907d72ef..6f15c8d7 100644
--- a/src/hooks/useCreate.ts
+++ b/src/hooks/useCreate.ts
@@ -54,7 +54,7 @@ import { buildDynamicWorkflow, buildLocalOpWorkflow, checkVideoOutputCapability
import { getAllNodeInfo, clearNodeCache } from '../api/comfyui-nodes'
import { apiNodes, type ComfyApiGraph, type ComfyExecutionMessage, type ComfyHistoryEntry } from '../types/comfy-graph'
import { restartComfyForNewNodes } from '../api/comfy-restart'
-import { installCustomNodes, startModelDownload, getDownloadProgress, modelsNotVisibleInComfy, comfyModelTarget } from '../api/discover'
+import { installCustomNodes, startModelDownload, getDownloadProgress, modelsNotVisibleInComfy, comfyModelTarget, catalogDigestFor } from '../api/discover'
import { downloadBundleFiles, waitForModelsVisible } from '../lib/bundle-install'
import { buildWithFixups, wasDeclined, type FixupDeps } from '../lib/render-fixups'
import { useDownloadStore } from '../stores/downloadStore'
@@ -113,7 +113,7 @@ function renderFixupDeps(onStatus: (line: string) => void, signal?: AbortSignal)
for (const f of files) dl.setMeta(f.downloadFilename, f.downloadUrl, f.subfolder)
dl.startPolling()
await downloadBundleFiles(
- files.map((f) => ({ filename: f.downloadFilename, subfolder: f.subfolder, downloadUrl: f.downloadUrl, sizeGB: f.sizeGB })),
+ files.map((f) => ({ filename: f.downloadFilename, subfolder: f.subfolder, downloadUrl: f.downloadUrl, sizeGB: f.sizeGB, sha256: catalogDigestFor(f.downloadFilename, f.downloadUrl).sha256 })),
{
start: startModelDownload,
progress: getDownloadProgress,
diff --git a/src/lib/bundle-install.ts b/src/lib/bundle-install.ts
index da0b2e94..114b9013 100644
--- a/src/lib/bundle-install.ts
+++ b/src/lib/bundle-install.ts
@@ -93,11 +93,13 @@ export interface BundleFile {
subfolder: string
downloadUrl: string
sizeGB?: number
+ /** Pinned SHA-256 of the file. Sent with EVERY start, so a mirror that swaps the file fails the check. */
+ sha256?: string
}
export interface DownloadDeps {
/** start_model_download. Resolves once the transfer is registered, not done. */
- start: (url: string, subfolder: string, filename: string, expectedBytes?: number) =>
+ start: (url: string, subfolder: string, filename: string, expectedBytes?: number, sha256?: string) =>
Promise<{ status: string; error?: string }>
/** download_progress, the whole Rust map keyed by filename. */
progress: () => Promise<Record<string, DownloadProgress>>
@@ -130,7 +132,7 @@ async function downloadOneFile(file: BundleFile, fileLabel: string, deps: Downlo
const expected = file.sizeGB ? Math.round(file.sizeGB * 1_073_741_824) : undefined
onStatus?.(`${fileLabel}Starting ${file.filename}.`)
- const started = await start(file.downloadUrl, file.subfolder, file.filename, expected)
+ const started = await start(file.downloadUrl, file.subfolder, file.filename, expected, file.sha256)
if (started.status === 'error') {
throw new Error(started.error || `Could not start the ${file.filename} download.`)
}
diff --git a/src/stores/__tests__/cloud-op-pick-per-subcategory.test.ts b/src/stores/__tests__/cloud-op-pick-per-subcategory.test.ts
new file mode 100644
index 00000000..f3ccd1ff
--- /dev/null
+++ b/src/stores/__tests__/cloud-op-pick-per-subcategory.test.ts
@@ -0,0 +1,73 @@
+/**
+ * Jede Unterkategorie behaelt ihre eigene Modellwahl (Opus-Endpruefung
+ * 02.10.2026). cloudOpModel war ein gemeinsamer Platz fuer Lipsync, Musik,
+ * Verlaengern, Motion und Enhance Image: eine Wahl in Enhance Image loeschte die
+ * Musikwahl. Die Wahl ist nur Laufzeitzustand (nicht gespeichert), also gibt es
+ * keine gespeicherte Wahl, die zu migrieren waere.
+ *
+ * Run: npx vitest run src/stores/__tests__/cloud-op-pick-per-subcategory.test.ts
+ */
+import { describe, it, expect, beforeEach } from 'vitest'
+import { useCreateStore, opSlot } from '../createStore'
+
+const st = () => useCreateStore.getState()
+
+beforeEach(() => {
+ useCreateStore.setState({ cloudOpModel: '', cloudOpPicks: {}, cloudOp: null, utilityOp: null, removebg: false, mode: 'image', imageSubMode: 'text2img', videoSubMode: 't2v', characterTab: 'train' })
+})
+
+describe('die Wahl je Unterkategorie', () => {
+ it('Enhance Image loescht die Musikwahl nicht', () => {
+ st().setIntent('music')
+ st().setCloudOpModel('music-model-a')
+ st().setIntent('upscale')
+ expect(st().cloudOpModel).toBe('') // Enhance Image hat noch keine eigene Wahl
+ st().setCloudOpModel('seedvr2')
+ expect(st().cloudOpModel).toBe('seedvr2')
+ st().setIntent('music')
+ expect(st().cloudOpModel).toBe('music-model-a')
+ st().setIntent('upscale')
+ expect(st().cloudOpModel).toBe('seedvr2')
+ })
+
+ it('Lipsync, Musik, Verlaengern und Motion halten je ihre Wahl', () => {
+ const picks: Record<string, string> = { lipsync: 'l-1', music: 'm-1', extend: 'e-1', motion: 'mo-1', upscale: 'u-1' }
+ for (const [intent, id] of Object.entries(picks)) {
+ st().setIntent(intent as never)
+ st().setCloudOpModel(id)
+ }
+ for (const [intent, id] of Object.entries(picks)) {
+ st().setIntent(intent as never)
+ expect(st().cloudOpModel, intent).toBe(id)
+ }
+ })
+
+ it('eine Wahl, die ohne setter geschrieben wird (setState), gehoert der aktuellen Unterkategorie', () => {
+ st().setIntent('music')
+ useCreateStore.setState({ cloudOpModel: 'direct-pick' })
+ st().setIntent('lipsync')
+ expect(st().cloudOpModel).toBe('')
+ st().setIntent('music')
+ expect(st().cloudOpModel).toBe('direct-pick')
+ })
+
+ it('Character Studio: Trainieren und Benutzen sind zwei Plaetze', () => {
+ st().setIntent('character')
+ st().setCloudOpModel('trainer-x')
+ st().setCharacterTab('use')
+ expect(opSlot(st())).toBe('character:use')
+ expect(st().cloudOpModel).toBe('')
+ st().setCloudOpModel('gen-y')
+ st().setCharacterTab('train')
+ expect(st().cloudOpModel).toBe('trainer-x')
+ })
+
+ it('der Wechsel zwischen Unterkategorien verliert keine Wahl, auch ueber Video und Bild hinweg', () => {
+ st().setIntent('lipsync')
+ st().setCloudOpModel('l-1')
+ st().setIntent('video')
+ st().setIntent('image')
+ st().setIntent('lipsync')
+ expect(st().cloudOpModel).toBe('l-1')
+ })
+})
diff --git a/src/stores/__tests__/downloadStore-pruefsumme-bleibt.test.ts b/src/stores/__tests__/downloadStore-pruefsumme-bleibt.test.ts
new file mode 100644
index 00000000..4be8c939
--- /dev/null
+++ b/src/stores/__tests__/downloadStore-pruefsumme-bleibt.test.ts
@@ -0,0 +1,103 @@
+/**
+ * Die Pruefsumme gilt nicht nur beim ersten Versuch (Opus-Endpruefung 02.10.2026).
+ *
+ * Retry und Resume lesen nur den Meta-Eintrag des Stores. Wurde er ohne sha256
+ * geschrieben (Installationspfade, die sie vergassen, oder ein gespeicherter
+ * Eintrag von frueher), startete ein Retry nach einem Hash-Fehler dieselbe
+ * Datei ohne Pruefsumme, und eine vom Spiegel ausgetauschte Datei wurde
+ * ungeprueft installiert. Jetzt fuellt der Store fehlende Werte aus dem Katalog
+ * auf, wenn der Katalog dieselbe Adresse nennt.
+ *
+ * Gegen den ECHTEN Katalog und den echten Store; nur der Rust-Aufruf ist Attrappe.
+ *
+ * Run: npx vitest run src/stores/__tests__/downloadStore-pruefsumme-bleibt.test.ts
+ */
+import { describe, it, expect, vi, beforeEach } from 'vitest'
+
+const backendCall = vi.fn(async (_cmd: string, _args?: Record<string, unknown>) => ({}) as unknown)
+vi.mock('../../api/backend', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('../../api/backend')>()),
+ backendCall: (cmd: string, args?: Record<string, unknown>) => backendCall(cmd, args),
+}))
+
+import { useDownloadStore } from '../downloadStore'
+import { getVideoBundles } from '../../api/model-bundles'
+import { downloadBundleFiles } from '../../lib/bundle-install'
+
+const ltx = () => getVideoBundles().find((b) => b.name === 'LTX 2.5 · Video with Sound')!
+const dit = () => ltx().files[0]
+const callsOf = (cmd: string) => backendCall.mock.calls.filter((c) => c[0] === cmd).map((c) => c[1] as Record<string, unknown>)
+
+beforeEach(() => {
+ backendCall.mockClear()
+ backendCall.mockImplementation(async (cmd: string) => (cmd === 'download_progress' ? {} : ({} as unknown)))
+ useDownloadStore.setState({ downloads: {}, downloadMeta: {}, orphans: {} })
+ useDownloadStore.getState().stopPolling()
+})
+
+describe('der Katalog liefert Pruefsumme und Bytes nach', () => {
+ it('setMeta ohne Zusatzwerte bekommt die sha256 der Katalogdatei', () => {
+ const f = dit()
+ useDownloadStore.getState().setMeta(f.filename!, f.downloadUrl!, f.subfolder!)
+ expect(f.sha256).toMatch(/^[0-9a-f]{64}$/)
+ expect(useDownloadStore.getState().downloadMeta[f.filename!]).toMatchObject({
+ sha256: f.sha256, expectedBytes: Math.round(f.sizeGB! * 1_073_741_824),
+ })
+ })
+
+ it('eine gleichnamige Datei von einer ANDEREN Adresse erbt keine fremde Pruefsumme', () => {
+ const f = dit()
+ useDownloadStore.getState().setMeta(f.filename!, 'https://example.test/other.safetensors', 'diffusion_models')
+ expect(useDownloadStore.getState().downloadMeta[f.filename!].sha256).toBeUndefined()
+ })
+})
+
+describe('Retry und Resume nach einem Hash-Fehler schicken den Hash wieder mit', () => {
+ const hashFehler = 'SHA-256 mismatch: the downloaded file is not the one the catalog pinned'
+
+ it('Retry: auch wenn der Eintrag ohne sha256 geschrieben wurde', async () => {
+ const f = dit()
+ useDownloadStore.setState({
+ downloads: { [f.filename!]: { progress: 5, total: 10, speed: 0, filename: f.filename!, status: 'error', error: hashFehler } },
+ // So sah ein von einem Installationspfad ohne Zusatzwerte geschriebener Eintrag aus.
+ downloadMeta: { [f.filename!]: { url: f.downloadUrl!, subfolder: f.subfolder! } },
+ })
+ await useDownloadStore.getState().retry(f.filename!)
+ const started = callsOf('download_model')
+ expect(started).toHaveLength(1)
+ expect(started[0]).toMatchObject({ filename: f.filename, expectedSha256: f.sha256 })
+ expect(started[0].expectedBytes).toBe(Math.round(f.sizeGB! * 1_073_741_824))
+ useDownloadStore.getState().stopPolling()
+ })
+
+ it('Resume: ebenso', async () => {
+ const f = dit()
+ useDownloadStore.setState({
+ downloadMeta: { [f.filename!]: { url: f.downloadUrl!, subfolder: f.subfolder! } },
+ })
+ await useDownloadStore.getState().resume(f.filename!)
+ const resumed = callsOf('resume_download')
+ expect(resumed).toHaveLength(1)
+ expect(resumed[0]).toMatchObject({ id: f.filename, expectedSha256: f.sha256 })
+ useDownloadStore.getState().stopPolling()
+ })
+
+ it('ganz ohne Eintrag fragt Retry weiter den Katalog (wie bisher)', async () => {
+ const f = dit()
+ await useDownloadStore.getState().retry(f.filename!)
+ expect(callsOf('download_model')[0]).toMatchObject({ expectedSha256: f.sha256 })
+ useDownloadStore.getState().stopPolling()
+ })
+})
+
+describe('der erste Start schickt die Pruefsumme ebenfalls mit', () => {
+ it('downloadBundleFiles (Create-Installation) gibt sha256 und Bytes an den Start', async () => {
+ const f = dit()
+ const start = vi.fn(async () => ({ status: 'exists' }))
+ await downloadBundleFiles(
+ [{ filename: f.filename!, subfolder: f.subfolder!, downloadUrl: f.downloadUrl!, sizeGB: f.sizeGB, sha256: f.sha256 }],
+ { start, progress: async () => ({}) },
+ )
+ expect(start).toHaveBeenCalledWith(f.downloadUrl, f.subfolder, f.filename, Math.round(f.sizeGB! * 1_073_741_824), f.sha256)
+ })
+})
diff --git a/src/stores/createStore.ts b/src/stores/createStore.ts
index 39b7cb3a..51f43883 100644
--- a/src/stores/createStore.ts
+++ b/src/stores/createStore.ts
@@ -351,9 +351,14 @@ interface CreateState {
cloudImageModel: string
cloudVideoModel: string
/** Runtime-only: the model picked inside a 2.5.8 specialized intent
- * (trainer/lipsync/music/extend/motion). One slot for all — modelForOp
+ * (trainer/lipsync/music/extend/motion/enhance). Mirror of the current
+ * sub-category's entry in cloudOpPicks; modelForOp
* coerces a stale cross-intent pick onto the op's own list. */
cloudOpModel: string
+ /** The pick of EACH sub-category (see opSlot), runtime-only like cloudOpModel.
+ * cloudOpModel mirrors the entry of the current sub-category, so choosing a
+ * model in Enhance Image no longer wipes the music pick (02.10.2026). */
+ cloudOpPicks: Record<string, string>
/** Studio: the schema-driven option values for the picked cloudOpModel step
* (studio-contract.ts). Belongs to the model, not the run: a model switch
* drops them, see setCloudOpModel. */
@@ -671,6 +676,7 @@ export const useCreateStore = create<CreateState>()(
cloudImageModel: '',
cloudVideoModel: '',
cloudOpModel: '',
+ cloudOpPicks: {} as Record<string, string>,
cloudStudioOptions: {} as Record<string, unknown>,
cloudStudioCredits: null as number | null,
localOpModel: '',
@@ -1237,3 +1243,27 @@ export const useCreateStore = create<CreateState>()(
}
)
)
+
+/** Which pick slot the current sub-category owns. Character Studio USE picks a
+ * generation endpoint, TRAIN a trainer, so they are two slots. */
+export function opSlot(s: Pick<CreateState, 'characterTab' | 'removebg' | 'utilityOp' | 'cloudOp' | 'mode' | 'imageSubMode' | 'videoSubMode'>): string {
+ const intent = deriveIntent(s)
+ return intent === 'character' && s.characterTab === 'use' ? 'character:use' : intent
+}
+
+// One shared cloudOpModel used to serve lip sync, music, extend, motion and
+// Enhance Image, so a pick in one sub-category replaced the pick of another
+// (Opus review 02.10.2026). The slot map keeps one pick each, and the single
+// field every reader uses stays, as the mirror of the current slot:
+// - the slot changed: the field takes that slot's own pick ('' if none yet);
+// - the field changed inside a slot: that is a pick for the slot, remember it.
+// Runtime-only, nothing is persisted, so there is no stored pick to migrate.
+useCreateStore.subscribe((s, prev) => {
+ const slot = opSlot(s)
+ if (slot !== opSlot(prev)) {
+ const want = s.cloudOpPicks[slot] ?? ''
+ if (s.cloudOpModel !== want) useCreateStore.setState({ cloudOpModel: want })
+ } else if (s.cloudOpModel !== prev.cloudOpModel && s.cloudOpPicks[slot] !== s.cloudOpModel) {
+ useCreateStore.setState({ cloudOpPicks: { ...s.cloudOpPicks, [slot]: s.cloudOpModel } })
+ }
+})
diff --git a/src/stores/downloadStore.ts b/src/stores/downloadStore.ts
index 6e5a6d9e..0e7fe94a 100644
--- a/src/stores/downloadStore.ts
+++ b/src/stores/downloadStore.ts
@@ -296,7 +296,12 @@ export const useDownloadStore = create<DownloadStoreState>()(persist((set, get)
setMeta: (filename, url, subfolder, destDir?, extra?) => {
set(s => {
- const next = { ...s.downloadMeta, [filename]: { url, subfolder, destDir, ...extra } }
+ // Defence in depth: a caller that forgot the digest or the byte count gets
+ // the catalog's, when the catalog names the SAME address. Retry and resume
+ // read only this record, so a hole here is a download that installs a
+ // swapped file unchecked.
+ const filled = fillFromCatalog({ url, subfolder, destDir, ...extra }, filename)
+ const next = { ...s.downloadMeta, [filename]: filled }
const keys = Object.keys(next)
if (keys.length > META_LIMIT) {
// Oldest first — insertion order is the only age we have, and the
@@ -522,11 +527,34 @@ export const useDownloadStore = create<DownloadStoreState>()(persist((set, get)
},
}))
+/** Add the catalog's sha256 and byte count to a record that lacks them, but only
+ * when the catalog entry is the same address: a Civitai file or a user's own
+ * GGUF that happens to share a name must never inherit a foreign digest. */
+export function fillFromCatalog(meta: DownloadMeta, filename: string): DownloadMeta {
+ if (meta.sha256 && meta.expectedBytes) return meta
+ const cat = lookupFileMeta(filename)
+ if (!cat || cat.url !== meta.url) return meta
+ const sha256 = meta.sha256 ?? cat.sha256
+ const expectedBytes = meta.expectedBytes ?? cat.expectedBytes
+ if (sha256 === meta.sha256 && expectedBytes === meta.expectedBytes) return meta
+ return { ...meta, sha256, expectedBytes }
+}
+
/** Meta for `id`, filling in from the catalog and remembering what it found.
* Retry and resume both need it and both used to lose the destDir. */
function ensureMeta(get: () => DownloadStoreState, id: string): DownloadMeta | null {
const known = get().downloadMeta[id]
- if (known) return known
+ if (known) {
+ // A record written without the digest (older callers, a persisted one) is
+ // completed from the catalog before retry or resume reads it.
+ const filled = fillFromCatalog(known, id)
+ if (filled !== known) {
+ get().setMeta(id, filled.url, filled.subfolder, filled.destDir, {
+ expectedBytes: filled.expectedBytes, sha256: filled.sha256,
+ })
+ }
+ return filled
+ }
const found = lookupFileMeta(id)
if (!found) return null
const meta: DownloadMeta = {