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 comic-page render buttons stuck loading on already-rendered pages

[._.]/ Adam Eivyf96d6407bae6
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 5a004b257f..fa32e2de25 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -36,6 +36,8 @@
## Fixed
+- **Comic-page proof/final render buttons no longer get stuck "loading"/disabled on already-rendered pages.** Navigating into an issue's Comic tab — for example right after kicking off an unrelated render like a volume cover — could leave a page's **Proof**/**Final** buttons spinning and disabled even though that page's render finished long ago. The in-flight check re-armed an "unknown" status on every navigation and only cleared it once a job-status fetch (or a 5-second grace timer) resolved, ignoring that the slot already carried a rendered image. It now treats a slot that already has a rendered filename as settled immediately (the server clears the filename when a re-render is queued, so a present filename is an authoritative "done" signal), so the buttons are clickable right away and you can queue the next render without waiting. (`client/src/hooks/useSlotInFlight.js`)
+- **The Volume covers section on a series page is now expanded by default** instead of starting collapsed, so the front/back cover editors and render buttons are visible without an extra click. (`client/src/components/pipeline/ArcCanvas.jsx`)
- **Claude Code TUI agents now reliably wait for the input prompt before sending their task (and no longer wedge the shell on startup hiccups).** TUI-provider CoS agents (e.g. `claude-code-tui`) run their CLI as a *child* of a persistent PTY shell, and the old prompt-delivery gate fired on a crude "saw output, then went idle" heuristic. During Claude Code's startup that lull happens *before* the input box exists — and on a folder it hasn't seen, claude shows a **"trust this folder?" gate** that `--dangerously-skip-permissions` does not bypass (common because agents start in fresh worktrees). The gate would paste the task into the banner / trust menu, or — if claude had already exited — into the returned shell prompt, leaving a frozen, un-typeable session showing a literal `^[[200~ …` and a silently-failed run. The spawner now (1) **waits until the shell can actually run commands** before injecting the CLI command — a fixed 200 ms delay raced a heavy interactive shell (powerlevel10k / async plugins / nvm-PATH setup), so the command ran before the env was ready and the launched TUI fell straight back to the prompt. Heuristic timing watches (a prompt-marker, or settle-on-output-quiet) are *both* fooled by powerlevel10k's *instant prompt* (it renders a fake-ready prompt — and enables bracketed-paste mode — before `.zshrc` finishes) and by slow mid-load quiet gaps (nvm/plugins) that trip a settle timer just as easily, sending the command into a half-loaded shell where the instant-prompt→real-prompt redraw swallows it (the command sits echoed-but-unexecuted at a bare prompt — the intermittent wedge). It now **proves the shell is executing commands with a round-trip probe**: it prints a unique nonce and waits to *see that nonce in the output* before injecting the command. The nonce is split in the probe source (`'PORTOSRDY' '<nonce>'`) so the command echo never contains the assembled string — only the executed output matches — and instant-prompt keystroke buffering replays the probe into the real shell, so the gate is theme- and shell-agnostic with a bounded fallback if the probe never round-trips, (2) gates the paste on claude **re-enabling bracketed-paste mode** (`ESC[?2004h`, after the shell turned it off to run the command) as the input-ready signal — this is what makes the paste's leading `ESC` read as a paste rather than as Escape (which cancels claude's input — the intermittent "something other than Enter canceled it" failure); the visible footer text (`bypass permissions on (shift+tab to cycle)`) is deliberately NOT used because claude renders it with inter-glyph cursor moves that strip its spaces after ANSI-stripping, making it unmatchable, (3) **auto-confirms the folder-trust prompt** (Enter on the default "Yes, I trust") so claims run in fresh worktrees, (4) probes that the CLI is still a live child of the shell before pasting, and (5) **never blind-pastes** — if the input prompt never appears within 45 s (or the CLI exited), it finalizes the run as a failure carrying the CLI's captured output (`tui-not-ready` / `tui-exited-early`) instead of dumping into the shell. Non-claude TUI providers keep their existing handshake. (`server/services/agentTuiSpawning.js`, `server/lib/tuiHandshake.js`, `server/services/shell.js`)
- **AudioLDM2 music generation no longer crashes on current transformers.** Rendering with the AudioLDM2 engine failed mid-generation with `AttributeError: 'GPT2Model' object has no attribute '_update_model_kwargs_for_generation'`. AudioLDM2's internal language model is a bare `GPT2Model` (the pipeline reads its hidden states), and diffusers' `generate_language_model` drives it by hand using generation helpers that used to live on every `PreTrainedModel` — but transformers ≥4.50 decoupled `GenerationMixin`, so non-generative base models like `GPT2Model` no longer carry them, leaving diffusers calling a method that no longer exists. The AudioLDM2 sidecar now re-binds the missing helpers (`_update_model_kwargs_for_generation`, `_get_initial_cache_position`) from `GenerationMixin` onto the language model after loading the pipeline — keeping the runtime on a current transformers instead of pinning an EOL release, and a no-op on older transformers where the methods are already present. (`scripts/generate_audioldm2.py`)
- **Client test suite no longer floods CI with React "not wrapped in act(...)" warnings.** Across eight component/page suites, state updates were being driven outside `act()` — hand-fired mock-EventSource frames (`emit`/`fail`), raw DOM `.blur()` calls, manually-invoked tracker callbacks, and resolved in-flight gates whose follow-up `setState` landed after the test body returned (plus a few synchronous tests whose mount-time fetches resolved late). These surfaced only under CI's verbose reporter (the default reporter hides console output), so they were invisible locally. Each driving call is now wrapped in `act()` (or switched to `fireEvent`, which wraps internally), and synchronous tests that mount components with async effects now flush inside `act()`. The full client suite (2497 tests) runs clean with zero act warnings. (`PipelineManuscriptEditor`, `Layout`, `WidgetSuggestions`, `ApiAccessTab`, `PitchTuner`, `SongTraining`, `AudioStage`, `LocalLlmPlayground` test suites)
diff --git a/client/src/components/pipeline/ArcCanvas.jsx b/client/src/components/pipeline/ArcCanvas.jsx
index 61778b02cd..c2587d20ed 100644
--- a/client/src/components/pipeline/ArcCanvas.jsx
+++ b/client/src/components/pipeline/ArcCanvas.jsx
@@ -2138,7 +2138,7 @@ function VolumeCoverThumb({ slot, label, emptyHint }) {
}
function VolumeCoversPanel({ series, season, seasons, onSeriesUpdate }) {
- const [expanded, setExpanded] = useState(false);
+ const [expanded, setExpanded] = useState(true);
const cover = season.cover || { script: '', proofImage: null, finalImage: null };
const backCover = season.backCover || { script: '', proofImage: null, finalImage: null };
diff --git a/client/src/components/pipeline/stages/ComicScriptStage.jsx b/client/src/components/pipeline/stages/ComicScriptStage.jsx
index 1b0414c0f1..a9faf035b5 100644
--- a/client/src/components/pipeline/stages/ComicScriptStage.jsx
+++ b/client/src/components/pipeline/stages/ComicScriptStage.jsx
@@ -29,6 +29,7 @@ import { getSettings, patchSettingsSlice } from '../../../services/apiSystem';
import { listImageModels } from '../../../services/apiImageVideo';
import ConfirmButtonPair from '../../ui/ConfirmButtonPair';
import { useConfirmDelete } from '../../../hooks/useConfirmDelete';
+import useSlotInFlight from '../../../hooks/useSlotInFlight';
import MediaJobThumb from '../MediaJobThumb';
import MediaPreview from '../../media/MediaPreview';
import usePreviewRoute from '../../../hooks/usePreviewRoute';
@@ -94,26 +95,6 @@ const getFinalSlot = (rec) => (rec?.finalImage?.jobId || rec?.finalImage?.filena
// and the lightbox preview — final wins over proof when both exist.
const getPreferredSlot = (rec) => getFinalSlot(rec) || getProofSlot(rec);
-// 5s grace window for stale-jobId staleness: if MediaJobThumb never reports
-// a real status (job archive expired before this session), stop treating the
-// unresolved 'unknown' as in-flight so the render button isn't permanently
-// disabled.
-function useSlotInFlight(slot) {
- const [status, setStatus] = useState('unknown');
- const [expired, setExpired] = useState(false);
- useEffect(() => {
- setStatus('unknown');
- setExpired(false);
- if (!slot?.jobId) return undefined;
- const t = setTimeout(() => setExpired(true), 5000);
- return () => clearTimeout(t);
- }, [slot?.jobId]);
- const inFlight = !!slot?.jobId
- && status !== 'completed' && status !== 'failed' && status !== 'canceled'
- && !(status === 'unknown' && expired);
- return { inFlight, setStatus };
-}
-
// Tooltip text for the "Render final" button — picks the first applicable
// reason from a precedence chain so the user always sees the most specific
// blocker. `dirtyMsg` is page-only; the cover row passes null.
diff --git a/client/src/hooks/README.md b/client/src/hooks/README.md
index 71cf946658..a2776ff281 100644
--- a/client/src/hooks/README.md
+++ b/client/src/hooks/README.md
@@ -41,6 +41,7 @@ grep -i "what you want to do" client/src/hooks/README.md
| `useImageGenProgress` | Live diffusion progress for an image-gen call. | Showing per-call image-gen progress. |
| `useImporterProgress` | Live analyze-phase stage checklist via the `importer:progress` socket (runId-filtered); exports `stageStatusIcon` for the status→icon lookup. | Importer analyze progress UI only. |
| `useMediaJobProgress` | Live progress for a single `mediaJobQueue` job. | Subscribing to a known media-job id. |
+| `useSlotInFlight` | Whether a render slot (`{ jobId, filename }`) has an in-flight render; returns `{ inFlight, setStatus }`. A present `filename` (or 5s grace on a stale/expired job) clears `inFlight` so the render button never sticks "loading". | A render button that should disable + spin only while its own slot is actually rendering (comic pages, covers). Wire `setStatus` to the slot's `MediaJobThumb` `onStatus`. |
| `useMediaJobSse` | Imperative per-job `/{kind}-gen/:id/events` SSE; `attach()` returns a Promise that settles on the terminal frame. | POST-then-attach media render flows that await completion (ImageGen/VideoGen). |
| `useOpenClawStream` | OpenClaw SSE chat stream. | OpenClaw file-browser chat surface only. |
| `usePipelineProgress` | Id-derived runner SSE stream: builds the URL from `(urlBuilder, ids)`, connects only when every id is truthy. | Any runner SSE keyed by record ids (pipeline auto-run, editorial, manuscript completeness, volume beats, story steps). |
diff --git a/client/src/hooks/index.js b/client/src/hooks/index.js
index e2eb856cae..749cda3e46 100644
--- a/client/src/hooks/index.js
+++ b/client/src/hooks/index.js
@@ -19,6 +19,7 @@ export { default as useFieldDraft } from './useFieldDraft.js';
export { default as useImageGenQueue } from './useImageGenQueue.js';
export { default as useImageRenderSettings } from './useImageRenderSettings.js';
export { default as useSingleImageRender } from './useSingleImageRender.js';
+export { default as useSlotInFlight } from './useSlotInFlight.js';
export { default as useSingToScore } from './useSingToScore.js';
export * from './useSingToScore.js';
export { default as useSongTraining } from './useSongTraining.js';
diff --git a/client/src/hooks/useSlotInFlight.js b/client/src/hooks/useSlotInFlight.js
new file mode 100644
index 0000000000..7295889817
--- /dev/null
+++ b/client/src/hooks/useSlotInFlight.js
@@ -0,0 +1,42 @@
+import { useEffect, useState } from 'react';
+
+/**
+ * Track whether a render slot ({ jobId, filename, ... }) has an in-flight
+ * render, so a "render" button can disable + spin while its own render is
+ * still going.
+ *
+ * Returns `{ inFlight, setStatus }`. Wire `setStatus` to the slot's
+ * MediaJobThumb `onStatus` so a live/fetched terminal status clears the
+ * in-flight flag.
+ *
+ * Two staleness guards keep the button from getting stuck "loading" forever:
+ *
+ * 1. A truthy `slot.filename` means the render is complete by definition — the
+ * server clears `filename` when a re-render is queued, so a present filename
+ * is an authoritative "not in flight" signal (mirrors MediaJobThumb's
+ * `fallbackFilename` short-circuit). Without this, every fresh navigation
+ * re-arms `status='unknown'` and the button shows a disabled/loading flash
+ * until the job-status fetch (or the 5s grace) resolves — even though the
+ * render finished long ago. That's what made comic-page proof/final buttons
+ * look stuck after kicking off an unrelated render (e.g. a volume cover).
+ *
+ * 2. A 5s grace window: if MediaJobThumb never reports a real status (the job
+ * archive expired before this session), stop treating the unresolved
+ * 'unknown' as in-flight so the button isn't permanently disabled.
+ */
+export default function useSlotInFlight(slot) {
+ const [status, setStatus] = useState('unknown');
+ const [expired, setExpired] = useState(false);
+ const settled = !!slot?.filename;
+ useEffect(() => {
+ setStatus('unknown');
+ setExpired(false);
+ if (!slot?.jobId || settled) return undefined;
+ const t = setTimeout(() => setExpired(true), 5000);
+ return () => clearTimeout(t);
+ }, [slot?.jobId, settled]);
+ const inFlight = !!slot?.jobId && !settled
+ && status !== 'completed' && status !== 'failed' && status !== 'canceled'
+ && !(status === 'unknown' && expired);
+ return { inFlight, setStatus };
+}
diff --git a/client/src/hooks/useSlotInFlight.test.jsx b/client/src/hooks/useSlotInFlight.test.jsx
new file mode 100644
index 0000000000..ca34dd12ff
--- /dev/null
+++ b/client/src/hooks/useSlotInFlight.test.jsx
@@ -0,0 +1,64 @@
+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
+import { renderHook, act } from '@testing-library/react';
+import useSlotInFlight from './useSlotInFlight';
+
+describe('useSlotInFlight', () => {
+ beforeEach(() => { vi.useFakeTimers(); });
+ afterEach(() => { vi.useRealTimers(); });
+
+ it('is not in flight for an empty / jobless slot', () => {
+ expect(renderHook(() => useSlotInFlight(null)).result.current.inFlight).toBe(false);
+ expect(renderHook(() => useSlotInFlight({})).result.current.inFlight).toBe(false);
+ expect(renderHook(() => useSlotInFlight({ prompt: 'x' })).result.current.inFlight).toBe(false);
+ });
+
+ it('treats a slot that already has a filename as settled, even with a jobId present', () => {
+ // The completed-render case: server leaves both jobId + filename on the
+ // slot. Navigating back to it must NOT re-arm a disabled/loading flash.
+ const slot = { jobId: 'job-1', filename: 'page0.png' };
+ const { result } = renderHook(() => useSlotInFlight(slot));
+ expect(result.current.inFlight).toBe(false);
+ // No grace timer should be needed to clear it.
+ act(() => { vi.advanceTimersByTime(6000); });
+ expect(result.current.inFlight).toBe(false);
+ });
+
+ it('is in flight for a jobId-only slot until status resolves', () => {
+ const slot = { jobId: 'job-2' };
+ const { result } = renderHook(() => useSlotInFlight(slot));
+ expect(result.current.inFlight).toBe(true);
+ act(() => result.current.setStatus('completed'));
+ expect(result.current.inFlight).toBe(false);
+ });
+
+ it('clears in flight via the 5s grace when status never resolves (archived job)', () => {
+ const slot = { jobId: 'job-3' };
+ const { result } = renderHook(() => useSlotInFlight(slot));
+ expect(result.current.inFlight).toBe(true);
+ act(() => { vi.advanceTimersByTime(5000); });
+ expect(result.current.inFlight).toBe(false);
+ });
+
+ it('stays in flight while a fetched status is non-terminal (queued/running)', () => {
+ const slot = { jobId: 'job-4' };
+ const { result } = renderHook(() => useSlotInFlight(slot));
+ act(() => result.current.setStatus('queued'));
+ expect(result.current.inFlight).toBe(true);
+ // Grace only applies to an unresolved 'unknown' — a real queued status
+ // keeps the button disabled until it actually finishes.
+ act(() => { vi.advanceTimersByTime(6000); });
+ expect(result.current.inFlight).toBe(true);
+ act(() => result.current.setStatus('completed'));
+ expect(result.current.inFlight).toBe(false);
+ });
+
+ it('re-arms in flight when the slot swaps to a fresh jobId with no filename', () => {
+ // A re-render clears filename server-side and assigns a new jobId.
+ const { result, rerender } = renderHook(({ slot }) => useSlotInFlight(slot), {
+ initialProps: { slot: { jobId: 'job-5', filename: 'old.png' } },
+ });
+ expect(result.current.inFlight).toBe(false);
+ act(() => rerender({ slot: { jobId: 'job-6' } }));
+ expect(result.current.inFlight).toBe(true);
+ });
+});