The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(create): weggeklickte Cross-Origin-Leiste bleibt weg, statt nach jedem Render
purple36c5ba4da0d8
diff --git a/src/api/comfyui.ts b/src/api/comfyui.tsindex ad891b2b..4525eb1e 100644--- a/src/api/comfyui.ts+++ b/src/api/comfyui.ts@@ -567,6 +567,28 @@ export async function getSystemVRAM(): Promise<number | null> {return null}+/**+ * The running ComfyUI's own version string, or null if it does not say.+ *+ * /system_stats carries `system.comfyui_version` on every current build; very+ * old ones simply have no such field, and that is an answer too (the caller+ * maps it to the `unknown` placeholder). Used by the Create tab's cross-origin+ * notice to tell "the same ComfyUI as when you dismissed this" from "a+ * different one", see lib/comfy-cors-notice.ts. Not cached: a restart under+ * LU's management, or a user update, is exactly the change worth noticing.+ */+export async function getComfyVersion(): Promise<string | null> {+ try {+ const res = await localFetch(comfyuiUrl('/system_stats'), { timeoutMs: COMFY_STATS_TIMEOUT_MS })+ if (!res.ok) return null+ const data = await res.json()+ const v = data?.system?.comfyui_version+ return typeof v === 'string' && v.trim() ? v.trim() : null+ } catch {+ return null+ }+}+// Check if a specific node exists in ComfyUI (lightweight, single node check)async function nodeExists(nodeName: string): Promise<boolean> {try {diff --git a/src/components/create/experimental/CreateExperimental.tsx b/src/components/create/experimental/CreateExperimental.tsxindex b0f16c57..d9f2a278 100644--- a/src/components/create/experimental/CreateExperimental.tsx+++ b/src/components/create/experimental/CreateExperimental.tsx@@ -3,6 +3,8 @@ import { AnimatePresence, motion } from 'framer-motion'import { AlertTriangle, Cloud, X } from 'lucide-react'import { useCreateStore, type GalleryItem } from '../../../stores/createStore'import { useCloudNoticeStore, CLOUD_RETENTION_DAYS, shouldShowRetentionNotice } from '../../../stores/cloudNoticeStore'+import { useComfyNoticeStore } from '../../../stores/comfyNoticeStore'+import { loadComfyCorsSignature, shouldShowCorsNotice } from '../../../lib/comfy-cors-notice'import { useWorkflowStore } from '../../../stores/workflowStore'import { CreateExpProvider, useCreateExp } from './CreateContext'import { IntentBar } from './IntentBar'@@ -36,6 +38,9 @@ function CreateExperimentalInner() {const comfyCorsBlocked = useCreateStore((s) => s.comfyCorsBlocked)const setComfyCorsBlocked = useCreateStore((s) => s.setComfyCorsBlocked)const isGenerating = useCreateStore((s) => s.isGenerating)+ const corsNoticeDismissedFor = useComfyNoticeStore((s) => s.corsNoticeDismissedFor)+ const dismissCorsNotice = useComfyNoticeStore((s) => s.dismissCorsNotice)+ const adoptCorsSignature = useComfyNoticeStore((s) => s.adoptCorsSignature)const retentionNoticeSeen = useCloudNoticeStore((s) => s.retentionNoticeSeen)const setRetentionNoticeSeen = useCloudNoticeStore((s) => s.setRetentionNoticeSeen)const setManagerNoticeSeen = useWorkflowStore((s) => s.setManagerNoticeSeen)@@ -54,6 +59,32 @@ function CreateExperimentalInner() {// error explains the manual route and stays visible in the banner.const [corsFixing, setCorsFixing] = useState(false)const [corsFixError, setCorsFixError] = useState<string | null>(null)++ // R18 Befund 1 (2026-08-30, Windows box, ComfyUI 0.33.0): the cross-origin+ // bar came back after EVERY render, dismissed or not. The X only flipped the+ // session flag that the next preview image set again (useComfyMedia). The+ // dismissal now sticks against a cause signature (which ComfyUI, which+ // version) and is persisted, so it survives a restart and only lifts if that+ // cause actually changes. Rules and reasoning: lib/comfy-cors-notice.ts.+ const [corsSignature, setCorsSignature] = useState<string | null>(null)+ useEffect(() => {+ if (backend !== 'local') return+ let cancelled = false+ void (async () => {+ const { getComfyHost, getComfyPort } = await import('../../../api/backend')+ const { getComfyVersion } = await import('../../../api/comfyui')+ const sig = await loadComfyCorsSignature({+ host: getComfyHost, port: getComfyPort, version: getComfyVersion,+ })+ if (cancelled || !sig) return+ setCorsSignature(sig)+ // A dismissal made before the signature landed is upgraded to it, or the+ // very next render would show the bar again — the finding itself.+ adoptCorsSignature(sig)+ })()+ return () => { cancelled = true }+ }, [backend, connected, adoptCorsSignature])+const fixCorsForMe = useCallback(async () => {setCorsFixing(true)setCorsFixError(null)@@ -178,8 +209,12 @@ function CreateExperimentalInner() {live progress bar + native video seeking degrade. David 2026-07-17: keepthe message short and offer a one-click fix — LU restarts ComfyUI underits own management, which always passes the CORS flag. Local only,- dismissible; the long manual-flag hint only appears if the fix fails. */}- {backend === 'local' && comfyCorsBlocked && (+ dismissible; the long manual-flag hint only appears if the fix fails.++ R18 Befund 1: dismissible now MEANS dismissed. shouldShowCorsNotice+ holds the X against the cause signature, so the bar cannot return+ after every render the way it did on the box with ComfyUI 0.33.0. */}+ {backend === 'local' && shouldShowCorsNotice(comfyCorsBlocked, corsSignature, corsNoticeDismissedFor) && (<div className="flex items-start gap-2 px-4 py-2 bg-yellow-500/5 border-b border-yellow-500/10 text-yellow-300 text-xs shrink-0"><AlertTriangle size={12} className="shrink-0 mt-0.5" /><span className="flex-1 min-w-0">@@ -199,7 +234,7 @@ function CreateExperimentalInner() {Let me do it for you!</button>)}- <button onClick={() => { setComfyCorsBlocked(false); setCorsFixError(null) }} className="shrink-0 text-yellow-300/70 hover:text-yellow-100" title="Dismiss">+ <button onClick={() => { setComfyCorsBlocked(false); setCorsFixError(null); dismissCorsNotice(corsSignature) }} className="shrink-0 text-yellow-300/70 hover:text-yellow-100" title="Dismiss"><X size={14} /></button></div>diff --git a/src/lib/__tests__/comfy-cors-notice.test.ts b/src/lib/__tests__/comfy-cors-notice.test.tsnew file mode 100644index 00000000..b412ddc0--- /dev/null+++ b/src/lib/__tests__/comfy-cors-notice.test.ts@@ -0,0 +1,148 @@+import { describe, it, expect, beforeEach } from 'vitest'+import { readFileSync } from 'fs'+import { join } from 'path'+import {+ comfyCorsSignature,+ shouldShowCorsNotice,+ loadComfyCorsSignature,+ UNKNOWN_COMFY_VERSION,+ PENDING_SIGNATURE,+} from '../comfy-cors-notice'+import { useComfyNoticeStore } from '../../stores/comfyNoticeStore'++describe('comfyCorsSignature', () => {+ it('names the ComfyUI and its version', () => {+ expect(comfyCorsSignature('localhost', 8188, '0.33.0')).toBe('localhost:8188|0.33.0')+ })++ it('falls back to the placeholder when the version is missing', () => {+ expect(comfyCorsSignature('localhost', 8188, null)).toBe(`localhost:8188|${UNKNOWN_COMFY_VERSION}`)+ expect(comfyCorsSignature('localhost', 8188, ' ')).toBe(`localhost:8188|${UNKNOWN_COMFY_VERSION}`)+ })++ it('separates two different ComfyUIs and two different versions', () => {+ expect(comfyCorsSignature('localhost', 8188, '0.33.0'))+ .not.toBe(comfyCorsSignature('192.168.0.54', 8188, '0.33.0'))+ expect(comfyCorsSignature('localhost', 8188, '0.33.0'))+ .not.toBe(comfyCorsSignature('localhost', 8188, '0.34.0'))+ })+})++describe('shouldShowCorsNotice', () => {+ const SIG = 'localhost:8188|0.33.0'++ it('says nothing while no media load was blocked', () => {+ expect(shouldShowCorsNotice(false, SIG, null)).toBe(false)+ })++ it('shows the bar on a block nobody dismissed yet', () => {+ expect(shouldShowCorsNotice(true, SIG, null)).toBe(true)+ expect(shouldShowCorsNotice(true, null, null)).toBe(true)+ })++ /**+ * DER BEFUND SELBST (R18 Befund 1, Windows box, ComfyUI 0.33.0).+ *+ * Rueckwaerts gefahrene Negativkontrolle: die alte Bedingung war das nackte+ * `comfyCorsBlocked`, also true, sobald irgendein Vorschaubild ueber den+ * Proxy gerettet wurde. Genau dieser Ausdruck steht unten und ist nach dem+ * Wegklicken immer noch true. Die neue Regel ist es nicht.+ */+ it('THE FINDING: a dismissed bar stays gone across the next renders', () => {+ const blockedAgainByNextRender = true+ expect(blockedAgainByNextRender).toBe(true) // was die alte Bedingung sah+ expect(shouldShowCorsNotice(blockedAgainByNextRender, SIG, SIG)).toBe(false)+ })++ it('stays quiet after a dismissal while the signature is still loading', () => {+ expect(shouldShowCorsNotice(true, null, SIG)).toBe(false)+ })++ it('comes back once for a different ComfyUI or a new version', () => {+ expect(shouldShowCorsNotice(true, 'localhost:8188|0.34.0', SIG)).toBe(true)+ expect(shouldShowCorsNotice(true, 'lu-box:8188|0.33.0', SIG)).toBe(true)+ })+})++describe('loadComfyCorsSignature', () => {+ it('builds the signature from host, port and the reported version', async () => {+ const sig = await loadComfyCorsSignature({+ host: () => 'localhost', port: () => 8188, version: async () => '0.33.0',+ })+ expect(sig).toBe('localhost:8188|0.33.0')+ })++ it('still answers when ComfyUI reports no version at all', async () => {+ const sig = await loadComfyCorsSignature({+ host: () => 'localhost', port: () => 8188, version: async () => null,+ })+ expect(sig).toBe(`localhost:8188|${UNKNOWN_COMFY_VERSION}`)+ })++ it('survives a throwing version probe instead of losing the signature', async () => {+ const sig = await loadComfyCorsSignature({+ host: () => 'localhost', port: () => 8188, version: async () => { throw new Error('down') },+ })+ expect(sig).toBe(`localhost:8188|${UNKNOWN_COMFY_VERSION}`)+ })++ it('gives up honestly when there is no usable port', async () => {+ const sig = await loadComfyCorsSignature({+ host: () => 'localhost', port: () => 0, version: async () => '0.33.0',+ })+ expect(sig).toBeNull()+ })+})++describe('comfyNoticeStore', () => {+ beforeEach(() => {+ useComfyNoticeStore.setState({ corsNoticeDismissedFor: null })+ })++ it('remembers which cause was dismissed', () => {+ useComfyNoticeStore.getState().dismissCorsNotice('localhost:8188|0.33.0')+ expect(useComfyNoticeStore.getState().corsNoticeDismissedFor).toBe('localhost:8188|0.33.0')+ })++ it('records a dismissal made before the signature landed, then adopts it', () => {+ useComfyNoticeStore.getState().dismissCorsNotice(null)+ expect(useComfyNoticeStore.getState().corsNoticeDismissedFor).toBe(PENDING_SIGNATURE)+ // Ohne diese Uebernahme waere der Wegklick beim naechsten Render wertlos.+ expect(shouldShowCorsNotice(true, 'localhost:8188|0.33.0', PENDING_SIGNATURE)).toBe(true)+ useComfyNoticeStore.getState().adoptCorsSignature('localhost:8188|0.33.0')+ expect(useComfyNoticeStore.getState().corsNoticeDismissedFor).toBe('localhost:8188|0.33.0')+ expect(shouldShowCorsNotice(true, 'localhost:8188|0.33.0', 'localhost:8188|0.33.0')).toBe(false)+ })++ it('never overwrites a real dismissal with a later signature', () => {+ useComfyNoticeStore.getState().dismissCorsNotice('localhost:8188|0.33.0')+ useComfyNoticeStore.getState().adoptCorsSignature('localhost:8188|0.34.0')+ expect(useComfyNoticeStore.getState().corsNoticeDismissedFor).toBe('localhost:8188|0.33.0')+ })+})++describe('the Create tab actually uses the rule', () => {+ const src = readFileSync(+ join(__dirname, '../../components/create/experimental/CreateExperimental.tsx'),+ 'utf-8',+ )++ it('gates the bar through shouldShowCorsNotice, not the bare session flag', () => {+ expect(src).toMatch(/shouldShowCorsNotice\(comfyCorsBlocked, corsSignature, corsNoticeDismissedFor\)/)+ // Negativkontrolle: die alte Bedingung darf nicht mehr im Markup stehen.+ expect(src).not.toMatch(/backend === 'local' && comfyCorsBlocked &&/)+ })++ it('records the dismissal on the X, or nothing would stick', () => {+ expect(src).toMatch(/dismissCorsNotice\(corsSignature\)/)+ })+})++describe('the dismissal is persisted like the other one-time notices', () => {+ it('lu_comfy_notice is a resettable settings key and survives an update', async () => {+ const { SETTINGS_STORAGE_KEYS } = await import('../fatal-error')+ const { STORE_KEYS } = await import('../store-backup')+ expect(SETTINGS_STORAGE_KEYS).toContain('lu_comfy_notice')+ expect(STORE_KEYS).toContain('lu_comfy_notice')+ })+})diff --git a/src/lib/comfy-cors-notice.ts b/src/lib/comfy-cors-notice.tsnew file mode 100644index 00000000..0f43925d--- /dev/null+++ b/src/lib/comfy-cors-notice.ts@@ -0,0 +1,117 @@+/**+ * Wann die gelbe Cross-Origin-Leiste im Create-Tab noch etwas zu sagen hat.+ *+ * R18 Befund 1, gemessen am echten 2.6.7 Windows Build (2026-08-30, ComfyUI+ * 0.33.0 auf der Box): die Leiste "Your ComfyUI blocks direct loads (v0.19+),+ * so previews use a slower fallback." kam nach JEDEM Render zurueck, auch nach+ * dem Klick auf ihr X. Der Grund stand in zwei Zeilen, die nichts voneinander+ * wussten:+ *+ * useComfyMedia.onError -> setComfyCorsBlocked(true) (pro Medienelement)+ * CreateExperimental X -> setComfyCorsBlocked(false) (einmal, fluechtig)+ *+ * `comfyCorsBlocked` lebt im createStore und ist dort ausdruecklich von der+ * Persistenz ausgenommen. Das Wegklicken setzte also genau eine Variable+ * zurueck, die das naechste geladene Vorschaubild sofort wieder auf true zog.+ * Der Nutzer klickt weg, LU sagt es beim naechsten Bild wieder. Zwanzig Renders+ * lang.+ *+ * Ein Hinweis, den der Nutzer weggeklickt hat, bleibt weg, bis sich die Lage+ * aendert. Genau das ist die Regel hier, und "die Lage" ist keine Meinung,+ * sondern eine Signatur: welches ComfyUI, in welcher Version. Dieselbe+ * Signatur heisst dieselbe Ursache und dieselbe Antwort. Eine andere Signatur+ * (der Nutzer aktualisiert ComfyUI, oder zeigt LU auf ein anderes) darf die+ * Leiste ein einziges Mal wieder zeigen, weil dort niemand weggeklickt hat.+ *+ * Der Fix-Weg braucht davon nichts: gelingt "Let me do it for you!", laeuft+ * ComfyUI mit --enable-cors-header, kein Medienelement faellt mehr auf den+ * Proxy zurueck und die Leiste kommt aus eigener Kraft nie wieder.+ *+ * Rein und ohne React, damit die Regel im Test beweisbar ist. Die .tsx rendert+ * der node-Testlauf nicht.+ */++/**+ * Die Signatur, wenn die ComfyUI-Version nicht zu erfahren war.+ *+ * Sehr alte ComfyUI-Staende liefern in /system_stats kein `comfyui_version`.+ * Das ist ein gueltiger Zustand, kein Fehler, und bekommt deshalb einen festen+ * Platzhalter statt eines null, das die Regel unten anders behandeln wuerde.+ */+export const UNKNOWN_COMFY_VERSION = 'unknown'++/**+ * Was gespeichert wird, wenn beim Wegklicken noch gar keine Signatur vorlag.+ *+ * Kann vorkommen: die Signatur wird beim Mount geladen, der Klick koennte+ * theoretisch frueher kommen. Der Wegklick zaehlt trotzdem sofort, und sobald+ * die echte Signatur eintrifft, wird dieser Platzhalter durch sie ersetzt+ * (adoptCorsSignature im Store). Sonst waere der Wegklick beim naechsten+ * Render wieder wertlos gewesen, also genau der Befund von oben.+ */+export const PENDING_SIGNATURE = 'pending'++/**+ * Welches ComfyUI, in welcher Version.+ *+ * Host und Port stehen im Frontend-Spiegel, den AppShell beim Start aus+ * `comfyui_status` fuellt. Die Version kommt aus /system_stats.+ */+export function comfyCorsSignature(+ host: string,+ port: number,+ version: string | null | undefined,+): string {+ const h = String(host ?? '').trim() || 'localhost'+ const v = String(version ?? '').trim() || UNKNOWN_COMFY_VERSION+ return `${h}:${port}|${v}`+}++/**+ * Zeigt die Leiste jetzt etwas an, das der Nutzer nicht schon weggeklickt hat.+ *+ * `blocked` der Sitzungszustand aus createStore: ein Medienelement musste+ * ueber den Proxy gerettet werden.+ * `signature` die aktuelle Ursachensignatur, null solange sie laedt.+ * `dismissedFor` die Signatur, fuer die weggeklickt wurde, null wenn nie.+ *+ * Der Fall `dismissedFor` gesetzt und `signature` noch null ist bewusst still:+ * wer einmal weggeklickt hat, bekommt keine Leiste, solange LU nicht belegen+ * kann, dass sich die Ursache geaendert hat. Ein kurzes Aufblitzen beim Start+ * waere genau die Sorte Laerm, die dieser Befund abstellt.+ */+export function shouldShowCorsNotice(+ blocked: boolean,+ signature: string | null,+ dismissedFor: string | null,+): boolean {+ if (!blocked) return false+ if (!dismissedFor) return true+ if (!signature) return false+ return signature !== dismissedFor+}++/**+ * Die aktuelle Signatur besorgen, oder null, wenn das ComfyUI gerade nichts+ * sagt.+ *+ * Ein einziger Aufruf gegen /system_stats, und nur wenn der Create-Tab offen+ * ist. Kein Dauerfeuer auf Port 8188.+ */+export async function loadComfyCorsSignature(deps: {+ host: () => string+ port: () => number+ version: () => Promise<string | null>+}): Promise<string | null> {+ let version: string | null = null+ try {+ version = await deps.version()+ } catch {+ // Kein Grund, deswegen ohne Signatur dazustehen: der Platzhalter ist eine+ // gueltige Signatur, sie aendert sich nur, wenn sich die Version meldet.+ version = null+ }+ const port = deps.port()+ if (!Number.isFinite(port) || port <= 0) return null+ return comfyCorsSignature(deps.host(), port, version)+}diff --git a/src/lib/fatal-error.ts b/src/lib/fatal-error.tsindex 90feff57..cd3dec55 100644--- a/src/lib/fatal-error.ts+++ b/src/lib/fatal-error.ts@@ -32,6 +32,7 @@ export const SETTINGS_STORAGE_KEYS = ['lu-update-checker-v2','lu-benchmark-store','lu_cloud_notice',+ 'lu_comfy_notice',]/** Force the (initially hidden) Tauri window visible so recovery UI is seen. */diff --git a/src/lib/store-backup.ts b/src/lib/store-backup.tsindex 640f2fdd..d2917c28 100644--- a/src/lib/store-backup.ts+++ b/src/lib/store-backup.ts@@ -29,7 +29,7 @@ export const STORE_KEYS = ['locally-uncensored-agent-workflows', 'locally-uncensored-agent','locally-uncensored-voice', 'lu-benchmark-store', 'lu-update-checker-v2','rag-store', 'workflow-store', 'lu-cloud-catalog',- 'lu_cloud_notice', 'locally-uncensored-model-health',+ 'lu_cloud_notice', 'lu_comfy_notice', 'locally-uncensored-model-health','locally-uncensored-agent-goal',]diff --git a/src/stores/comfyNoticeStore.ts b/src/stores/comfyNoticeStore.tsnew file mode 100644index 00000000..64028ff1--- /dev/null+++ b/src/stores/comfyNoticeStore.ts@@ -0,0 +1,55 @@+import { create } from 'zustand'+import { persist } from 'zustand/middleware'+import { PENDING_SIGNATURE } from '../lib/comfy-cors-notice'++/**+ * Was der Nutzer an ComfyUI-Hinweisen im Create-Tab schon weggeklickt hat.+ *+ * Eigener Store und nicht createStore, aus einem Grund: createStore ist der+ * Arbeitszustand einer Sitzung und laesst genau diese Felder bewusst nicht in+ * die Persistenz (siehe partialize dort, `comfyCorsBlocked` steht in der+ * Ausschlussliste). Ein Wegklick ist aber kein Arbeitszustand, sondern eine+ * Entscheidung des Nutzers, und die haelt laenger als ein Fenster.+ *+ * R18 Befund 1 (2026-08-30, Windows Box, ComfyUI 0.33.0): die Cross-Origin+ * Leiste kam nach jedem Render zurueck, weil das X nur den fluechtigen Wert+ * umlegte, den das naechste Vorschaubild sofort wieder setzte. Die Begruendung+ * der Regel steht in lib/comfy-cors-notice.ts.+ *+ * `lu_comfy_notice` steht in fatal-error.ts (zuruecksetzbar, es sind+ * Einstellungen und keine Inhalte) und in store-backup.ts (ueberlebt ein+ * Update, sonst waere der Wegklick nach jeder Version wieder weg, genau der+ * Fehler, den `lu_cloud_notice` einmal hatte).+ */+interface ComfyNoticeState {+ /** Ursachensignatur, fuer die die Cross-Origin-Leiste weggeklickt wurde. */+ corsNoticeDismissedFor: string | null+ /** Wegklicken. Ohne bekannte Signatur wird der Platzhalter gesetzt. */+ dismissCorsNotice: (signature: string | null) => void+ /**+ * Den Platzhalter durch die echte Signatur ersetzen, sobald sie da ist.+ *+ * Wirkt NUR auf den Platzhalter. Eine bereits echte Signatur zu ueber+ * schreiben wuerde den Wegklick auf eine neue Ursache mituebertragen, und+ * damit die eine Lage verschweigen, in der die Leiste wieder etwas Neues zu+ * sagen haette.+ */+ adoptCorsSignature: (signature: string) => void+}++export const useComfyNoticeStore = create<ComfyNoticeState>()(+ persist(+ (set) => ({+ corsNoticeDismissedFor: null,+ dismissCorsNotice: (signature) =>+ set({ corsNoticeDismissedFor: signature ?? PENDING_SIGNATURE }),+ adoptCorsSignature: (signature) =>+ set((s) =>+ s.corsNoticeDismissedFor === PENDING_SIGNATURE+ ? { corsNoticeDismissedFor: signature }+ : s,+ ),+ }),+ { name: 'lu_comfy_notice' },+ ),+)