Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(create): #88 no-auto-display + Bug-A mask data: URL; LU_NO_KEYCHAIN test flag

purplec8b8977f4f87
diff --git a/src-tauri/src/commands/secret.rs b/src-tauri/src/commands/secret.rs
index da29e5d7..2aa0cfb9 100644
--- a/src-tauri/src/commands/secret.rs
+++ b/src-tauri/src/commands/secret.rs
@@ -148,9 +148,36 @@ mod chunked {
}
}
+/// Test-only kill switch for the OS keychain. A rebuilt ad-hoc-signed app gets a
+/// fresh code-signing hash, so macOS re-prompts for the login password on the
+/// first keychain read after every rebuild — which stalls unattended
+/// rebuild→open test loops. When `LU_NO_KEYCHAIN` is set (env var, or a
+/// `~/.lu-no-keychain` marker file), the secret commands report the keychain as
+/// unavailable; the frontend adapters (supabase.ts session, providerStore keys)
+/// then latch to their localStorage path and never touch the keychain, so no
+/// password prompt appears. A shipped build never triggers this — nothing
+/// creates the marker and no installer sets the env var.
+#[cfg(any(target_os = "windows", target_os = "macos"))]
+fn keychain_disabled() -> bool {
+ if let Some(v) = std::env::var_os("LU_NO_KEYCHAIN") {
+ if !v.is_empty() {
+ return true;
+ }
+ }
+ if let Some(home) = std::env::var_os("HOME") {
+ if std::path::Path::new(&home).join(".lu-no-keychain").exists() {
+ return true;
+ }
+ }
+ false
+}
+
#[cfg(any(target_os = "windows", target_os = "macos"))]
#[tauri::command]
pub fn secret_set(account: String, value: String) -> Result<(), String> {
+ if keychain_disabled() {
+ return Err("keychain unavailable (LU_NO_KEYCHAIN test mode)".into());
+ }
// An empty value means "no key" — delete rather than store an empty secret,
// so a cleared key never lingers in the vault.
if value.is_empty() {
@@ -162,12 +189,18 @@ pub fn secret_set(account: String, value: String) -> Result<(), String> {
#[cfg(any(target_os = "windows", target_os = "macos"))]
#[tauri::command]
pub fn secret_get(account: String) -> Result<Option<String>, String> {
+ if keychain_disabled() {
+ return Err("keychain unavailable (LU_NO_KEYCHAIN test mode)".into());
+ }
chunked::get(&account)
}
#[cfg(any(target_os = "windows", target_os = "macos"))]
#[tauri::command]
pub fn secret_delete(account: String) -> Result<(), String> {
+ if keychain_disabled() {
+ return Err("keychain unavailable (LU_NO_KEYCHAIN test mode)".into());
+ }
chunked::delete(&account)
}
diff --git a/src/components/create/experimental/CreateExperimental.tsx b/src/components/create/experimental/CreateExperimental.tsx
index bd2bffb4..d7b2866a 100644
--- a/src/components/create/experimental/CreateExperimental.tsx
+++ b/src/components/create/experimental/CreateExperimental.tsx
@@ -31,21 +31,30 @@ function CreateExperimentalInner() {
const backend = useCreateStore((s) => s.backend)
const { modelLoadError, connected, comfyOnCpu } = useCreateExp()
- const [pinnedId, setPinnedId] = useState<string | null>(null)
+ const [shownId, setShownId] = useState<string | null>(null)
const [advancedOpen, setAdvancedOpen] = useState(false)
const [maskOpen, setMaskOpen] = useState(false)
const [lightbox, setLightbox] = useState<GalleryItem | null>(null)
const [panelOpen, setPanelOpen] = useState(false)
- // When a fresh generation lands on top, drop any pinned selection so the
- // newest result shows.
- const prevTop = useRef<string | undefined>(undefined)
+ // David 2026-07-11: the Stage starts EMPTY and never auto-surfaces a persisted
+ // gallery item — not on mount, not on a mode/intent switch. It fills only on an
+ // explicit pick (a gallery tile, or a result's "Edit" action) or a fresh
+ // generation made in THIS session. Seed prevTop with whatever is already on top
+ // so a persisted item is never mistaken for a just-made result; only a genuinely
+ // new top id (an in-session generation) auto-shows.
+ const prevTop = useRef<string | undefined>(gallery[0]?.id)
useEffect(() => {
const top = gallery[0]?.id
- if (top && top !== prevTop.current) { setPinnedId(null); prevTop.current = top }
+ if (top && top !== prevTop.current) { setShownId(top); prevTop.current = top }
}, [gallery])
- const displayed = (pinnedId ? gallery.find((g) => g.id === pinnedId) : undefined) ?? gallery[0]
+ // Switching intent/mode returns the Stage to empty — the newest gallery item
+ // must not reappear just because the axis changed.
+ const intent = useCreateStore((s) => s.intent())
+ useEffect(() => { setShownId(null) }, [intent])
+
+ const displayed = shownId ? gallery.find((g) => g.id === shownId) : undefined
const banner = error ?? modelLoadError
// Pull a finished result back in as the working source (ImageRef). Needed
@@ -73,13 +82,12 @@ function CreateExperimentalInner() {
// InputSlot's "pick from gallery" strip, drag&drop, the file picker, or a
// result's "Edit" action. While an op intent owns the stage, clicking a
// gallery tile opens the Lightbox (view it, videos play) instead of
- // pinning into a stage that can't display it.
- const intent = useCreateStore((s) => s.intent())
+ // showing it in a stage that can't display it.
const openGalleryItem = useCallback((id: string) => {
const item = useCreateStore.getState().gallery.find((g) => g.id === id)
if (!item) return
if (INTENT_MAP[intent].needsSource) setLightbox(item)
- else setPinnedId(id)
+ else setShownId(id)
}, [intent])
return (
@@ -137,7 +145,7 @@ function CreateExperimentalInner() {
<MaskEditor open={maskOpen} onClose={() => setMaskOpen(false)} />
</div>
- <CreatePanel open={panelOpen} onOpenChange={setPanelOpen} activeId={pinnedId} onSelect={openGalleryItem} />
+ <CreatePanel open={panelOpen} onOpenChange={setPanelOpen} activeId={shownId} onSelect={openGalleryItem} />
</div>
<Lightbox item={lightbox} onClose={() => setLightbox(null)} />
diff --git a/src/components/create/experimental/MaskEditor.tsx b/src/components/create/experimental/MaskEditor.tsx
index 0b6e72c0..4d7ca9cb 100644
--- a/src/components/create/experimental/MaskEditor.tsx
+++ b/src/components/create/experimental/MaskEditor.tsx
@@ -11,6 +11,15 @@ import { Slider } from '../ui/Slider'
import { Button } from '../ui/Button'
import { cn } from '../ui/cn'
+function blobToDataUrl(blob: Blob): Promise<string> {
+ return new Promise((resolve, reject) => {
+ const r = new FileReader()
+ r.onload = () => resolve(r.result as string)
+ r.onerror = reject
+ r.readAsDataURL(blob)
+ })
+}
+
export function MaskEditor({ open, onClose }: { open: boolean; onClose: () => void }) {
const source = useCreateStore((s) => s.source)
// Opened without a source, nothing mounts below — and onClose only exists
@@ -182,13 +191,18 @@ function MaskEditorInner({ onClose }: { onClose: () => void }) {
const eng = engineRef.current!
if (!eng.hasPaint()) { setMask(null); onClose(); return }
const blob = await eng.exportMaskBlob()
+ // ImageRef.url must be a DATA url, never a blob: url. The cloud submit
+ // stages the mask through dataUrlToBlob() (no fetch — the app CSP blocks
+ // connect-src for blob:/data:), which turns a blob: url into a text blob
+ // and 415s the upload ("unsupported image format"). A data url round-trips.
+ const url = await blobToDataUrl(blob)
// Cloud sessions may have no ComfyUI to stage into — the cloud path
- // re-uploads from the blob URL at submit time (filename stays '').
+ // re-uploads from the data url at submit time (filename stays '').
const filename =
useCreateStore.getState().backend === 'cloud'
? ''
: await uploadImage(new File([blob], 'mask.png', { type: 'image/png' }))
- const ref: ImageRef = { filename, url: URL.createObjectURL(blob), width: source.width, height: source.height }
+ const ref: ImageRef = { filename, url, width: source.width, height: source.height }
setMask(ref)
onClose()
}
diff --git a/src/hooks/__tests__/dataUrlToBlob.test.ts b/src/hooks/__tests__/dataUrlToBlob.test.ts
index fc622bf4..6453b04f 100644
--- a/src/hooks/__tests__/dataUrlToBlob.test.ts
+++ b/src/hooks/__tests__/dataUrlToBlob.test.ts
@@ -31,4 +31,10 @@ describe('dataUrlToBlob', () => {
const blob = dataUrlToBlob(`data:;base64,${btoa('x')}`)
expect(blob.type).toBe('application/octet-stream')
})
+
+ it('throws on a blob: URL instead of silently making a text blob (mask 415 bug)', () => {
+ // A blob: url slipped through as a mask ref once and got parsed into a text
+ // blob of the url string, which the server 415'd. Guard fails loudly now.
+ expect(() => dataUrlToBlob('blob:http://localhost/abc-123')).toThrow(/data: URL/)
+ })
})
diff --git a/src/hooks/useCloudCreate.ts b/src/hooks/useCloudCreate.ts
index 9e0ceb93..d700b1c3 100644
--- a/src/hooks/useCloudCreate.ts
+++ b/src/hooks/useCloudCreate.ts
@@ -33,6 +33,12 @@ import { checkPromptSafety, SAFETY_BLOCK_MESSAGE } from '../lib/render/safety'
// (rightly) has no data: entry, so fetching a data URL throws "Load failed"
// and killed every source-needing op before the upload even started.
export function dataUrlToBlob(dataUrl: string): Blob {
+ // A blob:/http(s) url here means an ImageRef broke the "url is always a data
+ // url" invariant. Parsing it as a data url silently yields a text blob the
+ // server 415s ("unsupported image format") — fail loudly at the source.
+ if (!dataUrl.startsWith('data:')) {
+ throw new Error(`dataUrlToBlob expects a data: URL, got "${dataUrl.slice(0, 16)}…"`)
+ }
const comma = dataUrl.indexOf(',')
const meta = dataUrl.slice(5, comma)
const data = dataUrl.slice(comma + 1)