fix(ui): offer resume only where the server accepts it

This commit is contained in:
sam committed 2026-10-05 20:37:38 +11:00
1 parent 49482c9cb5
commit 8d42e6087e
5 files changed
+40 -5

No files matched your search

+1 -1
View File
@@ -167,7 +167,7 @@ const topIndex = computed(() => (menuPath.value?.length === 2 ? Number(menuPath.
<template v-if="menu.step?.kind === 'step' && menuPath">
<DropdownMenuLabel class="truncate">{{ menu.step.title || stepTitle(menu.step.type) }}</DropdownMenuLabel>
<template v-if="restart">
<DropdownMenuItem @select="emit('restart', restart.from)"><RotateCcw /> {{ restart.label }}</DropdownMenuItem>
<DropdownMenuItem :disabled="restart.blocked" @select="emit('restart', restart.from)"><RotateCcw /> {{ restart.label }}</DropdownMenuItem>
<DropdownMenuSeparator />
</template>
<DropdownMenuItem @select="emit('edit', menuPath)"><Pencil /> Edit</DropdownMenuItem>
+1 -1
View File
@@ -286,7 +286,7 @@ function syncScroll(event: Event): void {
<div class="flex items-center gap-2 border-b border-border px-3 py-2">
<Tabs v-model="stepTab"><TabsList><TabsTrigger value="run">Run</TabsTrigger><TabsTrigger value="definition">Definition</TabsTrigger></TabsList></Tabs>
<span class="min-w-0 flex-1 truncate text-xs" :title="selectedNode.run.name">{{ selectedNode.run.name }}</span>
<Button v-if="selectedRestart" type="button" size="sm" variant="outline" :disabled="restarting" @click="restartFrom(selectedRestart.from)"><RotateCcw /> {{ selectedRestart.label }}</Button>
<Button v-if="selectedRestart" type="button" size="sm" variant="outline" :disabled="restarting || selectedRestart.blocked" @click="restartFrom(selectedRestart.from)"><RotateCcw /> {{ selectedRestart.label }}</Button>
<Button type="button" variant="ghost" size="icon-sm" aria-label="Close step details" @click="selectedStep = null"><X /></Button>
</div>
<div v-if="stepTab === 'run'" class="min-h-0 w-[32rem] max-w-[calc(100vw-3rem)] flex-1 overflow-y-auto">
+12 -1
View File
@@ -76,8 +76,10 @@ export function withRuns(graph: WorkflowGraph, stages: StageRun[]): WorkflowGrap
* resumes, earlier ones re-run. Later steps, and runs that are not parked,
* offer nothing. */
export interface Restart {
label: "Resume from here" | "Re-run from here";
label: "Resume from here" | "Re-run from here" | "Add an id to resume here";
from: string;
/** The server would refuse this resume point: the step needs an id. */
blocked?: boolean;
}
export function restartAt(graph: WorkflowGraph, path: (string | number)[]): Restart | null {
@@ -88,6 +90,15 @@ export function restartAt(graph: WorkflowGraph, path: (string | number)[]): Rest
const stopped = Math.max(-1, ...graph.nodes.filter((candidate) => candidate.data.run).map((candidate) => top(candidate.data)));
const at = top(node);
if (at < 0 || at > stopped) return null;
// The server resumes by stage name, so it refuses a step whose name, or the
// name of the step before it, runs more than once.
const names = graph.nodes
.filter((candidate) => candidate.data.path?.length === 2)
.sort((a, b) => top(a.data) - top(b.data))
.map((candidate) => candidate.data.resume ?? candidate.data.stage ?? "");
const repeated = (name: string | undefined) => !!name && names.filter((n) => n === name).length > 1;
if (repeated(from) || (at > 0 && repeated(names[at - 1])))
return { label: "Add an id to resume here", from, blocked: true };
return { label: at === stopped ? "Resume from here" : "Re-run from here", from };
}