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

add "Start fresh" re-run mode to manuscript editorial review

[._.]/ Adam Eivyf6a938cb0470
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 640216b806..df1a46d57b 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -4,6 +4,7 @@
- **Daily budgets for the Chief of Staff's domains** — each domain (Brain auto-classify, Memory auto-extract, CoS auto-run, Messages auto-send) can now carry a daily cap on how many automatic actions it takes and how many minutes of work it does. When a domain reaches its cap it pauses that automatic work for the rest of the day and resumes after the counters reset at midnight; the Chief of Staff config panel shows each domain's usage so far today. Caps are off by default (blank means unlimited), so nothing changes until you set one. This rounds out the per-domain guardrails alongside the off / dry-run / execute controls.
- **Scheduled "Claim Issue" task** — a new built-in CoS schedule (CoS → Schedule → Claim Issue) that runs the `/claim --issues` flow on a cadence: it picks the next open GitHub issue, creates its own `claim/issue-<num>` worktree, implements the fix, opens a PR that closes the issue, runs the configured reviewers, merges, and cleans up. Configurable per app via an **Issue Author Filter** — claim only issues filed by the repository owner (default) or any open issue regardless of author. Off by default; enable and pick a provider/model per app like the other improvement tasks.
+- **Manuscript editorial review: "Start fresh" re-run mode** — re-running the editorial pass in the manuscript editor previously always *merged*, carrying every prior comment forward. A new "Start fresh" checkbox next to "Run editorial review" clears the current open and accepted notes and shows only the new pass's findings. Your dismissed notes are always kept so a dismissed finding can't quietly resurface, and accepted fixes are already applied to the manuscript so dropping their (historical) note loses nothing. Merge stays the default.
## Changed
diff --git a/client/src/pages/PipelineManuscriptEditor.jsx b/client/src/pages/PipelineManuscriptEditor.jsx
index df8ae0b4ff..6b18075913 100644
--- a/client/src/pages/PipelineManuscriptEditor.jsx
+++ b/client/src/pages/PipelineManuscriptEditor.jsx
@@ -75,6 +75,10 @@ export default function PipelineManuscriptEditor() {
// chunked run means the model couldn't hold the whole manuscript at once
// (small context window) — surfaced so the review's coverage isn't ambiguous.
const [reviewMeta, setReviewMeta] = useState(null);
+ // Re-run mode for the editorial pass: false = merge (augment existing notes),
+ // true = fresh (clear prior open/accepted notes, keep dismissed). See the
+ // route's seedReviewFromFindings.
+ const [freshReview, setFreshReview] = useState(false);
const [loading, setLoading] = useState(true);
const [switching, setSwitching] = useState(false);
const [pinning, setPinning] = useState(false);
@@ -162,10 +166,12 @@ export default function PipelineManuscriptEditor() {
// Re-run the editorial completeness pass over the manuscript with the chosen
// provider. The route persists findings as the review comment set, so we just
- // swap in the returned comments.
+ // swap in the returned comments. `mode`: 'merge' (default) augments existing
+ // comments; 'fresh' clears prior open/accepted notes and shows only this
+ // run's findings (kept dismissals still suppress resurfacing).
const [runEditorialReview, reviewing] = useAsyncAction(
- async () => {
- const result = await analyzePipelineManuscriptCompleteness(seriesId, { providerOverride, modelOverride });
+ async (mode = 'merge') => {
+ const result = await analyzePipelineManuscriptCompleteness(seriesId, { providerOverride, modelOverride, mode });
const next = Array.isArray(result?.review?.comments) ? result.review.comments : [];
setComments(next);
setReviewMeta({ chunked: !!result?.chunked, chunkCount: result?.chunkCount || 1 });
@@ -297,6 +303,10 @@ export default function PipelineManuscriptEditor() {
dismissed: comments.filter((c) => c.status === 'dismissed'),
}), [comments]);
+ // How many notes a "Start fresh" re-run would replace (open + accepted;
+ // dismissed are kept). Drives the checkbox's explanatory count.
+ const freshClearCount = grouped.open.length + grouped.accepted.length;
+
// Only pin still-open comments — accepting/dismissing flips the status, which
// resolves this to null and closes the overlay automatically (resolved
// comments are navigational only, with no actions to keep on screen).
@@ -419,7 +429,7 @@ export default function PipelineManuscriptEditor() {
</div>
<button
type="button"
- onClick={runEditorialReview}
+ onClick={() => runEditorialReview(freshReview ? 'fresh' : 'merge')}
disabled={reviewing || sections.length === 0}
title={sections.length === 0
? 'Draft at least one issue before running an editorial review'
@@ -429,6 +439,27 @@ export default function PipelineManuscriptEditor() {
{reviewing ? <Loader2 size={12} className="animate-spin" /> : <ClipboardCheck size={12} />}
{reviewing ? 'Running editorial review…' : 'Run editorial review'}
</button>
+ {/* Re-run mode. Merge keeps prior notes; fresh clears the current
+ open/accepted notes and shows only the new pass (dismissed are
+ kept so they don't resurface). */}
+ <label htmlFor="ms-fresh-review" className="flex items-start gap-1.5 text-[11px] text-gray-400 cursor-pointer">
+ <input
+ id="ms-fresh-review"
+ type="checkbox"
+ checked={freshReview}
+ onChange={(e) => setFreshReview(e.target.checked)}
+ disabled={reviewing}
+ className="mt-0.5 accent-port-accent"
+ />
+ <span>
+ Start fresh
+ <span className="text-gray-600">
+ {' '}— replace the current {grouped.open.length} open
+ {grouped.accepted.length > 0 ? ` + ${grouped.accepted.length} accepted` : ''}
+ {' '}note{freshClearCount === 1 ? '' : 's'} with this run; dismissed kept.
+ </span>
+ </span>
+ </label>
</div>
<h2 className="text-xs uppercase tracking-wider text-gray-500 flex items-center justify-between">
diff --git a/client/src/services/apiPipeline.js b/client/src/services/apiPipeline.js
index 8eccff26d6..a6699b3de9 100644
--- a/client/src/services/apiPipeline.js
+++ b/client/src/services/apiPipeline.js
@@ -412,10 +412,13 @@ export const commitPipelineArcFromManuscript = (seriesId, proposal = {}) =>
// Manuscript-completeness ("finish the draft") editor pass — reads the actual
// drafted script and returns categorized { severity, category, location,
// problem, suggestion } findings. Advisory; no auto-resolve. Empty = complete.
-export const analyzePipelineManuscriptCompleteness = (seriesId, { providerOverride, modelOverride } = {}) =>
+// `mode`: 'merge' (default) augments existing comments; 'fresh' clears prior
+// open/accepted comments and shows only this run's findings (kept dismissals
+// still suppress resurfacing).
+export const analyzePipelineManuscriptCompleteness = (seriesId, { providerOverride, modelOverride, mode } = {}) =>
request(`/pipeline/series/${encodeURIComponent(seriesId)}/manuscript/completeness`, {
method: 'POST',
- body: JSON.stringify({ providerOverride, modelOverride }),
+ body: JSON.stringify({ providerOverride, modelOverride, mode }),
});
// ---- Manuscript editor ----
diff --git a/server/routes/pipeline.js b/server/routes/pipeline.js
index a08c934c77..7c6c5d6af9 100644
--- a/server/routes/pipeline.js
+++ b/server/routes/pipeline.js
@@ -648,8 +648,14 @@ const arcDeriveCommitSchema = z.object({
})).max(200).optional(),
});
-// Manuscript-completeness ("finish the draft") editor pass — override shape only.
-const manuscriptCompletenessSchema = z.object(providerOverrideShape);
+// Manuscript-completeness ("finish the draft") editor pass — override shape plus
+// the re-run merge mode: 'merge' (default) augments existing comments; 'fresh'
+// clears prior open/accepted comments and shows only this run's findings (kept
+// dismissals still suppress resurfacing). See seedReviewFromFindings.
+const manuscriptCompletenessSchema = z.object({
+ ...providerOverrideShape,
+ mode: z.enum(manuscriptReview.REVIEW_RUN_MODES).optional(),
+});
// Manuscript editor — review comment operations.
const manuscriptFixGenerateSchema = z.object(providerOverrideShape);
@@ -1633,7 +1639,7 @@ router.post('/series/:id/manuscript/completeness', asyncHandler(async (req, res)
// Persist findings as a Word-style comment set so the manuscript editor can
// work through them across reloads. `issues` stays in the response for the
// existing ArcHeader caller — the editor reads the merged `review`.
- const review = await manuscriptReview.seedReviewFromFindings(req.params.id, result.issues, { runId: result.runId })
+ const review = await manuscriptReview.seedReviewFromFindings(req.params.id, result.issues, { runId: result.runId, mode: body.mode })
.catch((err) => { throw mapServiceError(err); });
res.json({ ...result, review });
}));
diff --git a/server/services/pipeline/manuscriptReview.js b/server/services/pipeline/manuscriptReview.js
index b1d3ba7515..965089715e 100644
--- a/server/services/pipeline/manuscriptReview.js
+++ b/server/services/pipeline/manuscriptReview.js
@@ -30,6 +30,10 @@ const SCHEMA_VERSION = 1;
export const COMMENT_STATUSES = Object.freeze(['open', 'accepted', 'dismissed']);
const STATUS_SET = new Set(COMMENT_STATUSES);
+// Re-run modes for seedReviewFromFindings — see its doc comment. Exported so the
+// route's Zod enum validates against the same source (mirrors COMMENT_STATUSES).
+export const REVIEW_RUN_MODES = Object.freeze(['merge', 'fresh']);
+
const REVIEW_FILE = 'manuscript-review.json';
const reviewPath = (seriesId) => join(seriesStore().recordDir(seriesId), REVIEW_FILE);
@@ -143,20 +147,40 @@ export async function getReview(seriesId) {
const findingKey = (c) => `${c.issueNumber ?? ''}|${c.anchorQuote}|${c.problem}`;
/**
- * Merge a fresh set of shaped completeness findings into the review. ALL
- * existing comments are preserved — open ones (the user may be mid-fix, with a
- * generated replacement attached) as well as accepted/dismissed decisions. Only
- * findings not already present (by (issueNumber, anchorQuote, problem)) are
- * appended, so re-running "Finish the draft" augments the list instead of
- * piling up duplicates or wiping work in progress. New findings resolve their
- * issueId/stageId from the current manuscript sections by issueNumber.
+ * Merge a fresh set of shaped completeness findings into the review.
+ *
+ * `mode` controls what survives a re-run:
+ *
+ * - 'merge' (default): ALL existing comments are preserved — open ones (the
+ * user may be mid-fix, with a generated replacement attached) as well as
+ * accepted/dismissed decisions. Only findings not already present (by
+ * (issueNumber, anchorQuote, problem)) are appended, so re-running augments
+ * the list instead of piling up duplicates or wiping work in progress.
+ *
+ * - 'fresh': clears the prior `open` and `accepted` comments and seeds only
+ * this run's findings, so the editor shows just the new editorial pass.
+ * `dismissed` comments are KEPT — they're the user's standing "ignore this"
+ * decisions and are NOT reflected in the manuscript, so dropping them would
+ * silently resurrect those findings as new open comments on the next run.
+ * `accepted` comments are dropped: their fix is already applied to the
+ * manuscript (see acceptManuscriptFix), so the record is only a historical
+ * marker. Fresh findings still dedupe against the surviving dismissed set.
+ *
+ * New findings resolve their issueId/stageId from the current manuscript
+ * sections by issueNumber.
*/
-export async function seedReviewFromFindings(seriesId, findings, { runId = null } = {}) {
+export async function seedReviewFromFindings(seriesId, findings, { runId = null, mode = 'merge' } = {}) {
const sections = await collectManuscriptSections(seriesId);
const byNumber = new Map(sections.map((s) => [s.number, s]));
return queueReviewWrite(seriesId, async () => {
const review = await readReview(seriesId);
- const seenKeys = new Set(review.comments.map(findingKey));
+ // In 'fresh' mode the surviving base is just the dismissed decisions; in
+ // 'merge' mode every existing comment is carried forward.
+ const base = mode === 'fresh'
+ ? review.comments.filter((c) => c.status === 'dismissed')
+ : review.comments;
+ const removed = review.comments.length - base.length;
+ const seenKeys = new Set(base.map(findingKey));
const now = new Date().toISOString();
const fresh = [];
@@ -174,15 +198,15 @@ export async function seedReviewFromFindings(seriesId, findings, { runId = null
fresh.push(candidate);
}
- const next = { schemaVersion: SCHEMA_VERSION, comments: [...review.comments, ...fresh] };
+ const next = { schemaVersion: SCHEMA_VERSION, comments: [...base, ...fresh] };
await writeReview(seriesId, next);
// The review is a sibling of the series record, so a review-only change
// doesn't move the series `index.json` — emit a series `updated` event so
// the peer-sync push + bucket re-export fire (both hash the review into
- // their payload). Only when something actually changed; a no-op seed
- // would just be short-circuited by the push hash anyway. Skipped on the
- // sync RECEIVE path (`mergeReviewFromSync`) to avoid an echo loop.
- if (fresh.length > 0) emitRecordUpdated('series', seriesId);
+ // their payload). Only when something actually changed — appended findings
+ // OR comments dropped by a 'fresh' re-run. Skipped on the sync RECEIVE path
+ // (`mergeReviewFromSync`) to avoid an echo loop.
+ if (fresh.length > 0 || removed > 0) emitRecordUpdated('series', seriesId);
return next;
});
}
diff --git a/server/services/pipeline/manuscriptReview.test.js b/server/services/pipeline/manuscriptReview.test.js
index a2bc6592f5..c563a866ef 100644
--- a/server/services/pipeline/manuscriptReview.test.js
+++ b/server/services/pipeline/manuscriptReview.test.js
@@ -91,3 +91,56 @@ describe('manuscriptReview — record-event emission on write', () => {
expect(mergedById['mrc-mc'].replacementStrategy).toBe('delta');
});
});
+
+describe('manuscriptReview — re-run merge vs fresh mode', () => {
+ beforeEach(() => { fileStore.clear(); });
+
+ // Seed three findings, then flip one accepted and one dismissed, leaving one
+ // open — the realistic state when a user re-runs the editorial pass.
+ async function seedDecidedState(seriesId) {
+ const seeded = await seedReviewFromFindings(seriesId, [
+ { problem: 'kept-dismissed', anchorQuote: 'a' },
+ { problem: 'was-accepted', anchorQuote: 'b' },
+ { problem: 'stale-open', anchorQuote: 'c' },
+ ]);
+ const byProblem = Object.fromEntries(seeded.comments.map((c) => [c.problem, c]));
+ await updateComment(seriesId, byProblem['kept-dismissed'].id, { status: 'dismissed' });
+ await updateComment(seriesId, byProblem['was-accepted'].id, { status: 'accepted' });
+ return byProblem;
+ }
+
+ it("merge (default) preserves every prior comment and appends new findings", async () => {
+ await seedDecidedState('ser-merge');
+ const next = await seedReviewFromFindings('ser-merge', [{ problem: 'brand new', anchorQuote: 'd' }]);
+ const problems = next.comments.map((c) => c.problem).sort();
+ expect(problems).toEqual(['brand new', 'kept-dismissed', 'stale-open', 'was-accepted']);
+ });
+
+ it('fresh drops prior open + accepted, keeps dismissed, and seeds the new pass', async () => {
+ await seedDecidedState('ser-fresh');
+ const next = await seedReviewFromFindings(
+ 'ser-fresh',
+ [{ problem: 'brand new', anchorQuote: 'd' }],
+ { mode: 'fresh' },
+ );
+ const byStatus = (s) => next.comments.filter((c) => c.status === s).map((c) => c.problem).sort();
+ // dismissed survives; open is exactly the new run; accepted is gone.
+ expect(byStatus('dismissed')).toEqual(['kept-dismissed']);
+ expect(byStatus('open')).toEqual(['brand new']);
+ expect(byStatus('accepted')).toEqual([]);
+ expect(next.comments.find((c) => c.problem === 'stale-open')).toBeUndefined();
+ });
+
+ it('fresh does NOT resurrect a finding the user dismissed (deduped against survivors)', async () => {
+ await seedDecidedState('ser-fresh-dedup');
+ // The new pass re-reports the same finding the user already dismissed.
+ const next = await seedReviewFromFindings(
+ 'ser-fresh-dedup',
+ [{ problem: 'kept-dismissed', anchorQuote: 'a' }],
+ { mode: 'fresh' },
+ );
+ const kept = next.comments.filter((c) => c.problem === 'kept-dismissed');
+ expect(kept).toHaveLength(1);
+ expect(kept[0].status).toBe('dismissed');
+ });
+});