feat(web): manage independent schedules and restore recorded stage navigation

This commit is contained in:
2026-10-21 02:06:15 +01:00
parent 4ab49a2749
commit 1e4654381e
31 changed files with 843 additions and 52 deletions
+21
View File
@@ -169,6 +169,23 @@ function sameResourceWait(a, b) {
);
}
// Execution origin is immutable. Sparse lifecycle frames (or older peers)
// cannot turn a scheduled run into a manual run or retarget its schedule.
function scheduleOriginFields(current, frame) {
const oldId = Number.isSafeInteger(current.schedule_id) && current.schedule_id > 0 ? current.schedule_id : 0;
const newId = Number.isSafeInteger(frame.schedule_id) && frame.schedule_id > 0 ? frame.schedule_id : 0;
const known = Object.hasOwn(current, "scheduled") || Object.hasOwn(frame, "scheduled") || oldId > 0 || newId > 0;
if (!known) return {};
const id = oldId > 0 ? oldId : newId > 0 ? newId : 0;
const incomingName = oldId > 0 && newId > 0 && oldId !== newId ? "" : frame.schedule_name;
const name = String(current.schedule_name || incomingName || "");
return {
scheduled: current.scheduled === true || frame.scheduled === true || id > 0,
...(id > 0 ? { schedule_id: id } : {}),
...(name ? { schedule_name: name } : {}),
};
}
/** The run-state fields a frame advances, shared by the summary row and the detail. */
function runStateFields(current) {
return {
@@ -195,11 +212,13 @@ function runStateFields(current) {
function applyRunStateFields(current, frame) {
if (isStaleRunFrame(current.status, frame.status, frame.resource_wait_set === true)) return current;
const before = runStateFields(current);
const origin = scheduleOriginFields(current, frame);
const status =
frame.resource_wait_set === true && frame.status === "queued" && !isTerminalRunStatus(before.status)
? "queued"
: advanceRunStatus(before.status, frame.status);
const merged = {
...origin,
notify_mode: blank(frame.notify_mode) ? before.notify_mode : frame.notify_mode,
resource_wait: isTerminalRunStatus(status)
? null
@@ -222,6 +241,7 @@ function applyRunStateFields(current, frame) {
// Detail already maintains full visits below; compact evidence is list-only.
const graphEvidence = Array.isArray(current.steps) ? current.graph_evidence : mergeGraphEvidence(current.graph_evidence, frame);
const changed =
Object.keys(origin).some((key) => current[key] !== origin[key]) ||
graphEvidence !== current.graph_evidence ||
merged.notify_mode !== before.notify_mode ||
!sameResourceWait(merged.resource_wait, before.resource_wait) ||
@@ -276,6 +296,7 @@ export function newRunSummaryFromFrame(frame) {
if (!(pipelineId > 0) || blank(name)) return null;
const graphEvidence = mergeGraphEvidence(null, frame);
return {
...scheduleOriginFields({}, frame),
...(graphEvidence ? { graph_evidence: graphEvidence } : {}),
resource_wait: frame.resource_wait ?? null,
id: Number(frame.run_id),