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.

feat(create): the workflow manager lives inside Create, in the house design

purplea32089e220c5
diff --git a/package-lock.json b/package-lock.json
index 33992faf..cbfaa3a3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "locally-uncensored",
- "version": "2.5.7",
+ "version": "2.6.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "locally-uncensored",
- "version": "2.5.7",
+ "version": "2.6.1",
"license": "AGPL-3.0",
"dependencies": {
"@react-three/drei": "^10.7.7",
diff --git a/src/api/workflows.ts b/src/api/workflows.ts
index c3a684bd..cb35e9ef 100644
--- a/src/api/workflows.ts
+++ b/src/api/workflows.ts
@@ -13,6 +13,18 @@ import type {
// ─── Validation ───
+// A node of the API-format graph. The JSON arrives from a file the user picked
+// or a download, so no field is guaranteed; every walk over a graph narrows
+// through this guard before it reads one.
+interface WorkflowNode {
+ class_type?: string
+ inputs?: Record<string, any>
+}
+
+function isWorkflowNode(value: unknown): value is WorkflowNode {
+ return !!value && typeof value === 'object'
+}
+
export function validateWorkflowJson(json: unknown): json is Record<string, any> {
if (!json || typeof json !== 'object' || Array.isArray(json)) return false
const obj = json as Record<string, any>
@@ -335,8 +347,7 @@ export async function injectParameters(
if (!widthMapping || !heightMapping) {
const resizeEntry = Object.entries(wf).find(
([, node]) =>
- node &&
- typeof node === 'object' &&
+ isWorkflowNode(node) &&
node.class_type === 'ImageResizeKJv2' &&
typeof node.inputs?.width === 'number' &&
typeof node.inputs?.height === 'number',
@@ -379,10 +390,7 @@ export async function injectParameters(
// so users do not have to remove and re-import those workflows.
if (!inputImageMapping) {
const loadImageEntry = Object.entries(wf).find(
- ([, node]) =>
- node &&
- typeof node === 'object' &&
- node.class_type === 'LoadImage',
+ ([, node]) => isWorkflowNode(node) && node.class_type === 'LoadImage',
)
if (loadImageEntry) {
@@ -397,24 +405,26 @@ export async function injectParameters(
}
if ('frames' in params) {
- inject(paramMap.frames, (params as VideoParams).frames)
- inject(paramMap.fps, (params as VideoParams).fps)
-
- for (const node of Object.values(wf)) {
- if (node?.class_type === 'VHS_VideoCombine' && node.inputs) {
- node.inputs.save_output = true
+ inject(paramMap.frames, (params as VideoParams).frames)
+ inject(paramMap.fps, (params as VideoParams).fps)
+
+ // A VHS_VideoCombine left on save_output:false writes the clip to
+ // ComfyUI's temp folder, where the gallery cannot play it back.
+ for (const node of Object.values(wf)) {
+ if (isWorkflowNode(node) && node.class_type === 'VHS_VideoCombine' && node.inputs) {
+ node.inputs.save_output = true
+ }
}
}
-}
log.info('[workflows] Injected workflow nodes', { nodes: Object.entries(wf).map(([id, n]: [string, any]) =>
`${id}: ${n.class_type} (${Object.keys(n.inputs || {}).join(', ')})`
).join(' | ') })
// Auto-resolve VAE and CLIP loaders with real model files
- for (const [nodeId, node] of Object.entries(wf)) {
- if (!node || typeof node !== 'object') continue
- const ct = node.class_type as string
+ for (const node of Object.values(wf)) {
+ if (!isWorkflowNode(node)) continue
+ const ct = node.class_type
try {
if (ct === 'VAELoader' && node.inputs) {
const vae = await findMatchingVAE(modelType)
diff --git a/src/components/create/WorkflowCard.tsx b/src/components/create/WorkflowCard.tsx
deleted file mode 100644
index e161015c..00000000
--- a/src/components/create/WorkflowCard.tsx
+++ /dev/null
@@ -1,110 +0,0 @@
-import { Download, Check, ExternalLink, RotateCcw, Star } from 'lucide-react'
-import type { WorkflowSearchResult } from '../../types/workflows'
-import type { ModelType } from '../../api/comfyui'
-import { proxyImageUrl } from '../../lib/privacy'
-import { openExternal } from '../../api/backend'
-
-interface Props {
- result: WorkflowSearchResult
- isInstalled: boolean
- isActive: boolean
- currentModelType?: ModelType
- onInstall: (result: WorkflowSearchResult) => void
-}
-
-const SOURCE_BADGE: Record<string, { label: string; color: string }> = {
- civitai: { label: 'CivitAI', color: 'bg-blue-500/20 text-blue-300' },
- manual: { label: 'Template', color: 'bg-emerald-500/20 text-emerald-300' },
-}
-
-export function WorkflowCard({ result, isInstalled, isActive, currentModelType, onInstall }: Props) {
- const badge = SOURCE_BADGE[result.source] ?? SOURCE_BADGE.manual
- const displayName = result.name || result.sourceUrl?.split('/').pop() || 'Unnamed Workflow'
- const isCompatible = currentModelType && result.modelTypes.includes(currentModelType)
-
- return (
- <div className={`flex gap-3 p-3 rounded-xl border transition-colors ${
- isActive
- ? 'bg-white/8 border-emerald-500/30'
- : 'bg-white/5 border-white/10 hover:border-white/20'
- }`}>
- {/* Thumbnail */}
- {result.thumbnailUrl ? (
- <img
- src={proxyImageUrl(result.thumbnailUrl)}
- alt={displayName}
- className="w-16 h-16 rounded-lg object-cover flex-shrink-0 bg-white/5"
- loading="lazy"
- />
- ) : (
- <div className="w-16 h-16 rounded-lg bg-white/5 flex items-center justify-center flex-shrink-0">
- <Download size={20} className="text-gray-500" />
- </div>
- )}
-
- {/* Info */}
- <div className="flex-1 min-w-0">
- <div className="flex items-center gap-2 mb-0.5">
- <span className="text-sm font-semibold text-white truncate" title={displayName}>
- {displayName}
- </span>
- <span className={`px-1.5 py-0.5 rounded text-[10px] font-medium flex-shrink-0 ${badge.color}`}>
- {badge.label}
- </span>
- {isCompatible && (
- <span className="flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium bg-emerald-500/20 text-emerald-300 flex-shrink-0">
- <Star size={8} /> Match
- </span>
- )}
- </div>
-
- {result.description && (
- <p className="text-xs text-gray-400 line-clamp-2 mb-1.5" title={result.description}>
- {result.description}
- </p>
- )}
-
- {result.modelTypes.length > 0 && result.modelTypes[0] !== 'unknown' && (
- <div className="flex gap-1 mb-1.5">
- {result.modelTypes.map((mt) => (
- <span key={mt} className="px-1 py-0.5 rounded text-[9px] font-medium bg-white/10 text-gray-300">
- {mt.toUpperCase()}
- </span>
- ))}
- </div>
- )}
-
- {/* Actions */}
- <div className="flex items-center gap-2">
- {isActive ? (
- <span className="flex items-center gap-1 px-2 py-1 rounded-lg bg-emerald-500/20 text-emerald-300 text-xs">
- <Check size={12} /> Active
- </span>
- ) : isInstalled ? (
- <button
- onClick={() => onInstall(result)}
- className="flex items-center gap-1 px-2 py-1 rounded-lg bg-white/10 hover:bg-white/20 text-white text-xs transition-colors"
- >
- <RotateCcw size={12} /> Use
- </button>
- ) : (
- <button
- onClick={() => onInstall(result)}
- className="flex items-center gap-1 px-2 py-1 rounded-lg bg-white/10 hover:bg-white/20 text-white text-xs transition-colors"
- >
- <Download size={12} /> Install
- </button>
- )}
- {result.sourceUrl && (
- <button
- onClick={() => openExternal(result.sourceUrl!)}
- className="flex items-center gap-1 px-2 py-1 rounded-lg bg-white/5 hover:bg-white/10 text-gray-400 hover:text-white text-xs transition-colors"
- >
- <ExternalLink size={12} /> Source
- </button>
- )}
- </div>
- </div>
- </div>
- )
-}
diff --git a/src/components/create/WorkflowFinder.tsx b/src/components/create/WorkflowFinder.tsx
index c2159e21..13ee4463 100644
--- a/src/components/create/WorkflowFinder.tsx
+++ b/src/components/create/WorkflowFinder.tsx
@@ -1,5 +1,5 @@
import { Workflow } from 'lucide-react'
-import { isVideoModelType, type ModelType, } from '../../api/comfyui'
+import { isVideoModelType, type ModelType } from '../../api/comfyui'
import { useWorkflowStore } from '../../stores/workflowStore'
import { Select } from './ui/Select'
@@ -8,11 +8,9 @@ interface Props {
modelType: ModelType
}
-export function WorkflowFinder({
- modelName,
- modelType,
-}: Props) {
+export function WorkflowFinder({ modelName, modelType }: Props) {
const {
+ tags,
workflowTags,
getWorkflowForModel,
getMatchingWorkflows,
@@ -21,62 +19,41 @@ export function WorkflowFinder({
unassignModelType,
} = useWorkflowStore()
- const mode = isVideoModelType(modelType)
- ? 'video'
- : 'image'
-
- const matchingWorkflows = getMatchingWorkflows(
- modelName,
- mode,
- )
-
- const activeWorkflow = getWorkflowForModel(
- modelName,
- modelType,
- )
+ const mode = isVideoModelType(modelType) ? 'video' : 'image'
+ const matchingWorkflows = getMatchingWorkflows(modelName, mode)
+ const activeWorkflow = getWorkflowForModel(modelName, modelType)
const selectedWorkflow =
- activeWorkflow &&
- matchingWorkflows.some(
- (workflow) => workflow.id === activeWorkflow.id,
- )
+ activeWorkflow && matchingWorkflows.some((workflow) => workflow.id === activeWorkflow.id)
? activeWorkflow
: null
- const handleSelection = (
- workflowId: string,
- ) => {
+ const handleSelection = (workflowId: string) => {
if (!workflowId) {
unassignModelName(modelName)
unassignModelType(modelType)
return
}
-
- // A specific model selection should take priority over any legacy
- // model-type-wide assignment.
+ // A specific model selection beats any legacy model-type-wide assignment.
unassignModelType(modelType)
assignToModelName(modelName, workflowId)
}
return (
<div>
- <label className="mb-1.5 flex items-center gap-1.5 text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400">
+ <label className="mb-1.5 flex items-center gap-1.5 t-label text-gray-500">
<Workflow size={12} />
Workflow
</label>
- {matchingWorkflows.length > 0 ? (
+ {matchingWorkflows.length > 0 ? (
<Select
value={selectedWorkflow?.id ?? ''}
onChange={handleSelection}
placeholder="Auto"
maxHeight={240}
options={[
- {
- value: '',
- label: 'Auto',
- sublabel: 'Use the built-in workflow',
- },
+ { value: '', label: 'Auto', sublabel: 'Use the built-in workflow' },
...matchingWorkflows.map((workflow) => ({
value: workflow.id,
label: workflow.name,
@@ -88,50 +65,41 @@ export function WorkflowFinder({
: 'Image',
badge: {
label: workflow.mode.toUpperCase(),
- color:
- 'bg-violet-500/15 text-violet-300',
+ color: 'bg-lu-accent-soft text-lu-accent',
},
})),
]}
/>
) : (
- <div className="flex h-[var(--control-h-md)] w-full items-center rounded-[var(--radius-control)] border border-white/[0.08] bg-white/[0.04] px-2.5 text-sm text-gray-500">
- No tagged workflows available
+ <div className="flex h-[var(--control-h-md)] w-full items-center rounded-[var(--radius-control)] border border-white/[0.08] bg-white/[0.04] px-2.5 t-control text-gray-500">
+ No tagged workflows
</div>
)}
{matchingWorkflows.length === 0 ? (
- <p className="mt-1.5 text-[10px] leading-relaxed text-gray-500">
- Assign matching tags to this model and a workflow in Tags &amp; Workflows.
+ <p className="mt-1.5 t-body text-gray-500">
+ Give this model and a workflow the same tag in the workflow manager, then it shows up here.
</p>
) : selectedWorkflow ? (
<div className="mt-1.5 flex flex-wrap items-center gap-1">
- {(workflowTags[selectedWorkflow.id] ?? []).map(
- (tagId) => (
+ {(workflowTags[selectedWorkflow.id] ?? []).map((tagId) => {
+ const tag = tags.find((t) => t.id === tagId)
+ return tag ? (
<span
key={tagId}
- className="rounded bg-violet-500/15 px-1.5 py-0.5 text-[10px] text-violet-600 dark:text-violet-300"
+ className="rounded bg-lu-accent-soft px-1.5 py-0.5 t-label text-lu-accent"
>
- {
- useWorkflowStore
- .getState()
- .tags.find(
- (tag) => tag.id === tagId,
- )?.name
- }
+ {tag.name}
</span>
- ),
- )}
+ ) : null
+ })}
</div>
) : (
- <p className="mt-1.5 text-[10px] text-gray-500">
+ <p className="mt-1.5 t-body text-gray-500">
{matchingWorkflows.length} compatible{' '}
- {matchingWorkflows.length === 1
- ? 'workflow'
- : 'workflows'}{' '}
- available
+ {matchingWorkflows.length === 1 ? 'workflow' : 'workflows'}
</p>
)}
</div>
)
-}
\ No newline at end of file
+}
diff --git a/src/components/create/WorkflowSearchModal.tsx b/src/components/create/WorkflowSearchModal.tsx
deleted file mode 100644
index 5f907205..00000000
--- a/src/components/create/WorkflowSearchModal.tsx
+++ /dev/null
@@ -1,500 +0,0 @@
-import { useState, useEffect, useRef } from 'react'
-import { Search, Upload, Loader2, AlertCircle, Key, Eye, EyeOff } from 'lucide-react'
-import { v4 as uuid } from 'uuid'
-import { Modal } from '../ui/Modal'
-import { openExternal } from '../../api/backend'
-import { WorkflowCard } from './WorkflowCard'
-import { useWorkflowStore } from '../../stores/workflowStore'
-import {
- searchWorkflows,
- fetchWorkflowFromUrl,
- validateWorkflowJson,
- parseImportedWorkflow,
- extractSearchTerms,
-} from '../../api/workflows'
-import type { WorkflowSearchResult, WorkflowTemplate } from '../../types/workflows'
-import type { ModelType } from '../../api/comfyui'
-
-interface Props {
- open: boolean
- onClose: () => void
- modelName: string
- modelType: ModelType
-}
-
-type TabId = 'discover' | 'templates' | 'import'
-
-const TABS: { id: TabId; label: string }[] = [
- { id: 'templates', label: 'Templates' },
- { id: 'discover', label: 'Discover' },
- { id: 'import', label: 'Import' },
-]
-
-export function WorkflowSearchModal({ open, onClose, modelName, modelType }: Props) {
- const [activeTab, setActiveTab] = useState<TabId>('discover')
- const [query, setQuery] = useState('')
- const [results, setResults] = useState<WorkflowSearchResult[]>([])
- const [loading, setLoading] = useState(false)
- const [error, setError] = useState<string | null>(null)
- const [importUrl, setImportUrl] = useState('')
- const [importJson, setImportJson] = useState('')
- const [importName, setImportName] = useState('')
- const [importLoading, setImportLoading] = useState(false)
- // Visible success confirmation after a manual Import action. Without this the
- // Import button silently clears its inputs on success and the user sees no
- // feedback at all (diimmortalis' report: "doesn't seem to persist manually
- // entered json … no feedback or console output when clicking the Import
- // button"). The toast auto-clears after a few seconds.
- const [importSuccess, setImportSuccess] = useState<string | null>(null)
- const initialSearchDone = useRef(false)
- const templatesCached = useRef<WorkflowSearchResult[] | null>(null)
-
- const { installedWorkflows, installWorkflow, assignToModelName, civitaiApiKey, setCivitaiApiKey, civitaiHost } = useWorkflowStore()
- const [showApiKey, setShowApiKey] = useState(false)
- const [showApiKeyInput, setShowApiKeyInput] = useState(false)
- const [showApiKeyWarning, setShowApiKeyWarning] = useState(false)
- const [installStatus, setInstallStatus] = useState<string | null>(null)
-
- // Reset state and load templates when modal opens
- useEffect(() => {
- if (open) {
- const terms = extractSearchTerms(modelName, modelType)
- setQuery(terms)
- setError(null)
- setActiveTab('templates')
- initialSearchDone.current = false
- // Load templates immediately, sorted by compatibility (matching first)
- searchWorkflows('', 'templates' as any).then(r => {
- const sorted = [...r].sort((a, b) => {
- const aMatch = a.modelTypes.includes(modelType) ? -1 : 1
- const bMatch = b.modelTypes.includes(modelType) ? -1 : 1
- return aMatch - bMatch
- })
- templatesCached.current = sorted
- setResults(sorted)
- })
- }
- }, [open, modelName, modelType])
-
- const performSearch = async (source: TabId, searchQuery: string) => {
- if (source === 'import') return
- setLoading(true)
- setError(null)
- try {
- const searchSource = source === 'discover' ? 'civitai' : 'templates'
- const r = await searchWorkflows(searchQuery, searchSource as any, civitaiHost)
- setResults(r)
- if (r.length === 0) setError('No workflows found. Try different search terms.')
- } catch (err) {
- setError(`Search failed: ${err instanceof Error ? err.message : String(err)}`)
- } finally {
- setLoading(false)
- }
- }
-
- const handleSearch = () => {
- if (activeTab !== 'import') {
- performSearch(activeTab, activeTab === 'templates' ? '' : query)
- }
- }
-
- const handleTabChange = (tab: TabId) => {
- setActiveTab(tab)
- setError(null)
-
- if (tab === 'templates') {
- // Load templates synchronously — they're local data
- if (templatesCached.current) {
- setResults(templatesCached.current)
- } else {
- const templates = searchWorkflows('', 'templates' as any)
- // searchWorkflows returns a Promise, but templates are sync
- templates.then(r => {
- templatesCached.current = r
- setResults(r)
- })
- }
- } else if (tab === 'discover') {
- // Restore discover results or clear
- setResults([])
- if (query) {
- performSearch('discover', query)
- }
- } else {
- setResults([])
- }
- }
-
- const handleInstallResult = async (result: WorkflowSearchResult) => {
- if (!result.downloadUrl && !result.rawWorkflow) {
- setError('No download link available. Try the Import tab with the workflow page URL.')
- return
- }
-
- if (!result.rawWorkflow && result.source === 'civitai' && !civitaiApiKey) {
- setShowApiKeyWarning(true)
- return
- }
-
- setLoading(true)
- setError(null)
- setInstallStatus('Downloading workflow...')
- try {
- let workflow: Record<string, any>
- if (result.rawWorkflow) {
- workflow = result.rawWorkflow
- } else {
- workflow = await fetchWorkflowFromUrl(result.downloadUrl!, civitaiApiKey || undefined)
- }
-
- setInstallStatus('Processing...')
- const parsed = parseImportedWorkflow(
- result.name,
- workflow,
- result.source,
- result.sourceUrl,
- result.description,
- )
-
- const template: WorkflowTemplate = {
- ...parsed,
- id: uuid(),
- installedAt: Date.now(),
- thumbnailUrl: result.thumbnailUrl,
- }
-
- installWorkflow(template)
- assignToModelName(modelName, template.id)
- setInstallStatus(null)
- } catch (err) {
- setError(`Install failed: ${err instanceof Error ? err.message : String(err)}`)
- setInstallStatus(null)
- } finally {
- setLoading(false)
- }
- }
-
- const handleImportUrl = async () => {
- if (!importUrl.trim()) return
- setImportLoading(true)
- setError(null)
- setImportSuccess(null)
- try {
- const workflow = await fetchWorkflowFromUrl(importUrl.trim())
- const name = importName.trim() || new URL(importUrl).pathname.split('/').pop()?.replace('.json', '') || 'Imported Workflow'
- const parsed = parseImportedWorkflow(name, workflow, 'manual', importUrl)
- const template: WorkflowTemplate = {
- ...parsed,
- id: uuid(),
- installedAt: Date.now(),
- }
- installWorkflow(template)
- assignToModelName(modelName, template.id)
- setImportUrl('')
- setImportName('')
- setImportSuccess(`Imported "${name}" and assigned to ${modelName}.`)
- setTimeout(() => setImportSuccess(null), 4000)
- } catch (err) {
- setError(`Import failed: ${err instanceof Error ? err.message : String(err)}`)
- } finally {
- setImportLoading(false)
- }
- }
-
- const handleImportJson = () => {
- if (!importJson.trim()) return
- setError(null)
- setImportSuccess(null)
- try {
- const json = JSON.parse(importJson.trim())
- if (!validateWorkflowJson(json)) {
- setError('Invalid workflow format. Expected ComfyUI API format with nodes (class_type).')
- return
- }
- const name = importName.trim() || 'Imported Workflow'
- const parsed = parseImportedWorkflow(name, json, 'manual')
- const template: WorkflowTemplate = {
- ...parsed,
- id: uuid(),
- installedAt: Date.now(),
- }
- installWorkflow(template)
- assignToModelName(modelName, template.id)
- setImportJson('')
- setImportName('')
- setImportSuccess(`Imported "${name}" and assigned to ${modelName}.`)
- setTimeout(() => setImportSuccess(null), 4000)
- } catch (err) {
- if (err instanceof SyntaxError) {
- setError('Invalid JSON. Please paste valid JSON.')
- } else {
- setError(`Import failed: ${err instanceof Error ? err.message : String(err)}`)
- }
- }
- }
-
- const findInstalledWorkflow = (result: WorkflowSearchResult) =>
- installedWorkflows.find(w => w.name === result.name && w.source === result.source)
-
- const isInstalledResult = (result: WorkflowSearchResult) => !!findInstalledWorkflow(result)
-
- const isActiveResult = (result: WorkflowSearchResult) => {
- const installed = findInstalledWorkflow(result)
- if (!installed) return false
- const activeWf = useWorkflowStore.getState().getWorkflowForModel(modelName, modelType)
- return activeWf?.id === installed.id
- }
-
- const handleInstallOrUse = async (result: WorkflowSearchResult) => {
- const existing = findInstalledWorkflow(result)
- if (existing) {
- // Already installed — just assign to current model
- assignToModelName(modelName, existing.id)
- return
- }
- // Not installed — download and install
- handleInstallResult(result)
- }
-
- const inputClass = 'w-full px-3 py-2 rounded-lg bg-white/5 border border-white/10 text-white text-sm focus:outline-none focus:border-white/20 placeholder-gray-500'
-
- return (
- <Modal open={open} onClose={onClose} title="Workflow Finder">
- <div className="relative">
- <div className={`space-y-4 max-h-[70vh] flex flex-col transition-all duration-200 ${showApiKeyWarning ? 'blur-sm opacity-40 pointer-events-none' : ''}`}>
- {/* Tab Bar */}
- <div className="flex gap-1 p-1 rounded-lg bg-white/5">
- {TABS.map((tab) => (
- <button
- key={tab.id}
- onClick={() => handleTabChange(tab.id)}
- className={`flex-1 px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${
- activeTab === tab.id
- ? 'bg-white/15 text-white'
- : 'text-gray-400 hover:text-white hover:bg-white/5'
- }`}
- >
- {tab.label}
- </button>
- ))}
- </div>
-
- {/* Search bar (Discover tab) */}
- {activeTab === 'discover' && (
- <>
- <div className="flex gap-2">
- <input
- type="text"
- value={query}
- onChange={(e) => setQuery(e.target.value)}
- onKeyDown={(e) => e.key === 'Enter' && handleSearch()}
- placeholder="e.g. flux workflow, sdxl inpainting..."
- className={`${inputClass} flex-1`}
- />
- <button
- onClick={handleSearch}
- disabled={loading}
- className="px-3 py-2 rounded-lg bg-white/10 hover:bg-white/20 text-white transition-colors disabled:opacity-50"
- >
- {loading ? <Loader2 size={16} className="animate-spin" /> : <Search size={16} />}
- </button>
- <button
- onClick={() => setShowApiKeyInput(!showApiKeyInput)}
- className={`p-2 rounded-lg border transition-colors ${
- civitaiApiKey
- ? 'bg-emerald-500/10 border-emerald-500/30 text-emerald-400'
- : 'bg-white/5 border-white/10 text-gray-500 hover:text-white'
- }`}
- title={civitaiApiKey ? 'API key set' : 'Add CivitAI API key (required for downloads)'}
- aria-label="CivitAI API key"
- >
- <Key size={16} />
- </button>
- </div>
-
- {/* API Key Input */}
- {showApiKeyInput && (
- <div className="flex gap-2 items-center">
- <div className="relative flex-1">
- <input
- type={showApiKey ? 'text' : 'password'}
- value={civitaiApiKey}
- onChange={(e) => setCivitaiApiKey(e.target.value)}
- placeholder="CivitAI API key (civitai.com/user/account)"
- className={`${inputClass} pr-8`}
- />
- <button
- onClick={() => setShowApiKey(!showApiKey)}
- className="absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-white"
- aria-label="Toggle API key visibility"
- >
- {showApiKey ? <EyeOff size={14} /> : <Eye size={14} />}
- </button>
- </div>
- {civitaiApiKey && (
- <span className="text-[10px] text-emerald-400 flex-shrink-0">Saved</span>
- )}
- </div>
- )}
- </>
- )}
-
- {/* Error */}
- {error && (
- <div className="flex items-start gap-2 p-2 rounded-lg bg-red-500/10 border border-red-500/20 text-red-300 text-xs">
- <AlertCircle size={14} className="mt-0.5 flex-shrink-0" />
- <span>{error}</span>
- </div>
- )}
-
- {/* Success — visible confirmation that the manual Import landed */}
- {importSuccess && (
- <div className="flex items-start gap-2 p-2 rounded-lg bg-emerald-500/10 border border-emerald-500/25 text-emerald-300 text-xs">
- <span aria-hidden className="mt-0.5">✓</span>
- <span>{importSuccess}</span>
- </div>
- )}
-
- {/* Content */}
- {activeTab === 'import' ? (
- <div className="space-y-3 overflow-y-auto flex-1">
- <div>
- <label className="text-xs font-medium text-gray-400 uppercase tracking-wider mb-1 block">Name</label>
- <input
- type="text"
- value={importName}
- onChange={(e) => setImportName(e.target.value)}
- placeholder="Workflow name (optional)"
- className={inputClass}
- />
- </div>
-
- <div>
- <label className="text-xs font-medium text-gray-400 uppercase tracking-wider mb-1 block">URL Import</label>
- <div className="flex gap-2">
- <input
- type="text"
- value={importUrl}
- onChange={(e) => setImportUrl(e.target.value)}
- placeholder="https://example.com/workflow.json"
- className={`${inputClass} flex-1`}
- />
- <button
- onClick={handleImportUrl}
- disabled={importLoading || !importUrl.trim()}
- className="px-3 py-2 rounded-lg bg-white/10 hover:bg-white/20 text-white transition-colors disabled:opacity-50"
- >
- {importLoading ? <Loader2 size={16} className="animate-spin" /> : <Upload size={16} />}
- </button>
- </div>
- </div>
-
- <div>
- <label className="text-xs font-medium text-gray-400 uppercase tracking-wider mb-1 block">Paste JSON</label>
- <textarea
- value={importJson}
- onChange={(e) => setImportJson(e.target.value)}
- placeholder='{"1": {"class_type": "CheckpointLoaderSimple", ...}}'
- className={`${inputClass} h-32 resize-none font-mono text-xs`}
- />
- <button
- onClick={handleImportJson}
- disabled={!importJson.trim()}
- className="mt-2 w-full px-3 py-2 rounded-lg bg-white/10 hover:bg-white/20 text-white text-sm transition-colors disabled:opacity-50"
- >
- Import
- </button>
- </div>
- </div>
- ) : (
- <div className="space-y-2 overflow-y-auto flex-1 min-h-0">
- {loading && (
- <div className="flex items-center justify-center py-4 text-gray-400 text-sm">
- <Loader2 size={16} className="animate-spin mr-2" />
- {installStatus || 'Searching...'}
- </div>
- )}
- {!loading && results.length === 0 && !error && activeTab === 'discover' && (
- <div className="text-center py-8 text-gray-500 text-sm">
- Search for ComfyUI workflows
- </div>
- )}
- {results.map((r, i) => (
- <WorkflowCard
- key={`${r.source}-${r.sourceUrl}-${i}`}
- result={r}
- isInstalled={isInstalledResult(r)}
- isActive={isActiveResult(r)}
- currentModelType={modelType}
- onInstall={handleInstallOrUse}
- />
- ))}
- </div>
- )}
- </div>
-
- {/* API Key Warning Overlay */}
- {showApiKeyWarning && (
- <div className="absolute inset-0 z-20 flex items-center justify-center p-6">
- <div className="absolute inset-0 bg-black/60 rounded-2xl" onClick={() => setShowApiKeyWarning(false)} />
- <div className="relative z-10 bg-neutral-900 border border-white/15 rounded-xl p-5 max-w-sm w-full space-y-4 shadow-2xl">
- <div className="flex items-center gap-2">
- <Key size={18} className="text-amber-400" />
- <h3 className="text-sm font-semibold text-white">CivitAI API Key Required</h3>
- </div>
- <p className="text-xs text-gray-300 leading-relaxed">
- CivitAI requires an API key to download workflows. You can create one for free in about a minute:
- </p>
- <button
- onClick={() => openExternal('https://civitai.com/user/account')}
- className="block w-full px-3 py-2 rounded-lg bg-white/10 hover:bg-white/15 border border-white/20 text-white text-sm font-medium text-center transition-colors"
- >
- Get Free API Key on CivitAI
- </button>
- <div>
- <label className="text-[10px] font-medium text-gray-500 uppercase tracking-wider mb-1 block">Paste your key here</label>
- <div className="relative">
- <input
- type={showApiKey ? 'text' : 'password'}
- value={civitaiApiKey}
- onChange={(e) => setCivitaiApiKey(e.target.value)}
- placeholder="Your CivitAI API key"
- className={`${inputClass} pr-8`}
- autoFocus
- />
- <button
- onClick={() => setShowApiKey(!showApiKey)}
- className="absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-white"
- aria-label="Toggle API key visibility"
- >
- {showApiKey ? <EyeOff size={14} /> : <Eye size={14} />}
- </button>
- </div>
- </div>
- <div className="flex gap-2">
- <button
- onClick={() => setShowApiKeyWarning(false)}
- className="flex-1 px-3 py-2 rounded-lg bg-white/10 hover:bg-white/15 text-gray-300 text-xs transition-colors"
- >
- Cancel
- </button>
- <button
- onClick={() => {
- if (civitaiApiKey) {
- setShowApiKeyWarning(false)
- setShowApiKeyInput(false)
- }
- }}
- disabled={!civitaiApiKey}
- className="flex-1 px-3 py-2 rounded-lg bg-white hover:bg-gray-200 disabled:opacity-40 text-gray-900 text-xs font-medium transition-colors"
- >
- Save & Continue
- </button>
- </div>
- </div>
- </div>
- )}
- </div>
- </Modal>
- )
-}
diff --git a/src/components/create/WorkflowsModal.tsx b/src/components/create/WorkflowsModal.tsx
new file mode 100644
index 00000000..ead1044a
--- /dev/null
+++ b/src/components/create/WorkflowsModal.tsx
@@ -0,0 +1,542 @@
+import { useEffect, useMemo, useRef, useState } from 'react'
+import { AnimatePresence, motion } from 'framer-motion'
+import {
+ Check,
+ FileJson,
+ Pencil,
+ Plus,
+ RefreshCw,
+ Search,
+ Tags,
+ Trash2,
+ Upload,
+ Workflow,
+ X,
+} from 'lucide-react'
+import { v4 as uuid } from 'uuid'
+import { parseImportedWorkflow, validateWorkflowJson } from '../../api/workflows'
+import { useModels } from '../../hooks/useModels'
+import {
+ useWorkflowStore,
+ workflowModelKey,
+ type WorkflowTagMode,
+} from '../../stores/workflowStore'
+import { TagPicker } from '../workflows/TagPicker'
+import { Button } from './ui/Button'
+import { EmptyState } from './ui/EmptyState'
+import { Segmented } from './ui/Segmented'
+import { cn } from './ui/cn'
+
+type PageTab = 'workflows' | 'models' | 'tags'
+type ModelFilter = 'all' | WorkflowTagMode
+
+const TABS: Array<{ value: PageTab; label: string }> = [
+ { value: 'workflows', label: 'Workflows' },
+ { value: 'models', label: 'Models' },
+ { value: 'tags', label: 'Tags' },
+]
+
+const INPUT =
+ 'h-[var(--control-h-md)] w-full px-2.5 t-control text-gray-200 placeholder:text-gray-600 ' +
+ 'rounded-[var(--radius-control)] bg-white/[0.04] border border-white/[0.08] ' +
+ 'outline-none focus:border-white/20 transition-colors'
+
+/** Full-surface workflow manager, opened from the Create composer. */
+export function WorkflowsModal({ open, onClose }: { open: boolean; onClose: () => void }) {
+ useEffect(() => {
+ if (!open) return
+ const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose() }
+ window.addEventListener('keydown', onKey)
+ return () => window.removeEventListener('keydown', onKey)
+ }, [open, onClose])
+
+ return (
+ <AnimatePresence>
+ {open && <WorkflowsModalInner onClose={onClose} />}
+ </AnimatePresence>
+ )
+}
+
+function WorkflowsModalInner({ onClose }: { onClose: () => void }) {
+ const [tab, setTab] = useState<PageTab>('workflows')
+
+ const {
+ installedWorkflows,
+ tags,
+ workflowTags,
+ modelTags,
+ installWorkflow,
+ removeWorkflow,
+ createTag,
+ renameTag,
+ deleteTag,
+ setWorkflowTags,
+ setModelTags,
+ } = useWorkflowStore()
+
+ const { models, fetchModels } = useModels()
+
+ // Fill the model list from here as well, so the manager stands on its own
+ // instead of depending on the Models view having refreshed first.
+ useEffect(() => { fetchModels().catch(() => {}) }, [fetchModels])
+
+ const [importName, setImportName] = useState('')
+ const [importJson, setImportJson] = useState('')
+ const [importError, setImportError] = useState<string | null>(null)
+ const [importSuccess, setImportSuccess] = useState<string | null>(null)
+ const fileInputRef = useRef<HTMLInputElement>(null)
+
+ const [newTagName, setNewTagName] = useState('')
+ const [editingTagId, setEditingTagId] = useState<string | null>(null)
+ const [editingTagName, setEditingTagName] = useState('')
+
+ const [modelSearch, setModelSearch] = useState('')
+ const [modelFilter, setModelFilter] = useState<ModelFilter>('all')
+
+ // Two-step delete, the same pattern the agent workflow list uses. A raw
+ // window.confirm renders as an OS dialog that blocks the whole webview,
+ // which is why it was taken out of the codex gate and the RAG panel.
+ const [confirmId, setConfirmId] = useState<string | null>(null)
+ const armDelete = (id: string, remove: () => void) => {
+ if (confirmId === id) {
+ remove()
+ setConfirmId(null)
+ return
+ }
+ setConfirmId(id)
+ setTimeout(() => setConfirmId((c) => (c === id ? null : c)), 3000)
+ }
+
+ const comfyModels = useMemo(() => {
+ const query = modelSearch.trim().toLowerCase()
+ return models
+ .filter((model) => {
+ if (model.type !== 'image' && model.type !== 'video') return false
+ if (model.providerName !== 'ComfyUI') return false
+ if (modelFilter !== 'all' && model.type !== modelFilter) return false
+ if (query && !model.name.toLowerCase().includes(query)) return false
+ return true
+ })
+ .sort((left, right) =>
+ left.type !== right.type
+ ? left.type.localeCompare(right.type)
+ : left.name.localeCompare(right.name),
+ )
+ }, [models, modelFilter, modelSearch])
+
+ const importWorkflowJson = (rawText: string, suggestedName?: string) => {
+ setImportError(null)
+ setImportSuccess(null)
+ try {
+ const json = JSON.parse(rawText)
+ if (!validateWorkflowJson(json)) {
+ setImportError('Invalid workflow. Export it from ComfyUI using Save (API Format).')
+ return
+ }
+ const name = importName.trim() || suggestedName?.trim() || 'Imported Workflow'
+ const parsed = parseImportedWorkflow(name, json, 'manual')
+
+ // Re-importing under the same name updates in place, which also keeps
+ // the tags that workflow already carries.
+ const existing = installedWorkflows.find(
+ (workflow) =>
+ workflow.source === 'manual' &&
+ workflow.name.toLowerCase() === name.toLowerCase(),
+ )
+ installWorkflow({
+ ...parsed,
+ id: existing?.id ?? uuid(),
+ installedAt: existing?.installedAt ?? Date.now(),
+ })
+ setImportName('')
+ setImportJson('')
+ setImportSuccess(existing ? `Updated "${name}".` : `Installed "${name}".`)
+ } catch (error) {
+ setImportError(
+ error instanceof SyntaxError
+ ? 'That file does not contain valid JSON.'
+ : `Import failed: ${error instanceof Error ? error.message : String(error)}`,
+ )
+ }
+ }
+
+ const handleFileImport = async (event: React.ChangeEvent<HTMLInputElement>) => {
+ const file = event.target.files?.[0]
+ if (!file) return
+ try {
+ importWorkflowJson(await file.text(), file.name.replace(/\.json$/i, ''))
+ } catch (error) {
+ setImportError(
+ `Could not read that file: ${error instanceof Error ? error.message : String(error)}`,
+ )
+ } finally {
+ event.target.value = ''
+ }
+ }
+
+ const handleCreateTag = () => {
+ if (createTag(newTagName)) setNewTagName('')
+ }
+
+ const finishRenameTag = () => {
+ if (!editingTagId) return
+ renameTag(editingTagId, editingTagName)
+ setEditingTagId(null)
+ setEditingTagName('')
+ }
+
+ return (
+ <motion.div
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ exit={{ opacity: 0 }}
+ transition={{ duration: 0.15 }}
+ className="fixed inset-0 z-[90] bg-white dark:bg-[#141414] flex flex-col"
+ role="dialog"
+ aria-modal="true"
+ aria-label="Workflows and tags"
+ >
+ <div className="flex items-center gap-3 px-4 h-12 border-b border-white/[0.06] shrink-0">
+ <Workflow size={15} className="text-lu-accent shrink-0" />
+ <span className="t-title text-gray-200">Workflows &amp; tags</span>
+ <div className="flex-1" />
+ <Segmented
+ size="sm"
+ layoutId="workflows-tab"
+ value={tab}
+ onChange={setTab}
+ options={TABS}
+ ariaLabel="Workflow manager section"
+ />
+ <div className="flex-1" />
+ <Button variant="ghost" size="sm" icon={X} iconOnly onClick={onClose} title="Close" />
+ </div>
+
+ <div className="flex-1 min-h-0 overflow-y-auto scrollbar-thin">
+ <div className="mx-auto w-full max-w-[860px] px-5 py-5">
+ {tab === 'workflows' && (
+ <div className="space-y-4">
+ <section className="rounded-[var(--radius-panel)] bg-white/[0.03] border border-white/[0.06] p-4">
+ <div className="flex items-center gap-1.5">
+ <Upload size={13} className="text-gray-500" />
+ <span className="t-label text-gray-400">Install a workflow</span>
+ </div>
+ <p className="mt-1.5 t-body text-gray-500">
+ Import a ComfyUI JSON saved in API format. An editable graph export will not work.
+ </p>
+
+ <div className="mt-3 flex gap-2">
+ <div className="flex-1 min-w-0">
+ <input
+ value={importName}
+ onChange={(e) => setImportName(e.target.value)}
+ placeholder="Workflow name (optional)"
+ className={INPUT}
+ />
+ </div>
+ <input
+ ref={fileInputRef}
+ type="file"
+ accept=".json,application/json"
+ onChange={handleFileImport}
+ className="hidden"
+ />
+ <div className="shrink-0 whitespace-nowrap">
+ <Button
+ variant="secondary"
+ icon={FileJson}
+ onClick={() => fileInputRef.current?.click()}
+ >
+ Choose file
+ </Button>
+ </div>
+ </div>
+
+ <textarea
+ value={importJson}
+ onChange={(e) => setImportJson(e.target.value)}
+ placeholder={'Or paste the API JSON here: {"1":{"class_type":"KSampler",…}}'}
+ className="mt-2 h-28 w-full resize-y px-2.5 py-2 t-mono text-gray-300 placeholder:text-gray-600 rounded-[var(--radius-control)] bg-white/[0.04] border border-white/[0.08] outline-none focus:border-white/20 transition-colors scrollbar-thin"
+ />
+ <div className="mt-2">
+ <Button
+ variant="primary"
+ disabled={!importJson.trim()}
+ onClick={() => importWorkflowJson(importJson)}
+ >
+ Install pasted workflow
+ </Button>
+ </div>
+
+ {importError && (
+ <div className="mt-2.5 rounded-[var(--radius-control)] bg-red-500/10 border border-red-500/20 px-2.5 py-1.5 t-body text-red-300">
+ {importError}
+ </div>
+ )}
+ {importSuccess && (
+ <div className="mt-2.5 rounded-[var(--radius-control)] bg-emerald-500/10 border border-emerald-500/20 px-2.5 py-1.5 t-body text-emerald-300">
+ {importSuccess}
+ </div>
+ )}
+ </section>
+
+ <section>
+ <div className="flex items-center gap-1.5 mb-2">
+ <Workflow size={13} className="text-gray-500" />
+ <span className="t-label text-gray-400">Installed</span>
+ <span className="t-label text-gray-600">{installedWorkflows.length}</span>
+ </div>
+
+ {installedWorkflows.length === 0 ? (
+ <div className="py-12">
+ <EmptyState
+ icon={Workflow}
+ title="No workflows installed"
+ description="Import an API-format JSON above, then tag it so a model can find it."
+ />
+ </div>
+ ) : (
+ <div className="space-y-2">
+ {installedWorkflows.map((workflow) => (
+ <article
+ key={workflow.id}
+ className="rounded-[var(--radius-panel)] bg-white/[0.03] border border-white/[0.06] p-3.5"
+ >
+ <div className="flex gap-3">
+ <div className="min-w-0 flex-1">
+ <div className="flex flex-wrap items-center gap-2">
+ <span className="truncate t-title text-gray-200">{workflow.name}</span>
+ <Chip>{workflow.mode}</Chip>
+ <Chip>{workflow.source}</Chip>
+ </div>
+ {workflow.description && (
+ <p className="mt-1 line-clamp-2 t-body text-gray-500">
+ {workflow.description}
+ </p>
+ )}
+ <div className="mt-3">
+ <p className="mb-1.5 t-label text-gray-500">Compatibility tags</p>
+ <TagPicker
+ tags={tags}
+ selectedIds={workflowTags[workflow.id] ?? []}
+ onChange={(tagIds) => setWorkflowTags(workflow.id, tagIds)}
+ />
+ </div>
+ </div>
+ <DeleteButton
+ armed={confirmId === workflow.id}
+ label="workflow"
+ onClick={() => armDelete(workflow.id, () => removeWorkflow(workflow.id))}
+ />
+ </div>
+ </article>
+ ))}
+ </div>
+ )}
+ </section>
+ </div>
+ )}
+
+ {tab === 'models' && (
+ <div className="space-y-3">
+ <div className="flex items-center gap-2">
+ <div className="relative flex-1 min-w-0">
+ <Search
+ size={13}
+ className="absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-600"
+ />
+ <input
+ value={modelSearch}
+ onChange={(e) => setModelSearch(e.target.value)}
+ placeholder="Search installed models"
+ className={cn(INPUT, 'pl-8')}
+ />
+ </div>
+ <Segmented
+ size="sm"
+ layoutId="workflows-model-filter"
+ value={modelFilter}
+ onChange={setModelFilter}
+ ariaLabel="Model kind"
+ options={[
+ { value: 'all', label: 'All' },
+ { value: 'image', label: 'Image' },
+ { value: 'video', label: 'Video' },
+ ]}
+ />
+ <Button
+ variant="ghost"
+ size="sm"
+ icon={RefreshCw}
+ iconOnly
+ title="Refresh the model list"
+ onClick={() => void fetchModels()}
+ />
+ </div>
+
+ {comfyModels.length === 0 ? (
+ <div className="py-12">
+ <EmptyState
+ icon={Search}
+ title="No ComfyUI models found"
+ description="Make sure ComfyUI is running, then refresh."
+ />
+ </div>
+ ) : (
+ <div className="space-y-2">
+ {comfyModels.map((model) => {
+ const mode = model.type as WorkflowTagMode
+ const key = workflowModelKey(model.name, mode)
+ return (
+ <article
+ key={key}
+ className="rounded-[var(--radius-panel)] bg-white/[0.03] border border-white/[0.06] p-3.5"
+ >
+ <div className="flex flex-wrap items-center gap-2">
+ <span className="min-w-0 flex-1 break-all t-title text-gray-200">
+ {model.name}
+ </span>
+ <Chip>{mode}</Chip>
+ </div>
+ <div className="mt-3">
+ <p className="mb-1.5 t-label text-gray-500">Model tags</p>
+ <TagPicker
+ tags={tags}
+ selectedIds={modelTags[key] ?? []}
+ onChange={(tagIds) => setModelTags(model.name, mode, tagIds)}
+ />
+ </div>
+ </article>
+ )
+ })}
+ </div>
+ )}
+ </div>
+ )}
+
+ {tab === 'tags' && (
+ <div className="space-y-3">
+ <div className="flex gap-2">
+ <div className="flex-1 min-w-0">
+ <input
+ value={newTagName}
+ onChange={(e) => setNewTagName(e.target.value)}
+ onKeyDown={(e) => { if (e.key === 'Enter') handleCreateTag() }}
+ placeholder="New tag, for example Wan 2.2"
+ className={INPUT}
+ />
+ </div>
+ <div className="shrink-0 whitespace-nowrap">
+ <Button
+ variant="primary"
+ icon={Plus}
+ disabled={!newTagName.trim()}
+ onClick={handleCreateTag}
+ >
+ Create
+ </Button>
+ </div>
+ </div>
+
+ {tags.length === 0 ? (
+ <div className="py-12">
+ <EmptyState
+ icon={Tags}
+ title="No tags yet"
+ description="A tag on a model and on a workflow is what pairs the two."
+ />
+ </div>
+ ) : (
+ <div className="space-y-1.5">
+ {tags.map((tag) => (
+ <div
+ key={tag.id}
+ className="flex items-center gap-2 rounded-[var(--radius-panel)] bg-white/[0.03] border border-white/[0.06] px-3 py-2"
+ >
+ {editingTagId === tag.id ? (
+ <>
+ <input
+ value={editingTagName}
+ onChange={(e) => setEditingTagName(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') finishRenameTag()
+ if (e.key === 'Escape') setEditingTagId(null)
+ }}
+ autoFocus
+ className={INPUT}
+ />
+ <Button
+ variant="ghost"
+ size="sm"
+ icon={Check}
+ iconOnly
+ title="Save"
+ onClick={finishRenameTag}
+ />
+ <Button
+ variant="ghost"
+ size="sm"
+ icon={X}
+ iconOnly
+ title="Cancel"
+ onClick={() => setEditingTagId(null)}
+ />
+ </>
+ ) : (
+ <>
+ <span className="min-w-0 flex-1 truncate t-body text-gray-200">
+ {tag.name}
+ </span>
+ <Button
+ variant="ghost"
+ size="sm"
+ icon={Pencil}
+ iconOnly
+ title="Rename"
+ onClick={() => { setEditingTagId(tag.id); setEditingTagName(tag.name) }}
+ />
+ <DeleteButton
+ armed={confirmId === tag.id}
+ label="tag"
+ onClick={() => armDelete(tag.id, () => deleteTag(tag.id))}
+ />
+ </>
+ )}
+ </div>
+ ))}
+ </div>
+ )}
+ </div>
+ )}
+ </div>
+ </div>
+ </motion.div>
+ )
+}
+
+function Chip({ children }: { children: React.ReactNode }) {
+ return (
+ <span className="t-label text-gray-500 rounded bg-white/[0.06] px-1.5 py-0.5">{children}</span>
+ )
+}
+
+function DeleteButton({
+ armed,
+ label,
+ onClick,
+}: {
+ armed: boolean
+ label: string
+ onClick: () => void
+}) {
+ return (
+ <Button
+ variant={armed ? 'danger' : 'ghost'}
+ size="sm"
+ icon={Trash2}
+ iconOnly
+ onClick={onClick}
+ title={armed ? `Click again to remove this ${label}` : `Remove ${label}`}
+ />
+ )
+}
diff --git a/src/components/create/experimental/Composer.tsx b/src/components/create/experimental/Composer.tsx
index 3275357b..a94edf9b 100644
--- a/src/components/create/experimental/Composer.tsx
+++ b/src/components/create/experimental/Composer.tsx
@@ -1,6 +1,6 @@
import { useCallback, useRef, useState } from 'react'
import { motion, AnimatePresence } from 'framer-motion'
-import { Sparkles, X, History, SlidersHorizontal, Square } from 'lucide-react'
+import { Sparkles, X, History, SlidersHorizontal, Square, Workflow } from 'lucide-react'
import { useCreateStore, MODEL_TYPE_DEFAULTS } from '../../../stores/createStore'
import { classifyModel } from '../../../api/comfyui'
import { useCreateExp } from './CreateContext'
@@ -28,9 +28,10 @@ import { useClickAway } from '../ui/useClickAway'
interface Props {
onOpenAdvanced: () => void
+ onOpenWorkflows: () => void
}
-export function Composer({ onOpenAdvanced }: Props) {
+export function Composer({ onOpenAdvanced, onOpenWorkflows }: Props) {
const intent = useCreateStore((s) => s.intent())
const meta = INTENT_MAP[intent]
const prompt = useCreateStore((s) => s.prompt)
@@ -223,6 +224,13 @@ export function Composer({ onOpenAdvanced }: Props) {
</div>
</Tooltip>
)}
+ {/* Custom ComfyUI graphs only run on the local backend, so the
+ manager only shows where it can do something. */}
+ {backend === 'local' && (
+ <Tooltip content="Your own ComfyUI workflows, and the tags that pair them with models.">
+ <Button variant="ghost" size="sm" icon={Workflow} iconOnly onClick={onOpenWorkflows} title="Workflows and tags" />
+ </Tooltip>
+ )}
{!isUtility && (
<>
<ModelChip />
diff --git a/src/components/create/experimental/CreateExperimental.tsx b/src/components/create/experimental/CreateExperimental.tsx
index d44f5ff0..78cb5a76 100644
--- a/src/components/create/experimental/CreateExperimental.tsx
+++ b/src/components/create/experimental/CreateExperimental.tsx
@@ -1,8 +1,9 @@
import { useCallback, useEffect, useRef, useState } from 'react'
import { AnimatePresence, motion } from 'framer-motion'
-import { AlertTriangle, Cloud, X } from 'lucide-react'
+import { AlertTriangle, Cloud, Workflow, X } from 'lucide-react'
import { useCreateStore, type GalleryItem } from '../../../stores/createStore'
import { useCloudNoticeStore, CLOUD_RETENTION_DAYS, shouldShowRetentionNotice } from '../../../stores/cloudNoticeStore'
+import { useWorkflowStore, shouldShowManagerNotice } from '../../../stores/workflowStore'
import { CreateExpProvider, useCreateExp } from './CreateContext'
import { IntentBar } from './IntentBar'
import { Stage } from './Stage'
@@ -10,6 +11,7 @@ import { Composer } from './Composer'
import { CreatePanel } from './CreatePanel'
import { Lightbox } from './Lightbox'
import { AdvancedDrawer } from './AdvancedDrawer'
+import { WorkflowsModal } from '../WorkflowsModal'
import { MaskEditor } from './MaskEditor'
import { VhsInstallModal } from './VhsInstallModal'
import { INTENT_MAP, isIntentAvailable } from './intents'
@@ -36,6 +38,8 @@ function CreateExperimentalInner() {
const isGenerating = useCreateStore((s) => s.isGenerating)
const retentionNoticeSeen = useCloudNoticeStore((s) => s.retentionNoticeSeen)
const setRetentionNoticeSeen = useCloudNoticeStore((s) => s.setRetentionNoticeSeen)
+ const managerNoticeSeen = useWorkflowStore((s) => s.managerNoticeSeen)
+ const setManagerNoticeSeen = useWorkflowStore((s) => s.setManagerNoticeSeen)
const { modelLoadError, connected, comfyOnCpu } = useCreateExp()
const [shownId, setShownId] = useState<string | null>(null)
@@ -43,6 +47,7 @@ function CreateExperimentalInner() {
const [maskOpen, setMaskOpen] = useState(false)
const [lightbox, setLightbox] = useState<GalleryItem | null>(null)
const [panelOpen, setPanelOpen] = useState(false)
+ const [workflowsOpen, setWorkflowsOpen] = useState(false)
// One-click CORS fix (David 2026-07-17): restart the user-managed ComfyUI
// under LU's management so it carries --enable-cors-header. On success the
@@ -218,6 +223,34 @@ function CreateExperimentalInner() {
</div>
)}
+ {/* Workflow manager arrival (2.6.2). Own ComfyUI graphs used to be a
+ dead end here, so the surface says once that they are not any more
+ and opens the manager from the notice. Local only, same shape as the
+ retention notice above: no auto-hide, dismissed by the explicit
+ button, and it stays dismissed across updates. */}
+ {shouldShowManagerNotice(backend, managerNoticeSeen) && (
+ <div className="flex items-start gap-2 px-4 py-2 bg-lu-accent-soft border-b border-white/[0.06] text-gray-300 text-xs shrink-0">
+ <Workflow size={12} className="shrink-0 mt-0.5 text-lu-accent" />
+ <span className="flex-1 min-w-0">
+ You can bring your own ComfyUI workflows now. Import one, tag it, and any model
+ with a matching tag will offer it.
+ </span>
+ <button
+ onClick={() => { setWorkflowsOpen(true); setManagerNoticeSeen(true) }}
+ className="shrink-0 px-2 py-0.5 rounded bg-white/10 hover:bg-white/15 text-gray-100 transition-colors whitespace-nowrap"
+ >
+ Take a look
+ </button>
+ <button
+ onClick={() => setManagerNoticeSeen(true)}
+ className="shrink-0 text-gray-500 hover:text-gray-200"
+ title="Dismiss"
+ >
+ <X size={14} />
+ </button>
+ </div>
+ )}
+
{/* The viewer (Stage) and the Gallery bubble share ONE row, so they're
always the exact same height; the prompt window spans the full width
beneath them. (Previously the Gallery ran full-height alongside both the
@@ -233,9 +266,13 @@ function CreateExperimentalInner() {
</div>
{/* Prompt window — full width, beneath the viewer + gallery. */}
- <Composer onOpenAdvanced={() => setAdvancedOpen(true)} />
+ <Composer
+ onOpenAdvanced={() => setAdvancedOpen(true)}
+ onOpenWorkflows={() => { setWorkflowsOpen(true); setManagerNoticeSeen(true) }}
+ />
<AdvancedDrawer open={advancedOpen} onClose={() => setAdvancedOpen(false)} />
+ <WorkflowsModal open={workflowsOpen} onClose={() => setWorkflowsOpen(false)} />
<MaskEditor open={maskOpen} onClose={() => setMaskOpen(false)} />
<Lightbox item={lightbox} onClose={() => setLightbox(null)} />
diff --git a/src/components/create/experimental/__tests__/galleryUrl.test.ts b/src/components/create/experimental/__tests__/galleryUrl.test.ts
index c370e3e4..9390ffce 100644
--- a/src/components/create/experimental/__tests__/galleryUrl.test.ts
+++ b/src/components/create/experimental/__tests__/galleryUrl.test.ts
@@ -1,4 +1,4 @@
-import { describe, it, expect, vi, beforeEach } from 'vitest'
+import { describe, it, expect, vi, beforeEach } from 'vitest'
import {
fetchGalleryItemBlob,
galleryItemUrl,
@@ -16,7 +16,7 @@ import {
} from '../../../../stores/createStore'
// zustand persist reads window.localStorage at store-module load (node env
-// has no DOM) — same hoisted Map shim as createStore.test.ts.
+// has no DOM) — same hoisted Map shim as createStore.test.ts.
vi.hoisted(() => {
const map = new Map<string, string>()
const ls = {
@@ -61,7 +61,7 @@ vi.mock('../../../../api/cloud/jobs', () => ({
resolveResultUrl: vi.fn(),
}))
-// Only backendCall is faked — fetchLocalhostBytes/isTauri keep their real
+// Only backendCall is faked — fetchLocalhostBytes/isTauri keep their real
// behaviour, which the ComfyUI-path tests below depend on.
vi.mock('../../../../api/backend', async (importOriginal) => ({
...(await importOriginal<typeof import('../../../../api/backend')>()),
@@ -75,7 +75,7 @@ const baseItem: GalleryItem = {
batchSize: 1, createdAt: 1,
} as GalleryItem
-describe('galleryItemUrl — ComfyUI file location', () => {
+describe('galleryItemUrl — ComfyUI file location', () => {
it('preserves temp outputs from VHS_VideoCombine', () => {
const url = galleryItemUrl({
...baseItem,
@@ -139,7 +139,7 @@ describe('fetchGalleryItemBlob', () => {
// Cloud renders are deleted after seven days (the Create banner says so, and
// services/render-worker/src/reaper.ts now does it). A tile whose render is
// gone must settle into an honest state, not retry a dead re-sign forever.
-describe('recoverGalleryUrl — expired cloud renders', () => {
+describe('recoverGalleryUrl — expired cloud renders', () => {
beforeEach(() => {
vi.restoreAllMocks()
useCreateStore.setState({ gallery: [] })
@@ -182,11 +182,11 @@ describe('recoverGalleryUrl — expired cloud renders', () => {
/**
* Local MLX renders (Mac). partialize strips `dataUrl` on persist, so after a
- * restart the tile has only a filename — and galleryItemUrl turns that into a
+ * restart the tile has only a filename — and galleryItemUrl turns that into a
* ComfyUI /view URL, which on a Mac can never answer. Every locally generated
* image therefore died on the next launch. The file on disk is the way back.
*/
-describe('recoverGalleryUrl — local MLX renders on disk', () => {
+describe('recoverGalleryUrl — local MLX renders on disk', () => {
beforeEach(() => {
vi.mocked(backendCall).mockReset()
useCreateStore.setState({ gallery: [] })
@@ -198,7 +198,7 @@ describe('recoverGalleryUrl — local MLX renders on disk', () => {
it('re-reads the file and hands the tile a fresh blob URL', async () => {
const item = { ...baseItem, id: 'disk-ok', localPath: '/tmp/mlx-1.png' }
useCreateStore.setState({ gallery: [item] })
- // base64 of "PNG" — content is irrelevant, the decode path is what matters.
+ // base64 of "PNG" — content is irrelevant, the decode path is what matters.
vi.mocked(backendCall).mockResolvedValueOnce('UE5H' as never)
recoverGalleryUrl(item)
@@ -233,13 +233,13 @@ describe('recoverGalleryUrl — local MLX renders on disk', () => {
it('never asks ComfyUI about a file we own on disk', async () => {
// Without this guard the recovery took a pointless round trip to port 8188
- // first — and on a Mac that happens to run ComfyUI for something else, it
+ // first — and on a Mac that happens to run ComfyUI for something else, it
// asked the wrong server about a file it never made.
const item = { ...baseItem, id: 'disk-noproxy', localPath: '/tmp/mlx-3.png' }
expect(await proxiedComfyBlobUrl(item)).toBeNull()
})
- it('still marks a ComfyUI item unavailable — no localPath, nothing to re-read', async () => {
+ it('still marks a ComfyUI item unavailable — no localPath, nothing to re-read', async () => {
const item = { ...baseItem, id: 'comfy-dead' }
useCreateStore.setState({ gallery: [item] })
diff --git a/src/components/layout/AppShell.tsx b/src/components/layout/AppShell.tsx
index bdd3573e..51ae6995 100644
--- a/src/components/layout/AppShell.tsx
+++ b/src/components/layout/AppShell.tsx
@@ -34,10 +34,9 @@ import { CloudExampleModal } from '../cloud/CloudExampleModal'
import { ShortcutsModal } from './ShortcutsModal'
import { CreditsExhaustedModal } from './CreditsExhaustedModal'
import { Titlebar } from './Titlebar'
-import { TagsAndWorkflowsPage } from '../workflows/TagsAndWorkflowsPage'
// The backup triad must never write %APPDATA%/store_backup.json before the
-// restore decision — on a post-NSIS boot the first doBackup would otherwise
+// restore decision — on a post-NSIS boot the first doBackup would otherwise
// snapshot the wiped localStorage over the only good backup. Resolved on every
// exit path of the restore effect (intact-store fast path, restore-then-reload,
// no-backup fallback, browser give-up); module-level so a reload starts fresh.
@@ -61,13 +60,13 @@ export function AppShell() {
// the cloud Create axis and the lu-cloud chat provider in sync.
useCloudAuth()
- // ── Global Local/Cloud mode (2.5.7) — appMode drives everything ──
+ // ── Global Local/Cloud mode (2.5.7) — appMode drives everything ──
const appMode = settings.appMode
const cloudAvailable = useCloudAuthStore(deriveCloudAvailable)
// Boot-sync the configured ComfyUI host/port into the FE URL builder.
// The backend loads them from config.json at startup, but the only FE
- // mirror lived in SettingsPage's mount effect — so after an app restart
+ // mirror lived in SettingsPage's mount effect — so after an app restart
// every comfyuiUrl() (gallery media, control plane) pointed at localhost
// until the user happened to open Settings. On a remote-host setup (#82)
// that made the app look dead after every launch. Found live 2026-07-17.
@@ -81,7 +80,7 @@ export function AppShell() {
const s = await backendCall<{ port?: number; host?: string }>('comfyui_status')
if (typeof s?.port === 'number' && s.port > 0) setComfyPort(s.port)
if (typeof s?.host === 'string' && s.host.trim()) setComfyHost(s.host)
- } catch { /* backend not up yet — Settings' own mirror still applies later */ }
+ } catch { /* backend not up yet — Settings' own mirror still applies later */ }
})()
}, [])
@@ -95,14 +94,14 @@ export function AppShell() {
}, [appMode, cloudAvailable])
// Never leave an out-of-mode model active: flipping the switch moves the
- // chat selection onto the first model of the new mode (cloud ↔ local).
- // Depends on the model list too — the hosted catalog arrives ASYNC after
+ // chat selection onto the first model of the new mode (cloud ↔ local).
+ // Depends on the model list too — the hosted catalog arrives ASYNC after
// the lu-cloud provider gets enabled, so the reselect must fire again the
// moment those models land.
const allModels = useModelStore((s) => s.models)
useEffect(() => {
const { activeModel, setActiveModel } = useModelStore.getState()
- // Chat models only — ComfyUI image/video checkpoints share the list but
+ // Chat models only — ComfyUI image/video checkpoints share the list but
// carry no provider field, so a bare provider check would pin a checkpoint
// as the active CHAT model (mirrors the pull auto-activate guard in
// useModels; an unprefixed checkpoint name routes to Ollama and fails).
@@ -121,7 +120,7 @@ export function AppShell() {
if (fallback) setActiveModel(fallback.name)
}, [appMode, allModels])
- // Local-hardware views (Models/Benchmark) don't exist in cloud mode — the
+ // Local-hardware views (Models/Benchmark) don't exist in cloud mode — the
// header hides them, this guard covers a view that was already open.
useEffect(() => {
const ui = useUIStore.getState()
@@ -130,12 +129,12 @@ export function AppShell() {
}
}, [appMode])
- // ── Cloud = cloud-only: release every LOCAL model backend so nothing sits
+ // ── Cloud = cloud-only: release every LOCAL model backend so nothing sits
// in RAM/VRAM while inference runs in the cloud (David 2026-07-11). Whisper
// STT, the bundled llama.cpp sidecar + embeddings, Ollama-loaded models and
// ComfyUI VRAM are freed by offload_local_models; LM Studio via its own JIT
// unload (`lms unload --all`). Local mode reloads LAZILY on first use
- // (chat/voice/render) — nothing is pre-warmed. Fires on entering cloud
+ // (chat/voice/render) — nothing is pre-warmed. Fires on entering cloud
// (switch OR launch-in-cloud); local mode is a no-op.
useEffect(() => {
if (!isTauri() || appMode !== 'cloud') return
@@ -146,13 +145,13 @@ export function AppShell() {
// Push the persisted ComfyUI GPU override to the backend on boot + change
// (rhodium92 AMD, 2026-07-01). The backend resets to "auto" each launch, so
// without this a saved force-cpu / force-gpu wouldn't apply until the user
- // re-opened Settings. Desktop-only — the web build has no local ComfyUI.
+ // re-opened Settings. Desktop-only — the web build has no local ComfyUI.
useEffect(() => {
if (!isTauri()) return
backendCall('set_comfy_gpu_mode', { mode: settings.comfyGpuMode || 'auto' }).catch(() => {})
}, [settings.comfyGpuMode])
- // ── Store backup/restore: survive NSIS updates that wipe WebView2 data ──
+ // ── Store backup/restore: survive NSIS updates that wipe WebView2 data ──
const STORE_KEYS = [
'chat-conversations', 'chat-settings', 'chat-models', 'lu-providers',
'create-store', 'locally-uncensored-codex',
@@ -161,7 +160,7 @@ export function AppShell() {
'locally-uncensored-agent-workflows', 'locally-uncensored-agent',
'locally-uncensored-voice', 'lu-benchmark-store', 'lu-update-checker-v2',
'rag-store', 'workflow-store', 'lu-cloud-catalog',
- // One-shot notices — back these up so "seen it once" survives an NSIS
+ // One-shot notices — back these up so "seen it once" survives an NSIS
// update that wipes WebView2 localStorage. `lu_cloud_notice` (the Create
// retention line) claimed in its own comment that it survived an update
// and did not, because it was never listed here.
@@ -170,7 +169,7 @@ export function AppShell() {
'locally-uncensored-agent-goal',
]
const STORE_KEYS_SET = new Set(STORE_KEYS)
- // These two persist via idbStorage (IndexedDB) since v2.5.0 — the backup
+ // These two persist via idbStorage (IndexedDB) since v2.5.0 — the backup
// snapshot must read them from there; their localStorage copy is deleted by
// the one-time idb migration, so localStorage.getItem returns nothing.
const IDB_STORE_KEYS = new Set(['chat-conversations', 'locally-uncensored-memory'])
@@ -195,11 +194,11 @@ export function AppShell() {
}
// On startup: if localStorage was wiped, restore from %APPDATA% backup.
- // Tauri v2 sets the global asynchronously via `withGlobalTauri` — on slow
+ // Tauri v2 sets the global asynchronously via `withGlobalTauri` — on slow
// cold-starts the first render beats it (commit 835ce86, same reason the
// backup triad polls). A bare isTauri() bail here would skip the restore
// permanently and let the triad's first doBackup clobber the backup file
- // with the freshly-wiped state, so we poll with the same 100 ms × 50 pattern.
+ // with the freshly-wiped state, so we poll with the same 100 ms × 50 pattern.
useEffect(() => {
const runRestore = () => {
const hasStores = STORE_KEYS.some(k => localStorage.getItem(k))
@@ -221,7 +220,7 @@ export function AppShell() {
const parsed = await restoreMemoryVectorsFrom(rawParsed)
const { exportAllChunks, importAllChunks } = await import('../../lib/ragDB')
const live = await exportAllChunks()
- // Only import entries the live store is missing — never clobber
+ // Only import entries the live store is missing — never clobber
// newer in-app activity with a stale backup.
const toImport: Record<string, any> = {}
for (const [docId, chunks] of Object.entries(parsed)) {
@@ -236,7 +235,7 @@ export function AppShell() {
}
} catch { /* best-effort */ }
// Release the triad only after the quiet import read the backup
- // file — doRagBackup would otherwise overwrite it first.
+ // file — doRagBackup would otherwise overwrite it first.
resolveRestoreDecided()
})()
return
@@ -256,7 +255,7 @@ export function AppShell() {
let restored = 0
for (const [key, value] of Object.entries(parsed)) {
if (STORE_KEYS_SET.has(key) && typeof value === 'string' && value) {
- // IDB-backed keys go back to IndexedDB — the chat blob can
+ // IDB-backed keys go back to IndexedDB — the chat blob can
// exceed the ~5 MB localStorage quota (that's why those
// stores moved to IDB), and hydration reads them from there.
// Per-key try/catch: one failing key must not abort the rest.
@@ -296,7 +295,7 @@ export function AppShell() {
}
} catch {}
- // 3. No backup available — at least recover onboarding from marker file
+ // 3. No backup available — at least recover onboarding from marker file
if (markerExists) {
updateSettings({ onboardingDone: true })
}
@@ -316,7 +315,7 @@ export function AppShell() {
clearInterval(waitForTauri)
runRestore()
} else if (tries >= 50) {
- // 5 s elapsed — probably browser dev session, nothing to restore.
+ // 5 s elapsed — probably browser dev session, nothing to restore.
clearInterval(waitForTauri)
resolveRestoreDecided()
}
@@ -324,18 +323,18 @@ export function AppShell() {
return () => clearInterval(waitForTauri)
}, [])
- // Backup stores to %APPDATA% — three-pronged so chat history survives
+ // Backup stores to %APPDATA% — three-pronged so chat history survives
// NSIS updates + abrupt process kills:
- // 1. 10 s safety-net interval (was 30 s — too slow, users lost chats if
+ // 1. 10 s safety-net interval (was 30 s — too slow, users lost chats if
// they sent a message shortly before an upgrade).
// 2. Debounced event-driven backup: 1 s after every chat/codex/memory
// mutation. Catches "typed + restart within interval window" case.
// 3. beforeunload sync flush on Tauri window close. Fires for graceful
// quits and "X" button; does NOT fire for taskkill / NSIS upgrade
// (why we need 1+2 as well).
- // No dependency — we want this to run ONCE on mount and not rerun on
+ // No dependency — we want this to run ONCE on mount and not rerun on
// every settings flip. Tauri v2 sets `window.__TAURI__` asynchronously
- // via `withGlobalTauri` — on slower machines the first render fires
+ // via `withGlobalTauri` — on slower machines the first render fires
// BEFORE the global exists, so we poll for up to 5 s, then arm the triad.
useEffect(() => {
let cleanup: (() => void) | null = null
@@ -343,7 +342,7 @@ export function AppShell() {
let tries = 0
const setupTriad = async () => {
- // Never write the first backup before the restore effect decided — a
+ // Never write the first backup before the restore effect decided — a
// post-NSIS boot with wiped storage would otherwise snapshot the empty
// state over the only good store_backup.json.
await restoreDecided
@@ -352,7 +351,7 @@ export function AppShell() {
let backupInflight = false
// In-memory mirror of the IDB-backed values, refreshed by every doBackup
// run. beforeunload can't await IndexedDB (the page is tearing down), so
- // the sync flush below reads from this cache instead — at most one
+ // the sync flush below reads from this cache instead — at most one
// debounce-cycle stale, same freshness the old sync handler had.
const idbCache: Record<string, string> = {}
const doBackup = async () => {
@@ -371,7 +370,7 @@ export function AppShell() {
if (IDB_STORE_KEYS.has(key)) idbCache[key] = val
}
}
- // Always fire — we want backup even if snapshot is mostly empty, and the
+ // Always fire — we want backup even if snapshot is mostly empty, and the
// sentinel tells the restore-flow this is a valid backup.
localStorage.setItem('lu-restore-complete', '1')
backendCall('backup_stores', { data: JSON.stringify(snapshot) }).catch(() => {})
@@ -382,7 +381,7 @@ export function AppShell() {
// Separate, debounced backup for RAG IndexedDB chunks (Bug V, kj103x
// 2026-05-23). These are heavy (768-float embedding vectors per chunk,
// sometimes thousands per doc) so we don't bundle them into the chat
- // snapshot — the chat-store backup must stay fast for the 1 s debounce
+ // snapshot — the chat-store backup must stay fast for the 1 s debounce
// case. RAG backup runs at most once every 30 s and after IndexedDB
// grows, which is the right cadence: chunks change on document upload
// / delete, both rare events compared to chat messages.
@@ -413,7 +412,7 @@ export function AppShell() {
// Migration: write onboarding marker if missing AND user has already
// onboarded (keeps NSIS-update recovery working). Do NOT rewrite the
- // marker for users who just hit Settings → "Re-run onboarding" — for
+ // marker for users who just hit Settings → "Re-run onboarding" — for
// them onboardingDone is false, and the missing marker is intentional.
backendCall<boolean>('is_onboarding_done').catch(() => false).then((markerExists) => {
if (!markerExists && useSettingsStore.getState().settings.onboardingDone) {
@@ -438,7 +437,7 @@ export function AppShell() {
// Synchronous "last write" flush for beforeunload: doBackup awaits
// IndexedDB reads, and an await during page teardown means the trailing
// backup_stores invoke may never fire. Build the snapshot synchronously
- // from localStorage + the idbCache mirror instead — no await before the
+ // from localStorage + the idbCache mirror instead — no await before the
// invoke, restoring the pre-async guarantee.
const flushSyncBackup = () => {
try {
@@ -457,7 +456,7 @@ export function AppShell() {
const onBeforeUnload = () => {
// The 5 s / 30 s intervals cover the common case; this is the "last
// write" insurance for changes since the previous interval. Must stay
- // synchronous — see flushSyncBackup.
+ // synchronous — see flushSyncBackup.
flushSyncBackup()
void doRagBackup()
}
@@ -478,7 +477,7 @@ export function AppShell() {
clearInterval(waitForTauri)
void setupTriad()
} else if (tries >= 50) {
- // 50 × 100 ms = 5 s. Give up silently — probably browser dev session.
+ // 50 × 100 ms = 5 s. Give up silently — probably browser dev session.
clearInterval(waitForTauri)
}
}, 100)
@@ -498,28 +497,28 @@ export function AppShell() {
// into index.html so the very first paint (before any React renders)
// is already dark even on cold-start.
useLayoutEffect(() => {
- const isDark = settings.theme !== 'light' // unset / undefined → dark
+ const isDark = settings.theme !== 'light' // unset / undefined → dark
document.documentElement.classList.toggle('dark', isDark)
document.documentElement.classList.toggle('light', !isDark)
}, [settings.theme])
- // ── Issue #31: Ollama host sync (Rust ↔ frontend) ─────────────
+ // ── Issue #31: Ollama host sync (Rust ↔ frontend) ─────────────
// Two async prereqs to serialize against:
// (a) Tauri v2 `__TAURI_INTERNALS__` is set async via `withGlobalTauri`.
- // (b) Zustand `persist` middleware hydrates `lu-providers` async — if we
+ // (b) Zustand `persist` middleware hydrates `lu-providers` async — if we
// push Rust's value into the store BEFORE hydration finishes,
// hydration replays the stale localStorage baseUrl and clobbers us.
//
// The deliberate order:
- // 1. Wait for the Tauri global via the same 100ms × 50-tick poll the
+ // 1. Wait for the Tauri global via the same 100ms × 50-tick poll the
// backup triad uses (v2.3.3 commit 835ce86).
// 2. Use zustand's own `onFinishHydration` callback for ordering against
- // hydration — more reliable than polling `hasHydrated()` because it
+ // hydration — more reliable than polling `hasHydrated()` because it
// fires deterministically AFTER the replay, not whenever we happen
// to check.
// 3. Fetch Rust's resolved base (config.json > OLLAMA_HOST > default)
// and push it into both the providerStore and backend.ts, regardless
- // of what hydration just wrote — Rust wins at cold start.
+ // of what hydration just wrote — Rust wins at cold start.
// 4. Arm a zustand subscribe listener for future GUI edits so
// `set_ollama_host` keeps Rust's config.json authoritative.
useEffect(() => {
@@ -561,7 +560,7 @@ export function AppShell() {
useProviderStore.getState().setProviderConfig('ollama', { baseUrl: res.base })
}
}
- } catch { /* Rust not ready — providerStore wins, subscription handles later edits */ }
+ } catch { /* Rust not ready — providerStore wins, subscription handles later edits */ }
const current = useProviderStore.getState().providers.ollama?.baseUrl
if (!cancelled && current) setOllamaBase(current)
@@ -585,7 +584,7 @@ export function AppShell() {
clearInterval(waitForTauri)
afterHydration()
} else if (tries >= 50) {
- // 5 s elapsed — probably browser dev session. Still wire the store
+ // 5 s elapsed — probably browser dev session. Still wire the store
// subscription so user edits reach Rust if Tauri appears later.
clearInterval(waitForTauri)
armSubscription()
@@ -601,7 +600,7 @@ export function AppShell() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
- // ── Mirror remote mobile chat into the dispatched desktop conversation ──
+ // ── Mirror remote mobile chat into the dispatched desktop conversation ──
useEffect(() => {
if (!isTauri()) return
let unlisten: (() => void) | undefined
@@ -614,7 +613,7 @@ export function AppShell() {
if (!role || !content) return
const chat = useChatStore.getState()
- // ── Codex route ──────────────────────────────────────────────
+ // ── Codex route ──────────────────────────────────────────────
// Find or create a Codex desktop conversation keyed by the mobile
// chat_id so successive messages from the same mobile Codex chat
// land in the same desktop conversation. Marked with `mode: 'codex'`
@@ -647,7 +646,7 @@ export function AppShell() {
return
}
- // ── Default LU route: dispatched conversation ────────────────
+ // ── Default LU route: dispatched conversation ────────────────
const { dispatchedConversationId } = useRemoteStore.getState()
if (!dispatchedConversationId) return
const conv = chat.conversations.find((c) => c.id === dispatchedConversationId)
@@ -688,10 +687,10 @@ export function AppShell() {
}
}, [])
- // Ollama 0.20.7 stale-manifest scan — runs once per session shortly after
+ // Ollama 0.20.7 stale-manifest scan — runs once per session shortly after
// startup. Flags installed models that the server now rejects with "does
// not support chat/completion/generate" (pulled before the registry-side
- // capabilities refresh). Populates useModelHealthStore → StaleModelsBanner
+ // capabilities refresh). Populates useModelHealthStore → StaleModelsBanner
// surfaces the result as a top-of-app notice with one-click Refresh All.
useEffect(() => {
if (!onboardingDone || !isTauri()) return
@@ -710,7 +709,7 @@ export function AppShell() {
const stale = results.filter((r) => r.stale).map((r) => r.name)
useModelHealthStore.getState().setStaleModels(stale)
} catch {
- // Scan is best-effort — silently fall back if Ollama is unreachable.
+ // Scan is best-effort — silently fall back if Ollama is unreachable.
} finally {
useModelHealthStore.getState().setScanning(false)
}
@@ -728,7 +727,7 @@ export function AppShell() {
detectLocalBackends().then((backends) => {
if (backends.length === 0) return
- // Auto-adopt the first non-Ollama openai-compat backend we find — but
+ // Auto-adopt the first non-Ollama openai-compat backend we find — but
// NOT when the app-managed built-in engine owns the `openai` slot.
// 2.5.7: that slot now holds the bundled llama-server (managed:true) by
// default. Silently overwriting it here would leave `managed:true`
@@ -737,8 +736,8 @@ export function AppShell() {
// auto-adopt an external backend when the user has already switched away
// from the built-in engine (slot not managed). When the built-in engine
// is the active default, detected externals stay opt-in via the selector
- // modal below and Settings → Providers ("use another engine").
- // (Pre-2.5.7 rationale — Discord #help-chat, djoks.exe 2026-04-21: without
+ // modal below and Settings → Providers ("use another engine").
+ // (Pre-2.5.7 rationale — Discord #help-chat, djoks.exe 2026-04-21: without
// auto-enable, dismissing the selector left LM Studio disabled and its
// models never appeared. Still true for users who left the built-in slot.)
const openaiSlot = useProviderStore.getState().providers.openai
@@ -756,7 +755,7 @@ export function AppShell() {
// Also auto-(re)enable Ollama when it's detected. The provider defaults
// to enabled=true, but a previous session may have disabled it; here we
// pin the detected baseUrl and bring it back so models show up in the
- // Settings → AI Backends list and the chat selector.
+ // Settings → AI Backends list and the chat selector.
const detectedOllama = backends.find((b) => b.id === 'ollama')
if (detectedOllama) {
useProviderStore.getState().setProviderConfig('ollama', {
@@ -766,16 +765,16 @@ export function AppShell() {
})
}
- // Single backend → we're done (already enabled above, or was Ollama).
+ // Single backend → we're done (already enabled above, or was Ollama).
if (backends.length === 1) return
// User previously opted out of the selector (tickbox "don't show again")
- // → never re-show. They manage providers via Settings → Providers.
+ // → never re-show. They manage providers via Settings → Providers.
// This is the persistent guard; the sessionStorage check above is just
// the within-session guard.
if (useProviderStore.getState().hideBackendSelector) return
- // Multiple backends detected → show selection dialog so the user can
+ // Multiple backends detected → show selection dialog so the user can
// change which one is the primary openai-compat provider if they want.
setDetectedBackends(backends)
setShowSelector(true)
@@ -798,16 +797,9 @@ export function AppShell() {
<StorageQuotaToast />
<div className="flex-1 flex overflow-hidden gap-2 p-2">
{!isComparing && <Sidebar />}
- <main
- className={`overflow-hidden rounded-xl bg-white dark:bg-[#1e1e1e] ring-1 ring-black/[0.04] dark:ring-white/[0.05] ${
- currentView === 'models' || currentView === 'workflows'
- ? 'flex-none w-[85%] mx-auto'
- : 'flex-1'
- }`}
- >
+ <main className="flex-1 overflow-hidden rounded-xl bg-white dark:bg-[#1e1e1e] ring-1 ring-black/[0.04] dark:ring-white/[0.05]">
{currentView === 'chat' && <ErrorBoundary><ChatView /></ErrorBoundary>}
{currentView === 'models' && <ErrorBoundary><ModelManager /></ErrorBoundary>}
- {currentView === 'workflows' && <ErrorBoundary><TagsAndWorkflowsPage /></ErrorBoundary>}
{currentView === 'benchmark' && <ErrorBoundary><BenchmarkView /></ErrorBoundary>}
{currentView === 'settings' && <ErrorBoundary><SettingsPage /></ErrorBoundary>}
{currentView === 'create' && <ErrorBoundary><CreateExperimental /></ErrorBoundary>}
@@ -821,7 +813,7 @@ export function AppShell() {
backends={detectedBackends}
onClose={() => setShowSelector(false)}
/>
- {/* Cloud gate: login → plan → beta wall, opened by the header switch. */}
+ {/* Cloud gate: login → plan → beta wall, opened by the header switch. */}
<CloudGateModal />
{/* Cloud discovery sheet: opened by the Local-mode teaser surfaces
(locked Create tabs, hosted model rows). */}
diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx
index 615c862c..2a72f4c0 100644
--- a/src/components/layout/Header.tsx
+++ b/src/components/layout/Header.tsx
@@ -275,7 +275,6 @@ export function Header() {
}>
{textNav('chat', 'Chat')}
{textNav('create', 'Create')}
- {textNav('workflows', 'Tags & Workflows')}
<button
onClick={() => {
@@ -317,7 +316,6 @@ export function Header() {
{dropdownNav('chat', 'Chat')}
{dropdownNav('create', 'Create')}
- {dropdownNav('workflows', 'Tags & Workflows')}
<button
onClick={() => {
diff --git a/src/components/workflows/TagPicker.tsx b/src/components/workflows/TagPicker.tsx
index 37c08884..552513f0 100644
--- a/src/components/workflows/TagPicker.tsx
+++ b/src/components/workflows/TagPicker.tsx
@@ -1,4 +1,5 @@
import type { WorkflowTag } from '../../types/workflows'
+import { cn } from '../create/ui/cn'
interface Props {
tags: WorkflowTag[]
@@ -20,33 +21,29 @@ export function TagPicker({
onChange(selectedIds.filter((id) => id !== tagId))
return
}
-
onChange([...selectedIds, tagId])
}
if (tags.length === 0) {
- return (
- <p className="text-xs text-gray-500 dark:text-gray-500">
- {emptyLabel}
- </p>
- )
+ return <p className="t-body text-gray-500">{emptyLabel}</p>
}
return (
<div className="flex flex-wrap gap-1.5">
{tags.map((tag) => {
const active = selected.has(tag.id)
-
return (
<button
key={tag.id}
type="button"
+ aria-pressed={active}
onClick={() => toggleTag(tag.id)}
- className={`rounded-full border px-2.5 py-1 text-xs transition-colors ${
+ className={cn(
+ 't-control rounded-full border px-2.5 py-1 transition-colors lu-focus-ring',
active
- ? 'border-violet-500/50 bg-violet-500/20 text-violet-700 dark:text-violet-200'
- : 'border-gray-200 bg-gray-50 text-gray-500 hover:border-gray-300 hover:text-gray-800 dark:border-white/10 dark:bg-white/5 dark:text-gray-400 dark:hover:border-white/20 dark:hover:text-white'
- }`}
+ ? 'border-lu-accent/50 bg-lu-accent-soft text-lu-accent'
+ : 'border-white/[0.08] bg-white/[0.04] text-gray-500 hover:border-white/20 hover:text-gray-200',
+ )}
>
{tag.name}
</button>
@@ -54,4 +51,4 @@ export function TagPicker({
})}
</div>
)
-}
\ No newline at end of file
+}
diff --git a/src/components/workflows/TagsAndWorkflowsPage.tsx b/src/components/workflows/TagsAndWorkflowsPage.tsx
deleted file mode 100644
index 82c98b6e..00000000
--- a/src/components/workflows/TagsAndWorkflowsPage.tsx
+++ /dev/null
@@ -1,665 +0,0 @@
-import { useEffect, useMemo, useRef, useState } from 'react'
-import {
- Check,
- FileJson,
- Pencil,
- Plus,
- RefreshCw,
- Search,
- Tags,
- Trash2,
- Upload,
- Workflow,
- X,
-} from 'lucide-react'
-import { v4 as uuid } from 'uuid'
-import { parseImportedWorkflow, validateWorkflowJson } from '../../api/workflows'
-import { useModels } from '../../hooks/useModels'
-import {
- useWorkflowStore,
- workflowModelKey,
- type WorkflowTagMode,
-} from '../../stores/workflowStore'
-import { TagPicker } from './TagPicker'
-
-type PageTab = 'workflows' | 'models' | 'tags'
-type ModelFilter = 'all' | WorkflowTagMode
-
-const tabs: Array<{
- id: PageTab
- label: string
-}> = [
- { id: 'workflows', label: 'Workflows' },
- { id: 'models', label: 'Models' },
- { id: 'tags', label: 'Tags' },
-]
-
-export function TagsAndWorkflowsPage() {
- const [activeTab, setActiveTab] = useState<PageTab>('workflows')
-
- const {
- installedWorkflows,
- tags,
- workflowTags,
- modelTags,
- installWorkflow,
- removeWorkflow,
- createTag,
- renameTag,
- deleteTag,
- setWorkflowTags,
- setModelTags,
- } = useWorkflowStore()
-
- const {
- models,
- fetchModels,
- } = useModels()
-
-// Populate installed ComfyUI models when this page is opened instead of
-// relying on the separate Models page to perform the first refresh.
-useEffect(() => {
- fetchModels().catch(() => {})
-}, [fetchModels])
-
- const [importName, setImportName] = useState('')
- const [importJson, setImportJson] = useState('')
- const [importError, setImportError] = useState<string | null>(null)
- const [importSuccess, setImportSuccess] = useState<string | null>(null)
- const fileInputRef = useRef<HTMLInputElement>(null)
-
- const [newTagName, setNewTagName] = useState('')
- const [editingTagId, setEditingTagId] = useState<string | null>(null)
- const [editingTagName, setEditingTagName] = useState('')
-
- const [modelSearch, setModelSearch] = useState('')
- const [modelFilter, setModelFilter] = useState<ModelFilter>('all')
-
- const comfyModels = useMemo(() => {
- const query = modelSearch.trim().toLowerCase()
-
- return models
- .filter((model) => {
- if (model.type !== 'image' && model.type !== 'video') {
- return false
- }
-
- if (model.providerName !== 'ComfyUI') {
- return false
- }
-
- if (modelFilter !== 'all' && model.type !== modelFilter) {
- return false
- }
-
- if (query && !model.name.toLowerCase().includes(query)) {
- return false
- }
-
- return true
- })
- .sort((left, right) => {
- if (left.type !== right.type) {
- return left.type.localeCompare(right.type)
- }
-
- return left.name.localeCompare(right.name)
- })
- }, [models, modelFilter, modelSearch])
-
- const importWorkflowJson = (
- rawText: string,
- suggestedName?: string,
- ) => {
- setImportError(null)
- setImportSuccess(null)
-
- try {
- const json = JSON.parse(rawText)
-
- if (!validateWorkflowJson(json)) {
- setImportError(
- 'Invalid workflow. Export it from ComfyUI using Save (API Format).',
- )
- return
- }
-
- const name =
- importName.trim() ||
- suggestedName?.trim() ||
- 'Imported Workflow'
-
- const parsed = parseImportedWorkflow(
- name,
- json,
- 'manual',
- )
-
- // Re-importing a workflow with the same name updates it in place. Keeping
- // the existing ID also keeps any tags already assigned to that workflow.
- const existing = installedWorkflows.find(
- (workflow) =>
- workflow.source === 'manual' &&
- workflow.name.toLowerCase() === name.toLowerCase(),
- )
-
- installWorkflow({
- ...parsed,
- id: existing?.id ?? uuid(),
- installedAt: existing?.installedAt ?? Date.now(),
- })
-
- setImportName('')
- setImportJson('')
- setImportSuccess(
- existing
- ? `Updated "${name}".`
- : `Installed "${name}".`,
- )
- } catch (error) {
- setImportError(
- error instanceof SyntaxError
- ? 'The selected file does not contain valid JSON.'
- : `Import failed: ${
- error instanceof Error
- ? error.message
- : String(error)
- }`,
- )
- }
- }
-
- const handleFileImport = async (
- event: React.ChangeEvent<HTMLInputElement>,
- ) => {
- const file = event.target.files?.[0]
-
- if (!file) {
- return
- }
-
- try {
- const text = await file.text()
- const suggestedName = file.name.replace(/\.json$/i, '')
-
- importWorkflowJson(text, suggestedName)
- } catch (error) {
- setImportError(
- `Could not read file: ${
- error instanceof Error
- ? error.message
- : String(error)
- }`,
- )
- } finally {
- event.target.value = ''
- }
- }
-
- const handleCreateTag = () => {
- const id = createTag(newTagName)
-
- if (id) {
- setNewTagName('')
- }
- }
-
- const beginRenameTag = (
- tagId: string,
- currentName: string,
- ) => {
- setEditingTagId(tagId)
- setEditingTagName(currentName)
- }
-
- const finishRenameTag = () => {
- if (!editingTagId) {
- return
- }
-
- renameTag(editingTagId, editingTagName)
- setEditingTagId(null)
- setEditingTagName('')
- }
-
- return (
- <div className="flex h-full min-h-0 flex-col">
- <div className="border-b border-gray-200 px-6 py-5 dark:border-white/10">
- <div className="flex items-center gap-3">
- <div className="rounded-xl bg-violet-500/10 p-2.5 text-violet-600 dark:text-violet-300">
- <Tags size={22} />
- </div>
-
- <div>
- <h1 className="text-xl font-semibold text-gray-900 dark:text-white">
- Tags &amp; Workflows
- </h1>
-
- <p className="mt-0.5 text-sm text-gray-500 dark:text-gray-400">
- Install ComfyUI workflows and match them to models using reusable tags.
- </p>
- </div>
- </div>
-
- <div className="mt-5 flex gap-1 rounded-xl bg-gray-100 p-1 dark:bg-white/5">
- {tabs.map((tab) => (
- <button
- key={tab.id}
- type="button"
- onClick={() => setActiveTab(tab.id)}
- className={`flex-1 rounded-lg px-4 py-2 text-sm font-medium transition-colors ${
- activeTab === tab.id
- ? 'bg-white text-gray-900 shadow-sm dark:bg-white/10 dark:text-white'
- : 'text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white'
- }`}
- >
- {tab.label}
- </button>
- ))}
- </div>
- </div>
-
- <div className="min-h-0 flex-1 overflow-y-auto p-6">
- {activeTab === 'workflows' && (
- <div className="mx-auto max-w-5xl space-y-6">
- <section className="rounded-2xl border border-gray-200 bg-gray-50 p-5 dark:border-white/10 dark:bg-white/[0.025]">
- <div className="flex items-center gap-2">
- <Upload size={17} className="text-violet-500" />
- <h2 className="font-semibold text-gray-900 dark:text-white">
- Install workflow
- </h2>
- </div>
-
- <p className="mt-1 text-xs text-gray-500 dark:text-gray-400">
- Import a ComfyUI API-format JSON file. Editable graph exports are not supported.
- </p>
-
- <div className="mt-4 grid gap-3 md:grid-cols-[1fr_auto]">
- <input
- value={importName}
- onChange={(event) => setImportName(event.target.value)}
- placeholder="Workflow name (optional)"
- className="rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm text-gray-900 outline-none focus:border-violet-400 dark:border-white/10 dark:bg-white/5 dark:text-white"
- />
-
- <input
- ref={fileInputRef}
- type="file"
- accept=".json,application/json"
- onChange={handleFileImport}
- className="hidden"
- />
-
- <button
- type="button"
- onClick={() => fileInputRef.current?.click()}
- className="flex items-center justify-center gap-2 rounded-lg bg-violet-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-violet-500"
- >
- <FileJson size={16} />
- Choose API JSON
- </button>
- </div>
-
- <div className="mt-3">
- <textarea
- value={importJson}
- onChange={(event) => setImportJson(event.target.value)}
- placeholder='Or paste API JSON here: {"1":{"class_type":"KSampler",...}}'
- className="h-32 w-full resize-y rounded-lg border border-gray-200 bg-white px-3 py-2 font-mono text-xs text-gray-900 outline-none focus:border-violet-400 dark:border-white/10 dark:bg-white/5 dark:text-white"
- />
-
- <button
- type="button"
- disabled={!importJson.trim()}
- onClick={() => importWorkflowJson(importJson)}
- className="mt-2 rounded-lg bg-gray-900 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-gray-700 disabled:cursor-not-allowed disabled:opacity-40 dark:bg-white dark:text-gray-900 dark:hover:bg-gray-200"
- >
- Install pasted workflow
- </button>
- </div>
-
- {importError && (
- <div className="mt-3 rounded-lg border border-red-500/20 bg-red-500/10 px-3 py-2 text-xs text-red-600 dark:text-red-300">
- {importError}
- </div>
- )}
-
- {importSuccess && (
- <div className="mt-3 rounded-lg border border-emerald-500/20 bg-emerald-500/10 px-3 py-2 text-xs text-emerald-700 dark:text-emerald-300">
- {importSuccess}
- </div>
- )}
- </section>
-
- <section>
- <div className="mb-3 flex items-center gap-2">
- <Workflow size={17} />
- <h2 className="font-semibold text-gray-900 dark:text-white">
- Installed workflows
- </h2>
-
- <span className="rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-500 dark:bg-white/5 dark:text-gray-400">
- {installedWorkflows.length}
- </span>
- </div>
-
- {installedWorkflows.length === 0 ? (
- <div className="rounded-2xl border border-dashed border-gray-300 px-6 py-12 text-center dark:border-white/15">
- <Workflow
- size={28}
- className="mx-auto text-gray-400"
- />
-
- <p className="mt-3 text-sm text-gray-500">
- No workflows are installed yet.
- </p>
- </div>
- ) : (
- <div className="space-y-3">
- {installedWorkflows.map((workflow) => (
- <article
- key={workflow.id}
- className="rounded-2xl border border-gray-200 bg-white p-4 dark:border-white/10 dark:bg-white/[0.025]"
- >
- <div className="flex gap-4">
- <div className="min-w-0 flex-1">
- <div className="flex flex-wrap items-center gap-2">
- <h3 className="truncate font-medium text-gray-900 dark:text-white">
- {workflow.name}
- </h3>
-
- <span className="rounded bg-gray-100 px-1.5 py-0.5 text-[10px] uppercase text-gray-500 dark:bg-white/5 dark:text-gray-400">
- {workflow.mode}
- </span>
-
- <span className="rounded bg-gray-100 px-1.5 py-0.5 text-[10px] uppercase text-gray-500 dark:bg-white/5 dark:text-gray-400">
- {workflow.source}
- </span>
- </div>
-
- {workflow.description && (
- <p className="mt-1 line-clamp-2 text-xs text-gray-500 dark:text-gray-400">
- {workflow.description}
- </p>
- )}
-
- <div className="mt-3">
- <p className="mb-1.5 text-[10px] font-medium uppercase tracking-wider text-gray-500">
- Compatibility tags
- </p>
-
- <TagPicker
- tags={tags}
- selectedIds={workflowTags[workflow.id] ?? []}
- onChange={(tagIds) =>
- setWorkflowTags(
- workflow.id,
- tagIds,
- )
- }
- />
- </div>
- </div>
-
- <button
- type="button"
- title="Remove workflow"
- onClick={() => {
- const confirmed = window.confirm(
- `Remove "${workflow.name}"?`,
- )
-
- if (confirmed) {
- removeWorkflow(workflow.id)
- }
- }}
- className="self-start rounded-lg p-2 text-gray-400 transition-colors hover:bg-red-500/10 hover:text-red-500"
- >
- <Trash2 size={16} />
- </button>
- </div>
- </article>
- ))}
- </div>
- )}
- </section>
- </div>
- )}
-
- {activeTab === 'models' && (
- <div className="mx-auto max-w-5xl space-y-4">
- <div className="flex flex-col gap-3 md:flex-row">
- <div className="relative flex-1">
- <Search
- size={15}
- className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"
- />
-
- <input
- value={modelSearch}
- onChange={(event) =>
- setModelSearch(event.target.value)
- }
- placeholder="Search installed models"
- className="w-full rounded-lg border border-gray-200 bg-white py-2 pl-9 pr-3 text-sm text-gray-900 outline-none focus:border-violet-400 dark:border-white/10 dark:bg-white/5 dark:text-white"
- />
- </div>
-
- <div className="flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-white/5">
- {(['all', 'image', 'video'] as ModelFilter[]).map(
- (filter) => (
- <button
- key={filter}
- type="button"
- onClick={() => setModelFilter(filter)}
- className={`rounded-md px-3 py-1.5 text-xs capitalize transition-colors ${
- modelFilter === filter
- ? 'bg-white text-gray-900 shadow-sm dark:bg-white/10 dark:text-white'
- : 'text-gray-500 dark:text-gray-400'
- }`}
- >
- {filter}
- </button>
- ),
- )}
- </div>
-
- <button
- type="button"
- onClick={() => void fetchModels()}
- className="flex items-center justify-center gap-2 rounded-lg border border-gray-200 px-3 py-2 text-sm text-gray-600 transition-colors hover:bg-gray-100 dark:border-white/10 dark:text-gray-300 dark:hover:bg-white/5"
- >
- <RefreshCw size={15} />
- Refresh
- </button>
- </div>
-
- {comfyModels.length === 0 ? (
- <div className="rounded-2xl border border-dashed border-gray-300 px-6 py-12 text-center dark:border-white/15">
- <p className="text-sm text-gray-500">
- No matching ComfyUI image or video models were found.
- </p>
-
- <p className="mt-1 text-xs text-gray-400">
- Make sure ComfyUI is running, then press Refresh.
- </p>
- </div>
- ) : (
- <div className="space-y-3">
- {comfyModels.map((model) => {
- const mode = model.type as WorkflowTagMode
- const key = workflowModelKey(
- model.name,
- mode,
- )
-
- return (
- <article
- key={key}
- className="rounded-2xl border border-gray-200 bg-white p-4 dark:border-white/10 dark:bg-white/[0.025]"
- >
- <div className="flex flex-wrap items-center gap-2">
- <h3 className="min-w-0 flex-1 break-all font-medium text-gray-900 dark:text-white">
- {model.name}
- </h3>
-
- <span className="rounded bg-gray-100 px-2 py-0.5 text-[10px] font-medium uppercase text-gray-500 dark:bg-white/5 dark:text-gray-400">
- {mode}
- </span>
- </div>
-
- <div className="mt-3">
- <p className="mb-1.5 text-[10px] font-medium uppercase tracking-wider text-gray-500">
- Model tags
- </p>
-
- <TagPicker
- tags={tags}
- selectedIds={modelTags[key] ?? []}
- onChange={(tagIds) =>
- setModelTags(
- model.name,
- mode,
- tagIds,
- )
- }
- />
- </div>
- </article>
- )
- })}
- </div>
- )}
- </div>
- )}
-
- {activeTab === 'tags' && (
- <div className="mx-auto max-w-3xl">
- <div className="flex gap-2">
- <input
- value={newTagName}
- onChange={(event) =>
- setNewTagName(event.target.value)
- }
- onKeyDown={(event) => {
- if (event.key === 'Enter') {
- handleCreateTag()
- }
- }}
- placeholder="New tag, for example Wan 2.2"
- className="min-w-0 flex-1 rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm text-gray-900 outline-none focus:border-violet-400 dark:border-white/10 dark:bg-white/5 dark:text-white"
- />
-
- <button
- type="button"
- disabled={!newTagName.trim()}
- onClick={handleCreateTag}
- className="flex items-center gap-2 rounded-lg bg-violet-600 px-4 py-2 text-sm font-medium text-white hover:bg-violet-500 disabled:opacity-40"
- >
- <Plus size={16} />
- Create tag
- </button>
- </div>
-
- <div className="mt-5 space-y-2">
- {tags.length === 0 ? (
- <div className="rounded-2xl border border-dashed border-gray-300 px-6 py-12 text-center dark:border-white/15">
- <Tags
- size={28}
- className="mx-auto text-gray-400"
- />
-
- <p className="mt-3 text-sm text-gray-500">
- No tags have been created.
- </p>
- </div>
- ) : (
- tags.map((tag) => (
- <div
- key={tag.id}
- className="flex items-center gap-3 rounded-xl border border-gray-200 bg-white px-4 py-3 dark:border-white/10 dark:bg-white/[0.025]"
- >
- {editingTagId === tag.id ? (
- <>
- <input
- value={editingTagName}
- onChange={(event) =>
- setEditingTagName(
- event.target.value,
- )
- }
- onKeyDown={(event) => {
- if (event.key === 'Enter') {
- finishRenameTag()
- }
-
- if (event.key === 'Escape') {
- setEditingTagId(null)
- }
- }}
- autoFocus
- className="min-w-0 flex-1 rounded-lg border border-violet-400 bg-white px-2 py-1 text-sm text-gray-900 outline-none dark:bg-white/5 dark:text-white"
- />
-
- <button
- type="button"
- onClick={finishRenameTag}
- className="rounded-lg p-2 text-emerald-500 hover:bg-emerald-500/10"
- >
- <Check size={16} />
- </button>
-
- <button
- type="button"
- onClick={() => setEditingTagId(null)}
- className="rounded-lg p-2 text-gray-400 hover:bg-gray-100 dark:hover:bg-white/5"
- >
- <X size={16} />
- </button>
- </>
- ) : (
- <>
- <span className="min-w-0 flex-1 font-medium text-gray-900 dark:text-white">
- {tag.name}
- </span>
-
- <button
- type="button"
- onClick={() =>
- beginRenameTag(
- tag.id,
- tag.name,
- )
- }
- className="rounded-lg p-2 text-gray-400 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-white/5 dark:hover:text-white"
- >
- <Pencil size={15} />
- </button>
-
- <button
- type="button"
- onClick={() => {
- const confirmed = window.confirm(
- `Delete the tag "${tag.name}" from all workflows and models?`,
- )
-
- if (confirmed) {
- deleteTag(tag.id)
- }
- }}
- className="rounded-lg p-2 text-gray-400 hover:bg-red-500/10 hover:text-red-500"
- >
- <Trash2 size={15} />
- </button>
- </>
- )}
- </div>
- ))
- )}
- </div>
- </div>
- )}
- </div>
- </div>
- )
-}
\ No newline at end of file
diff --git a/src/hooks/useModels.ts b/src/hooks/useModels.ts
index 407432d6..a19108e3 100644
--- a/src/hooks/useModels.ts
+++ b/src/hooks/useModels.ts
@@ -8,6 +8,7 @@ import {
filterPartialFiles,
} from '../api/comfyui'
import { parseNDJSONStream } from '../api/stream'
+import { log } from '../lib/logger'
import { useModelStore } from '../stores/modelStore'
import { useProviderStore } from '../stores/providerStore'
import { useSettingsStore } from '../stores/settingsStore'
@@ -40,7 +41,7 @@ async function resumeBuiltinEngines(bundled: BundledModel[]) {
) {
await activateBuiltinModel(activeModel)
}
- } catch { /* engine unavailable — non-critical */ }
+ } catch { /* engine unavailable — non-critical */ }
await resumeEmbedServer(bundled)
}
@@ -54,7 +55,7 @@ async function resumeEmbedServer(bundled: BundledModel[]) {
const embedStatus = await bundledEmbedStatus()
if (!embedStatus.running) await startBundledEmbed(embed.path)
}
- } catch { /* embeddings server unavailable — non-critical */ }
+ } catch { /* embeddings server unavailable — non-critical */ }
}
export function useModels() {
@@ -64,7 +65,7 @@ export function useModels() {
pausePull, completePull, dismissPull, setCategoryFilter,
} = useModelStore()
- // Global Local/Cloud switch: one choke point for every picker — cloud mode
+ // Global Local/Cloud switch: one choke point for every picker — cloud mode
// surfaces only the hosted catalog, local mode hides it. The store keeps
// the full list (no refetch on flip); this is a view, not a mutation.
const appMode = useSettingsStore((s) => s.settings.appMode)
@@ -82,7 +83,7 @@ export function useModels() {
useEffect(() => {
const handler = () => { fetchModels().catch(() => {}) }
window.addEventListener('lu-models-refresh', handler)
- // A finished ComfyUI image/video download fires 'comfyui-model-downloaded' —
+ // A finished ComfyUI image/video download fires 'comfyui-model-downloaded' —
// from the download-store poller on completion AND from installBundleComplete
// after it rescans ComfyUI. useModels must refetch on it too, or a freshly
// downloaded model stays missing from the Installed tab + the chat/create
@@ -96,7 +97,7 @@ export function useModels() {
window.removeEventListener('comfyui-model-downloaded', handler)
}
// fetchModels is reassigned below on every render but always wraps the
- // same setModels — depending on it would just churn listeners.
+ // same setModels — depending on it would just churn listeners.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
@@ -128,7 +129,7 @@ export function useModels() {
provider: pm.provider, providerName: pm.providerName,
contextLength: pm.contextLength, supportsTools: pm.supportsTools, supportsVision: pm.supportsVision,
thinkMode: pm.thinkMode,
- // Friendly server label (LU Cloud) — pickers prefer it over the id.
+ // Friendly server label (LU Cloud) — pickers prefer it over the id.
displayName: pm.name !== pm.id ? pm.name : undefined,
} satisfies CloudModel
})
@@ -136,7 +137,7 @@ export function useModels() {
)
for (const result of providerResults) {
if (result.status === 'fulfilled') {
- // Filter out embedding models (e.g. nomic-embed-text) — not usable for chat
+ // Filter out embedding models (e.g. nomic-embed-text) — not usable for chat
allModels.push(...result.value.filter(m => !isEmbeddingModel(m.name)))
}
}
@@ -151,14 +152,14 @@ export function useModels() {
builtinResumeAttempted = true
void resumeBuiltinEngines(bundledRaw)
}
- } catch { /* engine command unavailable — non-critical */ }
+ } catch { /* engine command unavailable — non-critical */ }
} else if (!builtinResumeAttempted) {
// Non-builtin chat backend (LM Studio etc.): still resume the bundled
// embeddings server when its GGUF exists, so RAG survives a relaunch.
builtinResumeAttempted = true
try {
void resumeEmbedServer(await listBundledModels())
- } catch { /* engine command unavailable — non-critical */ }
+ } catch { /* engine command unavailable — non-critical */ }
}
const ollamaEnabled = useProviderStore.getState().providers.ollama.enabled
const hasOllamaModels = allModels.some(m => m.provider === 'ollama')
@@ -171,92 +172,46 @@ export function useModels() {
} catch { /* Ollama might not be running */ }
}
-let comfyModels: AIModel[] = []
-
-// macOS local media uses MLX rather than ComfyUI.
-const comfyOk = !isMacOS() && (await checkComfyConnection())
-
-if (comfyOk) {
- const [imageResult, videoResult] = await Promise.allSettled([
- getComfyImageModels(),
- getComfyVideoModels(),
- ])
-
- if (imageResult.status === 'rejected') {
- console.warn(
- '[useModels] Failed to discover ComfyUI image models:',
- imageResult.reason,
- )
- }
-
- if (videoResult.status === 'rejected') {
- console.warn(
- '[useModels] Failed to discover ComfyUI video models:',
- videoResult.reason,
- )
- }
-
- const imageModels =
- imageResult.status === 'fulfilled'
- ? imageResult.value
- : []
-
- const videoModels =
- videoResult.status === 'fulfilled'
- ? videoResult.value
- : []
-
- // Preserve upstream's protection against incomplete multipart downloads.
- const completeNames = await filterPartialFiles([
- ...imageModels.map((model) => model.name),
- ...videoModels.map((model) => model.name),
- ])
-
- const completeImageModels = imageModels.filter((model) =>
- completeNames.has(model.name),
- )
-
- const completeVideoModels = videoModels.filter((model) =>
- completeNames.has(model.name),
- )
-
- console.log('[useModels] ComfyUI models discovered:', {
- images: completeImageModels.map((model) => model.name),
- videos: completeVideoModels.map((model) => model.name),
- })
-
- const getFormat = (name: string) =>
- name.toLowerCase().endsWith('.gguf')
- ? 'gguf'
- : 'safetensors'
-
- const comfyImages: ImageModel[] = completeImageModels.map((model) => ({
- name: model.name,
- model: model.name,
- size: 0,
- format: getFormat(model.name),
- architecture: model.type,
- type: 'image',
- providerName: 'ComfyUI',
- }))
-
- const comfyVideos: VideoModel[] = completeVideoModels.map((model) => ({
- name: model.name,
- model: model.name,
- size: 0,
- format: getFormat(model.name),
- architecture: model.type,
- type: 'video',
- providerName: 'ComfyUI',
- }))
-
- comfyModels = [...comfyImages, ...comfyVideos]
-}
-
-setModels([...allModels, ...comfyModels])
-
- } catch (error) {
- console.warn('[useModels] Failed to fetch models:', error)
+ let comfyModels: AIModel[] = []
+ // Hard rule: Mac local media is MLX-only — ComfyUI never auto-starts
+ // there (process.rs::auto_start_comfyui), so skip the probe outright
+ // instead of a doomed connection check on every model-list refresh.
+ const comfyOk = !isMacOS() && (await checkComfyConnection())
+ if (comfyOk) {
+ // Settled, not all: a folder ComfyUI cannot read costs that one lane,
+ // never the whole list. The old code lost both to a single throw.
+ const [imageResult, videoResult] = await Promise.allSettled([
+ getComfyImageModels(),
+ getComfyVideoModels(),
+ ])
+ if (imageResult.status === 'rejected') {
+ log.warn('[useModels] ComfyUI image discovery failed', { err: imageResult.reason })
+ }
+ if (videoResult.status === 'rejected') {
+ log.warn('[useModels] ComfyUI video discovery failed', { err: videoResult.reason })
+ }
+ const imageModels = imageResult.status === 'fulfilled' ? imageResult.value : []
+ const videoModels = videoResult.status === 'fulfilled' ? videoResult.value : []
+
+ // Still drop half-downloaded multipart files, as before.
+ const complete = await filterPartialFiles([
+ ...imageModels.map((m) => m.name),
+ ...videoModels.map((m) => m.name),
+ ])
+ const format = (name: string) =>
+ name.toLowerCase().endsWith('.gguf') ? 'gguf' : 'safetensors'
+ const toModel = <T extends 'image' | 'video'>(m: { name: string; type: string }, type: T) => ({
+ name: m.name, model: m.name, size: 0, format: format(m.name),
+ architecture: m.type, type, providerName: 'ComfyUI' as const,
+ })
+ comfyModels = [
+ ...imageModels.filter((m) => complete.has(m.name)).map((m) => toModel(m, 'image') as ImageModel),
+ ...videoModels.filter((m) => complete.has(m.name)).map((m) => toModel(m, 'video') as VideoModel),
+ ]
+ }
+ setModels([...allModels, ...comfyModels])
+ } catch (err) {
+ log.warn('[useModels] Model list refresh failed', { err })
}
}, [setModels])
@@ -277,11 +232,11 @@ setModels([...allModels, ...comfyModels])
try {
await promise
completePull(name)
- try { await fetchModels() } catch { /* model list refresh failed — non-critical */ }
+ try { await fetchModels() } catch { /* model list refresh failed — non-critical */ }
// Auto-activate the freshly downloaded chat model so the chat actually
// switches to it instead of silently staying on the old default
// (forte_exe 2026-06-14: downloaded models didn't appear selected and
- // the chat kept reverting). Chat models only — image/video live in the
+ // the chat kept reverting). Chat models only — image/video live in the
// Create view. Matched by exact list name so a mismatch just no-ops.
{
const freshly = useModelStore.getState().models.find((m) => m.name === name)
@@ -290,7 +245,7 @@ setModels([...allModels, ...comfyModels])
// Auto-dismiss after 5s
setTimeout(() => dismissPull(name), 5000)
} catch (err) {
- // Bug Z/a v2.5.0 — leonsk29 GH #48. Pre-v2.5.0 this catch was
+ // Bug Z/a v2.5.0 — leonsk29 GH #48. Pre-v2.5.0 this catch was
// silent ("card stays visible"), which combined with the Rust-
// side Ok(()) on stream-ended-without-success made LU flip the
// badge to "Completed" even when Ollama returned a 400 or the
@@ -361,13 +316,13 @@ setModels([...allModels, ...comfyModels])
}
// Selecting a built-in model must also swap the loaded GGUF: the managed
- // engine serves one model per process, so activation → swap_bundled_model.
+ // engine serves one model per process, so activation → swap_bundled_model.
// Other providers just set the active model as before.
const activateModel = useCallback((name: string) => {
setActiveModel(name)
const cfg = useProviderStore.getState().providers.openai
if (cfg.enabled && cfg.managed && getProviderIdFromModel(name) === 'openai') {
- void activateBuiltinModel(name).catch(() => { /* engine unavailable — non-critical */ })
+ void activateBuiltinModel(name).catch(() => { /* engine unavailable — non-critical */ })
}
}, [setActiveModel])
diff --git a/src/stores/__tests__/workflowStore.test.ts b/src/stores/__tests__/workflowStore.test.ts
index a31b1177..99dbc7b4 100644
--- a/src/stores/__tests__/workflowStore.test.ts
+++ b/src/stores/__tests__/workflowStore.test.ts
@@ -1,5 +1,5 @@
import { describe, it, expect, beforeEach } from 'vitest'
-import { useWorkflowStore } from '../workflowStore'
+import { useWorkflowStore, shouldShowManagerNotice } from '../workflowStore'
import type { WorkflowTemplate } from '../../types/workflows'
// ── Helpers ─────────────────────────────────────────────────────
@@ -28,6 +28,7 @@ const INITIAL_STATE = {
modelTags: {},
civitaiApiKey: '',
civitaiHost: 'civitai.com',
+ managerNoticeSeen: false,
}
// ═══════════════════════════════════════════════════════════════
@@ -680,4 +681,27 @@ describe('workflowStore', () => {
expect(useWorkflowStore.getState().getWorkflowForModel('other-sdxl.safetensors', 'sdxl')).toBeNull()
})
})
+
+ // ── The one-time Create notice ─────────────────────────────
+
+ describe('manager notice', () => {
+ it('shows on the local backend until it is dismissed', () => {
+ expect(shouldShowManagerNotice('local', false)).toBe(true)
+ expect(shouldShowManagerNotice('local', true)).toBe(false)
+ })
+
+ it('never shows in cloud mode, where a local graph cannot run', () => {
+ expect(shouldShowManagerNotice('cloud', false)).toBe(false)
+ expect(shouldShowManagerNotice('cloud', true)).toBe(false)
+ })
+
+ it('starts undismissed and stays dismissed once set', () => {
+ expect(useWorkflowStore.getState().managerNoticeSeen).toBe(false)
+ useWorkflowStore.getState().setManagerNoticeSeen(true)
+ expect(useWorkflowStore.getState().managerNoticeSeen).toBe(true)
+ // Installing a workflow must not resurrect the notice.
+ useWorkflowStore.getState().installWorkflow(makeWorkflow('wf-9', 'Any'))
+ expect(useWorkflowStore.getState().managerNoticeSeen).toBe(true)
+ })
+ })
})
diff --git a/src/stores/uiStore.ts b/src/stores/uiStore.ts
index f35d1204..12703cf1 100644
--- a/src/stores/uiStore.ts
+++ b/src/stores/uiStore.ts
@@ -1,6 +1,6 @@
import { create } from 'zustand'
-export type View = 'chat' | 'models' | 'settings' | 'create' | 'benchmark' | 'workflows'
+export type View = 'chat' | 'models' | 'settings' | 'create' | 'benchmark'
/** Which Cloud teaser sheet is open (Local-mode discovery, 2.5.8).
* 'intent' = a locked Create tab (the cloud-only intents incl. the five
diff --git a/src/stores/workflowStore.ts b/src/stores/workflowStore.ts
index 35faffde..7f82d450 100644
--- a/src/stores/workflowStore.ts
+++ b/src/stores/workflowStore.ts
@@ -65,6 +65,10 @@ interface WorkflowState {
civitaiApiKey: string
civitaiHost: string
+ /** One-time "the manager is here" notice on the Create surface. */
+ managerNoticeSeen: boolean
+ setManagerNoticeSeen: (v: boolean) => void
+
installWorkflow: (wf: WorkflowTemplate) => void
removeWorkflow: (id: string) => void
@@ -118,6 +122,9 @@ export const useWorkflowStore = create<WorkflowState>()(
civitaiApiKey: '',
civitaiHost: 'civitai.com',
+ managerNoticeSeen: false,
+ setManagerNoticeSeen: (v) => set({ managerNoticeSeen: v }),
+
installWorkflow: (wf) => set((state) => ({
installedWorkflows: [
wf,
@@ -433,4 +440,18 @@ export const useWorkflowStore = create<WorkflowState>()(
name: 'workflow-store',
},
),
-)
\ No newline at end of file
+)
+
+/**
+ * Visibility rule for the one-time workflow manager notice, kept pure so it is
+ * unit-testable (the JSX condition would otherwise only be provable live).
+ * Local backend only — a custom ComfyUI workflow has nothing to run on in cloud
+ * mode — and never again once dismissed. 'workflow-store' is in the AppShell
+ * backup key list, so the dismissal survives an NSIS update.
+ */
+export function shouldShowManagerNotice(
+ backend: 'local' | 'cloud',
+ managerNoticeSeen: boolean,
+): boolean {
+ return backend === 'local' && !managerNoticeSeen
+}
\ No newline at end of file
diff --git a/vite.config.ts b/vite.config.ts
index 03159c24..d46c476c 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -2373,9 +2373,9 @@ export default defineConfig({
// own dropConsole can't be used (all-or-nothing, no warn/error carve-out).
plugins: [react(), tailwindcss(), stripConsolePlugin(), comfyLauncher()],
server: {
- watch: {
- ignored: ['**/src-tauri/target/**'],
- },
+ // The Rust build tree churns thousands of files per `cargo build`; watching
+ // it starves the dev server on a `tauri:dev` run.
+ watch: { ignored: ['**/src-tauri/target/**'] },
port: 5173,
cors: true,
allowedHosts: true,