Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

review(claude): flush imageGen readers before nulling activeJob (#2463)

Adam Eivy398006fa5532
diff --git a/server/services/imageGen/local.js b/server/services/imageGen/local.js
index 8ec304a825..bbf6d7264b 100644
--- a/server/services/imageGen/local.js
+++ b/server/services/imageGen/local.js
@@ -733,13 +733,15 @@ export async function generateImage({ pythonPath, prompt = '', negativePrompt =
// emit a second 'failed' event + second SSE error frame.
if (finalized) return;
finalized = true;
- activeProcess = null;
- activeJob = null;
// Emit any final unterminated marker line each stream wrote without a
// trailing newline (a SIGKILL mid-write, or a progress bar whose last
- // redraw never terminated) before finalizing the job.
+ // redraw never terminated) BEFORE nulling activeJob — handleLine's
+ // inference-progress branch mutates activeJob, so flushing first keeps a
+ // final progress line able to update it (mirrors videoGen's ordering).
stderrReader.flush();
stdoutReader.flush();
+ activeProcess = null;
+ activeJob = null;
if (watcher) { try { watcher.close(); } catch { /* ignore */ } }
rm(stepwiseDir, { recursive: true, force: true }).catch(() => {});
if (code !== 0) {