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

feat: emit an immediate cancel:acknowledged frame on autopilot cancel (#1617)

[._.]/ Adam Eivya9a77f289668
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index f57753caa4..659f58c66c 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -28,6 +28,7 @@
- **[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`)
+- **[issue-1617] Stopping a Series Autopilot run now gives you immediate feedback instead of looking frozen mid-step.** Cancellation is cooperative — it's honored between steps, so a Stop pressed during a long LLM call was only acted on once that call returned, with no acknowledgement in between. The server now emits a `cancel:acknowledged` SSE frame the instant you press Stop; the button switches to a disabled "Cancelling…" spinner and the live status reads "finishing the active step…" until the run unwinds and the terminal frame lands. The active step still finishes first (no mid-stream interruption) — this is purely the missing acknowledgement, now documented on the cancel route. (`server/services/pipeline/seriesAutopilot.js`, `server/routes/pipeline/autopilot.js`, `client/src/components/pipeline/AutopilotPanel.jsx`)
## Internal
diff --git a/client/src/components/pipeline/AutopilotPanel.jsx b/client/src/components/pipeline/AutopilotPanel.jsx
index 9d50befeed..df80b8f9df 100644
--- a/client/src/components/pipeline/AutopilotPanel.jsx
+++ b/client/src/components/pipeline/AutopilotPanel.jsx
@@ -135,6 +135,8 @@ function frameLabel(f) {
}
case 'render:queued': return `Queued draft render: ${f.target}`;
case 'gap:filed': return `Filed CoS task (${f.gapKind})`;
+ // #1617 — immediate cancel ack; the active step finishes before `canceled`.
+ case 'cancel:acknowledged': return 'Cancelling — finishing the active step…';
case 'paused': return `Paused — ${f.reason}`;
case 'complete': return f.dryRun ? 'Plan ready' : 'Complete';
case 'canceled': return 'Canceled';
@@ -380,6 +382,10 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate
const ap = series.autopilot;
const liveLabel = active ? (frameLabel(latest) || 'Working…') : null;
+ // #1617 — once the server acks the cancel, switch the Stop button to a
+ // disabled "Cancelling…" state so the user gets feedback (and can't re-fire
+ // cancel) while the active step finishes and the terminal frame arrives.
+ const canceling = active && latest?.type === 'cancel:acknowledged';
const runLabel = ap?.status === 'paused' ? 'Resume autopilot'
: ap?.status === 'done' ? 'Run autopilot again'
: 'Run autopilot';
@@ -416,9 +422,10 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate
<button
type="button"
onClick={cancel}
- className="inline-flex items-center gap-1 px-3 py-1.5 rounded text-xs text-port-warning hover:text-white border border-port-warning/40 bg-port-bg hover:bg-port-warning/10"
+ disabled={canceling}
+ className="inline-flex items-center gap-1 px-3 py-1.5 rounded text-xs text-port-warning hover:text-white border border-port-warning/40 bg-port-bg hover:bg-port-warning/10 disabled:opacity-50 disabled:hover:text-port-warning disabled:cursor-default"
>
- <X size={12} /> Stop
+ {canceling ? <Loader2 size={12} className="animate-spin" /> : <X size={12} />} {canceling ? 'Cancelling…' : 'Stop'}
</button>
)}
</div>
diff --git a/client/src/components/pipeline/AutopilotPanel.test.jsx b/client/src/components/pipeline/AutopilotPanel.test.jsx
index c7d7c0cb72..a413590a06 100644
--- a/client/src/components/pipeline/AutopilotPanel.test.jsx
+++ b/client/src/components/pipeline/AutopilotPanel.test.jsx
@@ -281,6 +281,20 @@ describe('AutopilotPanel', () => {
expect(await screen.findByText(/Editorial check: Info dumping — 3 finding\(s\) \(1H\/2M\/0L\)/i)).toBeInTheDocument();
});
+ // #1617 — a cancel:acknowledged frame switches the Stop button to a disabled
+ // "Cancelling…" state with the active-step-finishing live label.
+ it('shows a Cancelling… state when the server acks a cancel (#1617)', async () => {
+ getPipelineAutopilotStatus.mockResolvedValue({ autopilot: { status: 'running', runId: 'r1' }, active: true });
+ sseLatest = { type: 'cancel:acknowledged', runId: 'r1' };
+ renderPanel({ id: 's1', targetFormat: 'comic' });
+ await waitFor(() => expect(getPipelineAutopilotStatus).toHaveBeenCalled());
+ const btn = await screen.findByRole('button', { name: /cancelling/i });
+ expect(btn).toBeDisabled();
+ // The original Stop affordance is gone while cancelling.
+ expect(screen.queryByRole('button', { name: /^stop$/i })).not.toBeInTheDocument();
+ expect(screen.getByText(/finishing the active step/i)).toBeInTheDocument();
+ });
+
it('renders canon readiness gaps with a link to the issue Nouns page', async () => {
getPipelineSeriesCanonReadiness.mockResolvedValue({
ready: false,
diff --git a/server/routes/pipeline/autopilot.js b/server/routes/pipeline/autopilot.js
index 266ee21053..9477c38b32 100644
--- a/server/routes/pipeline/autopilot.js
+++ b/server/routes/pipeline/autopilot.js
@@ -8,6 +8,10 @@
* (404 series missing; 409 cos domain off)
* GET /series/:id/autopilot/progress → SSE (text/event-stream)
* POST /series/:id/autopilot/cancel → { canceled }
+ * Emits a `cancel:acknowledged` SSE frame
+ * immediately; the active step/LLM call
+ * finishes before the terminal `canceled`
+ * frame (cooperative, between-step cancel).
* GET /series/:id/autopilot/status → { autopilot } (resume / paused UI)
*/
diff --git a/server/services/pipeline/seriesAutopilot.js b/server/services/pipeline/seriesAutopilot.js
index e99adb130c..3a7b0736a0 100644
--- a/server/services/pipeline/seriesAutopilot.js
+++ b/server/services/pipeline/seriesAutopilot.js
@@ -579,6 +579,12 @@ export function cancelSeriesAutopilot(seriesId) {
const run = runs.get(seriesId);
if (!run || run.finished) return false;
run.cancelRequested = true;
+ // Emit an immediate acknowledgement frame so the UI can switch to a
+ // "cancelling…" state right away. Cancellation is cooperative and checked
+ // between steps (the terminal `canceled` frame follows once the active
+ // step/LLM call returns) — without this ack the user sees no feedback until
+ // the loop unwinds, which can be the length of a long in-flight LLM call (#1617).
+ broadcastSse(run, { type: 'cancel:acknowledged', runId: run.runId, requestedAt: new Date().toISOString() });
// Propagate to the currently-delegated child so cancel is responsive
// mid-step instead of only between steps.
const child = run.activeChild;
diff --git a/server/services/pipeline/seriesAutopilot.test.js b/server/services/pipeline/seriesAutopilot.test.js
index 6eda554224..11077ee1c4 100644
--- a/server/services/pipeline/seriesAutopilot.test.js
+++ b/server/services/pipeline/seriesAutopilot.test.js
@@ -1480,6 +1480,35 @@ describe('autopilot conductor', () => {
autopilot.cancelSeriesAutopilot(seriesId);
});
+ it('emits an immediate cancel:acknowledged frame on cancel (#1617)', async () => {
+ // Hold the run open at the arc verify step so cancel lands mid-run and the
+ // terminal `canceled` frame can't have fired yet.
+ verifyFindings = [{ severity: 'high', problem: 'x' }];
+ arcSpies.resolveVerifyIssues.mockImplementationOnce(() => new Promise(() => {})); // never resolves
+ const { seriesId } = await seedComplete();
+ const { runId } = await autopilot.startSeriesAutopilot(seriesId, { maxArcVerifyRounds: 5 });
+ // Wait until the run is actually running (first frame emitted).
+ await waitFor(() => autopilot.__testing.runs.get(seriesId)?.lastPayload != null);
+
+ // Attach a fake SSE client so we can assert the ack reaches subscribers,
+ // not just the cached lastPayload.
+ const writes = [];
+ autopilot.attachClient(seriesId, {
+ writeHead: () => {},
+ write: (chunk) => writes.push(chunk),
+ end: () => {},
+ req: { on: () => {} },
+ });
+
+ const canceled = autopilot.cancelSeriesAutopilot(seriesId);
+ expect(canceled).toBe(true);
+ // Synchronous: broadcastSse sets lastPayload last, before the loop can run.
+ const last = autopilot.__testing.runs.get(seriesId)?.lastPayload;
+ expect(last?.type).toBe('cancel:acknowledged');
+ expect(last?.runId).toBe(runId);
+ expect(writes.some((w) => w.includes('"type":"cancel:acknowledged"'))).toBe(true);
+ });
+
it('drafts cover + interior pages when includeVisual is set', async () => {
const { seriesId, issueId } = await seedComplete();
await autopilot.startSeriesAutopilot(seriesId, { includeVisual: true });