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(chat): render agent-generated images in web/dev + 3 reported fixes

purplea207631a6a5e
diff --git a/src/api/comfyui.ts b/src/api/comfyui.ts
index 3c2aaa74..d6d5eb92 100644
--- a/src/api/comfyui.ts
+++ b/src/api/comfyui.ts
@@ -511,9 +511,18 @@ export async function filterPartialFiles(filenames: string[]): Promise<Set<strin
try {
const { backendCall } = await import('./backend')
- const results: Array<{ filename: string; complete: boolean }> =
+ const results: Array<{ filename: string; exists?: boolean; complete: boolean }> =
await backendCall('check_model_sizes', { files: filesToCheck })
- const incomplete = new Set(results.filter(r => !r.complete).map(r => r.filename))
+ // Only hide a model when it is CONFIRMED partial: present on disk but too
+ // small (exists === true && !complete). A bare `!complete` also dropped
+ // files the size-checker simply couldn't locate (exists === false) — which
+ // happens whenever the checker looks at the wrong ComfyUI path (the dev
+ // server's hardcoded path guesses, a custom/remote comfy host, etc.). But
+ // these filenames came FROM ComfyUI's own /object_info enums, so ComfyUI
+ // can load them — never hide a model ComfyUI vouches for just because a
+ // secondary size probe missed it (konata 2026-06-07: "no image model"
+ // even though ComfyUI had Juggernaut/RealVis installed).
+ const incomplete = new Set(results.filter(r => r.exists === true && !r.complete).map(r => r.filename))
if (incomplete.size > 0) {
log.info('comfyui.filtered_partial_downloads', { count: incomplete.size, files: [...incomplete] })
}
diff --git a/src/components/chat/ToolCallBlock.tsx b/src/components/chat/ToolCallBlock.tsx
index 7204d0be..b8e29f2f 100644
--- a/src/components/chat/ToolCallBlock.tsx
+++ b/src/components/chat/ToolCallBlock.tsx
@@ -2,16 +2,36 @@ import { useState } from 'react'
import { motion, AnimatePresence } from 'framer-motion'
import { Search, Globe, FileText, FileEdit, Terminal, Image, Film, Loader2, Check, X, Clock, AlertCircle, FolderOpen, Cpu, Monitor, GitBranch, Database } from 'lucide-react'
import type { AgentToolCall } from '../../types/agent-mode'
+import { getComfyHost } from '../../api/backend'
-// F1 (konata3602 commitment 2026-05-23) — when image_generate / screenshot
-// produce an output URL the agent surfaces, we want the user to actually
-// SEE the picture rather than a path string. ComfyUI serves output via
-// http://localhost:8188/view?…; this regex pulls the URL out of the
-// result so we can render an <img> below the raw text. Only fires for
-// images we generated ourselves — third-party URLs in a tool result
-// must NOT be auto-loaded (CSP + privacy).
-// Exported for unit testing (see __tests__/ToolCallBlock-image.test.ts).
-export const INLINE_IMAGE_RE = /(http:\/\/(?:localhost|127\.0\.0\.1):\d+\/view\?[^\s)\]]+)/i
+// F1 (konata3602 commitment 2026-05-23) + render fix (konata3602 bug 2026-06-07)
+// — when image_generate / video_generate / screenshot produce a ComfyUI output,
+// the user must SEE the picture, not a path string. The tool result embeds a
+// ComfyUI /view URL whose exact form depends on the runtime:
+// - packaged desktop (Tauri): http://localhost:8188/view?filename=…
+// - custom / remote ComfyUI host: http://<host>:<port>/view?filename=…
+// - browser / dev (Vite proxy): /comfyui/view?filename=… ← konata's case
+// The original localhost-only regex silently failed on the latter two, so
+// konata (running the web build behind the /comfyui proxy) saw the raw
+// "/comfyui/view?…" text and NO image. comfyViewUrlFromResult() now accepts any
+// of those forms, but ONLY when the URL points at OUR ComfyUI — a relative
+// proxy path, a loopback host, or the user-configured comfy host — and carries
+// a filename. A third-party URL in a tool result is never auto-loaded (CSP +
+// privacy). Exported for unit testing (see __tests__/ToolCallBlock-image.test.ts).
+export function comfyViewUrlFromResult(result: string | null | undefined): string | null {
+ if (!result) return null
+ const m = result.match(/(https?:\/\/[^\s)\]]+\/view\?[^\s)\]]+|\/comfyui\/view\?[^\s)\]]+|\/view\?[^\s)\]]+)/i)
+ if (!m) return null
+ const url = m[1]
+ if (!/[?&]filename=/i.test(url)) return null // must be a real ComfyUI output view
+ if (url.startsWith('/comfyui/view') || url.startsWith('/view?')) return url // our own proxy path — safe
+ try {
+ const host = new URL(url).hostname.toLowerCase()
+ const loopback = host === 'localhost' || host === '127.0.0.1' || host === '::1' || host === '0.0.0.0'
+ if (loopback || host === getComfyHost().toLowerCase()) return url
+ } catch { /* not a parseable absolute URL — fall through to null */ }
+ return null
+}
// Feature EE (v2.5.0): video_generate can produce .mp4 (VHS_VideoCombine) or
// .webm outputs. We render those in a <video> element instead of an <img>.
@@ -72,6 +92,12 @@ export function ToolCallBlock({ toolCall, onApprove, onReject }: Props) {
const isPending = toolCall.status === 'pending_approval'
const isFailed = toolCall.status === 'failed' || toolCall.status === 'rejected'
+ // Inline media preview URL (image_generate / video_generate / screenshot).
+ // Computed once; rendered ALWAYS-visible below the header (even while the
+ // tool block is collapsed) so an auto-approved generation shows its picture
+ // without the user having to expand the block — konata's "and no image".
+ const previewUrl = comfyViewUrlFromResult(toolCall.result)
+
return (
<div className="mb-0.5">
{/* Header line — monochrome, only status icon has subtle color */}
@@ -94,6 +120,35 @@ export function ToolCallBlock({ toolCall, onApprove, onReject }: Props) {
)}
</button>
+ {/* Inline media preview — ALWAYS visible for a completed image/video
+ generation, even while the tool block stays collapsed. Before the
+ konata 2026-06-07 fix this lived inside the collapsed details, so a
+ user with auto-approve (block closed) saw "Image generated: …" text
+ and no picture. A .mp4/.webm output renders in a <video>; everything
+ else — including animated .webp — in an <img>. URL is bounded to OUR
+ ComfyUI by comfyViewUrlFromResult (never auto-loads arbitrary URLs). */}
+ {previewUrl && (
+ <div className="pl-5 pt-0.5">
+ {isInlineVideoUrl(previewUrl) ? (
+ <video
+ src={previewUrl}
+ controls
+ loop
+ className="block max-w-full max-h-[320px] rounded border border-gray-200 dark:border-white/[0.06]"
+ />
+ ) : (
+ <a href={previewUrl} target="_blank" rel="noopener noreferrer" className="block">
+ <img
+ src={previewUrl}
+ alt="Generated image"
+ className="max-w-full max-h-[320px] rounded border border-gray-200 dark:border-white/[0.06]"
+ loading="lazy"
+ />
+ </a>
+ )}
+ </div>
+ )}
+
{/* Expandable details */}
<AnimatePresence>
{open && (
@@ -110,49 +165,12 @@ export function ToolCallBlock({ toolCall, onApprove, onReject }: Props) {
{JSON.stringify(toolCall.args, null, 2)}
</pre>
- {/* Result */}
+ {/* Result (raw text). The inline media preview now renders
+ always-visible above the collapsible (konata 2026-06-07). */}
{toolCall.result && (
- <>
- <pre className="text-[0.55rem] leading-relaxed text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-white/[0.02] rounded px-2 py-1 overflow-auto scrollbar-thin max-h-[300px]">
- {toolCall.result}
- </pre>
- {/* Inline preview (F1 + Feature EE) — only when the result
- contains a ComfyUI view URL. Bounded to localhost so we
- never auto-load arbitrary tool output. A .mp4/.webm output
- (video_generate via VHS_VideoCombine) renders in a
- <video>; everything else — including animated .webp — in
- an <img>. */}
- {(() => {
- const m = toolCall.result?.match(INLINE_IMAGE_RE)
- if (!m) return null
- const url = m[1]
- if (isInlineVideoUrl(url)) {
- return (
- <video
- src={url}
- controls
- loop
- className="block mt-1 max-w-full max-h-[320px] rounded border border-gray-200 dark:border-white/[0.06]"
- />
- )
- }
- return (
- <a
- href={url}
- target="_blank"
- rel="noopener noreferrer"
- className="block mt-1"
- >
- <img
- src={url}
- alt="Generated image"
- className="max-w-full max-h-[320px] rounded border border-gray-200 dark:border-white/[0.06]"
- loading="lazy"
- />
- </a>
- )
- })()}
- </>
+ <pre className="text-[0.55rem] leading-relaxed text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-white/[0.02] rounded px-2 py-1 overflow-auto scrollbar-thin max-h-[300px]">
+ {toolCall.result}
+ </pre>
)}
{/* Error */}
diff --git a/src/components/chat/__tests__/ToolCallBlock-image.test.ts b/src/components/chat/__tests__/ToolCallBlock-image.test.ts
index d3da75e0..3ae643f7 100644
--- a/src/components/chat/__tests__/ToolCallBlock-image.test.ts
+++ b/src/components/chat/__tests__/ToolCallBlock-image.test.ts
@@ -1,72 +1,106 @@
/**
- * ToolCallBlock inline-image regex tests (F1 — konata3602 commitment 2026-05-23)
- *
- * INLINE_IMAGE_RE pulls a ComfyUI "/view" URL out of a tool result so the
- * chat UI can render the generated picture inline (ToolCallBlock.tsx:105
- * does `toolCall.result.match(INLINE_IMAGE_RE)` and feeds m[1] into <img src>).
- *
- * Two things must hold and are guarded here:
- * 1. The regex matches our own localhost/127.0.0.1 ComfyUI view URLs and
- * does NOT match arbitrary third-party https URLs — auto-loading a
- * remote image from tool output would be a CSP + privacy hole (see the
- * comment above the regex in ToolCallBlock.tsx).
- * 2. The string executeImageGenerate() returns (builtin-tools.ts:937,
- * `Image generated: <file> (prompt: "...")\n<url>`) places the URL where
- * the regex can extract it cleanly.
+ * ToolCallBlock inline-media tests
+ * - F1 (konata3602 commitment 2026-05-23): render generated pictures inline.
+ * - Render fix (konata3602 bug 2026-06-07): the old localhost-only regex
+ * silently failed on the /comfyui/view proxy path (web/dev build) and on a
+ * custom ComfyUI host, so the user saw the raw "/comfyui/view?…" text and
+ * NO image. comfyViewUrlFromResult() now accepts the proxy path, loopback
+ * hosts, and the user-configured comfy host — while still NOT auto-loading
+ * arbitrary third-party URLs from tool output (CSP + privacy).
*
* Run: npx vitest run src/components/chat/__tests__/ToolCallBlock-image.test.ts
*/
-import { describe, it, expect } from 'vitest'
-import { INLINE_IMAGE_RE, isInlineVideoUrl } from '../ToolCallBlock'
+import { describe, it, expect, afterEach } from 'vitest'
+import { comfyViewUrlFromResult, isInlineVideoUrl } from '../ToolCallBlock'
+import { setComfyHost, getComfyHost } from '../../../api/backend'
-describe('INLINE_IMAGE_RE', () => {
+describe('comfyViewUrlFromResult', () => {
describe('positive cases (our own ComfyUI output)', () => {
- it('matches a localhost /view URL', () => {
+ it('returns a localhost /view URL', () => {
const url = 'http://localhost:8188/view?filename=foo.png&subfolder=&type=output&t=123'
- expect(INLINE_IMAGE_RE.test(url)).toBe(true)
- // The component renders m[1], so the capture group must be the whole URL.
- expect(url.match(INLINE_IMAGE_RE)?.[1]).toBe(url)
+ expect(comfyViewUrlFromResult(url)).toBe(url)
})
- it('matches a 127.0.0.1 /view URL', () => {
+ it('returns a 127.0.0.1 /view URL', () => {
const url = 'http://127.0.0.1:8188/view?filename=x.png&subfolder=&type=output&t=456'
- expect(INLINE_IMAGE_RE.test(url)).toBe(true)
- expect(url.match(INLINE_IMAGE_RE)?.[1]).toBe(url)
+ expect(comfyViewUrlFromResult(url)).toBe(url)
+ })
+
+ // The exact bug konata hit: the web build talks to ComfyUI through the
+ // Vite "/comfyui" proxy, so the result URL is RELATIVE. The old regex
+ // (http://localhost only) never matched it → no image.
+ it('returns the /comfyui/view proxy path (konata regression)', () => {
+ const url = '/comfyui/view?filename=locally_uncensored_00018_.png&subfolder=&type=output'
+ expect(comfyViewUrlFromResult(url)).toBe(url)
+ })
+
+ it('returns a bare /view proxy path', () => {
+ const url = '/view?filename=foo.png&subfolder=&type=output'
+ expect(comfyViewUrlFromResult(url)).toBe(url)
})
})
describe('negative cases (must NOT auto-load)', () => {
- it('does NOT match a third-party https URL', () => {
- // The whole point of bounding to localhost: a remote image URL in a
- // tool result must never be auto-fetched.
- expect(INLINE_IMAGE_RE.test('https://example.com/image.png')).toBe(false)
+ it('returns null for a third-party https image URL', () => {
+ expect(comfyViewUrlFromResult('https://example.com/image.png')).toBeNull()
+ })
+
+ it('returns null for a non-local /view host (privacy)', () => {
+ // Has /view + filename but points at someone else's box — never auto-load.
+ expect(comfyViewUrlFromResult('http://evil.example.com:8188/view?filename=a.png')).toBeNull()
+ })
+
+ it('returns null for a localhost URL that is not /view', () => {
+ expect(comfyViewUrlFromResult('http://localhost:8188/api/history/abc')).toBeNull()
})
- it('does NOT match a non-localhost host even on http /view', () => {
- expect(INLINE_IMAGE_RE.test('http://evil.example.com:8188/view?filename=a.png')).toBe(false)
+ it('returns null for a /view URL with no filename', () => {
+ expect(comfyViewUrlFromResult('http://localhost:8188/view?subfolder=&type=output')).toBeNull()
})
- it('does NOT match a localhost URL that is not the /view endpoint', () => {
- expect(INLINE_IMAGE_RE.test('http://localhost:8188/api/history/abc')).toBe(false)
+ it('returns null for empty / missing result', () => {
+ expect(comfyViewUrlFromResult('')).toBeNull()
+ expect(comfyViewUrlFromResult(null)).toBeNull()
+ expect(comfyViewUrlFromResult(undefined)).toBeNull()
})
})
- describe('integration with executeImageGenerate() output format', () => {
- // Mirrors the exact return string of executeImageGenerate (builtin-tools.ts:937):
- // `Image generated: ${filename} (prompt: "${prompt}")\n${url}`
- // We hardcode a representative value rather than calling the function,
- // which submits a real ComfyUI workflow over the network. If that format
- // string changes, update this literal too.
- const result =
- 'Image generated: foo.png (prompt: "test")\n' +
- 'http://localhost:8188/view?filename=foo.png&subfolder=&type=output&t=123'
+ describe('custom / remote ComfyUI host', () => {
+ afterEach(() => setComfyHost('localhost'))
+
+ it('returns a /view URL on the user-configured comfy host', () => {
+ setComfyHost('192.168.1.50')
+ expect(getComfyHost()).toBe('192.168.1.50')
+ const url = 'http://192.168.1.50:8188/view?filename=foo.png&subfolder=&type=output'
+ expect(comfyViewUrlFromResult(url)).toBe(url)
+ })
- it('extracts the URL from the full result string', () => {
- const m = result.match(INLINE_IMAGE_RE)
- expect(m).not.toBeNull()
- // The "Image generated: …" prose and the prompt text must be stripped —
- // only the bare URL ends up in <img src>.
- expect(m?.[1]).toBe('http://localhost:8188/view?filename=foo.png&subfolder=&type=output&t=123')
+ it('still rejects a different host even when a custom host is set', () => {
+ setComfyHost('192.168.1.50')
+ expect(comfyViewUrlFromResult('http://10.0.0.9:8188/view?filename=foo.png&type=output')).toBeNull()
+ })
+ })
+
+ describe('integration with executeImageGenerate() / pollAndExtract output', () => {
+ // Desktop (Tauri) shape — vram-handoff pollAndExtract:
+ // `Image generated: <file> (prompt: "...")\n<absolute /view URL>`
+ it('extracts the absolute URL from the full desktop result string', () => {
+ const result =
+ 'Image generated: foo.png (prompt: "test")\n' +
+ 'http://localhost:8188/view?filename=foo.png&subfolder=&type=output&t=123'
+ expect(comfyViewUrlFromResult(result)).toBe(
+ 'http://localhost:8188/view?filename=foo.png&subfolder=&type=output&t=123',
+ )
+ })
+
+ // Web/dev (Vite proxy) shape — exactly what konata pasted on Discord.
+ it('extracts the relative proxy URL from the konata result string', () => {
+ const result =
+ 'Image generated: locally_uncensored_00018_.png (prompt: "...")\n' +
+ '/comfyui/view?filename=locally_uncensored_00018_.png&subfolder=&type=output'
+ expect(comfyViewUrlFromResult(result)).toBe(
+ '/comfyui/view?filename=locally_uncensored_00018_.png&subfolder=&type=output',
+ )
})
})
})
@@ -92,4 +126,7 @@ describe('isInlineVideoUrl', () => {
// The video check keys off the filename param, not a stray ".mp4" token.
expect(isInlineVideoUrl('http://localhost:8188/view?filename=foo.png&subfolder=a.mp4dir&type=output')).toBe(false)
})
+ it('detects a .mp4 on the relative /comfyui/view proxy path', () => {
+ expect(isInlineVideoUrl('/comfyui/view?filename=clip.mp4&subfolder=&type=output')).toBe(true)
+ })
})
diff --git a/src/hooks/useAgentChat.ts b/src/hooks/useAgentChat.ts
index f8fdbf3d..3a657d5d 100644
--- a/src/hooks/useAgentChat.ts
+++ b/src/hooks/useAgentChat.ts
@@ -11,9 +11,7 @@ import { agentVariantExists, createAgentVariant, getAgentModelName, canFixModel
import { useModelStore } from '../stores/modelStore'
import { useSettingsStore } from '../stores/settingsStore'
import { useRAGStore } from '../stores/ragStore'
-import { useVoiceStore } from '../stores/voiceStore'
import { retrieveContext } from '../api/rag'
-import { speakStreaming, isSpeechSynthesisSupported, getVoicesAsync } from '../api/voice'
import { toolRegistry } from '../api/mcp'
import { usePermissionStore } from '../stores/permissionStore'
import { isThinkingCompatible, isPlainTextPlanner } from '../lib/model-compatibility'
@@ -1224,20 +1222,9 @@ export function useAgentChat() {
approvalQueueRef.current = []
setPendingApproval(null)
- // Auto-speak if TTS enabled
- const voiceState = useVoiceStore.getState()
- if (voiceState.ttsEnabled && isSpeechSynthesisSupported() && contentRef.current.trim()) {
- try {
- let voice: SpeechSynthesisVoice | undefined
- if (voiceState.ttsVoice) {
- const voices = await getVoicesAsync()
- voice = voices.find((v) => v.name === voiceState.ttsVoice)
- }
- voiceState.setSpeaking(true)
- await speakStreaming(contentRef.current, voice, voiceState.ttsRate, voiceState.ttsPitch)
- } catch { /* TTS errors non-critical */ }
- finally { voiceState.setSpeaking(false) }
- }
+ // No auto-speak. Reading a response aloud is manual-only via the
+ // per-message Speaker button (David 2026-06-07: "nicht immer automatisch
+ // vorlesen"). Enabling TTS only surfaces that button; it never auto-reads.
// Auto-extract memories (fire-and-forget, agent mode always qualifies)
const memSettings = useMemoryStore.getState().settings
diff --git a/src/hooks/useChat.ts b/src/hooks/useChat.ts
index 3b022b5b..be66334d 100644
--- a/src/hooks/useChat.ts
+++ b/src/hooks/useChat.ts
@@ -4,10 +4,8 @@ import { useChatStore } from "../stores/chatStore"
import { useModelStore } from "../stores/modelStore"
import { useSettingsStore } from "../stores/settingsStore"
import { useRAGStore } from "../stores/ragStore"
-import { useVoiceStore } from "../stores/voiceStore"
import { useMemoryStore } from "../stores/memoryStore"
import { retrieveContext } from "../api/rag"
-import { speakStreaming, isSpeechSynthesisSupported, getVoicesAsync } from "../api/voice"
import { getModelMaxTokens } from "../lib/context-compaction"
import { getModelContextCached } from "../api/ollama"
import { effectiveContextWindow } from "../lib/context-window"
@@ -373,20 +371,9 @@ export function useChat() {
useModelStore.getState().setIsModelLoading(false)
abortRef.current = null
- // Auto-speak response if TTS is enabled
- const voiceState = useVoiceStore.getState()
- if (voiceState.ttsEnabled && isSpeechSynthesisSupported() && contentRef.current.trim()) {
- try {
- let voice: SpeechSynthesisVoice | undefined
- if (voiceState.ttsVoice) {
- const voices = await getVoicesAsync()
- voice = voices.find((v) => v.name === voiceState.ttsVoice)
- }
- voiceState.setSpeaking(true)
- await speakStreaming(contentRef.current, voice, voiceState.ttsRate, voiceState.ttsPitch)
- } catch { /* TTS errors are non-critical */ }
- finally { voiceState.setSpeaking(false) }
- }
+ // No auto-speak. Reading a response aloud is manual-only via the
+ // per-message Speaker button (David 2026-06-07: "nicht immer automatisch
+ // vorlesen"). Enabling TTS only surfaces that button; it never auto-reads.
// Auto-extract memories (fire-and-forget)
const memSettings = useMemoryStore.getState().settings
diff --git a/src/stores/voiceStore.ts b/src/stores/voiceStore.ts
index 127ed3a5..96dbd817 100644
--- a/src/stores/voiceStore.ts
+++ b/src/stores/voiceStore.ts
@@ -57,12 +57,14 @@ export const useVoiceStore = create<VoiceState>()(
sttAvailable: false,
ttsAvailable: false,
- // Persisted settings
- sttEnabled: true,
- // TTS (read-aloud) on by default — David 2026-06-06 "texttospeech
- // aktivieren". There is no auto-speak; this just shows/enables the
- // per-message read-aloud Speaker button when TTS is usable.
- ttsEnabled: true,
+ // Persisted settings — voice OFF by default (David 2026-06-07:
+ // "tts und stt standardmäßig AUS und nicht immer automatisch vorlesen").
+ // STT and TTS are opt-in; nothing reads responses aloud automatically
+ // (the auto-speak on turn-completion was removed in useChat/useAgentChat).
+ // When the user turns TTS on, it only enables the per-message read-aloud
+ // Speaker button — reading happens on click, never automatically.
+ sttEnabled: false,
+ ttsEnabled: false,
piperVoice: "en_US-lessac-medium",
ttsVoice: "",
ttsRate: 1.0,
diff --git a/vite.config.ts b/vite.config.ts
index 4b6df627..40272239 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -700,13 +700,27 @@ function comfyLauncher(): Plugin {
const { existsSync, statSync } = require('fs')
const { join } = require('path')
const home = require('os').homedir()
- // Try to find ComfyUI path
- const candidates = [
- join(home, 'ComfyUI'),
- join(home, 'Desktop', 'ComfyUI'),
- 'C:\\ComfyUI',
- ]
- const comfyPath = candidates.find(p => existsSync(p)) || join(home, 'ComfyUI')
+ // Prefer the ComfyUI path the app actually persisted (matches the
+ // Rust backend); only then fall back to common defaults. Without
+ // this the dev stub guessed wrong for non-default installs and
+ // reported every curated model "incomplete" → "no image model"
+ // (konata-session 2026-06-07).
+ let comfyPath = ''
+ try {
+ const cfgPath = join(process.env.APPDATA || join(home, 'AppData', 'Roaming'), 'locally-uncensored', 'config.json')
+ if (existsSync(cfgPath)) {
+ const cfg = JSON.parse(require('fs').readFileSync(cfgPath, 'utf8'))
+ if (cfg.comfyui_path && existsSync(cfg.comfyui_path)) comfyPath = cfg.comfyui_path
+ }
+ } catch { /* ignore — fall through to candidates */ }
+ if (!comfyPath) {
+ const candidates = [
+ join(home, 'ComfyUI'),
+ join(home, 'Desktop', 'ComfyUI'),
+ 'C:\\ComfyUI',
+ ]
+ comfyPath = candidates.find(p => existsSync(p)) || join(home, 'ComfyUI')
+ }
const results = (files as any[]).map((f: any) => {
const subfolder = f.subfolder || ''
const dir = subfolder.startsWith('custom_nodes')
@@ -1442,6 +1456,59 @@ function comfyLauncher(): Plugin {
}))
})
+ // API: System health (mirrors the Rust `system_health` command so the
+ // Settings → Troubleshoot "Re-probe" button works under `npm run dev`
+ // too. The plain dev server previously had no /local-api/system-health,
+ // so the button errored (konata-session 2026-06-07). Dev-only — the
+ // packaged app uses the real Rust probe.
+ server.middlewares.use('/local-api/system-health', async (_req, res) => {
+ const os = require('os')
+ const probe = async (url: string, endpoint: string) => {
+ try {
+ const r = await fetch(url)
+ return { status: r.ok ? 'ok' : 'error', detail: `HTTP ${r.status}`, endpoint }
+ } catch (e: any) {
+ return { status: 'unreachable', detail: String(e?.message || e), endpoint }
+ }
+ }
+ const ollamaBase = (process.env.OLLAMA_HOST && /^https?:/.test(process.env.OLLAMA_HOST))
+ ? process.env.OLLAMA_HOST.replace(/\/+$/, '')
+ : 'http://localhost:11434'
+ const [ollama, comfyui, lm_studio] = await Promise.all([
+ probe(`${ollamaBase}/api/tags`, ollamaBase),
+ probe('http://localhost:8188/system_stats', 'http://localhost:8188'),
+ probe('http://localhost:1234/v1/models', 'http://localhost:1234'),
+ ])
+ let vram_total_gb: number | null = null
+ let vram_free_gb: number | null = null
+ try {
+ const { execSync } = require('child_process')
+ const out = execSync('nvidia-smi --query-gpu=memory.total,memory.free --format=csv,noheader,nounits',
+ { encoding: 'utf8', timeout: 4000 })
+ const [tot, free] = String(out).trim().split('\n')[0].split(',').map((s: string) => parseFloat(s.trim()))
+ if (!isNaN(tot)) vram_total_gb = +(tot / 1024).toFixed(1)
+ if (!isNaN(free)) vram_free_gb = +(free / 1024).toFixed(1)
+ } catch { /* no nvidia-smi → null */ }
+ let disk_free_gb = 0
+ try {
+ const fs: any = require('fs')
+ if (fs.statfsSync) {
+ const st = fs.statfsSync(os.homedir())
+ disk_free_gb = +((st.bavail * st.bsize) / 1e9).toFixed(1)
+ }
+ } catch { /* statfs unavailable */ }
+ res.writeHead(200, { 'Content-Type': 'application/json' })
+ res.end(JSON.stringify({
+ version: 'dev',
+ host: {
+ os: process.platform, os_version: os.release(), arch: process.arch,
+ cpu_count: os.cpus().length, ram_gb: +(os.totalmem() / 1e9).toFixed(1),
+ disk_free_gb, vram_total_gb, vram_free_gb,
+ },
+ ollama, comfyui, lm_studio,
+ }))
+ })
+
// API: Process list
server.middlewares.use('/local-api/process-list', (_req, res) => {
// Simple stub — full process list needs native code