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

address review (codex): gate streamed-review terminal handler on reviewClosed

[._.]/ Adam Eivy7d62e377f913
diff --git a/.changelog/v2.20.0.md b/.changelog/v2.20.0.md
index ad1646ca8a..5dade5ae8b 100644
--- a/.changelog/v2.20.0.md
+++ b/.changelog/v2.20.0.md
@@ -50,6 +50,8 @@ Released: 2026-06-11
- **A watched TUI run no longer false-times-out after finishing its work** — companion fix to *Live TUI runs are now viewable AND drivable in the Shell page* (above). One-shot AI runs that drive a terminal UI (Claude Code, Codex, etc.) write their completed answer to a response file and then return to an interactive prompt **without exiting**. The runner only auto-completed such a run via output-idle — which is paused while you watch it in the Shell page (so it isn't snapped shut mid-read). With the process never exiting and idle paused, a watched run had no terminus but the 10-minute hard timeout — at which point it was marked **failed**, its already-written result was **discarded**, and a useless fallback retry ran in its place. The runner now watches for the response file as the model's authoritative "done" signal and completes the run the moment it's written — even while you're watching — since once the file exists the task is genuinely finished. A second safety net salvages the file on hard timeout: if the result was written but completion stalled for any other reason, the run finishes as **success** with that result instead of throwing it away and falling back. So a long editorial pass you keep open in the Shell tab now lands its findings when the model finishes, instead of silently dying at 10 minutes. (`server/lib/tuiPromptRunner.js`)
+- **A second editorial-review run in the same editor session no longer detaches itself on start** — the streamed "Generate edits" review gates its terminal-frame handler on `useSseProgress`'s `latest` frame, but that hook resets `latest` only when it (re)subscribes while resetting its `closed` flag on disable too. Between runs, `reviewLatest` still held the prior run's `complete` frame while `reviewClosed` was already back to false — so kicking off a second review in the same session consumed the stale terminal frame and tore the new stream down before its EventSource reported any progress (the run kept going server-side, but the UI dropped it). The terminal handler now also gates on `reviewClosed`, matching the recovery effect beside it, so only the *current* run's terminal frame is acted on. (`client/src/pages/PipelineManuscriptEditor.jsx`)
+
- **[issue-1178] Settings Security and Embeddings tabs use the full width** — both tabs were boxed into a narrow 672px column (Embeddings hugging the left edge) while the other Settings tabs spread across the page. They now lay their sections out in a responsive two-column grid on wider screens, matching the Database, Local LLM, and Backup tabs and putting the wasted horizontal space to use; on phones they stack as before.
- **[issue-1177] Brain's full-bleed tabs scroll cleanly** — the Graph, Daily Log, and Notes tabs no longer double-scroll or clip below the fold. Each Brain tab now gets the scroll context it needs: the full-height visual tabs fill the pane and manage their own scrolling, while the reading tabs keep a comfortable padded scroll — so more content sits above the fold and there's no second scrollbar fighting the first.
diff --git a/client/src/pages/PipelineManuscriptEditor.jsx b/client/src/pages/PipelineManuscriptEditor.jsx
index eb1c1fc49d..0ff0a7fb82 100644
--- a/client/src/pages/PipelineManuscriptEditor.jsx
+++ b/client/src/pages/PipelineManuscriptEditor.jsx
@@ -250,8 +250,14 @@ export default function PipelineManuscriptEditor() {
// Terminal-frame handler for the streamed run: refresh comments + toast, then
// tear the subscription down. Per-chunk frames only drive the button label.
+ // Gate on `reviewClosed` (not just the frame type): `useSseProgress` resets
+ // `latest` only on (re)subscribe, but resets `closed` on disable too — so
+ // between runs `reviewLatest` still holds the prior run's terminal frame while
+ // `reviewClosed` is already back to false. Without the `reviewClosed` gate,
+ // starting a SECOND review in the same editor session sees the stale frame and
+ // tears the new run's subscription down before its EventSource reports.
useEffect(() => {
- if (!reviewActive || !reviewLatest) return;
+ if (!reviewActive || !reviewClosed || !reviewLatest) return;
const type = reviewLatest.type;
if (type !== 'complete' && type !== 'canceled' && type !== 'error') return;
setReviewActive(false);
@@ -259,7 +265,7 @@ export default function PipelineManuscriptEditor() {
else if (type === 'canceled') toast.success('Editorial review canceled');
else toast.error(reviewLatest.error || 'Editorial review failed');
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [reviewActive, reviewLatest, seriesId]);
+ }, [reviewActive, reviewClosed, reviewLatest, seriesId]);
// Recovery: the stream died WITHOUT a terminal frame (attach 404, dropped
// connection, server restart). Don't strand the UI with the Run button stuck
diff --git a/client/src/pages/PipelineManuscriptEditor.test.jsx b/client/src/pages/PipelineManuscriptEditor.test.jsx
index 3b7fed7e6f..cb7f6ad41e 100644
--- a/client/src/pages/PipelineManuscriptEditor.test.jsx
+++ b/client/src/pages/PipelineManuscriptEditor.test.jsx
@@ -414,6 +414,37 @@ describe('PipelineManuscriptEditor — generate-edits streamed review', () => {
expect(screen.queryByText('Generate fix')).not.toBeInTheDocument();
});
+ it('a SECOND streamed review in the same session is not torn down by the prior run\'s stale terminal frame', async () => {
+ api.startPipelineManuscriptCompleteness.mockResolvedValue({ runId: 'cr-1', sseUrl: '/sse' });
+ api.getPipelineManuscriptReview.mockResolvedValue({ schemaVersion: 1, comments: [comment] });
+ renderEditor();
+ await screen.findByText('My Series');
+
+ // Run 1: start, complete, re-fetch (getReview now called twice — initial + post-complete).
+ fireEvent.click(screen.getByLabelText(/Generate edits for every finding/i));
+ fireEvent.click(screen.getByText('Run editorial review'));
+ await waitFor(() => expect(MockEventSource.instances.length).toBe(1));
+ lastEs().emit({ type: 'complete', openCount: 1, chunked: false, chunkCount: 1 });
+ await waitFor(() => expect(api.getPipelineManuscriptReview).toHaveBeenCalledTimes(2));
+ // Run 1's button is back to idle.
+ await screen.findByText('Run editorial review');
+
+ // Run 2: starting it must subscribe a fresh stream and STAY active — the
+ // prior run's `complete` frame is still in useSseProgress's `latest` until
+ // the resubscribe resets it, and without the reviewClosed gate the terminal
+ // effect would consume that stale frame and tear run 2 down on start
+ // (firing a spurious 3rd review re-fetch).
+ fireEvent.click(screen.getByText('Run editorial review'));
+ await waitFor(() => expect(MockEventSource.instances.length).toBe(2));
+ // Button stays busy (run 2 in flight) and no stale re-fetch fired.
+ await screen.findByText(/Starting editorial review|Drafting edits/);
+ expect(api.getPipelineManuscriptReview).toHaveBeenCalledTimes(2);
+
+ // Run 2's own complete frame drives the real re-fetch (3rd call).
+ lastEs().emit({ type: 'complete', openCount: 1, chunked: false, chunkCount: 1 });
+ await waitFor(() => expect(api.getPipelineManuscriptReview).toHaveBeenCalledTimes(3));
+ });
+
it('recovers when the SSE stream dies without a terminal frame (button re-enables, review re-fetched)', async () => {
api.startPipelineManuscriptCompleteness.mockResolvedValue({ runId: 'cr-1', sseUrl: '/sse' });
api.getPipelineManuscriptReview.mockResolvedValue({ schemaVersion: 1, comments: [comment] });