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
address review (codex): scope manuscript accept-all to previewed sections
[._.]/ Adam Eivy578ad2a5a79f
diff --git a/.changelog/v2.20.0.md b/.changelog/v2.20.0.mdindex 5dade5ae8b..b4d826a59b 100644--- a/.changelog/v2.20.0.md+++ b/.changelog/v2.20.0.md@@ -48,6 +48,8 @@ Released: 2026-06-11- **Dependency security** — Outlook message refresh no longer crashes on an uninstalled `uuid` import; `@protobufjs/utf8` override unpinned from its own CVE (1.1.1), `ws` 8.21.0 override added, eslint/brace-expansion/jsdom updated; npm audit is clean.- **Test quality** — the database-destroy safety guard and sharing identity/watcher modules now have real tests; timing-dependent suites use fake timers; vacuous assertions strengthened; temp dirs cleaned up.+- **Manuscript "Accept all" only applies the edits it actually previewed** — the impact preview derived its "Accept all N edits" count from the section-filtered, change-producing edits it renders, but the accept-all action built its work list from *every* passed comment with no section filter. A comment whose fix targeted a manuscript stage not present in the previewed sections (or whose edits were no-ops) would be applied without ever appearing in the modal — so the count under-reported and unseen edits could land. Accept-all now restricts targets to the same previewed section keys, filtered at the edit level (a comment may span stages), so it applies exactly what the preview shows. (`client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsx`)+- **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`)diff --git a/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsx b/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsxindex ffdc934de5..47f1547027 100644--- a/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsx+++ b/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsx@@ -76,10 +76,19 @@ export default function ManuscriptImpactPreview({ open, onClose, seriesId, secti// text the previous one produced). Failures are reported and stay open — the// preview re-derives from comment status, so applied sections drop out live.const acceptAll = async () => {+ // Only accept edits that landed in a PREVIEWED section. `changed` drops any+ // edit whose section isn't in the current `sections` (e.g. a fix for a+ // different manuscript stage) or that produced no visible change — so+ // building targets from every comment would apply unseen edits and make the+ // "Accept all N edits" count lie. Restrict to the same section keys the+ // modal rendered, filtering at the edit level (a comment may span stages).+ const previewedKeys = new Set(changed.map((c) => `${c.section.issueId}:${c.section.stageId}`));const targets = comments.map((c) => ({comment: c,- edits: selectedEditsFor(c, fixDrafts[c.id]).map(({ selected: _s, ...edit }) => edit),+ edits: selectedEditsFor(c, fixDrafts[c.id])+ .filter((e) => previewedKeys.has(`${e.issueId || ''}:${e.stageId || ''}`))+ .map(({ selected: _s, ...edit }) => edit),})).filter((t) => t.edits.length);if (!targets.length) return;diff --git a/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.test.jsx b/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.test.jsxindex aa69bb5f0b..f07867e3f0 100644--- a/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.test.jsx+++ b/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.test.jsx@@ -85,4 +85,20 @@ describe('ManuscriptImpactPreview accept-all', () => {renderPreview({ comments: [] });expect(screen.queryByText(/Accept all/)).not.toBeInTheDocument();});++ it('does not accept edits for sections that were not previewed (count must not lie)', async () => {+ acceptPipelineManuscriptFix.mockResolvedValue({ comment: {}, sections: [] });+ // c3 targets a stage with no matching `sections` entry → it is NOT rendered+ // in the preview. accept-all must skip it (only c1 + c2 are previewed),+ // otherwise it would apply an unseen edit and the "2 edits" count would lie.+ const unseen = { id: 'c3', status: 'open', issueNumber: 3, issueId: 'i3', stageId: 'comic', anchorQuote: 'x', fix: { find: 'x', replace: 'y' } };+ renderPreview({ comments: [...COMMENTS, unseen] });++ // The button still advertises only the 2 previewed edits.+ fireEvent.click(screen.getByText('Accept all 2 edits'));+ await waitFor(() => expect(acceptPipelineManuscriptFix).toHaveBeenCalledTimes(2));+ const acceptedIds = acceptPipelineManuscriptFix.mock.calls.map((c) => c[1]);+ expect(acceptedIds).toEqual(['c1', 'c2']);+ expect(acceptedIds).not.toContain('c3');+ });});