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.

v1.0.3: Fix all 24 video generation issues

PurpleDoubleD2d27973e59da
diff --git a/src/api/comfyui.ts b/src/api/comfyui.ts
index 5f834b61..313e4b97 100644
--- a/src/api/comfyui.ts
+++ b/src/api/comfyui.ts
@@ -25,7 +25,7 @@ export interface ComfyUIOutput {
type: string
}
-export type ModelType = 'flux' | 'sdxl' | 'sd15' | 'wan' | 'hunyuan' | 'unknown'
+export type ModelType = 'flux' | 'flux2' | 'sdxl' | 'sd15' | 'wan' | 'hunyuan' | 'unknown'
export type VideoBackend = 'wan' | 'animatediff' | 'none'
export interface ClassifiedModel {
@@ -38,6 +38,7 @@ export interface ClassifiedModel {
function classifyModel(name: string): ModelType {
const lower = name.toLowerCase()
+ if (lower.includes('flux-2') || lower.includes('flux2')) return 'flux2'
if (lower.includes('flux')) return 'flux'
if (lower.includes('wan')) return 'wan'
if (lower.includes('hunyuan')) return 'hunyuan'
@@ -47,7 +48,7 @@ function classifyModel(name: string): ModelType {
}
function isImageModelType(type: ModelType): boolean {
- return type === 'flux' || type === 'sdxl' || type === 'sd15' || type === 'unknown'
+ return type === 'flux' || type === 'flux2' || type === 'sdxl' || type === 'sd15' || type === 'unknown'
}
function isVideoModelType(type: ModelType): boolean {
@@ -65,6 +66,18 @@ export async function checkComfyConnection(): Promise<boolean> {
}
}
+// Check if a specific node exists in ComfyUI (lightweight, single node check)
+async function nodeExists(nodeName: string): Promise<boolean> {
+ try {
+ const res = await fetch(`/comfyui/object_info/${nodeName}`, { signal: AbortSignal.timeout(3000) })
+ if (!res.ok) return false
+ const data = await res.json()
+ return !!(data && data[nodeName])
+ } catch {
+ return false
+ }
+}
+
export async function getCheckpoints(): Promise<string[]> {
try {
const res = await fetch('/comfyui/object_info/CheckpointLoaderSimple')
@@ -181,20 +194,29 @@ export async function getVideoModels(): Promise<ClassifiedModel[]> {
return result
}
-// ─── Detect Video Backend (checks BOTH nodes AND models) ───
+// ─── Detect Video Backend (checks individual nodes + models — no full object_info fetch) ───
export async function detectVideoBackend(): Promise<VideoBackend> {
try {
- const [nodeRes, videoModels] = await Promise.all([
- fetch('/comfyui/object_info').then(r => r.ok ? r.json() : {}),
+ // Check Wan/Hunyuan: need specific nodes AND actual video models
+ const [hasWanLatent, hasUNET, hasCLIP, hasVAE, videoModels] = await Promise.all([
+ nodeExists('EmptyHunyuanLatentVideo'),
+ nodeExists('UNETLoader'),
+ nodeExists('CLIPLoader'),
+ nodeExists('VAELoader'),
getVideoModels(),
])
- const hasWanNodes = !!(nodeRes['EmptyHunyuanLatentVideo'] && nodeRes['UNETLoader'] && nodeRes['CLIPLoader'] && nodeRes['VAELoader'])
- const hasWanModels = videoModels.length > 0
- if (hasWanNodes && hasWanModels) return 'wan'
+ if (hasWanLatent && hasUNET && hasCLIP && hasVAE && videoModels.length > 0) {
+ return 'wan'
+ }
- if (nodeRes['ADE_LoadAnimateDiffModel'] && nodeRes['ADE_UseEvolvedSampling']) return 'animatediff'
+ // Check AnimateDiff: need custom extension nodes
+ const [hasADELoad, hasADESampling] = await Promise.all([
+ nodeExists('ADE_LoadAnimateDiffModel'),
+ nodeExists('ADE_UseEvolvedSampling'),
+ ])
+ if (hasADELoad && hasADESampling) return 'animatediff'
} catch (err) {
console.warn('[ComfyUI] Failed to detect video backend:', err)
}
@@ -208,18 +230,41 @@ async function findMatchingVAE(modelType: ModelType): Promise<string> {
if (vaes.length === 0) throw new Error('No VAE models found in ComfyUI. Add a VAE to models/vae/')
const lower = (s: string) => s.toLowerCase()
- if (modelType === 'flux') {
- return vaes.find(v => lower(v).includes('flux')) ?? vaes[0]
+ // Try to find a matching VAE by model type keywords
+ if (modelType === 'flux' || modelType === 'flux2') {
+ const match = vaes.find(v => lower(v).includes('flux'))
+ if (match) return match
}
- if (modelType === 'wan' || modelType === 'hunyuan') {
- return vaes.find(v => lower(v).includes('wan') || lower(v).includes('hunyuan')) ?? vaes[0]
+ if (modelType === 'wan') {
+ const match = vaes.find(v => lower(v).includes('wan'))
+ if (match) return match
+ }
+ if (modelType === 'hunyuan') {
+ const match = vaes.find(v => lower(v).includes('hunyuan') || lower(v).includes('wan'))
+ if (match) return match
}
+
+ // Fallback: first available VAE
+ console.warn(`[ComfyUI] No ${modelType}-specific VAE found, using fallback: ${vaes[0]}`)
return vaes[0]
}
async function findMatchingCLIP(modelType: ModelType): Promise<string> {
const clips = await getCLIPModels()
- if (clips.length === 0) throw new Error('No CLIP/text encoder models found. Add one to models/clip/ or models/text_encoders/')
+ if (clips.length === 0) throw new Error('No CLIP/text encoder models found. Add one to models/text_encoders/')
+ const lower = (s: string) => s.toLowerCase()
+
+ // Try to find a matching CLIP by model type
+ if (modelType === 'wan' || modelType === 'hunyuan') {
+ const match = clips.find(c => lower(c).includes('umt5') || lower(c).includes('wan') || lower(c).includes('t5'))
+ if (match) return match
+ }
+ if (modelType === 'flux' || modelType === 'flux2') {
+ const match = clips.find(c => lower(c).includes('t5') || lower(c).includes('clip'))
+ if (match) return match
+ }
+
+ console.warn(`[ComfyUI] No ${modelType}-specific CLIP found, using fallback: ${clips[0]}`)
return clips[0]
}
@@ -276,10 +321,28 @@ function validateParams(params: GenerateParams) {
if (params.steps < 1 || params.steps > 200) throw new Error('Steps must be 1-200')
}
+function validateVideoParams(params: VideoParams) {
+ validateParams(params)
+ if (params.frames < 1 || params.frames > 256) throw new Error('Frames must be 1-256')
+ if (params.fps < 1 || params.fps > 60) throw new Error('FPS must be 1-60')
+ // Wan requires width/height to be multiples of 16
+ if (params.width % 16 !== 0) throw new Error(`Width must be a multiple of 16 (current: ${params.width})`)
+ if (params.height % 16 !== 0) throw new Error(`Height must be a multiple of 16 (current: ${params.height})`)
+}
+
function getSeed(seed: number): number {
return seed === -1 ? Math.floor(Math.random() * 2147483647) : Math.floor(seed)
}
+// ─── Snap video dimensions to valid values ───
+
+export function snapToVideoGrid(width: number, height: number): { width: number; height: number } {
+ return {
+ width: Math.round(width / 16) * 16,
+ height: Math.round(height / 16) * 16,
+ }
+}
+
// ─── Image Workflow: SDXL/SD (CheckpointLoaderSimple) ───
export function buildSDXLImgWorkflow(params: GenerateParams): Record<string, any> {
@@ -308,12 +371,14 @@ export function buildSDXLImgWorkflow(params: GenerateParams): Record<string, any
export async function buildFluxImgWorkflow(params: GenerateParams): Promise<Record<string, any>> {
validateParams(params)
const seed = getSeed(params.seed)
- const vae = await findMatchingVAE('flux')
- const clip = await findMatchingCLIP('flux')
+ const modelType = classifyModel(params.model)
+ const vae = await findMatchingVAE(modelType)
+ const clip = await findMatchingCLIP(modelType)
+ const clipType = modelType === 'flux2' ? 'flux2' : 'flux'
return {
'1': { class_type: 'UNETLoader', inputs: { unet_name: params.model, weight_dtype: 'default' } },
- '2': { class_type: 'CLIPLoader', inputs: { clip_name: clip, type: 'flux', device: 'default' } },
+ '2': { class_type: 'CLIPLoader', inputs: { clip_name: clip, type: clipType, device: 'default' } },
'3': { class_type: 'VAELoader', inputs: { vae_name: vae } },
'4': { class_type: 'CLIPTextEncode', inputs: { text: params.prompt, clip: ['2', 0] } },
'5': { class_type: 'EmptySD3LatentImage', inputs: { width: params.width, height: params.height, batch_size: params.batchSize } },
@@ -333,19 +398,25 @@ export async function buildFluxImgWorkflow(params: GenerateParams): Promise<Reco
// ─── Auto-select Image Workflow ───
export async function buildTxt2ImgWorkflow(params: GenerateParams, modelType: ModelType): Promise<Record<string, any>> {
- if (modelType === 'flux') return buildFluxImgWorkflow(params)
+ if (modelType === 'flux' || modelType === 'flux2') return buildFluxImgWorkflow(params)
return buildSDXLImgWorkflow(params)
}
-// ─── Video Workflow: Wan 2.1/2.2 ───
+// ─── Video Workflow: Wan 2.1/2.2 (Hunyuan latent space) ───
export async function buildWanVideoWorkflow(params: VideoParams): Promise<Record<string, any>> {
- validateParams(params)
+ validateVideoParams(params)
const seed = getSeed(params.seed)
+
+ // Pre-check required nodes
+ const hasLatent = await nodeExists('EmptyHunyuanLatentVideo')
+ if (!hasLatent) throw new Error('EmptyHunyuanLatentVideo node not found. Update ComfyUI to latest version.')
+ const hasSaveWEBP = await nodeExists('SaveAnimatedWEBP')
+
const vae = await findMatchingVAE('wan')
const clip = await findMatchingCLIP('wan')
- return {
+ const workflow: Record<string, any> = {
'1': { class_type: 'CLIPLoader', inputs: { clip_name: clip, type: 'wan', device: 'default' } },
'2': { class_type: 'UNETLoader', inputs: { unet_name: params.model, weight_dtype: 'default' } },
'3': { class_type: 'VAELoader', inputs: { vae_name: vae } },
@@ -361,21 +432,35 @@ export async function buildWanVideoWorkflow(params: VideoParams): Promise<Record
},
},
'8': { class_type: 'VAEDecode', inputs: { samples: ['7', 0], vae: ['3', 0] } },
- '9': {
+ }
+
+ // Use SaveAnimatedWEBP if available, otherwise fall back to SaveImage (frame sequence)
+ if (hasSaveWEBP) {
+ workflow['9'] = {
class_type: 'SaveAnimatedWEBP',
inputs: { images: ['8', 0], filename_prefix: 'locally_uncensored_vid', fps: params.fps, lossless: false, quality: 90, method: 'default' },
- },
+ }
+ } else {
+ workflow['9'] = {
+ class_type: 'SaveImage',
+ inputs: { images: ['8', 0], filename_prefix: 'locally_uncensored_vid' },
+ }
}
+
+ return workflow
}
// ─── Video Workflow: AnimateDiff ───
export async function buildAnimateDiffWorkflow(params: VideoParams): Promise<Record<string, any>> {
- validateParams(params)
+ validateVideoParams(params)
const seed = getSeed(params.seed)
const motionModel = await findAnimateDiffModel()
- return {
+ // AnimateDiff: batch_size=1, motion model handles temporal dimension
+ const hasVHS = await nodeExists('VHS_VideoCombine')
+
+ const workflow: Record<string, any> = {
'1': { class_type: 'CheckpointLoaderSimple', inputs: { ckpt_name: params.model } },
'2': { class_type: 'ADE_LoadAnimateDiffModel', inputs: { model_name: motionModel } },
'3': { class_type: 'ADE_ApplyAnimateDiffModelSimple', inputs: { motion_model: ['2', 0] } },
@@ -392,11 +477,30 @@ export async function buildAnimateDiffWorkflow(params: VideoParams): Promise<Rec
},
},
'9': { class_type: 'VAEDecode', inputs: { samples: ['8', 0], vae: ['1', 2] } },
- '10': {
+ }
+
+ // Use VHS_VideoCombine if available (produces MP4), otherwise SaveAnimatedWEBP, otherwise SaveImage
+ if (hasVHS) {
+ workflow['10'] = {
class_type: 'VHS_VideoCombine',
inputs: { images: ['9', 0], frame_rate: params.fps, loop_count: 0, filename_prefix: 'locally_uncensored_vid', format: 'video/h264-mp4', pingpong: false, save_output: true },
- },
+ }
+ } else {
+ const hasSaveWEBP = await nodeExists('SaveAnimatedWEBP')
+ if (hasSaveWEBP) {
+ workflow['10'] = {
+ class_type: 'SaveAnimatedWEBP',
+ inputs: { images: ['9', 0], filename_prefix: 'locally_uncensored_vid', fps: params.fps, lossless: false, quality: 90, method: 'default' },
+ }
+ } else {
+ workflow['10'] = {
+ class_type: 'SaveImage',
+ inputs: { images: ['9', 0], filename_prefix: 'locally_uncensored_vid' },
+ }
+ }
}
+
+ return workflow
}
// ─── Auto-select Video Workflow ───
diff --git a/src/components/create/CreateView.tsx b/src/components/create/CreateView.tsx
index 33ba3dcb..7f5373b9 100644
--- a/src/components/create/CreateView.tsx
+++ b/src/components/create/CreateView.tsx
@@ -138,11 +138,20 @@ export function CreateView() {
{/* Status: Connected */}
{connected === true && (
- <div className="flex items-center gap-2 px-4 py-2 bg-green-50 dark:bg-green-500/10 border-b border-green-200 dark:border-green-500/20 text-green-600 dark:text-green-400 text-sm" role="status">
- <CheckCircle size={16} />
- <span>
- ComfyUI connected — {imageModels.length} image model{imageModels.length !== 1 ? 's' : ''}, {videoModels.length} video model{videoModels.length !== 1 ? 's' : ''}
- </span>
+ <div className="flex items-center justify-between px-4 py-2 bg-green-50 dark:bg-green-500/10 border-b border-green-200 dark:border-green-500/20 text-green-600 dark:text-green-400 text-sm" role="status">
+ <div className="flex items-center gap-2">
+ <CheckCircle size={16} />
+ <span>
+ ComfyUI connected — {imageModels.length} image model{imageModels.length !== 1 ? 's' : ''}, {videoModels.length} video model{videoModels.length !== 1 ? 's' : ''}
+ </span>
+ </div>
+ <button
+ onClick={fetchModels}
+ className="flex items-center gap-1 text-xs text-green-500 hover:text-green-700 dark:hover:text-green-300 transition-colors"
+ title="Refresh models"
+ >
+ <RefreshCw size={12} /> Refresh
+ </button>
</div>
)}
diff --git a/src/components/create/ParamPanel.tsx b/src/components/create/ParamPanel.tsx
index 44e3eef3..f389156a 100644
--- a/src/components/create/ParamPanel.tsx
+++ b/src/components/create/ParamPanel.tsx
@@ -1,7 +1,8 @@
import { useCreateStore } from '../../stores/createStore'
import { SliderControl } from '../settings/SliderControl'
-import { Dice5, Info } from 'lucide-react'
+import { Dice5, Info, AlertTriangle } from 'lucide-react'
import type { ClassifiedModel, ModelType } from '../../api/comfyui'
+import { snapToVideoGrid } from '../../api/comfyui'
interface Props {
imageModels: ClassifiedModel[]
@@ -20,14 +21,15 @@ const IMG_SIZE_PRESETS = [
]
const VID_SIZE_PRESETS = [
- { label: '480p', w: 832, h: 480 },
+ { label: '480p', w: 848, h: 480 },
+ { label: '640x480', w: 640, h: 480 },
{ label: '512', w: 512, h: 512 },
- { label: '768x480', w: 768, h: 480 },
- { label: '480x768', w: 480, h: 768 },
+ { label: '480x848', w: 480, h: 848 },
]
const TYPE_BADGE: Record<ModelType, { label: string; color: string }> = {
flux: { label: 'FLUX', color: 'bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-300' },
+ flux2: { label: 'FLUX 2', color: 'bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-300' },
sdxl: { label: 'SDXL', color: 'bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-300' },
sd15: { label: 'SD 1.5', color: 'bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-300' },
wan: { label: 'Wan', color: 'bg-orange-100 dark:bg-orange-500/20 text-orange-700 dark:text-orange-300' },
@@ -169,12 +171,28 @@ export function ParamPanel({ imageModels, videoModels, samplerList, schedulerLis
{/* Video-specific params */}
{isVideo && (
<>
- <SliderControl label="Frames" value={store.frames} min={8} max={81} step={1} onChange={store.setFrames} />
+ <SliderControl label="Frames" value={store.frames} min={1} max={81} step={4} onChange={store.setFrames} />
<SliderControl label="FPS" value={store.fps} min={4} max={30} step={1} onChange={store.setFps} />
<div className="flex items-center gap-1 text-xs text-gray-400">
<Info size={12} />
<span>Duration: ~{videoDuration}s ({store.frames} frames at {store.fps} fps)</span>
</div>
+ {(store.width % 16 !== 0 || store.height % 16 !== 0) && (
+ <button
+ onClick={() => {
+ const snapped = snapToVideoGrid(store.width, store.height)
+ store.setSize(snapped.width, snapped.height)
+ }}
+ className="flex items-center gap-1 text-xs text-yellow-600 dark:text-yellow-400 hover:underline"
+ >
+ <AlertTriangle size={12} /> Size must be multiple of 16 — click to fix ({snapToVideoGrid(store.width, store.height).width}x{snapToVideoGrid(store.width, store.height).height})
+ </button>
+ )}
+ {store.frames > 40 && (
+ <div className="flex items-center gap-1 text-xs text-orange-500">
+ <AlertTriangle size={12} /> High frame count — may need 10+ GB VRAM
+ </div>
+ )}
</>
)}
</div>
diff --git a/src/hooks/useCreate.ts b/src/hooks/useCreate.ts
index f55f6fdc..4e0cff62 100644
--- a/src/hooks/useCreate.ts
+++ b/src/hooks/useCreate.ts
@@ -127,10 +127,11 @@ export function useCreate() {
setCurrentPromptId(promptId)
addToPromptHistory(prompt)
- // Poll for completion
+ // Poll for completion — video gets 60min timeout, image 20min
+ const maxTime = mode === 'video' ? 60 * 60 * 1000 : 20 * 60 * 1000
await new Promise<void>((resolve, reject) => {
let attempts = 0
- const maxAttempts = 1200
+ let comfyCheckCounter = 0
const startTime = Date.now()
pollRef.current = setInterval(async () => {
@@ -140,20 +141,36 @@ export function useCreate() {
return
}
- attempts++
- if (attempts > maxAttempts) {
+ const elapsed = Date.now() - startTime
+ if (elapsed > maxTime) {
if (pollRef.current) clearInterval(pollRef.current)
- reject(new Error('Generation timed out after 20 minutes'))
+ reject(new Error(`Generation timed out after ${Math.round(maxTime / 60000)} minutes`))
return
}
- const elapsed = Math.round((Date.now() - startTime) / 1000)
- const pct = Math.min(10 + (attempts / (steps * 2) * 85), 95)
+ attempts++
+ comfyCheckCounter++
+
+ // Heartbeat: every 30 polls, check if ComfyUI is still alive
+ if (comfyCheckCounter >= 30) {
+ comfyCheckCounter = 0
+ const alive = await checkComfyConnection()
+ if (!alive) {
+ if (pollRef.current) clearInterval(pollRef.current)
+ reject(new Error('ComfyUI stopped responding during generation'))
+ return
+ }
+ }
+
+ const elapsedSec = Math.round(elapsed / 1000)
+ // Video progress: slower, more conservative estimate
+ const expectedSteps = mode === 'video' ? steps * frames * 0.5 : steps * 2
+ const pct = Math.min(10 + (attempts / expectedSteps * 85), 95)
try {
const history = await getHistory(promptId)
if (!history) {
- setProgress(pct, `Generating... ${elapsed}s elapsed`)
+ setProgress(pct, `Generating... ${elapsedSec}s elapsed`)
return
}
@@ -179,7 +196,7 @@ export function useCreate() {
subfolder: file.subfolder ?? '',
prompt, negativePrompt,
model: activeModel,
- modelType: mode === 'image' ? imageModelType : 'wan',
+ modelType: mode === 'image' ? imageModelType : (videoModelsList.find(m => m.name === activeModel)?.type ?? 'wan'),
seed: seed === -1 ? 0 : seed,
steps, cfgScale, sampler, scheduler, width, height,
batchSize,
diff --git a/src/stores/createStore.ts b/src/stores/createStore.ts
index 371660e0..de638558 100644
--- a/src/stores/createStore.ts
+++ b/src/stores/createStore.ts
@@ -1,6 +1,7 @@
import { create } from 'zustand'
import { persist } from 'zustand/middleware'
import type { ModelType } from '../api/comfyui'
+// ModelType includes: flux, flux2, sdxl, sd15, wan, hunyuan, unknown
export interface GalleryItem {
id: string