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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: clear stuck in-flight job on terminal render failure/cancel (#1393)
Adam Eivy0f1d95fbb1f3
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 9bb278e61e..50dd488cde 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -113,7 +113,7 @@## Fixed-- **[issue-1393] The universe base-style probe now scopes its in-flight render per universe instead of remounting on every switch.** The probe spinner used to be kept from leaking across universe switches by remounting the whole `StyleProbeImage` (a `key={universe.id}` in the Universe Builder and Story Builder). That worked but had two costs: every switch re-ran the probe's `{ silent: true }` image-settings GET, and switching *away* from an in-flight render abandoned its completion — the server still filed the image, but switching back never resumed the spinner or pinned the result onto the universe's style refs for that session. `useSingleImageRender` now takes a `scopeId` that namespaces the single-target key per universe (`<id>:__single__`), so the displayed universe's job is read without a remount: no per-switch settings refetch, and switching back to a still-running (or already-finished) render resumes it and captures its completion. The mid-render style-drift guard is now keyed per universe too, so a stale image can't pin to the wrong record when two probes overlap across a switch. (`client/src/hooks/useSingleImageRender.js`, `client/src/components/universe/StyleProbeImage.jsx`, `client/src/pages/{UniverseBuilder,StoryBuilder}.jsx`, #1393)+- **[issue-1393] The universe base-style probe now scopes its in-flight render per universe instead of remounting on every switch.** The probe spinner used to be kept from leaking across universe switches by remounting the whole `StyleProbeImage` (a `key={universe.id}` in the Universe Builder and Story Builder). That worked but had two costs: every switch re-ran the probe's `{ silent: true }` image-settings GET, and switching *away* from an in-flight render abandoned its completion — the server still filed the image, but switching back never resumed the spinner or pinned the result onto the universe's style refs for that session. `useSingleImageRender` now takes a `scopeId` that namespaces the single-target key per universe (`<id>:__single__`), so the displayed universe's job is read without a remount: no per-switch settings refetch, and switching back to a still-running (or already-finished) render resumes it and captures its completion. The mid-render style-drift guard is now keyed per universe too, so a stale image can't pin to the wrong record when two probes overlap across a switch. And because the render slot no longer remounts to reset itself, a render that *fails or is canceled* (which never produces a filename, so the slot's completion path can't clear it) now clears the stuck job explicitly — so a failed probe leaves the slot ready to re-render instead of disabling regenerate for the rest of the session. (`client/src/hooks/useSingleImageRender.js`, `client/src/components/universe/{StyleProbeImage,EntryThumbSlot}.jsx`, `client/src/pages/{UniverseBuilder,StoryBuilder}.jsx`, #1393)- **[issue-1422] Re-planning a goal that has scheduled calendar blocks no longer silently strands those calendar events, and a malformed AI plan now fails fast.** Accepting a new AI-generated plan (either *Generate Plan* phases or *Decompose into Tasks*) replaces a goal's milestones wholesale — but if you'd already pushed those milestones onto your calendar as time blocks, the old blocks were left pointing at milestones that no longer existed. Accepting now refuses with a clear message asking you to unschedule first, so your calendar can't drift out of sync with your plan. Separately, both *Generate Plan* and *Decompose into Tasks* now validate the AI's proposal the moment it comes back — a garbled response surfaces a clear error up front instead of looking fine in the review screen and only breaking when you try to accept it.diff --git a/client/src/components/universe/EntryThumbSlot.jsx b/client/src/components/universe/EntryThumbSlot.jsxindex c8025c763c..c0b51cc5ec 100644--- a/client/src/components/universe/EntryThumbSlot.jsx+++ b/client/src/components/universe/EntryThumbSlot.jsx@@ -58,6 +58,13 @@ export default function EntryThumbSlot({size={pendingSize}onPreview={onPreview}onFilename={onComplete}+ // A terminal failure/cancel never yields a filename, so `onComplete`+ // (which clears the in-flight job) would otherwise never fire and the+ // job stays pinned. Callers that scope render state per entity keep that+ // state across switches (no remount to reset it), so a failed job would+ // leave the slot stuck — clear it via the no-filename path so the slot+ // returns to an actionable state and the entity can be re-rendered.+ onStatus={(s) => { if (s === 'failed' || s === 'canceled') onComplete?.(null); }}/>);}diff --git a/client/src/components/universe/EntryThumbSlot.test.jsx b/client/src/components/universe/EntryThumbSlot.test.jsxindex 85a03d2fcd..f2efe33eda 100644--- a/client/src/components/universe/EntryThumbSlot.test.jsx+++ b/client/src/components/universe/EntryThumbSlot.test.jsx@@ -1,15 +1,19 @@-import { describe, it, expect, vi } from 'vitest';+import { describe, it, expect, vi, beforeEach } from 'vitest';import { render, screen, fireEvent } from '@testing-library/react';import EntryThumbSlot from './EntryThumbSlot';// MediaJobThumb subscribes to a socket via useMediaJobProgress. Stub the hook// so the test doesn't need a live socket / fetch; the empty + completed// branches don't invoke it (no jobId), so this only affects the pending case.+// `jobStatus` is mutable so a test can drive the terminal failure/cancel path.+let jobStatus = 'queued';vi.mock('../../hooks/useMediaJobProgress', () => ({- default: () => ({ status: 'queued', progress: 0, step: 0, totalSteps: 0, currentImage: null, filename: null, error: null }),+ default: () => ({ status: jobStatus, progress: 0, step: 0, totalSteps: 0, currentImage: null, filename: null, error: jobStatus === 'failed' ? 'boom' : null }),}));describe('EntryThumbSlot — three-state thumbnail', () => {+ beforeEach(() => { jobStatus = 'queued'; });+it('renders an empty placeholder with a Render button when nothing else is set', () => {const onRender = vi.fn();render(<EntryThumbSlot onRender={onRender} canRender alt="Var A render" />);@@ -53,4 +57,27 @@ describe('EntryThumbSlot — three-state thumbnail', () => {// implementation details.expect(container.querySelector('.animate-spin')).toBeInTheDocument();});++ it('clears the in-flight job (onComplete(null)) when the render terminally fails', () => {+ jobStatus = 'failed';+ const onComplete = vi.fn();+ render(<EntryThumbSlot inFlightJobId="job-x" onComplete={onComplete} canRender={false} />);+ // Terminal failure yields no filename, so without this the scoped job would+ // stay pinned forever (no remount to reset it) and regenerate stays disabled.+ expect(onComplete).toHaveBeenCalledWith(null);+ });++ it('clears the in-flight job when the render is canceled', () => {+ jobStatus = 'canceled';+ const onComplete = vi.fn();+ render(<EntryThumbSlot inFlightJobId="job-y" onComplete={onComplete} canRender={false} />);+ expect(onComplete).toHaveBeenCalledWith(null);+ });++ it('does NOT clear the in-flight job for non-terminal statuses', () => {+ jobStatus = 'running';+ const onComplete = vi.fn();+ render(<EntryThumbSlot inFlightJobId="job-z" onComplete={onComplete} canRender={false} />);+ expect(onComplete).not.toHaveBeenCalled();+ });});