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([unify-media-job-sse-hook-imagegen-videogen]): clear generating flag on resume connection loss

[._.]/ Adam Eivy4a5e7eacbaca
diff --git a/PLAN.md b/PLAN.md
index 2b32bb563a..d88ebca710 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -6,6 +6,7 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [.changel
Claimable, well-specified, no decision needed — `/claim`-able. Unordered.
+- [ ] [media-job-sse-transient-reconnect-resilience] **Make `useMediaJobSse`'s `onerror` resilient to transient EventSource reconnects.** `client/src/hooks/useMediaJobSse.js` closes + rejects on every `onerror`, including the transient `readyState === CONNECTING` blips the browser would otherwise auto-retry. The declarative `useSseProgress.js` already does this correctly — it only treats `readyState === EventSource.CLOSED` as terminal. Mirror that: in the hook's `onerror`, only `close()` + `reject()` (+ `onConnectionError`) when `es.readyState === EventSource.CLOSED`, leaving CONNECTING errors to the browser's auto-reconnect (the server replays the job's last SSE payload on re-attach). Deferred from the `[unify-media-job-sse-hook-imagegen-videogen]` review (Claude, MEDIUM, non-blocking): doing it changes the *main* ImageGen/VideoGen generation paths too — they currently reject on any blip (preserved from the pre-refactor inline handlers) — so it's a deliberate behavior improvement, not a refactor-neutral change. The resume path's stuck-`generating` symptom is already patched via `onConnectionError`; this is the deeper fix.
- [ ] [capabilities-cheap-memory-count] **Capabilities route should count active memories without sorting/paginating.** `GET /api/capabilities` calls `getMemories({ status: 'active' })` (`server/routes/capabilities.js` ~line 69) only to read `.total`, but `getMemories` loads the full index, filters, sorts, and paginates before returning `{ total, memories }` — the sort + slice is wasted work on a page polled every ~20s. Add a lightweight `countMemories({ status })` (or a `countOnly` option) to `server/services/memory.js` that returns the filtered count without the sort/paginate, and switch the route to it. Micro-opt; the index is cached via `loadIndex`, so low urgency.
- [ ] [banner-icon-aria-hidden] **Apply `aria-hidden="true"` to `<Banner>`'s rendered icon.** `client/src/components/ui/Banner.jsx` (~line 62) renders the `icon` prop as a bare `<Icon …>` — when the icon is decorative (the body text already conveys the meaning), screen readers should skip it. Either wrap the icon render in `<span aria-hidden="true">` inside Banner, or thread an `iconAriaHidden` prop. Once landed, re-migrate the `ImportTab.jsx` error row to `<Banner tone="error" size="md" icon={AlertCircle} actions={…}>` (it was reverted from `<Banner>` because the icon prop doesn't pass through a11y attributes).
- [ ] [inline-confirm-row-primitive] **Extract `<InlineConfirmRow tone="error">` primitive for inline delete-confirm rows.** Five sites (`client/src/components/brain/tabs/LinksTab.jsx:599`, `client/src/components/brain/tabs/InboxTab.jsx:387, 512, 606, 765`) share the same shape: `flex items-center gap-2 p-2 bg-port-error/10 border border-port-error/30 rounded` + `<span flex-1>{question}</span>` + Delete + Cancel buttons. They didn't migrate to `<Banner>` because `<Banner>` is shaped around "icon + content + actions" alerts, not "question + confirm/cancel" confirm rows. Build `client/src/components/ui/InlineConfirmRow.jsx` with `{ question, confirmText='Delete', cancelText='Cancel', onConfirm, onCancel, tone='error' }`, then swap the five sites. Pairs naturally with the existing confirmation-UX preference (no two-click-arm).
diff --git a/client/src/pages/ImageGen.jsx b/client/src/pages/ImageGen.jsx
index 7156af227d..494663c84c 100644
--- a/client/src/pages/ImageGen.jsx
+++ b/client/src/pages/ImageGen.jsx
@@ -313,15 +313,19 @@ export default function ImageGen() {
setGenerating(true);
setStatusMsg('Resuming…');
resumeGenerate(activeJob);
- // Re-attach the per-job SSE so raw status text resumes too. The reject
- // on a terminal error/canceled frame is expected here (we only want the
- // generating flag flipped off), so swallow it.
+ // Re-attach the per-job SSE so raw status text resumes too. Every
+ // terminal outcome (complete/error/canceled) and a lost connection just
+ // flips the generating flag off; the reject on the error/canceled/
+ // connection-loss paths is expected, so swallow it. onConnectionError is
+ // required so a connection blip can't leave the resumed render parked at
+ // "Resuming…" with generating stuck true.
attachJobEvents(activeJob.generationId, {
onStatus: (msg) => setStatusMsg(msg.message),
onProgress: (msg) => setLocalProgress({ progress: msg.progress }),
onComplete: () => setGenerating(false),
onError: () => setGenerating(false),
onCanceled: () => setGenerating(false),
+ onConnectionError: () => setGenerating(false),
}).catch(() => {});
}).catch(() => {});
return () => eventSourceRef.current?.close();