fix: keep cancellation pending until execution cleanup is confirmed

This commit is contained in:
2026-10-20 15:47:07 +01:00
parent 1cf5156c77
commit b96b9d94a6
26 changed files with 690 additions and 142 deletions
+1 -1
View File
@@ -154,7 +154,7 @@ export class DecisionDraft {
/** Cancel is offered only while the run is executing. */
export function canCancel(run) {
return Boolean(run?.executing);
return Boolean(run?.executing) && !run.cancel_requested && !run.cleanup_unconfirmed;
}
/** Retry is offered only for a loaded, non-executing, `failed` run. */
+11 -1
View File
@@ -181,6 +181,8 @@ function runStateFields(current) {
created_at: current.created_at ?? "",
finished_at: current.finished_at ?? "",
executing: Boolean(current.executing),
cancel_requested: Boolean(current.cancel_requested),
cleanup_unconfirmed: Boolean(current.cleanup_unconfirmed),
};
}
@@ -210,6 +212,8 @@ function applyRunStateFields(current, frame) {
created_at: blank(frame.created_at) ? before.created_at : frame.created_at,
finished_at: blank(frame.finished_at) ? before.finished_at : frame.finished_at,
executing: executingFor(status, before.executing),
cancel_requested: before.cancel_requested || frame.cancel_requested === true,
cleanup_unconfirmed: before.cleanup_unconfirmed || frame.cleanup_unconfirmed === true,
};
const changed =
merged.notify_mode !== before.notify_mode ||
@@ -220,7 +224,9 @@ function applyRunStateFields(current, frame) {
merged.completed_steps !== before.completed_steps ||
merged.created_at !== before.created_at ||
merged.finished_at !== before.finished_at ||
merged.executing !== before.executing;
merged.executing !== before.executing ||
merged.cancel_requested !== before.cancel_requested ||
merged.cleanup_unconfirmed !== before.cleanup_unconfirmed;
return changed ? { ...current, ...merged } : current;
}
@@ -244,6 +250,8 @@ export function newRunSummaryFromFrame(frame) {
version: Number(frame.version) || 0,
status: frame.status ?? "",
executing: executingFor(frame.status, true),
cancel_requested: frame.cancel_requested === true,
cleanup_unconfirmed: frame.cleanup_unconfirmed === true,
outcome: frame.outcome ?? "",
current_stage: frame.current_stage ?? "",
created_at: frame.created_at ?? "",
@@ -361,6 +369,8 @@ export function runDetailNeedsFullSync(frame) {
return (
stepSettled ||
stepWaiting ||
frame?.cancel_requested === true ||
frame?.cleanup_unconfirmed === true ||
isTerminalRunStatus(frame?.status) ||
isWaitingRunStatus(frame?.status)
);
+8
View File
@@ -37,6 +37,14 @@ export const RUN_STATES = [
* states so one chip set renders list, detail and timeline). Mirrors
* runStateOf: blank or unrecognised input is the safe `unknown` fallback.
*/
export function runStatusLabel(run) {
if (["queued", "running", "waiting"].includes(run?.status)) {
if (run.cleanup_unconfirmed) return "Cleanup unconfirmed — workspace reserved";
if (run.cancel_requested) return "Stopping — waiting for execution to stop";
}
return run?.status || "unknown";
}
export function runStateOf(status) {
switch (String(status ?? "").trim().toLowerCase()) {
case "running":
+3 -3
View File
@@ -6,7 +6,7 @@
import { h, kvMono, canCopyLink, canShare, copyArtifactLink, shareArtifact } from "../dom.js";
import { isExecuting, changeKindTone, describeError } from "../format.js";
import { resolveArtifactUrl } from "../serverUrl.js";
import { runStateOf } from "../runs.js";
import { runStateOf, runStatusLabel } from "../runs.js";
import { PIPELINE_GRAPH_EMPTY, RUN_GRAPH_MISSING, mount as mountGraph } from "../graph.js";
import { writeGraphExpanded } from "../graphPrefs.js";
import {
@@ -135,11 +135,11 @@ function renderRunDetail(now = Date.now()) {
if (decision) pane.append(renderDecisionCard(decision));
const status = runStateOf(d.status);
const kicker = h("div", { class: "run-kicker" });
kicker.append(h("span", { class: `chip chip-${status}`, text: d.status || status }));
kicker.append(h("span", { class: `chip chip-${status}`, text: runStatusLabel(d) }));
if (String(d.outcome ?? "").trim()) {
kicker.append(h("span", { class: "muted", text: `outcome ${d.outcome}` }));
}
if (d.executing) kicker.append(h("span", { class: "muted", text: "executing" }));
if (d.executing && !d.cleanup_unconfirmed) kicker.append(h("span", { class: "muted", text: "executing" }));
pane.append(kicker);
pane.append(
h("h1", {
+5 -1
View File
@@ -9,6 +9,7 @@ import {
RUN_TIME_RANGES,
RUN_SORTS,
runStateOf,
runStatusLabel,
runIdentity,
versionLabel,
progressText,
@@ -125,7 +126,10 @@ function renderRunRow(run, now) {
});
const head = h("span", { class: "run-row-head" });
head.append(statusIcon(status, status.charAt(0).toUpperCase() + status.slice(1)));
head.append(statusIcon(status, runStatusLabel(run)));
if (run.cancel_requested || run.cleanup_unconfirmed) {
head.append(h("span", { class: "muted", text: runStatusLabel(run) }));
}
if (run.executing) head.append(h("span", { class: "spinner", "aria-hidden": "true" }));
// The pipeline is the list's anchor: it names what ran, before the task title.
head.append(