fix(ui): trim the task page and draw a run's pinned definition on the canvas

This commit is contained in:
sam committed 2026-10-24 11:39:55 +11:00
1 parent 004177f0fb
commit fb7dcbe6cb
9 files changed
+93 -75

No files matched your search

+18 -2
View File
@@ -12,6 +12,10 @@ interface AttemptsView {
attempts?: { attempt: number; stages?: StageRun[] }[];
}
interface DebugView {
task?: { workflow_definition_yaml?: string };
}
const RECENT_RUNS = 20;
/**
@@ -24,6 +28,9 @@ export function useWorkflowRuns(workflow: Ref<string>) {
const watched = ref("");
const stages = ref<StageRun[]>([]);
const attempt = ref(0);
// The task list leaves the pinned definition out, so the watched run's is
// read from its own record.
const pinned = ref<string | undefined>(undefined);
let picked = false;
const error = ref("");
const loading = ref(false);
@@ -53,11 +60,16 @@ export function useWorkflowRuns(workflow: Ref<string>) {
if (!watched.value) {
if (stages.value.length) stages.value = [];
attempt.value = 0;
pinned.value = undefined;
return;
}
const requested = watched.value;
const view = await api.taskAttempts<AttemptsView>(requested).catch(() => null);
const [view, debug] = await Promise.all([
api.taskAttempts<AttemptsView>(requested).catch(() => null),
pinned.value === undefined ? api.taskDebug<DebugView>(requested).catch(() => null) : null,
]);
if (watched.value !== requested) return;
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
// would close any menu open on it.
@@ -87,11 +99,15 @@ export function useWorkflowRuns(workflow: Ref<string>) {
watch(watched, () => {
stages.value = [];
attempt.value = 0;
pinned.value = undefined;
void loadStages();
});
useLiveResource("tasks", () => void refresh(), 300);
const watchedRun = computed(() => runs.value.find((run) => String(run.id) === watched.value));
const watchedRun = computed(() => {
const run = runs.value.find((run) => String(run.id) === watched.value);
return run && pinned.value ? { ...run, workflow_definition_yaml: pinned.value } : run;
});
/** Watches a run that just started, once the task list has it. */
async function follow(id: number | string): Promise<void> {