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(community): cloud-provider CSP (#71), pdf attach hint (#69), model-list refresh, download progress self-heal

purpleda9214a4da27
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 20f04769..fbe0d994 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -24,7 +24,7 @@
}
],
"security": {
- "csp": "default-src 'self' http://ipc.localhost; connect-src 'self' http://ipc.localhost http://tauri.localhost http://localhost:* http://127.0.0.1:* https://civitai.com https://*.civitai.com https://huggingface.co https://*.huggingface.co https://ollama.com ws://localhost:8188 ws://127.0.0.1:8188; img-src 'self' data: blob: http://localhost:8188 http://127.0.0.1:8188 https://*.civitai.com https://*.githubusercontent.com; media-src 'self' blob: http://localhost:8188 http://127.0.0.1:8188; font-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self' 'wasm-unsafe-eval'"
+ "csp": "default-src 'self' http://ipc.localhost; connect-src 'self' http://ipc.localhost http://tauri.localhost http://localhost:* http://127.0.0.1:* https://civitai.com https://*.civitai.com https://huggingface.co https://*.huggingface.co https://ollama.com https://openrouter.ai https://api.openai.com https://api.groq.com https://api.together.xyz https://api.deepseek.com https://api.mistral.ai https://api.anthropic.com ws://localhost:8188 ws://127.0.0.1:8188; img-src 'self' data: blob: http://localhost:8188 http://127.0.0.1:8188 https://*.civitai.com https://*.githubusercontent.com; media-src 'self' blob: http://localhost:8188 http://127.0.0.1:8188; font-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self' 'wasm-unsafe-eval'"
}
},
"plugins": {
diff --git a/src/api/__tests__/csp-cloud-hosts.test.ts b/src/api/__tests__/csp-cloud-hosts.test.ts
new file mode 100644
index 00000000..dc58cdad
--- /dev/null
+++ b/src/api/__tests__/csp-cloud-hosts.test.ts
@@ -0,0 +1,44 @@
+/**
+ * CSP connect-src must whitelist the cloud LLM provider API hosts (GH #71).
+ *
+ * matheusroberson hit "violates the following Content Security Policy" when
+ * testing OpenRouter on the desktop build. Cloud OpenAI-compatible + Anthropic
+ * providers are reached by a DIRECT webview fetch (useLocalProxy is LAN-only),
+ * so their API hosts must be in the desktop CSP connect-src or the provider
+ * "Test" button AND every chat request are blocked by the webview CSP. The 2.5.5
+ * security pass tightened this CSP, so pin the cloud hosts here — a future
+ * tightening must not silently re-break cloud providers again.
+ *
+ * Run: npx vitest run src/api/__tests__/csp-cloud-hosts.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { fileURLToPath } from 'node:url'
+import { dirname, resolve } from 'node:path'
+
+const here = dirname(fileURLToPath(import.meta.url))
+const conf = JSON.parse(readFileSync(resolve(here, '../../../src-tauri/tauri.conf.json'), 'utf8'))
+const csp: string = conf.app.security.csp
+const connectSrc = (csp.split(';').find((d) => d.trim().startsWith('connect-src')) ?? '').trim()
+
+describe('CSP connect-src cloud provider hosts (GH #71)', () => {
+ it.each([
+ 'https://openrouter.ai',
+ 'https://api.openai.com',
+ 'https://api.groq.com',
+ 'https://api.together.xyz',
+ 'https://api.deepseek.com',
+ 'https://api.mistral.ai',
+ 'https://api.anthropic.com',
+ ])('connect-src whitelists %s', (host) => {
+ expect(connectSrc).toContain(host)
+ })
+
+ it('keeps the existing localhost + model-download hosts', () => {
+ expect(connectSrc).toContain("'self'")
+ expect(connectSrc).toContain('http://localhost:*')
+ expect(connectSrc).toContain('https://civitai.com')
+ expect(connectSrc).toContain('https://huggingface.co')
+ expect(connectSrc).toContain('https://ollama.com')
+ })
+})
diff --git a/src/api/discover.ts b/src/api/discover.ts
index 450aa51a..ae77719e 100644
--- a/src/api/discover.ts
+++ b/src/api/discover.ts
@@ -259,6 +259,13 @@ export async function installBundleComplete(bundle: ModelBundle): Promise<void>
// Dispatch event so CreateView refreshes model list
window.dispatchEvent(new CustomEvent('comfyui-model-downloaded'))
+ // Also fire the canonical model-list refresh: the Model Manager's Installed
+ // tab and the shared model store (chat + create pickers) listen on
+ // 'lu-models-refresh', NOT the comfy-specific event above. Without this a
+ // freshly downloaded image/video model showed as installed in Discover but
+ // was missing from the Installed tab and unselectable until a manual refresh
+ // (d37d7bf5 + neejuh, 2026-06-24, on v2.5.5).
+ window.dispatchEvent(new CustomEvent('lu-models-refresh'))
if (errors.length > 0) {
throw new Error(`Bundle install had ${errors.length} issue(s): ${errors.join('; ')}`)
diff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsx
index 5654a07d..c76eb62d 100644
--- a/src/components/chat/ChatInput.tsx
+++ b/src/components/chat/ChatInput.tsx
@@ -23,6 +23,13 @@ interface Props {
* — slash commands belong there, not in the normal chat (David 2026-06-12).
*/
slashCommands?: boolean
+ /**
+ * Open the Documents (RAG) panel. The clip button is images-only; this lets the
+ * composer point a user who tried to attach a PDF/doc to the right place
+ * (GH #69 — a PDF was silently dropped and the model hallucinated it couldn't
+ * receive attachments).
+ */
+ onAttachDocs?: () => void
}
function fileToImageAttachment(file: File): Promise<ImageAttachment> {
@@ -38,10 +45,13 @@ function fileToImageAttachment(file: File): Promise<ImageAttachment> {
})
}
-export function ChatInput({ onSend, onStop, isGenerating, pendingApproval, onApprove, onReject, disabled, slashCommands }: Props) {
+export function ChatInput({ onSend, onStop, isGenerating, pendingApproval, onApprove, onReject, disabled, slashCommands, onAttachDocs }: Props) {
const [input, setInput] = useState('')
const [images, setImages] = useState<ImageAttachment[]>([])
const [isDragOver, setIsDragOver] = useState(false)
+ // Transient hint shown when a non-image file is attached. The clip + drop are
+ // images-only; PDFs/Word/text belong in the Documents (RAG) panel (GH #69).
+ const [docHint, setDocHint] = useState(false)
const [isVoiceRecording, setIsVoiceRecording] = useState(false)
// Slash-command autocomplete (v2.5.3). When the input is a lone "/token", show
// the matching agent commands; ↑/↓ to move, Enter/Tab to pick, Esc to dismiss.
@@ -68,12 +78,26 @@ export function ChatInput({ onSend, onStop, isGenerating, pendingApproval, onApp
}, [input])
const addFiles = useCallback(async (files: FileList | File[]) => {
- const imageFiles = Array.from(files).filter(f => f.type.startsWith('image/'))
+ const all = Array.from(files)
+ const imageFiles = all.filter(f => f.type.startsWith('image/'))
+ // A non-image file (PDF, Word, text, …) can't ride along as a chat image —
+ // it belongs in the Documents panel (RAG) so the model can actually read it.
+ // Silently dropping it made a user think their PDF attached when it didn't,
+ // and the model then hallucinated that it "couldn't receive attachments"
+ // (GH #69). Surface a hint pointing at the right place instead.
+ if (imageFiles.length < all.length) setDocHint(true)
if (imageFiles.length === 0) return
const newImages = await Promise.all(imageFiles.map(fileToImageAttachment))
setImages(prev => [...prev, ...newImages].slice(0, 5)) // max 5 images
}, [])
+ // Auto-dismiss the document hint after a few seconds.
+ useEffect(() => {
+ if (!docHint) return
+ const t = setTimeout(() => setDocHint(false), 8000)
+ return () => clearTimeout(t)
+ }, [docHint])
+
const removeImage = (index: number) => {
setImages(prev => prev.filter((_, i) => i !== index))
}
@@ -236,6 +260,29 @@ export function ChatInput({ onSend, onStop, isGenerating, pendingApproval, onApp
</div>
)}
+ {/* Non-image attach hint (GH #69) — the clip is images-only; PDFs, Word,
+ and text files go through the Documents panel so the model can read them. */}
+ {docHint && (
+ <div className="flex items-center gap-2 mb-1.5 px-2 py-1 rounded-md bg-amber-500/10 border border-amber-500/20 text-[0.62rem] text-amber-700 dark:text-amber-300">
+ <span className="flex-1">The clip attaches images. To ask about a PDF, Word, or text file, add it in the Documents panel.</span>
+ {onAttachDocs && (
+ <button
+ onMouseDown={(e) => { e.preventDefault(); setDocHint(false); onAttachDocs() }}
+ className="shrink-0 px-1.5 py-0.5 rounded bg-amber-500/20 hover:bg-amber-500/30 text-amber-800 dark:text-amber-200 font-medium transition-colors"
+ >
+ Open Documents
+ </button>
+ )}
+ <button
+ onMouseDown={(e) => { e.preventDefault(); setDocHint(false) }}
+ className="shrink-0 text-amber-600/70 hover:text-amber-700 dark:text-amber-400/70 dark:hover:text-amber-300"
+ aria-label="Dismiss"
+ >
+ <X size={11} />
+ </button>
+ </div>
+ )}
+
{/* Image previews */}
{images.length > 0 && (
<div className="flex gap-1.5 mb-1.5 flex-wrap">
@@ -277,7 +324,7 @@ export function ChatInput({ onSend, onStop, isGenerating, pendingApproval, onApp
onClick={() => fileInputRef.current?.click()}
disabled={isGenerating}
className="p-1.5 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 disabled:opacity-20 transition-all shrink-0"
- title="Attach images"
+ title="Attach images — for PDFs and documents use the Documents panel"
>
<Paperclip size={14} />
</button>
diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsx
index a2f251ef..2bcdc931 100644
--- a/src/components/chat/ChatView.tsx
+++ b/src/components/chat/ChatView.tsx
@@ -386,6 +386,7 @@ export function ChatView() {
pendingApproval={pendingApproval}
onApprove={approveToolCall}
onReject={rejectToolCall}
+ onAttachDocs={() => setRagPanelOpen(true)}
/>
</>)}
</div>
diff --git a/src/components/layout/DownloadBadge.tsx b/src/components/layout/DownloadBadge.tsx
index 4172bfc8..116b12a1 100644
--- a/src/components/layout/DownloadBadge.tsx
+++ b/src/components/layout/DownloadBadge.tsx
@@ -55,6 +55,20 @@ export function DownloadBadge() {
if (totalActive > 0) setOpen(true)
}, [totalActive])
+ // Self-heal polling: comfy download progress comes from a polled Rust/bridge
+ // endpoint, and polling was only ever kicked off from the Discover page. So a
+ // download watched from anywhere else — or after the idle auto-stop fired —
+ // showed a frozen progress bar until the user opened the Models page, which
+ // restarted polling (konata, web build, 2026-06-22). The global badge is
+ // always mounted, so let it keep polling alive whenever a comfy download is
+ // active. Strictly additive: it only starts polling, never stops it.
+ const polling = useDownloadStore(s => s.polling)
+ useEffect(() => {
+ if (comfyActiveCount > 0 && !polling) {
+ useDownloadStore.getState().startPolling()
+ }
+ }, [comfyActiveCount, polling])
+
return (
<div ref={ref} className="relative">
{/* Icon trigger */}