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: stop obsolete manuscript batches after failed responses (#9953)

[._.]/ Adam Eivy1ae11eeb1044
diff --git a/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsx b/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsx
index fd66c99f2f..0ef2d44d38 100644
--- a/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsx
+++ b/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsx
@@ -44,7 +44,7 @@ function editsBySectionKey(comments, fixDrafts) {
return map;
}
-export default function ManuscriptImpactPreview({ open, onClose, seriesId, sections, comments, fixDrafts, onAccepted, onBeginMutation }) {
+export default function ManuscriptImpactPreview({ open, onClose, seriesId, sections, comments, fixDrafts, onAccepted, onBeginMutation, isCurrentOwner = () => true }) {
// null when idle, { done, total } while the accept-all pass runs.
const [acceptState, setAcceptState] = useState(null);
@@ -102,6 +102,10 @@ export default function ManuscriptImpactPreview({ open, onClose, seriesId, secti
// over an earlier member's change, stops the batch.
const snapshot = onBeginMutation ? await onBeginMutation(sectionKeysOf(target.edits)) : undefined;
if (!mountedRef.current) return;
+ if (!isCurrentOwner()) {
+ setAcceptState(null);
+ return;
+ }
if (snapshot === null) {
errors.push('a section has an unsaved or kept draft to resolve first');
break;
@@ -112,6 +116,10 @@ export default function ManuscriptImpactPreview({ open, onClose, seriesId, secti
return null;
});
if (!mountedRef.current) return;
+ if (!isCurrentOwner()) {
+ setAcceptState(null);
+ return;
+ }
if (result) {
applied += 1;
if (onAccepted(result, snapshot) === false) {
diff --git a/client/src/pages/PipelineManuscriptEditor.jsx b/client/src/pages/PipelineManuscriptEditor.jsx
index a29a6a9d10..49a1e1aab0 100644
--- a/client/src/pages/PipelineManuscriptEditor.jsx
+++ b/client/src/pages/PipelineManuscriptEditor.jsx
@@ -1133,6 +1133,7 @@ function SeriesManuscriptEditor() {
fixDrafts={fixDrafts}
onAccepted={applyAccepted}
onBeginMutation={beginSectionMutation}
+ isCurrentOwner={ownsView}
/>
<ManuscriptReadAloud
diff --git a/client/src/pages/PipelineManuscriptEditor.test.jsx b/client/src/pages/PipelineManuscriptEditor.test.jsx
index f7aa6f0b1e..62d15d556e 100644
--- a/client/src/pages/PipelineManuscriptEditor.test.jsx
+++ b/client/src/pages/PipelineManuscriptEditor.test.jsx
@@ -385,7 +385,7 @@ describe('PipelineManuscriptEditor', () => {
expect(api.undoPipelineManuscriptFix).toHaveBeenCalledWith('ser-1', comment.id, { silent: true });
});
- it('stops a delayed accept-all batch when another format replaces its owner (#9953)', async () => {
+ it.each(['success', 'failure'])('stops a delayed accept-all batch after %s when another format replaces its owner (#9953)', async (outcome) => {
mockBothFormats();
const second = { ...comment, id: 'mrc-2', anchorQuote: 'The hero walked in.', fix: { find: 'The hero walked in.', replace: 'A visitor arrived.' } };
api.getPipelineManuscriptReview.mockResolvedValue({ comments: [{ ...comment, fix: { find: 'She left.', replace: 'Accepted prose.' } }, second] });
@@ -397,7 +397,7 @@ describe('PipelineManuscriptEditor', () => {
fireEvent.click(await screen.findByRole('button', { name: 'Accept all 2 edits' }));
fireEvent.click(screen.getByRole('button', { name: 'Teleplay' }));
await screen.findByDisplayValue('INT. ROOM - DAY');
- await act(async () => { pending.resolve(acceptedProse); });
+ await act(async () => { pending.resolve(outcome === 'success' ? acceptedProse : null); });
await expectTeleplayUnchanged();
expect(api.acceptPipelineManuscriptFix).toHaveBeenCalledTimes(1);
expect(screen.getByRole('dialog', { name: 'Manuscript impact preview' })).toBeInTheDocument();