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): guard cross-format accept + reject fix with no find

[._.]/ Adam Eivy39461731f9fb
diff --git a/client/src/pages/PipelineManuscriptEditor.jsx b/client/src/pages/PipelineManuscriptEditor.jsx
index 76bed5bf92..f0a8a064b7 100644
--- a/client/src/pages/PipelineManuscriptEditor.jsx
+++ b/client/src/pages/PipelineManuscriptEditor.jsx
@@ -206,9 +206,14 @@ export default function PipelineManuscriptEditor() {
setComments((prev) => prev.map((c) => (c.id === next.id ? next : c)));
// After an accepted fix the server returns the rewritten section — reflect it
- // in the manuscript pane so the edit shows without a reload.
+ // in the manuscript pane so the edit shows without a reload. A comment can
+ // target a format other than the one on screen (the sidebar shows all
+ // comments); only patch the visible textarea when the edited stage matches
+ // the current view, or we'd paint (and later blur-save) the wrong format's
+ // text into this section. The edit still persisted server-side — it shows on
+ // switching to that format.
const applyAccepted = ({ comment, section }) => {
- if (section?.issueId) {
+ if (section?.issueId && section.stageId === viewType) {
patchSection(section.issueId, { content: section.content, versions: section.versions });
baselineRef.current.set(`${section.issueId}:${section.stageId}`, section.content);
setSaveState((prev) => ({ ...prev, [section.issueId]: 'saved' }));
diff --git a/server/services/pipeline/manuscriptEditor.test.js b/server/services/pipeline/manuscriptEditor.test.js
index c217015e5d..ccfb3672ee 100644
--- a/server/services/pipeline/manuscriptEditor.test.js
+++ b/server/services/pipeline/manuscriptEditor.test.js
@@ -130,6 +130,15 @@ describe('manuscriptFix', () => {
expect(fuzzy.fix.fuzzy).toBe(true);
});
+ it('generateManuscriptFix rejects a fix with no find (unappliable by the accept path)', async () => {
+ const { s } = await setupSeriesWithDraft();
+ const seeded = await review.seedReviewFromFindings(s.id, [finding()]);
+ stageRunnerSpy = vi.fn(async () => ({ content: { replace: 'only a replacement, no find' }, runId: 'rf3' }));
+ await expect(
+ fixer.generateManuscriptFix(s.id, { commentId: seeded.comments[0].id }),
+ ).rejects.toMatchObject({ code: 'PIPELINE_MANUSCRIPT_FIX_VALIDATION' });
+ });
+
it('acceptManuscriptFix applies the find/replace to the stage output and marks the comment accepted', async () => {
const { s, issue } = await setupSeriesWithDraft();
const seeded = await review.seedReviewFromFindings(s.id, [finding()]);
diff --git a/server/services/pipeline/manuscriptFix.js b/server/services/pipeline/manuscriptFix.js
index 57a9e70972..2a74e70d01 100644
--- a/server/services/pipeline/manuscriptFix.js
+++ b/server/services/pipeline/manuscriptFix.js
@@ -147,7 +147,10 @@ export async function generateManuscriptFix(seriesId, { commentId, providerOverr
const find = typeof content?.find === 'string' ? content.find : '';
const replace = typeof content?.replace === 'string' ? content.replace : '';
- if (!replace) throw makeErr('The model did not return a usable fix — try again', ERR_VALIDATION);
+ // The accept path locates the edit by `find` (schema requires it non-empty),
+ // and the UI only lets the user edit `replace` — so a fix missing `find`
+ // would be shown but could never be applied. Reject it as unusable.
+ if (!find || !replace) throw makeErr('The model did not return a usable fix — try again', ERR_VALIDATION);
const fix = { find, replace };
// A `find` that isn't present verbatim can't be applied surgically; mark it
// so the UI offers manual editing instead of a no-op accept.