feat(ui): the workflow canvas watches a run live: each step shows its state, duration and error, and the view follows the step in progress

This commit is contained in:
sam committed 2026-10-05 00:34:06 +11:00
1 parent dfff9f6b11
commit 720cd7a6f0
7 files changed
+270 -81

No files matched your search

+40 -2
View File
@@ -1,16 +1,43 @@
<script setup lang="ts">
import { computed } from "vue";
import { Handle, Position } from "@vue-flow/core";
import { Flag, GitBranch, Play, Repeat, SkipForward } from "@lucide/vue";
import type { StepNodeData } from "./workflow-graph";
defineProps<{ data: StepNodeData }>();
const props = defineProps<{ data: StepNodeData }>();
const STATE_CLASSES: Record<string, string> = {
ok: "border-ok/70",
failed: "border-danger/80",
interrupted: "border-warn/70",
running: "border-info step-running",
};
const stateClass = computed(() => {
if (props.data.kind === "start") return "border-primary/60";
return STATE_CLASSES[props.data.run?.status ?? ""] ?? "border-border";
});
const STATE_LABELS: Record<string, string> = {
ok: "Done",
failed: "Failed",
interrupted: "Interrupted",
running: "Running",
};
function duration(ms?: number): string {
if (ms === undefined) return "";
if (ms < 1000) return `${ms} ms`;
const seconds = Math.round(ms / 1000);
return seconds < 60 ? `${seconds}s` : `${Math.floor(seconds / 60)}m ${seconds % 60}s`;
}
</script>
<template>
<div
class="w-60 rounded-lg border bg-card px-3 py-2 text-left shadow-sm"
:class="data.kind === 'start' ? 'border-primary/60' : 'border-border'"
:class="[stateClass, data.run ? '' : data.kind === 'step' && 'opacity-90']"
>
<Handle v-if="data.kind !== 'start'" type="target" :position="Position.Top" />
<Handle id="data-in" type="target" :position="Position.Right" class="!opacity-0" />
@@ -34,6 +61,17 @@ defineProps<{ data: StepNodeData }>();
<SkipForward class="size-3" aria-hidden="true" />continues
</span>
</div>
<div
v-if="data.run"
class="mt-1 flex items-center gap-1.5 text-[11px]"
:class="{ 'text-ok': data.run.status === 'ok', 'text-danger': data.run.status === 'failed', 'text-info': data.run.status === 'running', 'text-warn': data.run.status === 'interrupted' }"
:title="data.run.error || undefined"
>
<span class="size-1.5 rounded-full bg-current" aria-hidden="true" />
{{ STATE_LABELS[data.run.status] ?? data.run.status }}
<span v-if="data.run.duration_ms !== undefined" class="text-fg-subtle">{{ duration(data.run.duration_ms) }}</span>
<span v-if="data.run.error" class="truncate text-danger">{{ data.run.error }}</span>
</div>
<Handle type="source" :position="Position.Bottom" />
<Handle id="data-out" type="source" :position="Position.Right" class="!opacity-0" />
</div>