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

fix(image-gen): stop preview flicker between progress frames

Adam Eivy633de2f07adb
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 4a46e4ff27..a4ea06da2e 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -41,6 +41,10 @@
Files: `server/services/dashboardLayouts.js` (new), `server/routes/dashboardLayouts.js` (new), `server/routes/dashboardLayouts.test.js` (new, 7 tests), `server/index.js` (mounts route), `client/src/services/apiDashboard.js` (new), `client/src/components/dashboard/{widgetRegistry.jsx,LayoutPicker.jsx,LayoutEditor.jsx,builtins/*}` (new), `client/src/pages/Dashboard.jsx` (fully rewritten), `client/src/components/CmdKSearch.jsx` (layouts section), `CLAUDE.md` ("Dashboard Widgets & Layouts" section with widget-entry contract).
+## Fixed
+
+- **Image Gen preview no longer flickers between progress and "Waiting for first preview..."** — `useImageGenProgress()` now merges progress events instead of replacing the whole state, so the throttled `currentImage` (server emits a base64 frame every ~2s while polling every 500ms) and any progress event missing `step`/`totalSteps` (some SD API states omit them) no longer cause the preview pane to revert to the empty/waiting state between frames. The hook also seeds initial progress from the `started` event (`step: 0, totalSteps: N`) so the status row shows "Step 0/N" immediately, never "Waiting for first preview..." once a render has begun. Affects both the Image Gen page and the Settings → Image Gen Test Render card. File: `client/src/hooks/useImageGenProgress.js`.
+
## Changed
- **Command palette cleanup pass** — post-review simplify: `normalizeLabel` is exported once from `navManifest.js` and imported by `voice/tools.js` (was duplicated verbatim); `getToolMetadata(id)` added to `voice/tools.js` so `routes/palette.js` no longer reaches through the OpenAI-shaped function spec; palette manifest frozen at module load (`buildActionManifest` no longer runs per request) with `Cache-Control: private, max-age=300`. Client scorer precomputes lowercased `_label`/`_aliases`/`_keywords`/`_section` so per-keystroke fuzzy matching does zero re-lowercasing over the 117-entry manifest. `CmdKSearch.jsx` trimmed ~80 lines: collapsed the triple `useMemo` chain, merged `renderCommandRow` + inline search-result row into a single `renderRow`/`renderGroup` pair, flattened `dispatchCommand` into a `DISPATCH` lookup table, dropped the dead `running` state, removed two `.catch()` error-swallows (errors now propagate to the central toast handler per CLAUDE.md), cleared `resultRefs` on close. `ALIAS_KEYS` cached once in `resolveNavCommand`. Decorative section-banner comments and narration comments removed across the new files.
diff --git a/client/src/hooks/useImageGenProgress.js b/client/src/hooks/useImageGenProgress.js
index 61e9d89953..db33ce44dc 100644
--- a/client/src/hooks/useImageGenProgress.js
+++ b/client/src/hooks/useImageGenProgress.js
@@ -14,12 +14,34 @@ export function useImageGenProgress() {
const onStarted = (data) => {
if (activeRef.current && !generationIdRef.current) {
generationIdRef.current = data.generationId;
+ // Seed with totalSteps from the started event so the status row
+ // can show "Step 0/N" immediately instead of falling back to
+ // "Waiting for first preview..." on the first poll cycle.
+ setProgress({
+ generationId: data.generationId,
+ progress: 0,
+ step: 0,
+ totalSteps: data.totalSteps ?? null,
+ eta: null,
+ currentImage: null
+ });
}
};
+ // Merge fields rather than replacing — the server throttles
+ // `currentImage` (every ~2s) and the SD API may omit step/totalSteps
+ // on some polls. Replacing on every event makes the preview flicker
+ // back to "Waiting for first preview..." between frames.
const onProgress = (data) => {
- if (activeRef.current && data.generationId === generationIdRef.current) {
- setProgress(data);
- }
+ if (!activeRef.current || data.generationId !== generationIdRef.current) return;
+ setProgress(prev => ({
+ ...(prev || {}),
+ generationId: data.generationId,
+ progress: data.progress ?? prev?.progress ?? 0,
+ eta: data.eta ?? prev?.eta ?? null,
+ step: data.step ?? prev?.step ?? 0,
+ totalSteps: data.totalSteps ?? prev?.totalSteps ?? null,
+ currentImage: data.currentImage ?? prev?.currentImage ?? null
+ }));
};
const onDone = (data) => {
if (activeRef.current && data.generationId === generationIdRef.current) {