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
feat: notify the user when a Series Autopilot run pauses (#1615)
[._.]/ Adam Eivyfa3188f3c70d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex d5b2a86b7c..f57753caa4 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -27,6 +27,7 @@- **[issue-1667] Final-part editorial verdicts no longer lose their carried setup context on a packed last chunk.** The cross-chunk "setup so far" digest normally yields to manuscript coverage — but two whole-story checks (`arc.climax-agency`, `emotion.reaction-proportionality`) gate their verdict to the final part and anchor it on a snippet carried in that digest (the climax candidate / the unprocessed event). When the final chunk packed to within a few hundred chars of the provider window, the digest was silently dropped and the final-only finding was missed. These checks now opt into a `reserveSetupDigest` guarantee that trims the final chunk's manuscript tail to make room for the digest (the inverse of the usual yield), scoped to the final chunk and opt-in checks only — every other chunk and every non-reserving check keeps full manuscript coverage. (`server/lib/editorial/checkRegistry.js`)- **[issue-1614] Series Autopilot no longer wastes an LLM call refreshing the reverse outline for a check that won't run, and never proceeds on a stale one.** The pre-checks reverse-outline refresh decided "does any enabled check consume the outline?" from declared sources alone — so a check that's enabled but whose runtime gate declines for this series (no POV-tagged scenes, a canon-less roster) could still trigger a billed regeneration nothing would read. The refresh now evaluates each consumer's gate against the current outline and skips the regen when nothing that would actually run consumes it; a never-generated outline still bootstraps unconditionally. Separately, when the regen no-ops as cached the run re-confirms staleness against the live manuscript and forces one regen if a concurrent edit moved it — so the editorial checks never read a stale outline mid-run. (`server/services/pipeline/seriesAutopilot.js`, `server/services/pipeline/editorial/checkRunner.js`)- **[issue-1613] Series Autopilot can now pause when an editorial-checks pass surfaces too many High findings.** Previously the registry-driven editorial-checks step always reported "complete" regardless of finding count — a pass that surfaced 50 High findings looked clean and only the downstream health gate caught it, making the per-step signal misleading. A new, off-by-default **pause threshold** (`pipelineEditorialChecks.checkFindingsPauseThreshold`, also a per-run override and an Options field) makes the run pause for human review when the checks pass finds at least N High findings — gating like the verify/editorial loops, with the High findings carried as residual and a "high findings" badge in the panel. The step's progress frame now also reports the real High count instead of a hardcoded `0`. 0 = off, so existing runs are unchanged. (`server/services/pipeline/seriesAutopilot.js`, `server/services/pipeline/series.js`, `server/lib/validation.js`, `server/routes/pipeline/autopilot.js`, `client/src/components/pipeline/AutopilotPanel.jsx`)+- **[issue-1615] Series Autopilot now actively notifies you when a run pauses, instead of going silent until you check the status page.** A paused run (budget exhausted, too many High findings, a convergence gate that couldn't auto-resolve, a failed child stage) previously only emitted a live SSE frame — so if you weren't watching the page, the run could sit indefinitely. Every pause now also posts an in-app notification (in the header notification center) with the pause reason and a one-click resume link to the series. A prior pause banner for the same series is cleared first, so a resume→pause cycle leaves exactly one current notification rather than a stack. This is the one autopilot signal that's **on by default** — it's a zero-cost informational banner — but it's overridable per run and via a persisted setting (`pipelineEditorialChecks.notifyOnPause`) and exposed as a "Notify me when a run pauses" checkbox in Options. (`server/services/pipeline/seriesAutopilot.js`, `server/services/notifications.js`, `server/lib/validation.js`, `server/routes/pipeline/autopilot.js`, `client/src/components/pipeline/AutopilotPanel.jsx`)## Internaldiff --git a/client/src/components/pipeline/AutopilotPanel.jsx b/client/src/components/pipeline/AutopilotPanel.jsxindex 03b7edeb3f..9d50befeed 100644--- a/client/src/components/pipeline/AutopilotPanel.jsx+++ b/client/src/components/pipeline/AutopilotPanel.jsx@@ -28,6 +28,9 @@ const DEFAULT_BEAT_CONTINUITY_ROUNDS = 2;// Editorial-checks pause threshold (#1613) — mirror the server default (0 = off).// Unlike the round bounds it has no upper cap; a large N is effectively off.const DEFAULT_CHECK_PAUSE_THRESHOLD = 0;+// Pause-notification escalation (#1615) — mirror the server default (on). The one+// autopilot setting that defaults ON: a zero-cost in-app banner when a run pauses.+const DEFAULT_NOTIFY_ON_PAUSE = true;// Editorial-health readiness gate (#1316/#1580) — the "manuscript clean" bar the// autopilot must clear before visuals. Mirrors READINESS_GATES on the server. The@@ -195,6 +198,10 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate// round inputs (saved default + per-run override), so a raised value is reused// on Resume.const [checkPauseThreshold, setCheckPauseThreshold] = useState(DEFAULT_CHECK_PAUSE_THRESHOLD);+ // Pause-notification escalation (#1615). Persisted like the round inputs (saved+ // default + per-run override) but defaults ON — toggling off silences the+ // in-app pause banner. Persisted on change so the choice is reused on Resume.+ const [notifyOnPause, setNotifyOnPause] = useState(DEFAULT_NOTIFY_ON_PAUSE);// Per-field dirty flags. Until a field is edited its input shows a display// default we must NOT persist (that would clobber a higher saved setting on// the untouched gate). Tracked per-field so editing one gate never discards@@ -204,6 +211,7 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdateconst editorialEditedRef = useRef(false);const beatContinuityEditedRef = useRef(false);const checkPauseEditedRef = useRef(false);+ const notifyEditedRef = useRef(false);const [canon, setCanon] = useState(null);const [canonLoading, setCanonLoading] = useState(false);@@ -222,6 +230,7 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdateif (!editorialEditedRef.current) setEditorialRounds(Number.isInteger(pec.maxEditorialRounds) ? pec.maxEditorialRounds : DEFAULT_EDITORIAL_ROUNDS);if (!beatContinuityEditedRef.current) setBeatContinuityRounds(Number.isInteger(pec.maxBeatContinuityRounds) ? pec.maxBeatContinuityRounds : DEFAULT_BEAT_CONTINUITY_ROUNDS);if (!checkPauseEditedRef.current) setCheckPauseThreshold(Number.isInteger(pec.checkFindingsPauseThreshold) ? pec.checkFindingsPauseThreshold : DEFAULT_CHECK_PAUSE_THRESHOLD);+ if (!notifyEditedRef.current) setNotifyOnPause(typeof pec.notifyOnPause === 'boolean' ? pec.notifyOnPause : DEFAULT_NOTIFY_ON_PAUSE);// Persisted readiness gate — display-only, drives the "saved default" label.setSavedGate(READINESS_GATE_LABELS[pec.readinessGate] ? pec.readinessGate : '');})@@ -250,6 +259,13 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdateconst editEditorialRounds = useCallback((v) => { editorialEditedRef.current = true; setEditorialRounds(v); }, []);const editBeatContinuityRounds = useCallback((v) => { beatContinuityEditedRef.current = true; setBeatContinuityRounds(v); }, []);const editCheckPauseThreshold = useCallback((v) => { checkPauseEditedRef.current = true; setCheckPauseThreshold(v); }, []);+ // Boolean checkbox — persist immediately on toggle (no blur event) so the saved+ // default tracks the choice and Resume reuses it.+ const editNotifyOnPause = useCallback((v) => {+ notifyEditedRef.current = true;+ setNotifyOnPause(v);+ persistRounds({ notifyOnPause: v });+ }, [persistRounds]);const { latest, frames } = usePipelineProgress(pipelineAutopilotSseUrl, [seriesId], { enabled: active });@@ -328,6 +344,9 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate// #1613 — the editorial-checks pause threshold persists + overrides like the// round inputs (clamps to a non-negative integer; 0 = off).if (checkPauseEditedRef.current) roundOverrides.checkFindingsPauseThreshold = clampThreshold(checkPauseThreshold);+ // #1615 — pause notification toggle persists + overrides like the others, but+ // is a plain boolean (no clamp). Untouched sends nothing → server default (on).+ if (notifyEditedRef.current) roundOverrides.notifyOnPause = notifyOnPause;if (Object.keys(roundOverrides).length) await persistRounds(roundOverrides);// Per-run readiness-gate override (#1580): send it ONLY when the user picked a// specific gate. Unlike the round inputs we never persist it — '' leaves the@@ -343,7 +362,7 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate// effect can reject a stale terminal frame from the previous run.activeRunIdRef.current = res.runId || null;setActive(true);- }, [seriesId, includeVisual, fileGaps, arcRounds, editorialRounds, beatContinuityRounds, checkPauseThreshold, readinessGate, persistRounds]);+ }, [seriesId, includeVisual, fileGaps, arcRounds, editorialRounds, beatContinuityRounds, checkPauseThreshold, notifyOnPause, readinessGate, persistRounds]);const cancel = useCallback(async () => {await cancelPipelineAutopilot(seriesId).catch(() => null);@@ -416,6 +435,10 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate<input type="checkbox" checked={fileGaps} onChange={(e) => setFileGaps(e.target.checked)} />File CoS tasks for gaps it can't resolve</label>+ <label className="flex items-center gap-2 text-xs text-gray-300">+ <input type="checkbox" checked={notifyOnPause} onChange={(e) => editNotifyOnPause(e.target.checked)} />+ Notify me when a run pauses (with a resume link)+ </label><div className="flex flex-wrap gap-4 pt-1"><RoundInputid="autopilot-arc-rounds"diff --git a/server/lib/validation.js b/server/lib/validation.jsindex b3338f43fc..682e667840 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -1125,6 +1125,12 @@ export const pipelineEditorialChecksSettingsSchema = z.object({// installs are unchanged. Optional + additive so older peers fall through to off.// No upper bound mirrors the round caps — a large N just means "effectively off".checkFindingsPauseThreshold: z.number().int().min(0).optional(),+ // Pause-notification escalation (#1615). When an autopilot run pauses, post an+ // in-app notification (reason + resume link) so a paused run isn't missed until+ // the user opens the status page. Defaults ON (true) when unset — a zero-cost+ // informational signal — so this is the one autopilot setting that's opt-OUT.+ // Optional + additive so older peers fall through to the default.+ notifyOnPause: z.boolean().optional(),}).strict();// Cursor-context payload for the CD-bridge suggest route — identical shape todiff --git a/server/routes/pipeline/autopilot.js b/server/routes/pipeline/autopilot.jsindex 4e955745c0..266ee21053 100644--- a/server/routes/pipeline/autopilot.js+++ b/server/routes/pipeline/autopilot.js@@ -67,6 +67,13 @@ const autopilotStartSchema = z.object({// pipelineEditorialChecks.checkFindingsPauseThreshold, then 0 (off). 0 disables// the gate for this run. No upper bound — a large N is effectively off.checkFindingsPauseThreshold: z.number().int().min(0).optional(),+ // Per-run pause-notification override (#1615). When the run pauses (budget,+ // findings, convergence, child failure), post an in-app notification with the+ // reason + a resume link so a paused run isn't missed until the user opens the+ // status page. When omitted, falls back to the persisted+ // pipelineEditorialChecks.notifyOnPause, then true (on by default — a zero-cost+ // informational signal). Set false to silence pause notifications for this run.+ notifyOnPause: z.boolean().optional(),});router.post('/series/:id/autopilot/start', asyncHandler(async (req, res) => {diff --git a/server/services/notifications.js b/server/services/notifications.jsindex 358c240f6d..c174fffe01 100644--- a/server/services/notifications.js+++ b/server/services/notifications.js@@ -34,7 +34,8 @@ export const NOTIFICATION_TYPES = {BRIEFING_READY: 'briefing_ready',AUTOBIOGRAPHY_PROMPT: 'autobiography_prompt',PLAN_QUESTION: 'plan_question',- AGENT_WARNING: 'agent_warning'+ AGENT_WARNING: 'agent_warning',+ AUTOPILOT_PAUSED: 'autopilot_paused'};// Priority levelsdiff --git a/server/services/pipeline/seriesAutopilot.js b/server/services/pipeline/seriesAutopilot.jsindex 16f474826c..07edd773c1 100644--- a/server/services/pipeline/seriesAutopilot.js+++ b/server/services/pipeline/seriesAutopilot.js@@ -100,6 +100,7 @@ import { readReadinessGate } from '../../lib/editorial/index.js';import { generateManuscriptFix, acceptManuscriptFix } from './manuscriptFix.js';import { verifyComicScript } from './scriptVerify.js';import { checkSeriesCanonReadiness } from './canonReadiness.js';+import { addNotification, removeByMetadata, NOTIFICATION_TYPES, PRIORITY_LEVELS } from '../notifications.js';// runs: Map<seriesId, { runId, clients[], lastPayload, cancelRequested, finished,// cleanupTimer, startedAt, mode, options, runState, activeChild }>@@ -174,6 +175,21 @@ export function resolveAutopilotCheckPauseThreshold(options = {}, settings = nulreturn DEFAULT_CHECK_FINDINGS_PAUSE_THRESHOLD;}+// Pause escalation (#1615): post an in-app notification (notification center,+// surfaced in the header dropdown) when a run pauses, so a paused run doesn't sit+// unnoticed until the user happens to open the status page. Unlike the other+// gates this defaults ON — it's a zero-cost informational signal that directly+// addresses the "paused runs go unnoticed" problem — but stays overridable per+// run and via the persisted setting for users who don't want the noise. Boolean+// at every layer: per-run option wins, then the persisted setting, then true.+export const DEFAULT_NOTIFY_ON_PAUSE = true;+export function resolveAutopilotNotifyOnPause(options = {}, settings = null) {+ if (typeof options?.notifyOnPause === 'boolean') return options.notifyOnPause;+ const pec = settings?.pipelineEditorialChecks || {};+ if (typeof pec?.notifyOnPause === 'boolean') return pec.notifyOnPause;+ return DEFAULT_NOTIFY_ON_PAUSE;+}+// Per-gate copy for the non-convergence pause — shared by the arc-verify and// editorial loops so the two messages can't drift.const PAUSE_GATES = {@@ -613,6 +629,30 @@ async function fileGap(record, sId, { gapKind, issueId = null, summary, context}}+// Pause escalation (#1615): post an in-app notification when a run pauses so the+// user is told actively, not only when they happen to open the status page. The+// SSE `paused` frame still fires for an attached client; this is the persistent+// out-of-band signal for a user who isn't watching. Opt-out via+// `options.notifyOnPause` / the persisted setting (default on); never fires in+// dry-run. Prior pause notifications for this series are cleared first so a+// resume→pause cycle leaves exactly one current banner instead of a stack, and+// the metadata field is series-scoped so removeByMetadata can't touch unrelated+// notifications. Best-effort — a notification failure must never abort the run.+async function notifyPause(record, sId, { reason, pauseKind = null, currentStep = null }) {+ if (record.options.notifyOnPause === false || record.mode !== 'execute') return;+ const series = await getSeries(sId).catch(() => null);+ const seriesName = series?.name || 'a series';+ await removeByMetadata('autopilotPauseSeriesId', sId).catch(() => {});+ await addNotification({+ type: NOTIFICATION_TYPES.AUTOPILOT_PAUSED,+ title: `Autopilot paused — ${seriesName}`,+ description: reason || 'The run paused and needs human review before it can continue.',+ priority: PRIORITY_LEVELS.HIGH,+ link: `/pipeline/series/${sId}`,+ metadata: { autopilotPauseSeriesId: sId, runId: record.runId, pauseKind, currentStep },+ }).catch((err) => { console.log(`⚠️ autopilot: pause notification failed for ${sId.slice(0, 12)}: ${err.message}`); });+}+// Series Autopilot threads BOTH its run provider AND its run model as SOFT// defaults, NOT hard overrides — so a deliberate per-stage pin (Prompts page /// stage-config.json) still wins for that stage, matching what verifyComicScript@@ -1625,6 +1665,7 @@ export async function startSeriesAutopilot(sId, options = {}) {...resolveAutopilotRounds(options, settings),readinessGate: resolveAutopilotReadinessGate(options, settings),checkFindingsPauseThreshold: resolveAutopilotCheckPauseThreshold(options, settings),+ notifyOnPause: resolveAutopilotNotifyOnPause(options, settings),};if (existing) {@@ -1762,8 +1803,10 @@ export async function startSeriesAutopilot(sId, options = {}) {if (!selfGatingStep && !zeroRoundSkip) {const budget = await getDomainBudgetStatus('cos');if (!budget.withinBudget) {- await persistMarker(sId, { status: 'paused', runId, currentStep: step.kind, lastError: `daily cos ${budget.exceeded} budget reached` });- broadcast(sId, { type: 'paused', runId, reason: `daily cos ${budget.exceeded} budget reached`, completedAt: new Date().toISOString() });+ const budgetReason = `daily cos ${budget.exceeded} budget reached`;+ await persistMarker(sId, { status: 'paused', runId, currentStep: step.kind, lastError: budgetReason });+ broadcast(sId, { type: 'paused', runId, reason: budgetReason, completedAt: new Date().toISOString() });+ await notifyPause(record, sId, { reason: budgetReason, pauseKind: 'budget', currentStep: step.kind });console.log(`⏸️ autopilot paused (budget) — series=${sId.slice(0, 12)} after ${ordinal} steps`);return;}@@ -1779,6 +1822,7 @@ export async function startSeriesAutopilot(sId, options = {}) {if (result?.pause) {await persistMarker(sId, { status: 'paused', runId, currentStep: step.kind, residualFindings: result.residual || [], lastError: result.reason, pauseKind: result.pauseKind || null, healthBreakdown: result.healthBreakdown || null });broadcast(sId, { type: 'paused', runId, scope: step.kind, reason: result.reason, residualFindings: result.residual || [], pauseKind: result.pauseKind || null, healthBreakdown: result.healthBreakdown || null, completedAt: new Date().toISOString() });+ await notifyPause(record, sId, { reason: result.reason, pauseKind: result.pauseKind || null, currentStep: step.kind });// Only file the generic stalled task when the step didn't already file// a more specific gap (canon-undescribed, visual-no-pages, …) — else// fileGaps would create two CoS tasks for one underlying problem (thediff --git a/server/services/pipeline/seriesAutopilot.test.js b/server/services/pipeline/seriesAutopilot.test.jsindex 89b81a0f6f..5a7faaea12 100644--- a/server/services/pipeline/seriesAutopilot.test.js+++ b/server/services/pipeline/seriesAutopilot.test.js@@ -143,6 +143,17 @@ const checkSeriesCanonReadiness = vi.fn(async (seriesId) => ({}));vi.mock('./canonReadiness.js', () => ({ checkSeriesCanonReadiness }));+// Pause-escalation notifications (#1615) — spy on the notification center so a+// test can assert a pause posts a banner (and a clean run / opt-out does not).+const addNotification = vi.fn(async () => ({ id: 'notif-1' }));+const removeByMetadata = vi.fn(async () => ({ success: true, removed: 0 }));+vi.mock('../notifications.js', () => ({+ addNotification,+ removeByMetadata,+ NOTIFICATION_TYPES: { AUTOPILOT_PAUSED: 'autopilot_paused' },+ PRIORITY_LEVELS: { HIGH: 'high', MEDIUM: 'medium', LOW: 'low', CRITICAL: 'critical' },+}));+// Mocked domainUsage binding, so a test can drive the budget per call.const { getDomainBudgetStatus } = await import('../domainUsage.js');// Mocked settings binding, so a test can drive the persisted convergence-round@@ -318,6 +329,29 @@ describe('resolveNextStep (pure)', () => {)).toBe(0);});+ it('resolveAutopilotNotifyOnPause: per-run option wins, else setting, else true/on (#1615)', () => {+ const { resolveAutopilotNotifyOnPause, DEFAULT_NOTIFY_ON_PAUSE } = autopilot;+ expect(DEFAULT_NOTIFY_ON_PAUSE).toBe(true);+ // per-run override wins (including an explicit false = silence)+ expect(resolveAutopilotNotifyOnPause(+ { notifyOnPause: false },+ { pipelineEditorialChecks: { notifyOnPause: true } },+ )).toBe(false);+ expect(resolveAutopilotNotifyOnPause(+ { notifyOnPause: true },+ { pipelineEditorialChecks: { notifyOnPause: false } },+ )).toBe(true);+ // persisted setting fills in when no per-run override+ expect(resolveAutopilotNotifyOnPause({}, { pipelineEditorialChecks: { notifyOnPause: false } })).toBe(false);+ // on by default when neither is set (the one opt-OUT autopilot gate)+ expect(resolveAutopilotNotifyOnPause({}, null)).toBe(true);+ // a non-boolean at any layer falls through to the next+ expect(resolveAutopilotNotifyOnPause(+ { notifyOnPause: 'yes' },+ { pipelineEditorialChecks: { notifyOnPause: 1 } },+ )).toBe(true);+ });+it('regenerates the arc for an arc-only series with no volumes', () => {const arcOnly = { targetFormat: 'comic', arc: { logline: 'L', summary: 'S' }, seasons: [] };expect(resolveNextStep(arcOnly, []).kind).toBe('generateArc');@@ -982,6 +1016,38 @@ describe('autopilot conductor', () => {expect(series.autopilot?.residualFindings?.[0]?.problem).toBe('plot hole');});+ it('posts an in-app notification when a run pauses, with a resume link (#1615)', async () => {+ verifyFindings = [{ severity: 'high', problem: 'plot hole', location: 'V1' }];+ const { seriesId } = await seedComplete();+ await autopilot.startSeriesAutopilot(seriesId, { maxArcVerifyRounds: 2 });+ await waitFor(runFinished(seriesId));+ expect(addNotification).toHaveBeenCalledTimes(1);+ const notif = addNotification.mock.calls[0][0];+ expect(notif.type).toBe('autopilot_paused');+ expect(notif.priority).toBe('high');+ expect(notif.link).toBe(`/pipeline/series/${seriesId}`);+ expect(notif.metadata?.autopilotPauseSeriesId).toBe(seriesId);+ // prior pause banners for this series are cleared first so resume→pause leaves one+ expect(removeByMetadata).toHaveBeenCalledWith('autopilotPauseSeriesId', seriesId);+ });++ it('does not notify on a clean complete (#1615)', async () => {+ const { seriesId } = await seedComplete();+ await autopilot.startSeriesAutopilot(seriesId, {});+ await waitFor(runFinished(seriesId));+ expect(autopilot.__testing.runs.get(seriesId)?.lastPayload?.type).toBe('complete');+ expect(addNotification).not.toHaveBeenCalled();+ });++ it('does not notify when notifyOnPause is opted out for the run (#1615)', async () => {+ verifyFindings = [{ severity: 'high', problem: 'plot hole', location: 'V1' }];+ const { seriesId } = await seedComplete();+ await autopilot.startSeriesAutopilot(seriesId, { maxArcVerifyRounds: 2, notifyOnPause: false });+ await waitFor(runFinished(seriesId));+ expect(autopilot.__testing.runs.get(seriesId)?.lastPayload?.type).toBe('paused');+ expect(addNotification).not.toHaveBeenCalled();+ });+it('uses the persisted maxArcVerifyRounds setting when no per-run override is given', async () => {// Strictly-decreasing blocking counts (4→3→2→1) so the loop runs to the cap// WITHOUT tripping the divergence guard (#1571) — this asserts the persisted