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): the image tool says when it sets an own workflow aside, and a Mac image has no agent wall clock (C72, C71)

purpleb35085876bff
diff --git a/src/api/__tests__/chat-image-uses-the-assigned-workflow.test.ts b/src/api/__tests__/chat-image-uses-the-assigned-workflow.test.ts
index b4ecfb36..2c1de643 100644
--- a/src/api/__tests__/chat-image-uses-the-assigned-workflow.test.ts
+++ b/src/api/__tests__/chat-image-uses-the-assigned-workflow.test.ts
@@ -11,7 +11,7 @@
import { describe, it, expect, beforeEach } from 'vitest'
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
-import { ownWorkflowFor } from '../vram-handoff'
+import { ownWorkflowFor, ownWorkflowSetAsideNote } from '../vram-handoff'
import { useWorkflowStore } from '../../stores/workflowStore'
const UNET_WF = {
@@ -54,4 +54,16 @@ describe('#192 part 3: the chat image tool takes the workflow assigned to the mo
const src = readFileSync(resolve(__dirname, '../vram-handoff.ts'), 'utf8')
expect(src).toMatch(/const own = await ownWorkflowFor\(model, type, listed\?\.source\)\s+const workflow = own\s+\? await injectParameters\(own\.workflow, own\.parameterMap, params, type, own\.overrides\)\s+: await buildFixable\('image', \(\) => buildDynamicWorkflow\(params, type\)\)/)
})
+
+ it('C72: a workflow set aside says so in the answer of the tool, with the words of Create', async () => {
+ assign(CKPT_WF)
+ expect(await ownWorkflowSetAsideNote('moss_image.safetensors', 'unknown', 'diffusion_model'))
+ .toBe('Your workflow "SDXL (own)" is not used: this model is a diffusion model and needs a UNETLoader, but the workflow loads a checkpoint (CheckpointLoaderSimple). LU builds its own workflow for this model instead. Change the loader in ComfyUI and import the workflow again, or use it with a model it fits.')
+ assign(UNET_WF)
+ expect(await ownWorkflowSetAsideNote('moss_image.safetensors', 'unknown', 'diffusion_model')).toBeNull()
+ assign(null)
+ expect(await ownWorkflowSetAsideNote('x.safetensors', 'sdxl', 'checkpoint')).toBeNull()
+ const src = readFileSync(resolve(__dirname, '../vram-handoff.ts'), 'utf8')
+ expect(src).toContain('return setAside ? `${made}\\n\\nNote: ${setAside}` : made')
+ })
})
diff --git a/src/api/vram-handoff.ts b/src/api/vram-handoff.ts
index 05d703c8..a3787218 100644
--- a/src/api/vram-handoff.ts
+++ b/src/api/vram-handoff.ts
@@ -49,7 +49,7 @@ import { gpuRolesSeparate } from '../lib/gpu-roles'
import { backendCall, ollamaUrl, localFetch, isOllamaLocal, isWindows, fetchLocalhostBytes } from './backend'
import { apiNodes, type ComfyApiGraph } from '../types/comfy-graph'
import { injectParameters } from './workflows'
-import { ownWorkflowMisfit } from '../lib/own-workflow-fit'
+import { ownWorkflowMisfit, ownWorkflowMisfitNote } from '../lib/own-workflow-fit'
import type { ComfyModelSource } from '../types/models'
import { asNumber, asRecordArray, asString, prop } from '../types/json-guards'
import { listRunningModels, loadModel, unloadModel } from './ollama'
@@ -1545,6 +1545,9 @@ async function generateImage(
? await injectParameters(own.workflow, own.parameterMap, params, type, own.overrides)
: await buildFixable('image', () => buildDynamicWorkflow(params, type))
if (own) log.info('vram_handoff.image.own_workflow', { model, workflow: own.name })
+ // C72: a workflow set aside for its loader is said in the answer, as
+ // Create says it under the result, not only in the log.
+ const setAside = own ? null : await ownWorkflowSetAsideNote(model, type, listed?.source)
// Phase markers (chat-agent hang 2026-06-03): make it obvious in the log
// whether a stall is in the workflow build (/object_info) or the submit
// (/prompt). Both are now timeout-bounded, so neither can strand the
@@ -1554,7 +1557,8 @@ async function generateImage(
if (submitted === CANCELLED) return `${label('image')} generation cancelled.`
const promptId = submitted
log.info('vram_handoff.image.submitted', { promptId })
- return await pollAndExtract(promptId, prompt, label('image'), getImageTimeoutMs())
+ const made = await pollAndExtract(promptId, prompt, label('image'), getImageTimeoutMs())
+ return setAside ? `${made}\n\nNote: ${setAside}` : made
} catch (err) {
// Surface ComfyUI's message verbatim — an OOM must NOT be masked.
return buildErrorResult('image', err)
@@ -1579,6 +1583,18 @@ export async function ownWorkflowFor(model: string, type: ModelType, source?: Co
return { ...wf, overrides: store.paramOverrides[wf.id] }
}
+/**
+ * C72: the sentence for a workflow the user assigned to `model` that is set
+ * aside because its loader does not fit (the same words Create shows), or
+ * null when there is none or it fits.
+ */
+export async function ownWorkflowSetAsideNote(model: string, type: ModelType, source?: ComfyModelSource): Promise<string | null> {
+ const { useWorkflowStore } = await import('../stores/workflowStore')
+ const wf = useWorkflowStore.getState().getWorkflowForModel(model, type)
+ if (!wf) return null
+ return ownWorkflowMisfitNote(wf.name, apiNodes(wf.workflow).map(([, n]) => n.class_type), type, source)
+}
+
/** Video path — buildTxt2VidWorkflow with MODEL_TYPE_DEFAULTS + snapToVideoGrid. */
async function generateVideo(
prompt: string,
diff --git a/src/lib/__tests__/mac-image-tool-has-no-wall-clock-c71.test.ts b/src/lib/__tests__/mac-image-tool-has-no-wall-clock-c71.test.ts
new file mode 100644
index 00000000..febcfad9
--- /dev/null
+++ b/src/lib/__tests__/mac-image-tool-has-no-wall-clock-c71.test.ts
@@ -0,0 +1,34 @@
+/**
+ * C71: a local image on a Mac is ended by Rust the moment it stops moving
+ * (the Image timeout). The agent's own wall clock for image_generate would
+ * cut a long render that is still making steps, so there is none there.
+ * Elsewhere, and in the cloud, the cap stays as it was.
+ *
+ * Run: npx vitest run src/lib/__tests__/mac-image-tool-has-no-wall-clock-c71.test.ts
+ */
+import { afterEach, describe, expect, it, vi } from 'vitest'
+
+const host = vi.hoisted(() => ({ mac: false }))
+vi.mock('../capabilities', async (o) => ({ ...(await o<typeof import('../capabilities')>()), hasMlx: () => host.mac }))
+
+import { MEDIA_CALL_OVERHEAD_MS, NO_PRACTICAL_CAP_MS, toolCallCapMs } from '../tool-timeout'
+
+afterEach(() => { host.mac = false })
+
+describe('the cap of image_generate', () => {
+ it('a Mac, local: no wall clock, Rust ends a stalled render', () => {
+ host.mac = true
+ expect(toolCallCapMs('image_generate', {}, { imageGenTimeoutMinutes: 20, appMode: 'local' })).toBe(NO_PRACTICAL_CAP_MS)
+ expect(toolCallCapMs('image_generate', {}, { imageGenTimeoutMinutes: 20 })).toBe(NO_PRACTICAL_CAP_MS)
+ })
+
+ it('COUNTER-CHECK: a Mac in cloud mode and every other desktop keep the cap', () => {
+ host.mac = true
+ expect(toolCallCapMs('image_generate', {}, { imageGenTimeoutMinutes: 20, appMode: 'cloud' })).toBe(20 * 60_000 + MEDIA_CALL_OVERHEAD_MS)
+ host.mac = false
+ expect(toolCallCapMs('image_generate', {}, { imageGenTimeoutMinutes: 20, appMode: 'local' })).toBe(20 * 60_000 + MEDIA_CALL_OVERHEAD_MS)
+ // Video is not touched.
+ host.mac = true
+ expect(toolCallCapMs('video_generate', {}, { videoGenTimeoutMinutes: 60 })).toBe(60 * 60_000 + MEDIA_CALL_OVERHEAD_MS)
+ })
+})
diff --git a/src/lib/tool-timeout.ts b/src/lib/tool-timeout.ts
index 49d01c39..aa30a665 100644
--- a/src/lib/tool-timeout.ts
+++ b/src/lib/tool-timeout.ts
@@ -16,6 +16,8 @@
/** Default args.timeout the loops inject for the exec tools (ms). Building an
* app (npm install, cargo/gradle) routinely runs minutes; the old 30 s
* default + 60 s JS cap killed every real build (2026-06-04). */
+import { hasMlx } from './capabilities'
+
export const SHELL_EXECUTE_DEFAULT_TIMEOUT_MS = 600_000
const LONG_RUNNING = new Set([
@@ -77,6 +79,8 @@ export const URL_CARD_CAP_MS = 10 * 60_000
export interface ToolTimeoutSettings {
imageGenTimeoutMinutes?: number
videoGenTimeoutMinutes?: number
+ /** 'cloud' renders on the server; anything else is this machine. */
+ appMode?: string
}
/**
@@ -118,7 +122,15 @@ export function toolCallCapMs(
args: Record<string, unknown> | undefined,
settings: ToolTimeoutSettings,
): number {
- if (name === 'image_generate') return renderStallLimitMs('image', settings) + MEDIA_CALL_OVERHEAD_MS
+ if (name === 'image_generate') {
+ // C71: a local image on a Mac runs on MLX, and Rust ends it the moment it
+ // stops moving (commands/mlx.rs, the Image timeout; the second engine has
+ // its own hour per image). A wall clock here would cut a long render that
+ // is still making steps, Chroma1-HD at 40 steps on an M1 Max among them.
+ // Stop still ends it.
+ if (settings.appMode !== 'cloud' && hasMlx()) return NO_PRACTICAL_CAP_MS
+ return renderStallLimitMs('image', settings) + MEDIA_CALL_OVERHEAD_MS
+ }
if (name === 'video_generate') return renderStallLimitMs('video', settings) + MEDIA_CALL_OVERHEAD_MS
if (AGENT_LOOP_TOOLS.has(name) && args?.background !== true) {
return NO_PRACTICAL_CAP_MS