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): 'Improving your prompt' counts its seconds like every other waiting line

purpleb1768071fe0a
diff --git a/src/hooks/__tests__/useCreate-qwen-enhancer.test.ts b/src/hooks/__tests__/useCreate-qwen-enhancer.test.ts
index dc8537b3..6fcda288 100644
--- a/src/hooks/__tests__/useCreate-qwen-enhancer.test.ts
+++ b/src/hooks/__tests__/useCreate-qwen-enhancer.test.ts
@@ -18,6 +18,8 @@ const seen = vi.hoisted(() => ({
chat: [] as { prompt: string; kind: string }[],
outcome: { status: 'improved', prompt: 'A long rewritten prompt from the enhancer.' } as { status: string; prompt?: string },
buildError: null as Error | null,
+ /** What the stage said while each writer was at work. */
+ lineWhileWriting: [] as string[],
}))
vi.mock('../../api/mlx-image', () => ({
@@ -59,12 +61,19 @@ vi.mock('../../api/qwen-enhancer', () => ({
seen.enhancer.push(req)
return { '4': { class_type: 'TextGenerate', inputs: {} } }
}),
- runQwenEnhancer: vi.fn(async () => { seen.order.push('run-enhancer'); return seen.outcome }),
+ runQwenEnhancer: vi.fn(async () => {
+ seen.order.push('run-enhancer')
+ const { useCreateStore } = await import('../../stores/createStore')
+ seen.lineWhileWriting.push(useCreateStore.getState().progressText)
+ return seen.outcome
+ }),
}))
vi.mock('../../lib/render/improve-prompt-run', () => ({
improvePrompt: vi.fn(async (prompt: string, target: { kind: string }) => {
seen.order.push('chat-rewrite')
seen.chat.push({ prompt, kind: target.kind })
+ const { useCreateStore } = await import('../../stores/createStore')
+ seen.lineWhileWriting.push(useCreateStore.getState().progressText)
return { status: 'improved', prompt: 'A rewrite from the chat model.' }
}),
}))
@@ -91,6 +100,7 @@ describe.each(QWEN21_WEIGHTS)('local Qwen-Image 2.1, %s', (_weights, QWEN) => {
seen.chat.length = 0
seen.outcome = { status: 'improved', prompt: 'A long rewritten prompt from the enhancer.' }
seen.buildError = null
+ seen.lineWhileWriting.length = 0
useCreateStore.setState({
backend: 'local', isGenerating: false, error: null, gallery: [], promptHistory: [],
improvePrompt: true, improveWith: 'auto',
@@ -120,6 +130,14 @@ describe.each(QWEN21_WEIGHTS)('local Qwen-Image 2.1, %s', (_weights, QWEN) => {
expect(useCreateStore.getState().prompt).toBe('a fox in snow')
})
+ // The box, 03.10.2026: 70 s for a new picture and 175 s for an edit
+ // under a line that did not move. It counts its seconds like every other
+ // waiting line.
+ it('the waiting line counts its seconds while the enhancer writes', async () => {
+ await run()
+ expect(seen.lineWhileWriting).toEqual(['Improving your prompt… 0s'])
+ })
+
it('order on the card: chat model out, enhancer runs, then the picture is built', async () => {
await run()
expect(seen.order).toEqual(['evict-chat', 'build-enhancer', 'run-enhancer', 'build-picture', 'submit-picture'])
@@ -188,6 +206,7 @@ describe.each(QWEN21_WEIGHTS)('local Qwen-Image 2.1, %s', (_weights, QWEN) => {
it('no enhancer installed: the chat model writes, before the card is cleared for the picture', async () => {
useCreateStore.setState({ textEncoderList: ['qwen3vl_8b_int8_convrot.safetensors'] } as never)
await run()
+ expect(seen.lineWhileWriting).toEqual(['Improving your prompt… 0s'])
expect(seen.enhancer).toHaveLength(0)
expect(seen.chat).toEqual([{ prompt: 'a fox in snow', kind: 'image' }])
expect(seen.order).toEqual(['chat-rewrite', 'evict-chat', 'build-picture', 'submit-picture'])
diff --git a/src/hooks/useCloudCreate.ts b/src/hooks/useCloudCreate.ts
index b9e80b52..98de7b0b 100644
--- a/src/hooks/useCloudCreate.ts
+++ b/src/hooks/useCloudCreate.ts
@@ -42,7 +42,8 @@ import { STANDARD_UPSCALE, intentRoles, intentRequiredInputs, isStudioModel, res
import { bumpSeed, runImageCount } from '../lib/render/image-count'
import { STUDIO_MODELS, studioFields } from '../lib/render/studio-contract'
import { modelLabel } from '../lib/render/preset-models'
-import { improveKindForIntent } from '../lib/render/improve-prompt'
+import { improveKindForIntent, IMPROVING_PROMPT } from '../lib/render/improve-prompt'
+import { elapsedLine } from '../lib/elapsed-line'
import { improvePrompt } from '../lib/render/improve-prompt-run'
import { bookedVideoSeconds } from '../lib/render/video-duration'
import { studioQuote, StudioQuoteChangedError } from '../api/cloud/studio'
@@ -577,8 +578,8 @@ export function useCloudCreate(opts: { onQuotaChange?: () => void } = {}) {
let improveFailed = false
const improveKind = s.improvePrompt && !characterUse ? improveKindForIntent(intent) : null
if (improveKind && s.prompt.trim() && !ac.signal.aborted) {
- s.setProgress(8, 'Improving your prompt…')
- const out = await improvePrompt(s.prompt, { kind: improveKind, modelLabel: modelLabel(model) }, ac.signal)
+ const improving = elapsedLine((text) => s.setProgress(8, text), IMPROVING_PROMPT)
+ const out = await improvePrompt(s.prompt, { kind: improveKind, modelLabel: modelLabel(model) }, ac.signal).finally(improving.stop)
// The safety check covers the rewrite too: the user wrote an allowed
// prompt, the model must not turn it into a refusal.
if (out.status === 'improved' && !clientSafety(out.prompt).blocked) {
diff --git a/src/hooks/useCreate.ts b/src/hooks/useCreate.ts
index e4cba1e5..ffe65d66 100644
--- a/src/hooks/useCreate.ts
+++ b/src/hooks/useCreate.ts
@@ -61,7 +61,8 @@ import { renderFixupDeps } from '../api/render-fixup-deps'
import { checkPromptSafety, SAFETY_BLOCK_MESSAGE } from '../lib/render/safety'
import { wantsTransparent } from '../lib/transparent-image'
import { scenePromptFor } from '../lib/ltx-multishot'
-import { improveKindForIntent, type ImproveOutcome } from '../lib/render/improve-prompt'
+import { improveKindForIntent, IMPROVING_PROMPT, type ImproveOutcome } from '../lib/render/improve-prompt'
+import { elapsedLine } from '../lib/elapsed-line'
import { improvePrompt } from '../lib/render/improve-prompt-run'
import { pickQwenEnhancer } from '../lib/render/qwen-enhancer'
import { buildQwenEnhancerWorkflow, runQwenEnhancer } from '../api/qwen-enhancer'
@@ -627,7 +628,7 @@ export function useCreate() {
const own = new AbortController()
abortRef.current = own
setIsGenerating(true)
- setProgress(3, 'Improving your prompt…')
+ const improving = elapsedLine((text) => setProgress(3, text), IMPROVING_PROMPT)
const runModel = improveKind === 'music' ? state.localOpModel : improveKind === 'video' ? effVideoModel : effImageModel
let out: ImproveOutcome = { status: 'failed' }
try {
@@ -637,6 +638,7 @@ export function useCreate() {
tags: improveKind === 'image' && ['sd15', 'sdxl'].includes(state.imageModelList.find((m) => m.name === runModel)?.type ?? classifyModel(runModel)),
}, own.signal)
} finally {
+ improving.stop()
if (abortRef.current === own) abortRef.current = null
setIsGenerating(false)
setProgress(0)
@@ -972,7 +974,7 @@ export function useCreate() {
// the same order, that the picture's graph numbers as image 1, 2, 3.
// A ComfyUI too old for it is offered the update, like the model itself.
if (qwenEnhancer) {
- setProgress(3, 'Improving your prompt…')
+ setProgress(3, IMPROVING_PROMPT)
const signal = abortRef.current?.signal
const images = qwenEnhancer.mode === 'i2i' && effInputImage
? [effInputImage, ...references.map((r) => r.filename).filter(Boolean).slice(0, extraReferenceSlots(imageModelType, activeModel))]
@@ -981,7 +983,10 @@ export function useCreate() {
() => buildQwenEnhancerWorkflow({ file: qwenEnhancer.file, mode: qwenEnhancer.mode, prompt: scenePrompt, images, seed: runSeed }),
renderFixupDeps((line) => setProgress(3, line), signal),
)
- const out = await runQwenEnhancer(enhancerGraph, scenePrompt, { clientId: CLIENT_ID, signal })
+ // The rewrite is the long wait (70 to 175 s on a 12 GB card), so the
+ // line counts from here; the build above has its own status lines.
+ const improving = elapsedLine((text) => setProgress(3, text), IMPROVING_PROMPT)
+ const out = await runQwenEnhancer(enhancerGraph, scenePrompt, { clientId: CLIENT_ID, signal }).finally(improving.stop)
if (signal?.aborted) throw new Error('Cancelled')
takeRewrite(out)
}
@@ -1317,7 +1322,6 @@ export function useCreate() {
if (useWS) {
// ── WebSocket-driven progress ──
await new Promise<void>((resolve, reject) => {
- const startTime = Date.now()
const store = useCreateStore.getState()
// The bar and its seconds used to repaint only when ComfyUI sent an
// event. Long silent stretches are normal here (a 14B sampling step
@@ -1327,19 +1331,12 @@ export function useCreate() {
// only change phase and percent; a ticker repaints the elapsed time
// every second so a working render never looks hung.
let phasePct = 10
- let phaseLabel = 'Queued...'
- const paint = () => {
- const elapsed = Math.round((Date.now() - startTime) / 1000)
- setProgress(phasePct, `${phaseLabel} ${elapsed}s`)
- }
+ store.setProgressPhase('queued')
+ const line = elapsedLine((text) => setProgress(phasePct, text), 'Queued...')
const setPhase = (pct: number, label: string) => {
phasePct = pct
- phaseLabel = label
- paint()
+ line.setLabel(label)
}
- store.setProgressPhase('queued')
- setPhase(10, 'Queued...')
- const ticker = setInterval(paint, 1000)
// Activity watchdog (2.5.8): the old hard wall-clock cap killed a
// REAL render at exactly 60 minutes while ComfyUI was still
@@ -1426,7 +1423,7 @@ export function useCreate() {
let abortCheck: ReturnType<typeof setInterval> | null = null
const cleanup = () => {
- clearInterval(ticker)
+ line.stop()
clearInterval(timeoutTimer)
clearInterval(heartbeat)
if (abortCheck) clearInterval(abortCheck)
diff --git a/src/lib/__tests__/elapsed-line.test.ts b/src/lib/__tests__/elapsed-line.test.ts
new file mode 100644
index 00000000..5daa8c0f
--- /dev/null
+++ b/src/lib/__tests__/elapsed-line.test.ts
@@ -0,0 +1,44 @@
+/**
+ * The one counter every waiting line of a local run uses: "<what is
+ * happening> 12s", repainted every second, so a step that takes minutes never
+ * looks hung. The box, 03.10.2026: "Improving your prompt…" stood still for
+ * 175 s on an edit, the only waiting line without it.
+ *
+ * Run: npx vitest run src/lib/__tests__/elapsed-line.test.ts
+ */
+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
+import { elapsedLine } from '../elapsed-line'
+
+beforeEach(() => { vi.useFakeTimers() })
+afterEach(() => { vi.useRealTimers() })
+
+describe('elapsedLine', () => {
+ it('paints at once and then every second, counting from its start', () => {
+ const lines: string[] = []
+ const line = elapsedLine((text) => lines.push(text), 'Improving your prompt…')
+ expect(lines).toEqual(['Improving your prompt… 0s'])
+ vi.advanceTimersByTime(3000)
+ expect(lines.at(-1)).toBe('Improving your prompt… 3s')
+ expect(lines).toHaveLength(4)
+ line.stop()
+ })
+
+ it('a new label repaints at once and keeps the count running', () => {
+ const lines: string[] = []
+ const line = elapsedLine((text) => lines.push(text), 'Queued...')
+ vi.advanceTimersByTime(5000)
+ line.setLabel('Loading model...')
+ expect(lines.at(-1)).toBe('Loading model... 5s')
+ vi.advanceTimersByTime(1000)
+ expect(lines.at(-1)).toBe('Loading model... 6s')
+ line.stop()
+ })
+
+ it('stops painting when it is stopped', () => {
+ const lines: string[] = []
+ const line = elapsedLine((text) => lines.push(text), 'Queued...')
+ line.stop()
+ vi.advanceTimersByTime(5000)
+ expect(lines).toHaveLength(1)
+ })
+})
diff --git a/src/lib/elapsed-line.ts b/src/lib/elapsed-line.ts
new file mode 100644
index 00000000..9d7f0632
--- /dev/null
+++ b/src/lib/elapsed-line.ts
@@ -0,0 +1,28 @@
+/**
+ * A waiting line that counts its seconds: "<what is happening> 12s".
+ *
+ * Long silent stretches are normal in a local run (a sampling step on a full
+ * card, a VAE decode, a prompt rewrite by a 9B model), and a line that does
+ * not move reads as a hang. So the line repaints every second, whatever the
+ * work behind it reports. One counter for every waiting line: the render's
+ * phases use it, and so does "Improving your prompt…", which stood still for
+ * 175 s on the test box (03.10.2026) because it was the one line without it.
+ */
+export interface ElapsedLine {
+ /** Change what is happening. Repaints at once, the count keeps running. */
+ setLabel: (label: string) => void
+ /** Stop repainting. The last line stays where the caller painted it. */
+ stop: () => void
+}
+
+export function elapsedLine(paint: (line: string) => void, label: string): ElapsedLine {
+ const startedAt = Date.now()
+ let current = label
+ const repaint = () => paint(`${current} ${Math.round((Date.now() - startedAt) / 1000)}s`)
+ repaint()
+ const ticker = setInterval(repaint, 1000)
+ return {
+ setLabel: (next) => { current = next; repaint() },
+ stop: () => clearInterval(ticker),
+ }
+}
diff --git a/src/lib/render/improve-prompt.ts b/src/lib/render/improve-prompt.ts
index 0d13ad15..e302c5d2 100644
--- a/src/lib/render/improve-prompt.ts
+++ b/src/lib/render/improve-prompt.ts
@@ -25,6 +25,10 @@ export function improveKindForIntent(intent: string): ImproveKind | null {
}
}
+/** The waiting line while the prompt is rewritten. The stage counts its
+ * seconds behind it (lib/elapsed-line). */
+export const IMPROVING_PROMPT = 'Improving your prompt…'
+
/** What the rewritten prompt may be at most. Under the 4000 characters the
* hosted queue accepts, so a long answer never turns into a rejected run. */
export const IMPROVE_MAX_CHARS = 3000