diff --git a/ui/src/workflows/AgentTranscript.vue b/ui/src/workflows/AgentTranscript.vue index 496d0e99f..0f3620ff4 100644 --- a/ui/src/workflows/AgentTranscript.vue +++ b/ui/src/workflows/AgentTranscript.vue @@ -58,7 +58,7 @@ async function load(): Promise { } } -watch(() => [props.taskId, props.attempt], () => { events.value = undefined; void load(); }, { immediate: true }); +watch(() => [props.taskId, props.attempt], () => { events.value = undefined; failed.value = false; void load(); }, { immediate: true }); watch(() => props.running, (running) => { clearInterval(timer); if (running) timer = setInterval(() => void load(), 3000); diff --git a/ui/src/workflows/BindEvent.vue b/ui/src/workflows/BindEvent.vue index 92a550543..4bbe71053 100644 --- a/ui/src/workflows/BindEvent.vue +++ b/ui/src/workflows/BindEvent.vue @@ -140,6 +140,7 @@ const paths = computed(() => payloadPaths(payload.value)); const fields = computed(() => mappingFields(inputs.value, rows.value, repository.value ? repositoryPath.value : "")); let previewTimer: ReturnType | undefined; +let previewGeneration = 0; watch([fields, captureId], () => { clearTimeout(previewTimer); if (captureId.value === null || !fields.value.length) { @@ -147,9 +148,12 @@ watch([fields, captureId], () => { return; } const id = captureId.value; + // Only the newest request may land: an older, slower preview would show + // results for fields that have since changed. + const request = ++previewGeneration; previewTimer = setTimeout(async () => { const result = await api.mappingPreview(id, fields.value).catch(() => null); - if (id === captureId.value) preview.value = result; + if (request === previewGeneration) preview.value = result; }, 250); }, { deep: true, immediate: true }); diff --git a/ui/src/workflows/WorkflowsPage.vue b/ui/src/workflows/WorkflowsPage.vue index 11ac95513..3abf799cb 100644 --- a/ui/src/workflows/WorkflowsPage.vue +++ b/ui/src/workflows/WorkflowsPage.vue @@ -67,21 +67,26 @@ const loading = ref(true); const statsKnown = ref(false); const statsOf = (id: string) => JSON.stringify(data.value.workflows?.find((w) => w.workflow === id) ?? null); +// Live reloads and actions overlap; only the newest read may land. +let loadGeneration = 0; async function load() { + const current = ++loadGeneration; try { // The sidebar's running count and last status come from the per-workflow // statistics: a page of the newest tasks across every workflow would show // nothing for a workflow whose runs are older than that page. const before = statsOf(selected.value); - data.value = keepValue(data.value, (await api.workflows()) ?? {}); + const response = (await api.workflows()) ?? {}; + if (current !== loadGeneration) return; + data.value = keepValue(data.value, response); error.value = null; statsKnown.value = true; // The runs page only changes when the workflow's own statistics do. if (runsFor !== selected.value || statsOf(selected.value) !== before) void loadWorkflowRuns(); } catch (err) { - error.value = describeError(err, errors.common.unknown); + if (current === loadGeneration) error.value = describeError(err, errors.common.unknown); } finally { - loading.value = false; + if (current === loadGeneration) loading.value = false; } } useLiveResource("tasks", () => void load(), 5000);