runner: keep export handoffs nonterminal through recovery
This commit is contained in:
+3
-1
@@ -96,6 +96,7 @@ export function decisionTargetLabel(option, target) {
|
||||
*/
|
||||
export function pendingDecision(run) {
|
||||
if (run == null || run.status !== RUN_STATUS_WAITING) return null;
|
||||
if (Number(run.export_pending_sequence) > 0) return null;
|
||||
const step = lastWaitingStep(run.steps ?? []);
|
||||
const stepStage = str(step?.stage).trim() !== "" ? String(step.stage) : "";
|
||||
const runStage = str(run.current_stage).trim() !== "" ? String(run.current_stage) : "";
|
||||
@@ -103,6 +104,7 @@ export function pendingDecision(run) {
|
||||
if (stageKey === "") return null;
|
||||
|
||||
const declared = (run.graph?.stages ?? []).find((candidate) => candidate?.key === stageKey) ?? null;
|
||||
if (declared?.type && declared.type !== "human") return null;
|
||||
const recorded = waitingOptions(step?.output);
|
||||
const keys = recorded.length > 0 ? recorded : humanOptions(declared?.edges);
|
||||
if (keys.length === 0) return null;
|
||||
@@ -154,7 +156,7 @@ export class DecisionDraft {
|
||||
|
||||
/** Cancel is offered only while the run is executing. */
|
||||
export function canCancel(run) {
|
||||
return Boolean(run?.executing) && !run.cancel_requested && !run.cleanup_unconfirmed;
|
||||
return (Boolean(run?.executing) || (run?.status === RUN_STATUS_WAITING && Number(run.export_pending_sequence) > 0)) && !run.cancel_requested && !run.cleanup_unconfirmed;
|
||||
}
|
||||
|
||||
/** Retry is offered only for a loaded, non-executing, `failed` run. */
|
||||
|
||||
@@ -33,7 +33,8 @@ export const AttentionKind = Object.freeze({
|
||||
* so queued, running, succeeded, canceled, interrupted and any unknown status
|
||||
* can never invent an entry.
|
||||
*/
|
||||
export function attentionKindOf(status) {
|
||||
export function attentionKindOf(status, exportPendingSequence = 0) {
|
||||
if (Number(exportPendingSequence) > 0 && String(status ?? "").trim().toLowerCase() === "waiting") return null;
|
||||
switch (String(status ?? "").trim().toLowerCase()) {
|
||||
case "waiting":
|
||||
return AttentionKind.Decision;
|
||||
@@ -99,7 +100,7 @@ export function attentionEntries(runs, dismissed, { since = 0 } = {}) {
|
||||
dismissed instanceof Set ? dismissed : new Set(Array.isArray(dismissed) ? dismissed : []);
|
||||
return (runs ?? [])
|
||||
.map((run) => {
|
||||
const kind = attentionKindOf(run?.status);
|
||||
const kind = attentionKindOf(run?.status, run?.export_pending_sequence);
|
||||
if (!kind) return null;
|
||||
const key = attentionKey(run.id, kind);
|
||||
if (dismissedKeys.has(key)) return null;
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ export function createAlertLedger() {
|
||||
if (frame?.notify_mode != null) modes.set(runId, normalizeStatus(frame.notify_mode));
|
||||
const mode = modes.get(runId) || "auto";
|
||||
|
||||
const kind = status === "succeeded" && mode === "on" ? RunAlertKind.Succeeded : attentionKindOf(status);
|
||||
const kind = status === "succeeded" && mode === "on" ? RunAlertKind.Succeeded : attentionKindOf(status, frame?.export_pending_sequence);
|
||||
if (!kind) {
|
||||
forget(runId, AttentionKind.Decision);
|
||||
forget(runId, AttentionKind.Failed);
|
||||
|
||||
@@ -183,6 +183,7 @@ function runStateFields(current) {
|
||||
executing: Boolean(current.executing),
|
||||
cancel_requested: Boolean(current.cancel_requested),
|
||||
cleanup_unconfirmed: Boolean(current.cleanup_unconfirmed),
|
||||
export_pending_sequence: Number(current.export_pending_sequence) || 0,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -206,6 +207,9 @@ function applyRunStateFields(current, frame) {
|
||||
? (frame.resource_wait ?? null)
|
||||
: before.resource_wait,
|
||||
status,
|
||||
...(before.export_pending_sequence || Number(frame.export_pending_sequence) > 0 || Object.hasOwn(current, "export_pending_sequence")
|
||||
? { export_pending_sequence: blank(frame.status) ? before.export_pending_sequence : status === "waiting" ? Number(frame.export_pending_sequence) || 0 : 0 }
|
||||
: {}),
|
||||
outcome: blank(frame.outcome) ? before.outcome : frame.outcome,
|
||||
current_stage: blank(frame.current_stage) ? before.current_stage : frame.current_stage,
|
||||
completed_steps: Math.max(before.completed_steps, Number(frame.completed_steps) || 0),
|
||||
@@ -230,7 +234,8 @@ function applyRunStateFields(current, frame) {
|
||||
merged.executing !== before.executing ||
|
||||
merged.cancel_requested !== before.cancel_requested ||
|
||||
merged.cleanup_unconfirmed !== before.cleanup_unconfirmed;
|
||||
return changed ? { ...current, ...merged, ...(graphEvidence ? { graph_evidence: graphEvidence } : {}) } : current;
|
||||
const exportWaitChanged = (Number(merged.export_pending_sequence) || 0) !== before.export_pending_sequence;
|
||||
return changed || exportWaitChanged ? { ...current, ...merged, ...(graphEvidence ? { graph_evidence: graphEvidence } : {}) } : current;
|
||||
}
|
||||
|
||||
// Reuse the detail's monotonic visit merge, then compact by last stage visit and
|
||||
@@ -280,6 +285,7 @@ export function newRunSummaryFromFrame(frame) {
|
||||
title: blank(frame.title) ? null : frame.title,
|
||||
version: Number(frame.version) || 0,
|
||||
status: frame.status ?? "",
|
||||
...(Number(frame.export_pending_sequence) > 0 ? { export_pending_sequence: Number(frame.export_pending_sequence) } : {}),
|
||||
executing: executingFor(frame.status, true),
|
||||
cancel_requested: frame.cancel_requested === true,
|
||||
cleanup_unconfirmed: frame.cleanup_unconfirmed === true,
|
||||
|
||||
@@ -41,6 +41,7 @@ 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";
|
||||
if (run.status === "waiting" && Number(run.export_pending_sequence) > 0) return "Waiting for session export";
|
||||
}
|
||||
return run?.status || "unknown";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user