fix(ui): workflow reads keep their error instead of showing empty (#1732)

Triggers: a failed bindings/schedules read surfaces as an error with
Retry in TriggerSettings instead of "Manual runs only." Run stages: a
failed attempts read sets stagesError, shown with Retry above the canvas
instead of a bare canvas. Bind form: failed reads show an error with
Retry rather than empty pickers, and save refuses to mappingUpdate an
existing mapping unless the bindings list actually loaded. History: a
failed revisions read shows the error with Retry in the revision list,
and "No recorded changes" appears only after a successful read.
This commit is contained in:
sam committed 2026-11-06 22:06:25 +11:00
1 parent 5bf0a696c6
commit 4dad1415e6
6 files changed
+63 -21

No files matched your search

+26 -6
View File
@@ -61,6 +61,11 @@ const eventTypes = ref<EventType[]>([]);
const mappings = ref<Mapping[]>([]);
const bindings = ref<Binding[]>([]);
const loading = ref(true);
// A failed read of the form's data is an error with Retry, not empty pickers.
const loadError = ref("");
// Saving must know whether the bindings list actually loaded: on a failed
// read, sharedMapping() cannot tell, and mappingUpdate must not run.
const bindingsLoaded = ref(false);
const source = ref("");
const newSource = ref("");
@@ -80,12 +85,14 @@ async function loadCaptures(): Promise<void> {
captures.value = listed?.captures ?? [];
}
onMounted(async () => {
async function loadAll(): Promise<void> {
loading.value = true;
let readError = "";
const [listed, types, mapped, bound] = await Promise.all([
api.sources<{ sources?: { path: string; name?: string }[] }>().catch(() => null),
api.eventTypes<{ event_types?: EventType[] }>().catch(() => null),
api.mappings<{ mappings?: Mapping[] }>().catch(() => null),
api.bindings<{ bindings?: Binding[] }>().catch(() => null),
api.sources<{ sources?: { path: string; name?: string }[] }>().catch((err) => { readError = String((err as Error).message || err); return null; }),
api.eventTypes<{ event_types?: EventType[] }>().catch((err) => { readError = String((err as Error).message || err); return null; }),
api.mappings<{ mappings?: Mapping[] }>().catch((err) => { readError = String((err as Error).message || err); return null; }),
api.bindings<{ bindings?: Binding[] }>().catch((err) => { readError = String((err as Error).message || err); return null; }),
loadCaptures(),
]);
sources.value = (listed?.sources ?? []).map((s) => s.path);
@@ -93,6 +100,8 @@ onMounted(async () => {
eventTypes.value = types?.event_types ?? [];
mappings.value = mapped?.mappings ?? [];
bindings.value = bound?.bindings ?? [];
bindingsLoaded.value = bound !== null;
loadError.value = [listed, types, mapped, bound].some((leg) => leg === null) ? readError || "Couldn't load the bind form" : "";
if (props.binding) {
source.value = props.binding.matcher?.source ?? "";
const mapping = mappings.value.find((m) => String(m.id) === props.binding?.mapping_id);
@@ -104,7 +113,8 @@ onMounted(async () => {
}
for (const [name] of inputs.value) rows.value[name] ??= { from: "path", path: "", value: "" };
loading.value = false;
});
}
onMounted(loadAll);
useLiveResource("captures", () => void loadCaptures(), 500);
const sourcePath = computed(() => (source.value === NEW_SOURCE ? newSource.value.trim() : source.value));
@@ -186,6 +196,12 @@ async function createSource(): Promise<void> {
async function save(): Promise<void> {
if (blockers.value.length || !capture.value) return;
// Without the bindings list, sharedMapping() cannot tell whether the
// mapping is shared, and mappingUpdate must not run on it.
if (props.binding?.mapping_id && !bindingsLoaded.value) {
error.value = "The bindings list did not load, so this edit cannot tell whether the mapping is shared. Retry the load first.";
return;
}
saving.value = true;
error.value = "";
try {
@@ -261,6 +277,10 @@ const resume = () => transition(api.bindingResume, "pending_approval");
</header>
<div v-if="loading" class="flex flex-1 items-center justify-center"><Spinner /></div>
<div v-else-if="loadError" class="flex flex-1 flex-col items-center justify-center gap-3 p-4">
<Alert variant="destructive" class="max-w-md"><AlertDescription>{{ loadError }}</AlertDescription></Alert>
<Button type="button" variant="outline" size="sm" @click="loadAll">Retry</Button>
</div>
<form v-else class="flex-1 space-y-5 overflow-y-auto px-4 py-4" @submit.prevent="save">
<section class="space-y-1.5">
<Label for="bind-source" class="text-xs font-medium text-fg-muted">Source</Label>
+7 -3
View File
@@ -10,8 +10,8 @@ import ScheduleTrigger from "./ScheduleTrigger.vue";
import SpecList from "./SpecList.vue";
import type { WorkflowTrigger } from "./workflow-triggers";
defineProps<{ yaml: string; triggers: WorkflowTrigger[] }>();
const emit = defineEmits<{ "update:yaml": [string]; bound: [] }>();
defineProps<{ yaml: string; triggers: WorkflowTrigger[]; error?: string }>();
const emit = defineEmits<{ "update:yaml": [string]; bound: []; reload: [] }>();
// The bind flow takes over the card; a null binding is a new one.
const binding = ref<Binding | null | undefined>();
@@ -53,7 +53,11 @@ function open(trigger: WorkflowTrigger): void {
</div>
</li>
</ul>
<p v-else class="text-xs text-fg-subtle">Manual runs only.</p>
<div v-if="error" class="flex items-center gap-2 text-xs text-danger" role="alert">
{{ error }}
<Button variant="link" size="xs" class="px-0" @click="emit('reload')">Retry</Button>
</div>
<p v-else-if="!triggers.length" class="text-xs text-fg-subtle">Manual runs only.</p>
</section>
<SpecList :yaml="yaml" field="inputs" @update:yaml="emit('update:yaml', $event)" />
</div>
+9 -5
View File
@@ -80,7 +80,7 @@ function openStepAt(path: StepPath | null): void {
}
const localError = ref("");
const { runs, error: runsError, loading: runsLoading, watched, watchedRun, stages, attempt, pick, follow, refresh } = useWorkflowRuns(selected);
const { runs, error: runsError, loading: runsLoading, watched, watchedRun, stages, stagesError, attempt, pick, follow, refresh } = useWorkflowRuns(selected);
const stepTab = ref("definition");
// A run without a pinned definition cannot be matched to the drawn steps, so
// the canvas draws the definition alone.
@@ -114,9 +114,9 @@ async function restartFrom(from: string): Promise<void> {
restarting.value = false;
}
}
const { triggers, reload: reloadTriggers } = useWorkflowTriggers(selected);
const { triggers, reload: reloadTriggers, error: triggersError } = useWorkflowTriggers(selected);
const { revisions, error: historyError } = useWorkflowHistory(selected);
const { revisions, error: historyError, reload: reloadHistory } = useWorkflowHistory(selected);
const historyRevision = ref(0);
const historyMode = ref("yaml");
// The revision a run used, matched by the definition it pinned.
@@ -454,6 +454,10 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
<p>Could not load recent runs: {{ runsError }}</p>
<Button type="button" variant="outline" size="sm" @click="refresh">Retry runs</Button>
</div>
<div v-if="stagesError" class="text-sm text-danger" role="alert">
<p>Could not load the watched run's stages: {{ stagesError }}</p>
<Button type="button" variant="outline" size="sm" @click="refresh">Retry</Button>
</div>
<p v-if="view === 'canvas' && unpinned" class="text-xs text-fg-muted" role="status">No snapshot for this run.</p>
<!-- Kept mounted so an Archie turn started here still finishes, unlocks the
editor and loads its draft when the operator switches tabs. -->
@@ -482,7 +486,7 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
>
<template #body="{ data }">
<fieldset v-if="data.kind === 'workflow'" :disabled="!!pinnedYaml" class="min-w-0"><WorkflowSettings :yaml="canvasYaml" @update:yaml="yaml = $event" /></fieldset>
<fieldset v-else-if="data.kind === 'start'" :disabled="!!pinnedYaml" class="min-w-0"><TriggerSettings :yaml="canvasYaml" :triggers="triggers" @update:yaml="yaml = $event" @bound="reloadTriggers" /></fieldset>
<fieldset v-else-if="data.kind === 'start'" :disabled="!!pinnedYaml" class="min-w-0"><TriggerSettings :yaml="canvasYaml" :triggers="triggers" :error="triggersError" @update:yaml="yaml = $event" @bound="reloadTriggers" @reload="reloadTriggers" /></fieldset>
<template v-else-if="data.path">
<div v-if="data.run && watchedRun" 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>
@@ -508,7 +512,7 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
</div>
</TabsContent>
<TabsContent value="history" class="max-md:min-h-0 max-md:overflow-y-auto">
<WorkflowHistory v-model:selected="historyRevision" v-model:mode="historyMode" :revisions="revisions" :current="yaml" :error="historyError" @restore="restoreRevision" />
<WorkflowHistory v-model:selected="historyRevision" v-model:mode="historyMode" :revisions="revisions" :current="yaml" :error="historyError" @restore="restoreRevision" @retry="reloadHistory" />
</TabsContent>
<TabsContent value="performance" class="grid gap-4 max-md:min-h-0 max-md:overflow-y-auto"><slot name="performance" /></TabsContent>
<TabsContent value="runs" class="max-md:min-h-0 max-md:overflow-y-auto"><slot name="runs" /></TabsContent>
+5 -2
View File
@@ -13,7 +13,7 @@ import WorkflowCanvas from "./WorkflowCanvas.vue";
import { lineDiff, stepMarks, type WorkflowRevision } from "./workflow-revisions";
const props = defineProps<{ revisions: WorkflowRevision[]; current: string; error?: string }>();
const emit = defineEmits<{ restore: [yaml: string] }>();
const emit = defineEmits<{ restore: [yaml: string]; retry: [] }>();
const selected = defineModel<number>("selected", { default: 0 });
const mode = defineModel<string>("mode", { default: "yaml" });
@@ -54,7 +54,10 @@ const CHANGE_VARIANTS = { added: "default", edited: "secondary", removed: "destr
<span class="mt-0.5 block truncate text-xs text-fg-muted" :title="item.at">{{ item.actor || "unknown" }} · {{ item.source || "unknown" }} · <Timestamp :at="item.at" /></span>
</button>
</li>
<li v-if="!revisions.length" class="px-3 py-2 text-sm text-fg-muted">{{ error || "No recorded changes" }}</li>
<li v-if="!revisions.length && error" class="px-3 py-2 text-sm text-danger">
{{ error }} <Button variant="link" size="xs" class="px-0" @click="emit('retry')">Retry</Button>
</li>
<li v-else-if="!revisions.length" class="px-3 py-2 text-sm text-fg-muted">No recorded changes</li>
</ol>
<!-- Below md the list above is hidden: one select picks the revision. -->
<Select v-if="revisions.length" :model-value="String(selected)" @update:model-value="selected = Number($event)">
+8 -2
View File
@@ -56,19 +56,25 @@ export function useWorkflowRuns(workflow: Ref<string>) {
}
}
// A failed attempts read is an error, not a canvas with no run states.
const stagesError = ref("");
async function loadStages(): Promise<void> {
if (!watched.value) {
if (stages.value.length) stages.value = [];
attempt.value = 0;
pinned.value = undefined;
stagesError.value = "";
return;
}
const requested = watched.value;
let readError = "";
const [view, debug] = await Promise.all([
api.taskAttempts<AttemptsView>(requested).catch(() => null),
api.taskAttempts<AttemptsView>(requested).catch((err) => { readError = String((err as Error).message || err); return null; }),
pinned.value === undefined ? api.taskDebug<DebugView>(requested).catch(() => null) : null,
]);
if (watched.value !== requested) return;
stagesError.value = view === null ? readError || "Couldn't load the run's stages" : "";
if (debug) pinned.value = debug.task?.workflow_definition_yaml ?? "";
const latest = [...(view?.attempts ?? [])].sort((a, b) => b.attempt - a.attempt)[0];
// A live refresh that changed nothing must not redraw the canvas, which
@@ -116,5 +122,5 @@ export function useWorkflowRuns(workflow: Ref<string>) {
await refresh();
}
return { runs, error, loading, watched, watchedRun, stages, attempt, pick, follow, refresh };
return { runs, error, loading, watched, watchedRun, stages, stagesError, attempt, pick, follow, refresh };
}
+8 -3
View File
@@ -142,13 +142,18 @@ export function useWorkflowTriggers(id: Ref<string>) {
const workflows = useWorkflowsStore();
const bindings = ref<TriggerSources["bindings"]>([]);
const schedules = ref<TriggerSources["schedules"]>([]);
// A failed read is an error, not an empty trigger list: "Manual runs only"
// would be a lie while the server is unreachable.
const error = ref("");
async function reload(): Promise<void> {
let readError = "";
const [response, listed] = await Promise.all([
api.bindings<{ bindings?: Binding[] }>().catch(() => null),
api.schedules<{ schedules?: TriggerSources["schedules"] }>().catch(() => null),
api.bindings<{ bindings?: Binding[] }>().catch((err) => { readError = String((err as Error).message || err); return null; }),
api.schedules<{ schedules?: TriggerSources["schedules"] }>().catch((err) => { readError = String((err as Error).message || err); return null; }),
]);
bindings.value = response?.bindings ?? [];
schedules.value = listed?.schedules ?? [];
error.value = response === null || listed === null ? readError || "Couldn't load triggers" : "";
}
onMounted(reload);
const triggers = computed(() =>
@@ -160,5 +165,5 @@ export function useWorkflowTriggers(id: Ref<string>) {
schedules: schedules.value,
}),
);
return { triggers, reload };
return { triggers, reload, error };
}