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
v1.0.2: Complete Create tab rewrite — fix all 55 issues
PurpleDoubleDfd475c0fed47
diff --git a/src/api/comfyui.ts b/src/api/comfyui.tsindex 2d918ca5..5f834b61 100644--- a/src/api/comfyui.ts+++ b/src/api/comfyui.ts@@ -5,12 +5,13 @@ export interface GenerateParams {negativePrompt: stringmodel: stringsampler: string+ scheduler: stringsteps: numbercfgScale: numberwidth: numberheight: numberseed: number- batchSize?: number+ batchSize: number}export interface VideoParams extends GenerateParams {@@ -41,15 +42,15 @@ function classifyModel(name: string): ModelType {if (lower.includes('wan')) return 'wan'if (lower.includes('hunyuan')) return 'hunyuan'if (lower.includes('sdxl') || lower.includes('xl')) return 'sdxl'- if (lower.includes('sd15') || lower.includes('sd_1') || lower.includes('v1-5')) return 'sd15'+ if (lower.includes('sd15') || lower.includes('sd_1') || lower.includes('v1-5') || lower.includes('1.5')) return 'sd15'return 'unknown'}-function isImageModel(type: ModelType): boolean {+function isImageModelType(type: ModelType): boolean {return type === 'flux' || type === 'sdxl' || type === 'sd15' || type === 'unknown'}-function isVideoModel(type: ModelType): boolean {+function isVideoModelType(type: ModelType): boolean {return type === 'wan' || type === 'hunyuan'}@@ -57,7 +58,7 @@ function isVideoModel(type: ModelType): boolean {export async function checkComfyConnection(): Promise<boolean> {try {- const res = await fetch('/comfyui/system_stats')+ const res = await fetch('/comfyui/system_stats', { signal: AbortSignal.timeout(5000) })return res.ok} catch {return false@@ -67,9 +68,11 @@ export async function checkComfyConnection(): Promise<boolean> {export async function getCheckpoints(): Promise<string[]> {try {const res = await fetch('/comfyui/object_info/CheckpointLoaderSimple')+ if (!res.ok) return []const data = await res.json()- return data?.CheckpointLoaderSimple?.input?.required?.ckpt_name?.[0] || []- } catch {+ return data?.CheckpointLoaderSimple?.input?.required?.ckpt_name?.[0] ?? []+ } catch (err) {+ console.warn('[ComfyUI] Failed to fetch checkpoints:', err)return []}}@@ -77,9 +80,11 @@ export async function getCheckpoints(): Promise<string[]> {export async function getDiffusionModels(): Promise<string[]> {try {const res = await fetch('/comfyui/object_info/UNETLoader')+ if (!res.ok) return []const data = await res.json()- return data?.UNETLoader?.input?.required?.unet_name?.[0] || []- } catch {+ return data?.UNETLoader?.input?.required?.unet_name?.[0] ?? []+ } catch (err) {+ console.warn('[ComfyUI] Failed to fetch diffusion models:', err)return []}}@@ -87,9 +92,11 @@ export async function getDiffusionModels(): Promise<string[]> {export async function getVAEModels(): Promise<string[]> {try {const res = await fetch('/comfyui/object_info/VAELoader')+ if (!res.ok) return []const data = await res.json()- return data?.VAELoader?.input?.required?.vae_name?.[0] || []- } catch {+ return data?.VAELoader?.input?.required?.vae_name?.[0] ?? []+ } catch (err) {+ console.warn('[ComfyUI] Failed to fetch VAE models:', err)return []}}@@ -97,41 +104,45 @@ export async function getVAEModels(): Promise<string[]> {export async function getCLIPModels(): Promise<string[]> {try {const res = await fetch('/comfyui/object_info/CLIPLoader')+ if (!res.ok) return []const data = await res.json()- return data?.CLIPLoader?.input?.required?.clip_name?.[0] || []- } catch {+ return data?.CLIPLoader?.input?.required?.clip_name?.[0] ?? []+ } catch (err) {+ console.warn('[ComfyUI] Failed to fetch CLIP models:', err)return []}}-export async function getTextEncoders(): Promise<string[]> {+export async function getSamplers(): Promise<string[]> {try {- // DualCLIPLoader is used by FLUX for text encoders- const res = await fetch('/comfyui/object_info/DualCLIPLoader')+ const res = await fetch('/comfyui/object_info/KSampler')+ if (!res.ok) throw new Error('Failed')const data = await res.json()- return data?.DualCLIPLoader?.input?.required?.clip_name1?.[0] || []+ return data?.KSampler?.input?.required?.sampler_name?.[0] ?? []} catch {- return []+ return ['euler', 'euler_ancestral', 'dpmpp_2m', 'dpmpp_2m_sde', 'dpmpp_sde', 'uni_pc', 'ddim']}}-export async function getSamplers(): Promise<string[]> {+export async function getSchedulers(): Promise<string[]> {try {const res = await fetch('/comfyui/object_info/KSampler')+ if (!res.ok) throw new Error('Failed')const data = await res.json()- return data?.KSampler?.input?.required?.sampler_name?.[0] || []+ return data?.KSampler?.input?.required?.scheduler?.[0] ?? []} catch {- return ['euler', 'euler_ancestral', 'dpmpp_2m', 'dpmpp_sde', 'uni_pc', 'ddim']+ return ['normal', 'karras', 'simple', 'exponential', 'sgm_uniform']}}-export async function getSchedulers(): Promise<string[]> {+export async function getAnimateDiffModels(): Promise<string[]> {try {- const res = await fetch('/comfyui/object_info/KSampler')+ const res = await fetch('/comfyui/object_info/ADE_LoadAnimateDiffModel')+ if (!res.ok) return []const data = await res.json()- return data?.KSampler?.input?.required?.scheduler?.[0] || []+ return data?.ADE_LoadAnimateDiffModel?.input?.required?.model_name?.[0] ?? []} catch {- return ['normal', 'karras', 'simple', 'exponential', 'sgm_uniform']+ return []}}@@ -139,20 +150,17 @@ export async function getSchedulers(): Promise<string[]> {export async function getImageModels(): Promise<ClassifiedModel[]> {const [checkpoints, diffModels] = await Promise.all([getCheckpoints(), getDiffusionModels()])-const result: ClassifiedModel[] = []- // All checkpoints are image models (SDXL, SD1.5, etc.)for (const name of checkpoints) {const type = classifyModel(name)- result.push({ name, type: type === 'unknown' ? 'sdxl' : type, source: 'checkpoint' })+ result.push({ name, type: isImageModelType(type) ? type : 'sdxl', source: 'checkpoint' })}- // Only FLUX/SD diffusion_models are image models (NOT wan/hunyuan)for (const name of diffModels) {const type = classifyModel(name)- if (isImageModel(type)) {- result.push({ name, type: type === 'unknown' ? 'flux' : type, source: 'diffusion_model' })+ if (isImageModelType(type)) {+ result.push({ name, type, source: 'diffusion_model' })}}@@ -161,13 +169,11 @@ export async function getImageModels(): Promise<ClassifiedModel[]> {export async function getVideoModels(): Promise<ClassifiedModel[]> {const diffModels = await getDiffusionModels()-const result: ClassifiedModel[] = []- // Only wan/hunyuan diffusion_models are video modelsfor (const name of diffModels) {const type = classifyModel(name)- if (isVideoModel(type)) {+ if (isVideoModelType(type)) {result.push({ name, type, source: 'diffusion_model' })}}@@ -180,44 +186,47 @@ export async function getVideoModels(): Promise<ClassifiedModel[]> {export async function detectVideoBackend(): Promise<VideoBackend> {try {const [nodeRes, videoModels] = await Promise.all([- fetch('/comfyui/object_info').then(r => r.json()),+ fetch('/comfyui/object_info').then(r => r.ok ? r.json() : {}),getVideoModels(),])- // Wan: need BOTH the nodes AND actual wan/hunyuan modelsconst hasWanNodes = !!(nodeRes['EmptyHunyuanLatentVideo'] && nodeRes['UNETLoader'] && nodeRes['CLIPLoader'] && nodeRes['VAELoader'])const hasWanModels = videoModels.length > 0-if (hasWanNodes && hasWanModels) return 'wan'- // AnimateDiff: need custom nodesif (nodeRes['ADE_LoadAnimateDiffModel'] && nodeRes['ADE_UseEvolvedSampling']) return 'animatediff'- } catch { /* ignore */ }+ } catch (err) {+ console.warn('[ComfyUI] Failed to detect video backend:', err)+ }return 'none'}// ─── Auto-find matching VAE/CLIP for a model ───-async function findMatchingVAE(modelType: ModelType): Promise<string | null> {+async function findMatchingVAE(modelType: ModelType): Promise<string> {const vaes = await getVAEModels()+ 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] || null+ return vaes.find(v => lower(v).includes('flux')) ?? vaes[0]}if (modelType === 'wan' || modelType === 'hunyuan') {- return vaes.find(v => lower(v).includes('wan') || lower(v).includes('hunyuan')) || vaes[0] || null+ return vaes.find(v => lower(v).includes('wan') || lower(v).includes('hunyuan')) ?? vaes[0]}- return vaes[0] || null+ return vaes[0]}-async function findMatchingCLIP(modelType: ModelType): Promise<string | null> {+async function findMatchingCLIP(modelType: ModelType): Promise<string> {const clips = await getCLIPModels()- const textEncoders = await getTextEncoders()- const all = [...clips, ...textEncoders]+ if (clips.length === 0) throw new Error('No CLIP/text encoder models found. Add one to models/clip/ or models/text_encoders/')+ return clips[0]+}- if (all.length === 0) return null- return all[0]+async function findAnimateDiffModel(): Promise<string> {+ const models = await getAnimateDiffModels()+ if (models.length === 0) throw new Error('No AnimateDiff motion models found. Install them via ComfyUI Manager.')+ return models[0]}// ─── Workflow Submission ───@@ -230,38 +239,63 @@ export async function submitWorkflow(workflow: Record<string, any>): Promise<str})if (!res.ok) {const err = await res.text()- throw new Error(`ComfyUI error: ${err}`)+ throw new Error(`ComfyUI rejected workflow: ${err}`)}const data = await res.json()return data.prompt_id}+export async function cancelGeneration(): Promise<void> {+ try {+ await fetch('/comfyui/interrupt', { method: 'POST' })+ } catch { /* best effort */ }+}+export async function getHistory(promptId: string): Promise<any> {- const res = await fetch(`/comfyui/history/${promptId}`)- if (!res.ok) return null- const data = await res.json()- return data[promptId] || null+ try {+ const res = await fetch(`/comfyui/history/${promptId}`)+ if (!res.ok) return null+ const data = await res.json()+ return data[promptId] ?? null+ } catch {+ return null+ }}export function getImageUrl(filename: string, subfolder: string = '', type: string = 'output'): string {- return `/comfyui/view?filename=${encodeURIComponent(filename)}&subfolder=${encodeURIComponent(subfolder)}&type=${type}`+ return `/comfyui/view?filename=${encodeURIComponent(filename)}&subfolder=${encodeURIComponent(subfolder)}&type=${type}&t=${Date.now()}`+}++// ─── Validate params ───++function validateParams(params: GenerateParams) {+ if (!params.prompt.trim()) throw new Error('Prompt is empty')+ if (!params.model) throw new Error('No model selected')+ if (params.width < 64 || params.width > 4096) throw new Error('Width must be 64-4096')+ if (params.height < 64 || params.height > 4096) throw new Error('Height must be 64-4096')+ if (params.steps < 1 || params.steps > 200) throw new Error('Steps must be 1-200')+}++function getSeed(seed: number): number {+ return seed === -1 ? Math.floor(Math.random() * 2147483647) : Math.floor(seed)}// ─── Image Workflow: SDXL/SD (CheckpointLoaderSimple) ───export function buildSDXLImgWorkflow(params: GenerateParams): Record<string, any> {- const seed = params.seed === -1 ? Math.floor(Math.random() * 2147483647) : params.seed+ validateParams(params)+ const seed = getSeed(params.seed)return {'1': { class_type: 'CheckpointLoaderSimple', inputs: { ckpt_name: params.model } },'2': { class_type: 'CLIPTextEncode', inputs: { text: params.prompt, clip: ['1', 1] } },'3': { class_type: 'CLIPTextEncode', inputs: { text: params.negativePrompt || '', clip: ['1', 1] } },- '4': { class_type: 'EmptyLatentImage', inputs: { width: params.width, height: params.height, batch_size: params.batchSize || 1 } },+ '4': { class_type: 'EmptyLatentImage', inputs: { width: params.width, height: params.height, batch_size: params.batchSize } },'5': {class_type: 'KSampler',inputs: {model: ['1', 0], positive: ['2', 0], negative: ['3', 0], latent_image: ['4', 0],seed, steps: params.steps, cfg: params.cfgScale,- sampler_name: params.sampler, scheduler: 'normal', denoise: 1.0,+ sampler_name: params.sampler, scheduler: params.scheduler, denoise: 1.0,},},'6': { class_type: 'VAEDecode', inputs: { samples: ['5', 0], vae: ['1', 2] } },@@ -272,27 +306,23 @@ export function buildSDXLImgWorkflow(params: GenerateParams): Record<string, any// ─── Image Workflow: FLUX (UNETLoader + CLIPLoader + VAELoader) ───export async function buildFluxImgWorkflow(params: GenerateParams): Promise<Record<string, any>> {- const seed = params.seed === -1 ? Math.floor(Math.random() * 2147483647) : params.seed-- // Find matching VAE and CLIP+ validateParams(params)+ const seed = getSeed(params.seed)const vae = await findMatchingVAE('flux')const clip = await findMatchingCLIP('flux')- if (!vae) throw new Error('No VAE found for FLUX. Add a flux VAE to ComfyUI models/vae/')- if (!clip) throw new Error('No text encoder found for FLUX. Add a CLIP/text encoder to ComfyUI models/clip/ or models/text_encoders/')-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' } },'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 || 1 } },+ '5': { class_type: 'EmptySD3LatentImage', inputs: { width: params.width, height: params.height, batch_size: params.batchSize } },'6': {class_type: 'KSampler',inputs: {model: ['1', 0], positive: ['4', 0], negative: ['4', 0], latent_image: ['5', 0],- seed, steps: params.steps, cfg: 1.0, // FLUX uses CFG 1.0- sampler_name: params.sampler || 'euler', scheduler: 'simple', denoise: 1.0,+ seed, steps: params.steps, cfg: params.cfgScale,+ sampler_name: params.sampler, scheduler: params.scheduler, denoise: 1.0,},},'7': { class_type: 'VAEDecode', inputs: { samples: ['6', 0], vae: ['3', 0] } },@@ -303,24 +333,18 @@ 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') return buildFluxImgWorkflow(params)return buildSDXLImgWorkflow(params)}// ─── Video Workflow: Wan 2.1/2.2 ───export async function buildWanVideoWorkflow(params: VideoParams): Promise<Record<string, any>> {- const seed = params.seed === -1 ? Math.floor(Math.random() * 2147483647) : params.seed-- // Dynamically find matching VAE and CLIP+ validateParams(params)+ const seed = getSeed(params.seed)const vae = await findMatchingVAE('wan')const clip = await findMatchingCLIP('wan')- if (!vae) throw new Error('No VAE found for Wan. Add a Wan VAE to ComfyUI models/vae/')- if (!clip) throw new Error('No text encoder found for Wan. Add a CLIP model to ComfyUI models/clip/ or models/text_encoders/')-return {'1': { class_type: 'CLIPLoader', inputs: { clip_name: clip, type: 'wan', device: 'default' } },'2': { class_type: 'UNETLoader', inputs: { unet_name: params.model, weight_dtype: 'default' } },@@ -333,7 +357,7 @@ export async function buildWanVideoWorkflow(params: VideoParams): Promise<Recordinputs: {model: ['2', 0], positive: ['4', 0], negative: ['5', 0], latent_image: ['6', 0],seed, steps: params.steps, cfg: params.cfgScale,- sampler_name: params.sampler || 'uni_pc', scheduler: 'simple', denoise: 1.0,+ sampler_name: params.sampler, scheduler: params.scheduler, denoise: 1.0,},},'8': { class_type: 'VAEDecode', inputs: { samples: ['7', 0], vae: ['3', 0] } },@@ -346,11 +370,14 @@ export async function buildWanVideoWorkflow(params: VideoParams): Promise<Record// ─── Video Workflow: AnimateDiff ───-export function buildAnimateDiffWorkflow(params: VideoParams): Record<string, any> {- const seed = params.seed === -1 ? Math.floor(Math.random() * 2147483647) : params.seed+export async function buildAnimateDiffWorkflow(params: VideoParams): Promise<Record<string, any>> {+ validateParams(params)+ const seed = getSeed(params.seed)+ const motionModel = await findAnimateDiffModel()+return {'1': { class_type: 'CheckpointLoaderSimple', inputs: { ckpt_name: params.model } },- '2': { class_type: 'ADE_LoadAnimateDiffModel', inputs: { model_name: 'mm_sd15_v3.safetensors' } },+ '2': { class_type: 'ADE_LoadAnimateDiffModel', inputs: { model_name: motionModel } },'3': { class_type: 'ADE_ApplyAnimateDiffModelSimple', inputs: { motion_model: ['2', 0] } },'4': { class_type: 'ADE_UseEvolvedSampling', inputs: { model: ['1', 0], m_models: ['3', 0], beta_schedule: 'autoselect' } },'5': { class_type: 'CLIPTextEncode', inputs: { text: params.prompt, clip: ['1', 1] } },@@ -361,7 +388,7 @@ export function buildAnimateDiffWorkflow(params: VideoParams): Record<string, aninputs: {model: ['4', 0], positive: ['5', 0], negative: ['6', 0], latent_image: ['7', 0],seed, steps: params.steps, cfg: params.cfgScale,- sampler_name: params.sampler, scheduler: 'normal', denoise: 1.0,+ sampler_name: params.sampler, scheduler: params.scheduler, denoise: 1.0,},},'9': { class_type: 'VAEDecode', inputs: { samples: ['8', 0], vae: ['1', 2] } },@@ -376,11 +403,8 @@ export function buildAnimateDiffWorkflow(params: VideoParams): Record<string, anexport async function buildTxt2VidWorkflow(params: VideoParams, backend: VideoBackend): Promise<Record<string, any>> {switch (backend) {- case 'wan':- return buildWanVideoWorkflow(params)- case 'animatediff':- return buildAnimateDiffWorkflow(params)- default:- throw new Error('No video backend available. Install Wan 2.1 models or AnimateDiff nodes in ComfyUI.')+ case 'wan': return buildWanVideoWorkflow(params)+ case 'animatediff': return buildAnimateDiffWorkflow(params)+ default: throw new Error('No video backend available. Install Wan 2.1 models or AnimateDiff nodes in ComfyUI.')}}diff --git a/src/components/create/CreateView.tsx b/src/components/create/CreateView.tsxindex 5a47603f..33ba3dcb 100644--- a/src/components/create/CreateView.tsx+++ b/src/components/create/CreateView.tsx@@ -1,5 +1,5 @@import { useEffect, useState, useCallback, useRef } from 'react'-import { Image, Video, WifiOff, Loader2, CheckCircle, AlertTriangle, RefreshCw } from 'lucide-react'+import { Image, Video, WifiOff, Loader2, CheckCircle, AlertTriangle, RefreshCw, Settings } from 'lucide-react'import { useCreate } from '../../hooks/useCreate'import { useCreateStore } from '../../stores/createStore'import { PromptInput } from './PromptInput'@@ -13,44 +13,55 @@ interface ComfyStatus {found: booleanpath: string | nulllogs: string[]+ processAlive?: boolean}export function CreateView() {- const { connected, imageModels, videoModels, samplerList, videoBackend, error, checkConnection, fetchModels, generate, cancel } = useCreate()- const { mode, setMode } = useCreateStore()+ const {+ connected, imageModels, videoModels, samplerList, schedulerList,+ videoBackend, modelsLoaded, checkConnection, fetchModels, generate, cancel,+ } = useCreate()+ const { mode, setMode, error } = useCreateStore()const [status, setStatus] = useState<ComfyStatus | null>(null)const [startupLogs, setStartupLogs] = useState<string[]>([])+ const [retrying, setRetrying] = useState(false)+ const [showParams, setShowParams] = useState(false) // mobile params toggleconst pollRef = useRef<ReturnType<typeof setInterval> | null>(null)+ const pollIdRef = useRef(0) // prevent duplicate polling- // Poll ComfyUI status with logsconst pollStatus = useCallback(async () => {try {- const res = await fetch('/local-api/comfyui-status')+ const res = await fetch('/local-api/comfyui-status', { signal: AbortSignal.timeout(3000) })const data: ComfyStatus = await res.json()setStatus(data)- if (data.logs.length > 0) setStartupLogs(data.logs)+ if (data.logs?.length > 0) setStartupLogs(data.logs)if (data.running) {const wasConnected = await checkConnection()if (wasConnected) fetchModels()return true}- } catch { /* ignore */ }+ } catch (err) {+ console.warn('[CreateView] Status poll failed:', err)+ }return false}, [checkConnection, fetchModels])- // Initial check + auto-poll until connected+ // Initial check + auto-poll (with duplicate prevention)useEffect(() => {+ const id = ++pollIdRef.currentlet stopped = falseconst init = async () => {const ready = await pollStatus()- if (ready || stopped) return+ if (ready || stopped || id !== pollIdRef.current) return- // Keep polling every 3s while ComfyUI is startingpollRef.current = setInterval(async () => {- if (stopped) return+ if (stopped || id !== pollIdRef.current) {+ if (pollRef.current) clearInterval(pollRef.current)+ return+ }const ready = await pollStatus()if (ready && pollRef.current) {clearInterval(pollRef.current)@@ -62,48 +73,44 @@ export function CreateView() {return () => {stopped = true- if (pollRef.current) clearInterval(pollRef.current)+ if (pollRef.current) { clearInterval(pollRef.current); pollRef.current = null }}}, [pollStatus])const retryConnect = async () => {+ setRetrying(true)try { await fetch('/local-api/start-comfyui') } catch { /* ignore */ }- // Start polling again- if (!pollRef.current) {- pollRef.current = setInterval(async () => {- const ready = await pollStatus()- if (ready && pollRef.current) {- clearInterval(pollRef.current)- pollRef.current = null- }- }, 3000)- }+ // Single poll attempt+ setTimeout(async () => {+ await pollStatus()+ setRetrying(false)+ }, 3000)}- const isStarting = status?.starting || (status && !status.running && status.found)+ const isStarting = status?.starting || status?.processAliveconst notFound = status && !status.found && !status.runningreturn (<div className="h-full flex flex-col">{/* Status: ComfyUI not found */}{notFound && (- <div className="flex items-center justify-between px-4 py-3 bg-red-50 dark:bg-red-500/10 border-b border-red-200 dark:border-red-500/20">+ <div className="flex items-center justify-between px-4 py-3 bg-red-50 dark:bg-red-500/10 border-b border-red-200 dark:border-red-500/20" role="alert"><div className="flex items-center gap-2 text-red-600 dark:text-red-400 text-sm"><WifiOff size={16} />- <span>ComfyUI not found. Install it or set COMFYUI_PATH in .env to enable image/video generation.</span>+ <span>ComfyUI not found. Install it or set COMFYUI_PATH in .env</span></div></div>)}{/* Status: ComfyUI is starting */}{isStarting && !connected && (- <div className="border-b border-yellow-200 dark:border-yellow-500/20">+ <div className="border-b border-yellow-200 dark:border-yellow-500/20" role="status"><div className="flex items-center gap-3 px-4 py-3 bg-yellow-50 dark:bg-yellow-500/10 text-yellow-700 dark:text-yellow-400 text-sm"><Loader2 size={16} className="animate-spin shrink-0" /><span>ComfyUI is loading... This can take a minute on first start.</span></div>{startupLogs.length > 0 && (- <div className="px-4 py-2 bg-gray-900 text-gray-400 text-xs font-mono max-h-24 overflow-y-auto">+ <div className="px-4 py-2 bg-gray-100 dark:bg-gray-900 text-gray-600 dark:text-gray-400 text-xs font-mono max-h-24 overflow-y-auto">{startupLogs.slice(-8).map((log, i) => (<div key={i} className="truncate">{log.trim()}</div>))}@@ -112,36 +119,39 @@ export function CreateView() {</div>)}- {/* Status: Not running but was found — offer retry */}+ {/* Status: Not running — offer retry */}{status && !status.running && status.found && !isStarting && !connected && (- <div className="flex items-center justify-between px-4 py-3 bg-orange-50 dark:bg-orange-500/10 border-b border-orange-200 dark:border-orange-500/20">+ <div className="flex items-center justify-between px-4 py-3 bg-orange-50 dark:bg-orange-500/10 border-b border-orange-200 dark:border-orange-500/20" role="alert"><div className="flex items-center gap-2 text-orange-600 dark:text-orange-400 text-sm"><AlertTriangle size={16} />- <span>ComfyUI found but not responding. It may still be loading.</span>+ <span>ComfyUI found but not responding.</span></div><buttononClick={retryConnect}- className="flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-orange-600 hover:bg-orange-700 text-white text-xs font-medium transition-colors"+ disabled={retrying}+ className="flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-orange-600 hover:bg-orange-700 disabled:opacity-50 text-white text-xs font-medium transition-colors">- <RefreshCw size={12} /> Retry+ <RefreshCw size={12} className={retrying ? 'animate-spin' : ''} /> {retrying ? 'Retrying...' : 'Retry'}</button></div>)}{/* 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">+ <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>+ <span>+ ComfyUI connected — {imageModels.length} image model{imageModels.length !== 1 ? 's' : ''}, {videoModels.length} video model{videoModels.length !== 1 ? 's' : ''}+ </span></div>)}<div className="flex-1 flex overflow-hidden">{/* Main content */}- <div className="flex-1 flex flex-col overflow-hidden p-4 gap-4">- {/* Mode switcher + Prompt */}- <div className="space-y-3">- <div className="flex gap-1 p-1 bg-gray-100 dark:bg-white/5 rounded-lg w-fit">+ <div className="flex-1 flex flex-col overflow-hidden p-4 gap-3">+ {/* Mode switcher */}+ <div className="flex items-center justify-between">+ <div className="flex gap-1 p-1 bg-gray-100 dark:bg-white/5 rounded-lg"><buttononClick={() => setMode('image')}className={`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-all ${@@ -160,29 +170,41 @@ export function CreateView() {</button></div>- {mode === 'video' && (videoBackend === 'none' || videoModels.length === 0) && connected === true && (- <div className="flex items-center gap-2 px-3 py-2 rounded-lg bg-yellow-50 dark:bg-yellow-500/10 border border-yellow-200 dark:border-yellow-500/20 text-yellow-700 dark:text-yellow-400 text-xs">- <AlertTriangle size={14} />- <span>No video models installed. Add Wan 2.1/2.2 or Hunyuan models to ComfyUI's models/diffusion_models/ folder.</span>- </div>- )}+ {/* Mobile params toggle */}+ <button+ onClick={() => setShowParams(!showParams)}+ className="lg:hidden p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/10 text-gray-500 dark:text-gray-400"+ title="Parameters"+ >+ <Settings size={18} />+ </button>+ </div>- {mode === 'video' && videoBackend !== 'none' && videoModels.length > 0 && connected === true && (- <div className="text-xs text-gray-400">- Video backend: <span className="text-gray-600 dark:text-gray-300 font-medium">{videoBackend === 'wan' ? 'Wan 2.1/2.2' : 'AnimateDiff'}</span>- {' · '}{videoModels.length} model{videoModels.length !== 1 ? 's' : ''}- </div>- )}+ {/* Video status */}+ {mode === 'video' && (videoBackend === 'none' || videoModels.length === 0) && connected === true && (+ <div className="flex items-center gap-2 px-3 py-2 rounded-lg bg-yellow-50 dark:bg-yellow-500/10 border border-yellow-200 dark:border-yellow-500/20 text-yellow-700 dark:text-yellow-400 text-xs" role="alert">+ <AlertTriangle size={14} />+ <span>No video models installed. Add Wan 2.1/2.2 or Hunyuan models to ComfyUI's models/diffusion_models/ folder.</span>+ </div>+ )}- <PromptInput onGenerate={generate} onCancel={cancel} />+ {mode === 'video' && videoBackend !== 'none' && videoModels.length > 0 && connected === true && (+ <div className="text-xs text-gray-500 dark:text-gray-400">+ Video backend: <span className="text-gray-700 dark:text-gray-300 font-medium">{videoBackend === 'wan' ? 'Wan 2.1/2.2' : 'AnimateDiff'}</span>+ {' · '}{videoModels.length} model{videoModels.length !== 1 ? 's' : ''}+ </div>+ )}- {error && (- <div className="flex items-center gap-2 px-3 py-2 rounded-lg bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20 text-red-600 dark:text-red-400 text-xs">- <AlertTriangle size={14} className="shrink-0" />- <span>{error}</span>- </div>- )}- </div>+ {/* Prompt */}+ <PromptInput onGenerate={generate} onCancel={cancel} disabled={!connected || !modelsLoaded} />++ {/* Error */}+ {error && (+ <div className="flex items-center gap-2 px-3 py-2 rounded-lg bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20 text-red-600 dark:text-red-400 text-xs" role="alert">+ <AlertTriangle size={14} className="shrink-0" />+ <span>{error}</span>+ </div>+ )}{/* Output area */}<div className="flex-1 min-h-0 rounded-xl border border-gray-200 dark:border-white/10 bg-gray-50 dark:bg-[#1a1a1a] overflow-hidden flex flex-col">@@ -191,11 +213,42 @@ export function CreateView() {</div></div>- {/* Parameter sidebar */}+ {/* Parameter sidebar — desktop */}<div className="w-64 border-l border-gray-200 dark:border-white/5 bg-gray-50 dark:bg-[#1a1a1a] p-4 overflow-y-auto scrollbar-thin hidden lg:block"><h3 className="text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-4">Parameters</h3>- <ParamPanel imageModels={imageModels} videoModels={videoModels} samplerList={samplerList} />+ <ParamPanel+ imageModels={imageModels}+ videoModels={videoModels}+ samplerList={samplerList}+ schedulerList={schedulerList}+ modelsLoaded={modelsLoaded}+ /></div>++ {/* Parameter sidebar — mobile overlay */}+ {showParams && (+ <div className="fixed inset-0 z-40 lg:hidden" onClick={() => setShowParams(false)}>+ <div className="absolute inset-0 bg-black/50" />+ <div+ className="absolute right-0 top-0 h-full w-72 bg-white dark:bg-[#1a1a1a] border-l border-gray-200 dark:border-white/5 p-4 overflow-y-auto"+ onClick={(e) => e.stopPropagation()}+ >+ <div className="flex items-center justify-between mb-4">+ <h3 className="text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider">Parameters</h3>+ <button onClick={() => setShowParams(false)} className="p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300">+ <Settings size={16} />+ </button>+ </div>+ <ParamPanel+ imageModels={imageModels}+ videoModels={videoModels}+ samplerList={samplerList}+ schedulerList={schedulerList}+ modelsLoaded={modelsLoaded}+ />+ </div>+ </div>+ )}</div></div>)diff --git a/src/components/create/Gallery.tsx b/src/components/create/Gallery.tsxindex 2f8242cd..f1e5235c 100644--- a/src/components/create/Gallery.tsx+++ b/src/components/create/Gallery.tsx@@ -1,74 +1,149 @@-import { motion } from 'framer-motion'-import { Trash2, Download } from 'lucide-react'+import { useState } from 'react'+import { motion, AnimatePresence } from 'framer-motion'+import { Trash2, Download, ChevronDown, ChevronUp, X } from 'lucide-react'import { getImageUrl } from '../../api/comfyui'import { useCreateStore, type GalleryItem } from '../../stores/createStore'-interface Props {- onSelect?: (item: GalleryItem) => void-}+const PAGE_SIZE = 20++export function Gallery() {+ const { gallery, removeFromGallery, clearGallery } = useCreateStore()+ const [expanded, setExpanded] = useState(true)+ const [page, setPage] = useState(0)+ const [selected, setSelected] = useState<GalleryItem | null>(null)++ if (gallery.length === 0) {+ return (+ <div className="border-t border-gray-200 dark:border-white/5 px-4 py-3">+ <p className="text-xs text-gray-400 text-center">No images generated yet</p>+ </div>+ )+ }-export function Gallery({ onSelect }: Props) {- const { gallery, removeFromGallery } = useCreateStore()+ const totalPages = Math.ceil(gallery.length / PAGE_SIZE)+ const visible = gallery.slice(page * PAGE_SIZE, (page + 1) * PAGE_SIZE)- if (gallery.length === 0) return null+ const handleDownload = (item: GalleryItem) => {+ const url = getImageUrl(item.filename, item.subfolder)+ const a = document.createElement('a')+ a.href = url+ a.download = item.filename+ document.body.appendChild(a)+ a.click()+ document.body.removeChild(a)+ }return (- <div className="border-t border-gray-200 dark:border-white/5 p-4">- <div className="flex items-center justify-between mb-3">- <h3 className="text-sm font-medium text-gray-600 dark:text-gray-400">Gallery ({gallery.length})</h3>- </div>- <div className="flex gap-2 overflow-x-auto scrollbar-thin pb-2">- {gallery.map((item, i) => {- const url = getImageUrl(item.filename, item.subfolder)- return (+ <>+ <div className="border-t border-gray-200 dark:border-white/5">+ {/* Header */}+ <button+ onClick={() => setExpanded(!expanded)}+ className="flex items-center justify-between w-full px-4 py-2 text-xs font-medium text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 transition-colors"+ >+ <span>Gallery ({gallery.length})</span>+ <div className="flex items-center gap-2">+ {gallery.length > 0 && (+ <span+ onClick={(e) => { e.stopPropagation(); if (confirm('Clear all gallery items?')) clearGallery() }}+ className="text-red-400 hover:text-red-500 transition-colors"+ >+ Clear+ </span>+ )}+ {expanded ? <ChevronDown size={14} /> : <ChevronUp size={14} />}+ </div>+ </button>++ <AnimatePresence>+ {expanded && (<motion.div- key={item.id}- className="relative group shrink-0 cursor-pointer"- initial={{ opacity: 0, scale: 0.9 }}- animate={{ opacity: 1, scale: 1 }}- transition={{ delay: i * 0.03 }}- onClick={() => onSelect?.(item)}+ initial={{ height: 0 }}+ animate={{ height: 'auto' }}+ exit={{ height: 0 }}+ className="overflow-hidden">- {item.type === 'video' ? (- <video- src={url}- className="w-20 h-20 object-cover rounded-lg border border-gray-200 dark:border-white/10"- muted- />- ) : (- <img- src={url}- alt={item.prompt}- className="w-20 h-20 object-cover rounded-lg border border-gray-200 dark:border-white/10"- />- )}- <div className="absolute inset-0 bg-black/50 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-1">- <button- onClick={(e) => {- e.stopPropagation()- const a = document.createElement('a')- a.href = url- a.download = item.filename- a.click()- }}- className="p-1 rounded bg-white/20 text-white hover:bg-white/30"- >- <Download size={12} />- </button>- <button- onClick={(e) => {- e.stopPropagation()- removeFromGallery(item.id)- }}- className="p-1 rounded bg-red-500/50 text-white hover:bg-red-500/70"- >- <Trash2 size={12} />- </button>+ <div className="flex gap-2 overflow-x-auto scrollbar-thin px-4 pb-3">+ {visible.map((item, i) => {+ const url = getImageUrl(item.filename, item.subfolder)+ return (+ <motion.div+ key={item.id}+ className={`relative group shrink-0 cursor-pointer rounded-lg overflow-hidden border-2 transition-colors ${+ selected?.id === item.id ? 'border-purple-500' : 'border-transparent'+ }`}+ initial={{ opacity: 0, scale: 0.9 }}+ animate={{ opacity: 1, scale: 1 }}+ transition={{ delay: i * 0.02 }}+ onClick={() => setSelected(selected?.id === item.id ? null : item)}+ >+ {item.type === 'video' ? (+ <video+ src={url}+ className="w-20 h-20 object-cover"+ muted+ playsInline+ onMouseEnter={(e) => e.currentTarget.play()}+ onMouseLeave={(e) => { e.currentTarget.pause(); e.currentTarget.currentTime = 0 }}+ />+ ) : (+ <img src={url} alt="" className="w-20 h-20 object-cover" loading="lazy" />+ )}+ <div className="absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-1">+ <button+ onClick={(e) => { e.stopPropagation(); handleDownload(item) }}+ className="p-1.5 rounded bg-white/20 text-white hover:bg-white/30"+ title="Download"+ >+ <Download size={12} />+ </button>+ <button+ onClick={(e) => { e.stopPropagation(); removeFromGallery(item.id) }}+ className="p-1.5 rounded bg-red-500/50 text-white hover:bg-red-500/70"+ title="Delete"+ >+ <Trash2 size={12} />+ </button>+ </div>+ </motion.div>+ )+ })}</div>++ {/* Pagination */}+ {totalPages > 1 && (+ <div className="flex items-center justify-center gap-2 px-4 pb-2 text-xs text-gray-400">+ <button+ onClick={() => setPage(Math.max(0, page - 1))}+ disabled={page === 0}+ className="disabled:opacity-30"+ >+ Prev+ </button>+ <span>{page + 1} / {totalPages}</span>+ <button+ onClick={() => setPage(Math.min(totalPages - 1, page + 1))}+ disabled={page >= totalPages - 1}+ className="disabled:opacity-30"+ >+ Next+ </button>+ </div>+ )}++ {/* Selected item info */}+ {selected && (+ <div className="px-4 pb-2 flex items-center gap-2 text-xs text-gray-400">+ <span className="truncate flex-1">{selected.prompt}</span>+ <span>{selected.width}x{selected.height}</span>+ <span>Seed: {selected.seed}</span>+ <span>{selected.sampler}/{selected.scheduler}</span>+ </div>+ )}</motion.div>- )- })}+ )}+ </AnimatePresence></div>- </div>+ </>)}diff --git a/src/components/create/OutputDisplay.tsx b/src/components/create/OutputDisplay.tsxindex 0002247f..118f4b3a 100644--- a/src/components/create/OutputDisplay.tsx+++ b/src/components/create/OutputDisplay.tsx@@ -1,97 +1,179 @@-import { motion } from 'framer-motion'-import { Download, Maximize2 } from 'lucide-react'+import { useState } from 'react'+import { motion, AnimatePresence } from 'framer-motion'+import { Download, Maximize2, X, Copy, Check, RefreshCw } from 'lucide-react'import { getImageUrl } from '../../api/comfyui'import { useCreateStore, type GalleryItem } from '../../stores/createStore'-import { ProgressBar } from '../ui/ProgressBar'-interface Props {- onFullscreen?: (item: GalleryItem) => void-}--export function OutputDisplay({ onFullscreen }: Props) {- const { isGenerating, progress, gallery } = useCreateStore()+export function OutputDisplay() {+ const { isGenerating, progress, progressText, gallery } = useCreateStore()+ const [fullscreen, setFullscreen] = useState<GalleryItem | null>(null)+ const [copiedSeed, setCopiedSeed] = useState(false)const latest = gallery[0]+ const handleDownload = (item: GalleryItem) => {+ const url = getImageUrl(item.filename, item.subfolder)+ const a = document.createElement('a')+ a.href = url+ a.download = item.filename+ document.body.appendChild(a)+ a.click()+ document.body.removeChild(a)+ }++ const copySeed = (seed: number) => {+ navigator.clipboard.writeText(String(seed))+ setCopiedSeed(true)+ setTimeout(() => setCopiedSeed(false), 1500)+ }++ // Generating stateif (isGenerating) {return (<div className="flex-1 flex flex-col items-center justify-center p-8"><div className="w-full max-w-sm space-y-4"><motion.divclassName="w-16 h-16 mx-auto rounded-2xl bg-gray-100 dark:bg-white/5 flex items-center justify-center"- animate={{ rotate: 360 }}- transition={{ duration: 2, repeat: Infinity, ease: 'linear' }}+ animate={{ scale: [1, 1.1, 1] }}+ transition={{ duration: 1.5, repeat: Infinity }}>- <span className="text-2xl">🎨</span>+ <span className="text-2xl">{useCreateStore.getState().mode === 'video' ? '🎬' : '🎨'}</span></motion.div>- <p className="text-center text-gray-500 text-sm">Generating...</p>- <ProgressBar progress={progress} />+ <div className="space-y-2">+ <div className="w-full bg-gray-200 dark:bg-white/10 rounded-full h-2 overflow-hidden">+ <motion.div+ className="bg-purple-500 h-full rounded-full"+ initial={{ width: 0 }}+ animate={{ width: `${progress}%` }}+ transition={{ duration: 0.3 }}+ />+ </div>+ <p className="text-center text-gray-500 dark:text-gray-400 text-xs">{progressText || `${Math.round(progress)}%`}</p>+ </div></div></div>)}+ // Empty stateif (!latest) {return (<div className="flex-1 flex items-center justify-center p-8"><div className="text-center"><div className="w-16 h-16 mx-auto rounded-2xl bg-gray-100 dark:bg-white/5 flex items-center justify-center mb-4">- <span className="text-2xl">🖼️</span>+ <span className="text-2xl">🖼</span></div>- <p className="text-gray-500 text-sm">Your creations will appear here</p>+ <p className="text-gray-400 dark:text-gray-500 text-sm">Your creations will appear here</p>+ <p className="text-gray-300 dark:text-gray-600 text-xs mt-1">Write a prompt and hit Generate</p></div></div>)}+ // Show latest resultconst url = getImageUrl(latest.filename, latest.subfolder)- const handleDownload = () => {- const a = document.createElement('a')- a.href = url- a.download = latest.filename- a.click()- }-return (- <div className="flex-1 flex flex-col items-center justify-center p-4 relative group">- <motion.div- initial={{ opacity: 0, scale: 0.95 }}- animate={{ opacity: 1, scale: 1 }}- className="relative max-w-full max-h-full"- >- {latest.type === 'video' ? (- <video- src={url}- controls- autoPlay- loop- className="max-w-full max-h-[60vh] rounded-xl border border-gray-200 dark:border-white/10"- />- ) : (- <img- src={url}- alt={latest.prompt}- className="max-w-full max-h-[60vh] rounded-xl border border-gray-200 dark:border-white/10 object-contain"- />- )}- <div className="absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity">- {onFullscreen && (+ <>+ <div className="flex-1 flex flex-col items-center justify-center p-4 relative group min-h-0">+ <motion.div+ initial={{ opacity: 0, scale: 0.95 }}+ animate={{ opacity: 1, scale: 1 }}+ className="relative max-w-full max-h-full flex flex-col items-center"+ >+ {latest.type === 'video' ? (+ <video+ src={url}+ controls+ autoPlay+ loop+ className="max-w-full max-h-[50vh] rounded-xl border border-gray-200 dark:border-white/10"+ />+ ) : (+ <img+ src={url}+ alt={latest.prompt}+ className="max-w-full max-h-[50vh] rounded-xl border border-gray-200 dark:border-white/10 object-contain cursor-pointer"+ onClick={() => setFullscreen(latest)}+ />+ )}++ {/* Hover controls */}+ <div className="absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity z-10"><button- onClick={() => onFullscreen(latest)}+ onClick={() => setFullscreen(latest)}className="p-2 rounded-lg bg-black/50 text-white hover:bg-black/70 transition-colors"+ title="Fullscreen"><Maximize2 size={14} /></button>- )}+ <button+ onClick={() => handleDownload(latest)}+ className="p-2 rounded-lg bg-black/50 text-white hover:bg-black/70 transition-colors"+ title="Download"+ >+ <Download size={14} />+ </button>+ </div>+ </motion.div>++ {/* Info bar */}+ <div className="flex items-center gap-3 mt-2 text-xs text-gray-400">+ <span className="truncate max-w-xs">{latest.prompt}</span>+ <span>·</span><button- onClick={handleDownload}- className="p-2 rounded-lg bg-black/50 text-white hover:bg-black/70 transition-colors"+ onClick={() => copySeed(latest.seed)}+ className="flex items-center gap-1 hover:text-gray-600 dark:hover:text-gray-300 transition-colors"+ title="Copy seed">- <Download size={14} />+ Seed: {latest.seed} {copiedSeed ? <Check size={10} /> : <Copy size={10} />}</button>+ <span>·</span>+ <span>{latest.width}x{latest.height}</span></div>- </motion.div>- <p className="text-xs text-gray-400 mt-2 truncate max-w-md">{latest.prompt}</p>- </div>+ </div>++ {/* Fullscreen overlay */}+ <AnimatePresence>+ {fullscreen && (+ <motion.div+ initial={{ opacity: 0 }}+ animate={{ opacity: 1 }}+ exit={{ opacity: 0 }}+ className="fixed inset-0 z-50 bg-black/90 flex items-center justify-center p-4"+ onClick={() => setFullscreen(null)}+ >+ <button+ className="absolute top-4 right-4 p-2 rounded-full bg-white/10 text-white hover:bg-white/20 z-50"+ onClick={() => setFullscreen(null)}+ >+ <X size={20} />+ </button>+ <button+ className="absolute top-4 right-14 p-2 rounded-full bg-white/10 text-white hover:bg-white/20 z-50"+ onClick={(e) => { e.stopPropagation(); handleDownload(fullscreen) }}+ >+ <Download size={20} />+ </button>+ {fullscreen.type === 'video' ? (+ <video+ src={getImageUrl(fullscreen.filename, fullscreen.subfolder)}+ controls+ autoPlay+ loop+ className="max-w-[95vw] max-h-[95vh]"+ onClick={(e) => e.stopPropagation()}+ />+ ) : (+ <img+ src={getImageUrl(fullscreen.filename, fullscreen.subfolder)}+ alt={fullscreen.prompt}+ className="max-w-[95vw] max-h-[95vh] object-contain"+ onClick={(e) => e.stopPropagation()}+ />+ )}+ </motion.div>+ )}+ </AnimatePresence>+ </>)}diff --git a/src/components/create/ParamPanel.tsx b/src/components/create/ParamPanel.tsxindex b12a1cfc..44e3eef3 100644--- a/src/components/create/ParamPanel.tsx+++ b/src/components/create/ParamPanel.tsx@@ -1,12 +1,14 @@import { useCreateStore } from '../../stores/createStore'import { SliderControl } from '../settings/SliderControl'-import { Dice5 } from 'lucide-react'+import { Dice5, Info } from 'lucide-react'import type { ClassifiedModel, ModelType } from '../../api/comfyui'interface Props {imageModels: ClassifiedModel[]videoModels: ClassifiedModel[]samplerList: string[]+ schedulerList: string[]+ modelsLoaded: boolean}const IMG_SIZE_PRESETS = [@@ -25,32 +27,33 @@ const VID_SIZE_PRESETS = []const TYPE_BADGE: Record<ModelType, { label: string; color: string }> = {- flux: { label: 'FLUX', color: 'bg-purple-500/20 text-purple-300' },- sdxl: { label: 'SDXL', color: 'bg-blue-500/20 text-blue-300' },- sd15: { label: 'SD 1.5', color: 'bg-green-500/20 text-green-300' },- wan: { label: 'Wan', color: 'bg-orange-500/20 text-orange-300' },- hunyuan: { label: 'Hunyuan', color: 'bg-red-500/20 text-red-300' },- unknown: { label: 'Model', color: 'bg-gray-500/20 text-gray-300' },+ flux: { label: 'FLUX', 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' },+ hunyuan: { label: 'Hunyuan', color: 'bg-red-100 dark:bg-red-500/20 text-red-700 dark:text-red-300' },+ unknown: { label: 'Model', color: 'bg-gray-100 dark:bg-gray-500/20 text-gray-700 dark:text-gray-300' },}-export function ParamPanel({ imageModels, videoModels, samplerList }: Props) {+export function ParamPanel({ imageModels, videoModels, samplerList, schedulerList, modelsLoaded }: Props) {const store = useCreateStore()const isVideo = store.mode === 'video'const sizePresets = isVideo ? VID_SIZE_PRESETS : IMG_SIZE_PRESETSconst models = isVideo ? videoModels : imageModels- const selectClass = 'w-full px-3 py-2 rounded-lg bg-gray-100 dark:bg-white/5 border border-gray-300 dark:border-white/10 text-gray-900 dark:text-white text-sm focus:outline-none focus:border-gray-400 dark:focus:border-white/20 appearance-none cursor-pointer'+ const selectClass = 'w-full px-3 py-2 rounded-lg bg-gray-100 dark:bg-white/5 border border-gray-200 dark:border-white/10 text-gray-900 dark:text-white text-sm focus:outline-none focus:border-gray-400 dark:focus:border-white/20 appearance-none cursor-pointer'const handleModelChange = (name: string) => {if (isVideo) {store.setVideoModel(name)} else {const model = imageModels.find(m => m.name === name)- store.setImageModel(name, model?.type || 'unknown')+ store.setImageModel(name, model?.type ?? 'unknown')}}const activeModel = isVideo ? store.videoModel : store.imageModel+ const videoDuration = isVideo ? (store.frames / store.fps).toFixed(1) : nullreturn (<div className="space-y-4">@@ -59,39 +62,36 @@ export function ParamPanel({ imageModels, videoModels, samplerList }: Props) {<label className="text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-1.5 block">{isVideo ? 'Video Model' : 'Image Model'}</label>- {models.length === 0 ? (+ {!modelsLoaded ? (+ <div className="px-3 py-2 rounded-lg bg-gray-100 dark:bg-white/5 border border-gray-200 dark:border-white/10 text-gray-400 text-xs animate-pulse">+ Loading models...+ </div>+ ) : models.length === 0 ? (<div className="px-3 py-2 rounded-lg bg-yellow-50 dark:bg-yellow-500/10 border border-yellow-200 dark:border-yellow-500/20 text-yellow-700 dark:text-yellow-400 text-xs">{isVideo? 'No video models found. Add Wan or Hunyuan models to ComfyUI.': 'No image models found. Add checkpoints or FLUX models to ComfyUI.'}</div>) : (- <select value={activeModel} onChange={(e) => handleModelChange(e.target.value)} className={selectClass}>- {models.map((m) => {- const badge = TYPE_BADGE[m.type]- const shortName = m.name.replace(/\.[^.]+$/, '')- return (- <option key={m.name} value={m.name}>- {shortName} ({badge.label})- </option>- )- })}- </select>- )}- {/* Type badge below dropdown */}- {activeModel && models.length > 0 && (- <div className="mt-1 flex items-center gap-1">- {(() => {+ <>+ <select value={activeModel} onChange={(e) => handleModelChange(e.target.value)} className={selectClass}>+ {models.map((m) => {+ const badge = TYPE_BADGE[m.type]+ const shortName = m.name.replace(/\.[^.]+$/, '')+ return <option key={m.name} value={m.name}>{shortName} ({badge.label})</option>+ })}+ </select>+ {activeModel && (() => {const model = models.find(m => m.name === activeModel)if (!model) return nullconst badge = TYPE_BADGE[model.type]return (- <span className={`px-1.5 py-0.5 rounded text-[10px] font-medium ${badge.color}`}>+ <span className={`mt-1 inline-block px-1.5 py-0.5 rounded text-[10px] font-medium ${badge.color}`}>{badge.label}</span>)})()}- </div>+ </>)}</div>@@ -99,9 +99,15 @@ export function ParamPanel({ imageModels, videoModels, samplerList }: Props) {<div><label className="text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-1.5 block">Sampler</label><select value={store.sampler} onChange={(e) => store.setSampler(e.target.value)} className={selectClass}>- {samplerList.map((s) => (- <option key={s} value={s}>{s}</option>- ))}+ {samplerList.map((s) => <option key={s} value={s}>{s}</option>)}+ </select>+ </div>++ {/* Scheduler */}+ <div>+ <label className="text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-1.5 block">Scheduler</label>+ <select value={store.scheduler} onChange={(e) => store.setScheduler(e.target.value)} className={selectClass}>+ {schedulerList.map((s) => <option key={s} value={s}>{s}</option>)}</select></div>@@ -109,7 +115,12 @@ export function ParamPanel({ imageModels, videoModels, samplerList }: Props) {<SliderControl label="Steps" value={store.steps} min={1} max={50} step={1} onChange={store.setSteps} />{/* CFG Scale */}- <SliderControl label="CFG Scale" value={store.cfgScale} min={1} max={20} step={0.5} onChange={store.setCfgScale} />+ <SliderControl label="CFG Scale" value={store.cfgScale} min={0} max={30} step={0.5} onChange={store.setCfgScale} />++ {/* Batch Size */}+ {!isVideo && (+ <SliderControl label="Batch Size" value={store.batchSize} min={1} max={4} step={1} onChange={store.setBatchSize} />+ )}{/* Size Presets */}<div>@@ -120,11 +131,11 @@ export function ParamPanel({ imageModels, videoModels, samplerList }: Props) {{sizePresets.map((preset) => (<buttonkey={preset.label}- onClick={() => { store.setWidth(preset.w); store.setHeight(preset.h) }}+ onClick={() => store.setSize(preset.w, preset.h)}className={`px-2 py-1 rounded text-xs transition-all ${store.width === preset.w && store.height === preset.h? 'bg-gray-800 dark:bg-white/15 text-white'- : 'bg-gray-100 dark:bg-white/5 text-gray-500 hover:bg-gray-200 dark:hover:bg-white/10'+ : 'bg-gray-100 dark:bg-white/5 text-gray-600 dark:text-gray-500 hover:bg-gray-200 dark:hover:bg-white/10'}`}>{preset.label}@@ -141,12 +152,13 @@ export function ParamPanel({ imageModels, videoModels, samplerList }: Props) {type="number"value={store.seed}onChange={(e) => store.setSeed(parseInt(e.target.value) || -1)}- className="flex-1 px-3 py-2 rounded-lg bg-gray-100 dark:bg-white/5 border border-gray-300 dark:border-white/10 text-gray-900 dark:text-white text-sm focus:outline-none font-mono"+ className="flex-1 px-3 py-2 rounded-lg bg-gray-100 dark:bg-white/5 border border-gray-200 dark:border-white/10 text-gray-900 dark:text-white text-sm focus:outline-none font-mono"placeholder="-1 = random"+ aria-label="Seed value, -1 for random"/><buttononClick={() => store.setSeed(-1)}- className="p-2 rounded-lg bg-gray-100 dark:bg-white/5 border border-gray-300 dark:border-white/10 text-gray-500 hover:text-gray-900 dark:hover:text-white transition-colors"+ className="p-2 rounded-lg bg-gray-100 dark:bg-white/5 border border-gray-200 dark:border-white/10 text-gray-500 hover:text-gray-900 dark:hover:text-white transition-colors"title="Random seed"><Dice5 size={16} />@@ -159,6 +171,10 @@ export function ParamPanel({ imageModels, videoModels, samplerList }: Props) {<><SliderControl label="Frames" value={store.frames} min={8} max={81} step={1} 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></>)}</div>diff --git a/src/components/create/PromptInput.tsx b/src/components/create/PromptInput.tsxindex 750587a9..766dfe20 100644--- a/src/components/create/PromptInput.tsx+++ b/src/components/create/PromptInput.tsx@@ -1,37 +1,84 @@-import { useState } from 'react'-import { motion } from 'framer-motion'-import { Sparkles, Square, ChevronDown, ChevronUp } from 'lucide-react'+import { useState, useRef } from 'react'+import { motion, AnimatePresence } from 'framer-motion'+import { Sparkles, Square, ChevronDown, ChevronUp, History, X } from 'lucide-react'import { useCreateStore } from '../../stores/createStore'interface Props {onGenerate: () => voidonCancel: () => void+ disabled?: boolean}-export function PromptInput({ onGenerate, onCancel }: Props) {- const { prompt, negativePrompt, isGenerating, setPrompt, setNegativePrompt } = useCreateStore()+export function PromptInput({ onGenerate, onCancel, disabled }: Props) {+ const { prompt, negativePrompt, isGenerating, promptHistory, setPrompt, setNegativePrompt } = useCreateStore()const [showNegative, setShowNegative] = useState(false)+ const [showHistory, setShowHistory] = useState(false)+ const textareaRef = useRef<HTMLTextAreaElement>(null)+ const isMac = navigator.platform.toUpperCase().includes('MAC')const handleKeyDown = (e: React.KeyboardEvent) => {- if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {+ if (e.key === 'Enter' && (isMac ? e.metaKey : e.ctrlKey)) {e.preventDefault()- onGenerate()+ if (!isGenerating && prompt.trim()) onGenerate()}}+ const selectFromHistory = (p: string) => {+ setPrompt(p)+ setShowHistory(false)+ textareaRef.current?.focus()+ }+return (- <div className="space-y-3">- <div className="glass-card rounded-xl p-4">- <textarea- value={prompt}- onChange={(e) => setPrompt(e.target.value)}- onKeyDown={handleKeyDown}- placeholder="Describe what you want to create..."- rows={3}- className="w-full bg-transparent resize-none text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none text-sm leading-relaxed"- disabled={isGenerating}- />- <div className="flex items-center justify-between mt-2 pt-2 border-t border-gray-200 dark:border-white/5">+ <div className="space-y-2">+ <div className="rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-[#2a2a2a] overflow-hidden">+ <div className="relative">+ <textarea+ ref={textareaRef}+ value={prompt}+ onChange={(e) => setPrompt(e.target.value)}+ onKeyDown={handleKeyDown}+ placeholder="Describe what you want to create..."+ rows={3}+ className="w-full bg-transparent resize-none text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none text-sm leading-relaxed p-4"+ disabled={isGenerating || disabled}+ aria-label="Image or video generation prompt"+ />+ {/* Prompt history button */}+ {promptHistory.length > 0 && (+ <button+ onClick={() => setShowHistory(!showHistory)}+ className="absolute top-2 right-2 p-1 rounded text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/10 transition-colors"+ title="Prompt history"+ >+ <History size={14} />+ </button>+ )}+ </div>++ {/* Prompt history dropdown */}+ <AnimatePresence>+ {showHistory && promptHistory.length > 0 && (+ <motion.div+ initial={{ opacity: 0, height: 0 }}+ animate={{ opacity: 1, height: 'auto' }}+ exit={{ opacity: 0, height: 0 }}+ className="border-t border-gray-200 dark:border-white/10 max-h-32 overflow-y-auto"+ >+ {promptHistory.map((p, i) => (+ <button+ key={i}+ onClick={() => selectFromHistory(p)}+ className="w-full text-left px-4 py-1.5 text-xs text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 truncate transition-colors"+ >+ {p}+ </button>+ ))}+ </motion.div>+ )}+ </AnimatePresence>++ <div className="flex items-center justify-between px-4 py-2 border-t border-gray-100 dark:border-white/5"><buttononClick={() => setShowNegative(!showNegative)}className="flex items-center gap-1 text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors"@@ -39,45 +86,56 @@ export function PromptInput({ onGenerate, onCancel }: Props) {{showNegative ? <ChevronUp size={14} /> : <ChevronDown size={14} />}Negative prompt</button>- {isGenerating ? (- <motion.button- onClick={onCancel}- className="flex items-center gap-2 px-4 py-2 rounded-lg bg-red-100 dark:bg-red-500/20 border border-red-300 dark:border-red-500/30 text-red-600 dark:text-red-400 text-sm font-medium"- whileTap={{ scale: 0.95 }}- >- <Square size={14} /> Cancel- </motion.button>- ) : (- <motion.button- onClick={onGenerate}- disabled={!prompt.trim()}- className="flex items-center gap-2 px-4 py-2 rounded-lg bg-gray-800 dark:bg-white/10 text-white text-sm font-medium disabled:opacity-30 disabled:cursor-not-allowed hover:bg-gray-700 dark:hover:bg-white/15 transition-all"- whileTap={{ scale: 0.95 }}- >- <Sparkles size={14} /> Generate- </motion.button>- )}+ <div className="flex items-center gap-2">+ {prompt.trim() && !isGenerating && (+ <button onClick={() => setPrompt('')} className="p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300">+ <X size={14} />+ </button>+ )}+ {isGenerating ? (+ <motion.button+ onClick={onCancel}+ className="flex items-center gap-2 px-4 py-1.5 rounded-lg bg-red-100 dark:bg-red-500/20 border border-red-300 dark:border-red-500/30 text-red-600 dark:text-red-400 text-sm font-medium"+ whileTap={{ scale: 0.95 }}+ >+ <Square size={14} /> Cancel+ </motion.button>+ ) : (+ <motion.button+ onClick={onGenerate}+ disabled={!prompt.trim() || disabled}+ className="flex items-center gap-2 px-4 py-1.5 rounded-lg bg-gray-800 dark:bg-white/10 text-white text-sm font-medium disabled:opacity-30 disabled:cursor-not-allowed hover:bg-gray-700 dark:hover:bg-white/15 transition-all"+ whileTap={{ scale: 0.95 }}+ >+ <Sparkles size={14} /> Generate+ </motion.button>+ )}+ </div></div></div>- {showNegative && (- <motion.div- initial={{ opacity: 0, height: 0 }}- animate={{ opacity: 1, height: 'auto' }}- className="glass-card rounded-xl p-4"- >- <textarea- value={negativePrompt}- onChange={(e) => setNegativePrompt(e.target.value)}- placeholder="What to avoid (e.g. blurry, low quality, watermark)..."- rows={2}- className="w-full bg-transparent resize-none text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none text-sm leading-relaxed"- disabled={isGenerating}- />- </motion.div>- )}+ <AnimatePresence>+ {showNegative && (+ <motion.div+ initial={{ opacity: 0, height: 0 }}+ animate={{ opacity: 1, height: 'auto' }}+ exit={{ opacity: 0, height: 0 }}+ className="rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-[#2a2a2a] overflow-hidden"+ >+ <textarea+ value={negativePrompt}+ onChange={(e) => setNegativePrompt(e.target.value)}+ placeholder="What to avoid (e.g. blurry, low quality, watermark)..."+ rows={2}+ className="w-full bg-transparent resize-none text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none text-sm leading-relaxed p-4"+ disabled={isGenerating}+ aria-label="Negative prompt"+ />+ </motion.div>+ )}+ </AnimatePresence>- <p className="text-xs text-gray-400 text-center">Ctrl+Enter to generate</p>+ <p className="text-xs text-gray-400 text-center">{isMac ? 'Cmd' : 'Ctrl'}+Enter to generate</p></div>)}diff --git a/src/hooks/useCreate.ts b/src/hooks/useCreate.tsindex 8e4a74e3..f55f6fdc 100644--- a/src/hooks/useCreate.ts+++ b/src/hooks/useCreate.ts@@ -1,11 +1,13 @@-import { useState, useCallback, useRef } from 'react'+import { useState, useCallback, useRef, useEffect } from 'react'import { v4 as uuid } from 'uuid'import {checkComfyConnection,getImageModels,getVideoModels,getSamplers,+ getSchedulers,detectVideoBackend,+ cancelGeneration,submitWorkflow,getHistory,buildTxt2ImgWorkflow,@@ -17,14 +19,22 @@ import {import { useCreateStore, type GalleryItem } from '../stores/createStore'export function useCreate() {- const store = useCreateStore()const [connected, setConnected] = useState<boolean | null>(null)const [imageModels, setImageModels] = useState<ClassifiedModel[]>([])const [videoModelsList, setVideoModelsList] = useState<ClassifiedModel[]>([])const [samplerList, setSamplerList] = useState<string[]>([])+ const [schedulerList, setSchedulerList] = useState<string[]>([])const [videoBackend, setVideoBackend] = useState<VideoBackend>('none')- const [error, setError] = useState<string | null>(null)+ const [modelsLoaded, setModelsLoaded] = useState(false)const pollRef = useRef<ReturnType<typeof setInterval> | null>(null)+ const abortRef = useRef<AbortController | null>(null)++ // Cleanup on unmount+ useEffect(() => {+ return () => {+ if (pollRef.current) clearInterval(pollRef.current)+ }+ }, [])const checkConnection = useCallback(async () => {const ok = await checkComfyConnection()@@ -33,37 +43,43 @@ export function useCreate() {}, [])const fetchModels = useCallback(async () => {- const [imgModels, vidModels, samplers, vBackend] = await Promise.all([- getImageModels(),- getVideoModels(),- getSamplers(),- detectVideoBackend(),- ])- setImageModels(imgModels)- setVideoModelsList(vidModels)- setSamplerList(samplers)- setVideoBackend(vBackend)-- // Auto-select first image model if none set- if (imgModels.length > 0 && !store.imageModel) {- store.setImageModel(imgModels[0].name, imgModels[0].type)- }- // Auto-select first video model if none set- if (vidModels.length > 0 && !store.videoModel) {- store.setVideoModel(vidModels[0].name)+ try {+ const [imgModels, vidModels, samplers, schedulers, vBackend] = await Promise.all([+ getImageModels(),+ getVideoModels(),+ getSamplers(),+ getSchedulers(),+ detectVideoBackend(),+ ])+ setImageModels(imgModels)+ setVideoModelsList(vidModels)+ setSamplerList(samplers)+ setSchedulerList(schedulers)+ setVideoBackend(vBackend)+ setModelsLoaded(true)++ // Auto-select first models if none set+ const state = useCreateStore.getState()+ if (imgModels.length > 0 && !state.imageModel) {+ state.setImageModel(imgModels[0].name, imgModels[0].type)+ }+ if (vidModels.length > 0 && !state.videoModel) {+ state.setVideoModel(vidModels[0].name)+ }+ } catch (err) {+ console.error('[useCreate] Failed to fetch models:', err)}- }, [store])+ }, [])const generate = useCallback(async () => {const state = useCreateStore.getState()const {mode, prompt, negativePrompt, imageModel, imageModelType, videoModel,- sampler, steps, cfgScale, width, height, seed, frames, fps,- setIsGenerating, setProgress, setCurrentPromptId, addToGallery,+ sampler, scheduler, steps, cfgScale, width, height, seed, batchSize, frames, fps,+ setIsGenerating, setProgress, setCurrentPromptId, setError, addToGallery, addToPromptHistory,} = statesetError(null)-const activeModel = mode === 'image' ? imageModel : videoModelif (!prompt.trim()) {@@ -73,34 +89,33 @@ export function useCreate() {if (!activeModel) {setError(mode === 'image'? 'No image model selected. Add checkpoints or FLUX models to ComfyUI.'- : 'No video model selected. Install Wan 2.1 or AnimateDiff models in ComfyUI.')+ : 'No video model selected. Install Wan 2.1 or AnimateDiff models.')return}const isRunning = await checkComfyConnection()if (!isRunning) {- setError('ComfyUI is not running. Wait for it to start or check the connection.')+ setError('ComfyUI is not running. Wait for it to start.')return}setIsGenerating(true)- setProgress(0)+ setProgress(0, 'Preparing workflow...')+ abortRef.current = new AbortController()try {- let workflow: Record<string, any>+ const baseParams = { prompt, negativePrompt, model: activeModel, sampler, scheduler, steps, cfgScale, width, height, seed, batchSize }+ let workflow: Record<string, any>if (mode === 'video') {- workflow = await buildTxt2VidWorkflow(- { prompt, negativePrompt, model: activeModel, sampler, steps, cfgScale, width, height, seed, frames, fps },- videoBackend- )+ setProgress(5, 'Building video workflow...')+ workflow = await buildTxt2VidWorkflow({ ...baseParams, frames, fps }, videoBackend)} else {- workflow = await buildTxt2ImgWorkflow(- { prompt, negativePrompt, model: activeModel, sampler, steps, cfgScale, width, height, seed },- imageModelType- )+ setProgress(5, 'Building image workflow...')+ workflow = await buildTxt2ImgWorkflow(baseParams, imageModelType)}+ setProgress(10, 'Submitting to ComfyUI...')let promptId: stringtry {promptId = await submitWorkflow(workflow)@@ -110,39 +125,50 @@ export function useCreate() {return}setCurrentPromptId(promptId)+ addToPromptHistory(prompt)// Poll for completionawait new Promise<void>((resolve, reject) => {let attempts = 0const maxAttempts = 1200+ const startTime = Date.now()pollRef.current = setInterval(async () => {+ if (abortRef.current?.signal.aborted) {+ if (pollRef.current) clearInterval(pollRef.current)+ reject(new Error('Cancelled'))+ return+ }+attempts++if (attempts > maxAttempts) {- clearInterval(pollRef.current!)+ if (pollRef.current) clearInterval(pollRef.current)reject(new Error('Generation timed out after 20 minutes'))return}+ const elapsed = Math.round((Date.now() - startTime) / 1000)+ const pct = Math.min(10 + (attempts / (steps * 2) * 85), 95)+try {const history = await getHistory(promptId)if (!history) {- setProgress(Math.min(attempts / (steps * 2) * 100, 95))+ setProgress(pct, `Generating... ${elapsed}s elapsed`)return}if (history.status?.completed) {- clearInterval(pollRef.current!)- setProgress(100)+ if (pollRef.current) clearInterval(pollRef.current)+ setProgress(100, 'Complete!')- const outputs = history.outputs || {}+ const outputs = history.outputs ?? {}let found = falsefor (const nodeId of Object.keys(outputs)) {const nodeOutput = outputs[nodeId]const files: ComfyUIOutput[] = [- ...(nodeOutput.images || []),- ...(nodeOutput.gifs || []),- ...(nodeOutput.videos || []),+ ...(nodeOutput.images ?? []),+ ...(nodeOutput.gifs ?? []),+ ...(nodeOutput.videos ?? []),]for (const file of files) {found = true@@ -150,59 +176,65 @@ export function useCreate() {id: uuid(),type: mode,filename: file.filename,- subfolder: file.subfolder || '',- prompt,- negativePrompt,+ subfolder: file.subfolder ?? '',+ prompt, negativePrompt,model: activeModel,modelType: mode === 'image' ? imageModelType : 'wan',seed: seed === -1 ? 0 : seed,- steps, cfgScale, width, height,+ steps, cfgScale, sampler, scheduler, width, height,+ batchSize,createdAt: Date.now(),}addToGallery(galleryItem)}}- if (!found) {- setError('Generation completed but no output was produced. Check ComfyUI logs.')- }+ if (!found) setError('Generation completed but no output was produced. Check ComfyUI logs.')resolve()} else if (history.status?.status_str === 'error') {- clearInterval(pollRef.current!)- const errMsg = history.status?.messages?.[0]?.[1]?.message || 'Unknown ComfyUI error'+ if (pollRef.current) clearInterval(pollRef.current)+ const errMsg = history.status?.messages?.[0]?.[1]?.message ?? 'Unknown ComfyUI error'reject(new Error(errMsg))}- } catch {- // Keep polling on network errors+ } catch (err) {+ console.warn('[useCreate] Poll error:', err)}}, 1000)})} catch (err) {- const msg = err instanceof Error ? err.message : String(err)- setError(`Generation failed: ${msg}`)- console.error('Generation error:', err)+ if (err instanceof Error && err.message === 'Cancelled') {+ // User cancelled, not an error+ } else {+ const msg = err instanceof Error ? err.message : String(err)+ useCreateStore.getState().setError(`Generation failed: ${msg}`)+ console.error('[useCreate] Generation error:', err)+ }} finally {- setIsGenerating(false)- setProgress(0)- setCurrentPromptId(null)- if (pollRef.current) clearInterval(pollRef.current)+ useCreateStore.getState().setIsGenerating(false)+ useCreateStore.getState().setProgress(0)+ useCreateStore.getState().setCurrentPromptId(null)+ if (pollRef.current) { clearInterval(pollRef.current); pollRef.current = null }+ abortRef.current = null}}, [videoBackend])- const cancel = useCallback(() => {- if (pollRef.current) clearInterval(pollRef.current)- store.setIsGenerating(false)- store.setProgress(0)- store.setCurrentPromptId(null)- setError(null)- }, [store])+ const cancel = useCallback(async () => {+ abortRef.current?.abort()+ await cancelGeneration()+ if (pollRef.current) { clearInterval(pollRef.current); pollRef.current = null }+ useCreateStore.getState().setIsGenerating(false)+ useCreateStore.getState().setProgress(0)+ useCreateStore.getState().setCurrentPromptId(null)+ useCreateStore.getState().setError(null)+ }, [])return {connected,imageModels,videoModels: videoModelsList,samplerList,+ schedulerList,videoBackend,- error,+ modelsLoaded,checkConnection,fetchModels,generate,diff --git a/src/stores/createStore.ts b/src/stores/createStore.tsindex 65394238..371660e0 100644--- a/src/stores/createStore.ts+++ b/src/stores/createStore.ts@@ -14,8 +14,11 @@ export interface GalleryItem {seed: numbersteps: numbercfgScale: number+ sampler: string+ scheduler: stringwidth: numberheight: number+ batchSize: numbercreatedAt: number}@@ -27,17 +30,22 @@ interface CreateState {imageModelType: ModelTypevideoModel: stringsampler: string+ scheduler: stringsteps: numbercfgScale: numberwidth: numberheight: numberseed: number+ batchSize: numberframes: numberfps: numberisGenerating: booleanprogress: number+ progressText: stringcurrentPromptId: string | null+ error: string | nullgallery: GalleryItem[]+ promptHistory: string[]setMode: (mode: 'image' | 'video') => voidsetPrompt: (prompt: string) => void@@ -45,19 +53,22 @@ interface CreateState {setImageModel: (model: string, type: ModelType) => voidsetVideoModel: (model: string) => voidsetSampler: (sampler: string) => void+ setScheduler: (scheduler: string) => voidsetSteps: (steps: number) => voidsetCfgScale: (cfgScale: number) => void- setWidth: (width: number) => void- setHeight: (height: number) => void+ setSize: (width: number, height: number) => voidsetSeed: (seed: number) => void+ setBatchSize: (batchSize: number) => voidsetFrames: (frames: number) => voidsetFps: (fps: number) => voidsetIsGenerating: (generating: boolean) => void- setProgress: (progress: number) => void+ setProgress: (progress: number, text?: string) => voidsetCurrentPromptId: (id: string | null) => void+ setError: (error: string | null) => voidaddToGallery: (item: GalleryItem) => voidremoveFromGallery: (id: string) => voidclearGallery: () => void+ addToPromptHistory: (prompt: string) => void}export const useCreateStore = create<CreateState>()(@@ -70,17 +81,22 @@ export const useCreateStore = create<CreateState>()(imageModelType: 'unknown' as ModelType,videoModel: '',sampler: 'euler',+ scheduler: 'normal',steps: 20,cfgScale: 7,width: 1024,height: 1024,seed: -1,+ batchSize: 1,frames: 24,fps: 8,isGenerating: false,progress: 0,+ progressText: '',currentPromptId: null,+ error: null,gallery: [],+ promptHistory: [],setMode: (mode) => set({ mode }),setPrompt: (prompt) => set({ prompt }),@@ -88,19 +104,28 @@ export const useCreateStore = create<CreateState>()(setImageModel: (model, type) => set({ imageModel: model, imageModelType: type }),setVideoModel: (model) => set({ videoModel: model }),setSampler: (sampler) => set({ sampler }),- setSteps: (steps) => set({ steps }),- setCfgScale: (cfgScale) => set({ cfgScale }),- setWidth: (width) => set({ width }),- setHeight: (height) => set({ height }),- setSeed: (seed) => set({ seed }),- setFrames: (frames) => set({ frames }),- setFps: (fps) => set({ fps }),+ setScheduler: (scheduler) => set({ scheduler }),+ setSteps: (steps) => set({ steps: Math.max(1, Math.min(200, Math.floor(steps))) }),+ setCfgScale: (cfgScale) => set({ cfgScale: Math.max(0, Math.min(30, cfgScale)) }),+ setSize: (width, height) => set({+ width: Math.max(64, Math.min(4096, Math.floor(width))),+ height: Math.max(64, Math.min(4096, Math.floor(height))),+ }),+ setSeed: (seed) => set({ seed: Math.floor(seed) }),+ setBatchSize: (batchSize) => set({ batchSize: Math.max(1, Math.min(8, Math.floor(batchSize))) }),+ setFrames: (frames) => set({ frames: Math.max(1, Math.min(120, Math.floor(frames))) }),+ setFps: (fps) => set({ fps: Math.max(1, Math.min(60, Math.floor(fps))) }),setIsGenerating: (generating) => set({ isGenerating: generating }),- setProgress: (progress) => set({ progress }),+ setProgress: (progress, text) => set({ progress, progressText: text ?? '' }),setCurrentPromptId: (id) => set({ currentPromptId: id }),- addToGallery: (item) => set((s) => ({ gallery: [item, ...s.gallery] })),+ setError: (error) => set({ error }),+ addToGallery: (item) => set((s) => ({ gallery: [item, ...s.gallery].slice(0, 200) })),removeFromGallery: (id) => set((s) => ({ gallery: s.gallery.filter((g) => g.id !== id) })),clearGallery: () => set({ gallery: [] }),+ addToPromptHistory: (prompt) => set((s) => {+ const filtered = s.promptHistory.filter(p => p !== prompt)+ return { promptHistory: [prompt, ...filtered].slice(0, 50) }+ }),}),{name: 'create-store',@@ -110,13 +135,16 @@ export const useCreateStore = create<CreateState>()(imageModelType: state.imageModelType,videoModel: state.videoModel,sampler: state.sampler,+ scheduler: state.scheduler,steps: state.steps,cfgScale: state.cfgScale,width: state.width,height: state.height,+ batchSize: state.batchSize,frames: state.frames,fps: state.fps,gallery: state.gallery,+ promptHistory: state.promptHistory,}),})