fix(ui): trim the task page and draw a run's pinned definition on the canvas
This commit is contained in:
9 files changed
+93
-75
No files matched your search
@@ -13,9 +13,14 @@ import {
|
||||
* attempt log render the same entry shape, so the row lives here rather than
|
||||
* being duplicated a second time.
|
||||
*/
|
||||
const props = defineProps<{ entry: LogEntry }>();
|
||||
const props = defineProps<{ entry: LogEntry; omit?: string[] }>();
|
||||
|
||||
const fields = () => Object.entries(props.entry.fields ?? {});
|
||||
// received_at restates the row's time; a page that sets the context (a task's
|
||||
// own log) also omits the fields naming it.
|
||||
const fields = () =>
|
||||
Object.entries(props.entry.fields ?? {}).filter(
|
||||
([k]) => k !== "received_at" && !props.omit?.includes(k),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -81,7 +81,7 @@ const nodeClass = computed(() =>
|
||||
allowed to break, or a long one pushes the status and duration off
|
||||
the row. -->
|
||||
<span
|
||||
class="min-w-0 font-mono font-medium break-words hover:underline"
|
||||
class="min-w-0 text-sm font-medium break-words hover:underline"
|
||||
:class="props.selected ? 'text-primary' : ''"
|
||||
>{{ stage.name || "(unnamed stage)" }}</span
|
||||
>
|
||||
@@ -91,9 +91,7 @@ const nodeClass = computed(() =>
|
||||
meta.label
|
||||
}}</Badge>
|
||||
<span v-else class="sr-only">ok</span>
|
||||
<span class="text-xs text-fg-muted">{{
|
||||
ran ? `ran for ${ran}` : "duration not recorded"
|
||||
}}</span>
|
||||
<span v-if="ran" class="text-xs text-fg-muted">{{ ran }}</span>
|
||||
</button>
|
||||
<div
|
||||
v-if="stage.error"
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
|
||||
import { computed } from "vue";
|
||||
|
||||
import { RUN_TABS } from "./task-run";
|
||||
import { useTaskRun } from "./use-task-run";
|
||||
|
||||
/**
|
||||
* The run page's tab bar. It owns no state and renders no panel: the open tab
|
||||
@@ -15,12 +18,17 @@ import { RUN_TABS } from "./task-run";
|
||||
* ends. Automatic activation is right here because every panel is a local
|
||||
* render, not a fetch: there is no cost to switching.
|
||||
*/
|
||||
const run = useTaskRun();
|
||||
// The sandbox follows a live container; a finished attempt has none to show.
|
||||
const tabs = computed(() =>
|
||||
RUN_TABS.filter((tab) => tab.id !== "sandbox" || run.task?.status === "running"),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TabsList variant="line" class="w-full justify-start">
|
||||
<TabsTrigger
|
||||
v-for="tab in RUN_TABS"
|
||||
v-for="tab in tabs"
|
||||
:key="tab.id"
|
||||
:value="tab.id"
|
||||
class="flex-none px-2"
|
||||
|
||||
@@ -197,6 +197,7 @@ watch([() => route.hash, current], async () => {
|
||||
line?.scrollIntoView({ block: "center" });
|
||||
line?.focus({ preventScroll: true });
|
||||
}, { immediate: true, flush: "post" });
|
||||
const TASK_FIELDS = ["task", "task_id"];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -251,7 +252,7 @@ watch([() => route.hash, current], async () => {
|
||||
ref="logFrame"
|
||||
class="max-h-[62vh] overflow-y-auto rounded-sm border border-border bg-card px-2"
|
||||
>
|
||||
<LogRow v-for="(entry, i) in view.entries" :key="entry.id ?? i" :entry="entry" :data-log-id="entry.id" tabindex="-1" />
|
||||
<LogRow v-for="(entry, i) in view.entries" :key="entry.id ?? i" :entry="entry" :omit="TASK_FIELDS" :data-log-id="entry.id" tabindex="-1" />
|
||||
</div>
|
||||
<div v-if="canPage" class="mt-2 flex flex-wrap items-center gap-2 px-1">
|
||||
<Button variant="outline" size="sm" :disabled="!canOlder" @click="loadOlder">Older</Button>
|
||||
|
||||
@@ -60,17 +60,10 @@ const run = useTaskRun();
|
||||
:task="run.task"
|
||||
/>
|
||||
|
||||
<AttemptConfig
|
||||
v-else-if="tab.id === 'config'"
|
||||
:events="run.events"
|
||||
:attempt="run.attemptNumber"
|
||||
/>
|
||||
|
||||
<DebugView
|
||||
v-else-if="tab.id === 'debug'"
|
||||
:state="run.debugState"
|
||||
:attempt="run.attemptNumber"
|
||||
/>
|
||||
<div v-else-if="tab.id === 'debug'" class="space-y-6">
|
||||
<DebugView :state="run.debugState" :attempt="run.attemptNumber" />
|
||||
<AttemptConfig :events="run.events" :attempt="run.attemptNumber" />
|
||||
</div>
|
||||
|
||||
<SandboxView
|
||||
v-else-if="tab.id === 'sandbox'"
|
||||
|
||||
@@ -29,15 +29,14 @@ export interface TaskRunTab {
|
||||
export const RUN_TABS: TaskRunTab[] = [
|
||||
{ id: "log", label: "Log" },
|
||||
{ id: "changes", label: "Changes" },
|
||||
{ id: "config", label: "Config" },
|
||||
{ id: "debug", label: "Debug" },
|
||||
{ id: "sandbox", label: "Sandbox" },
|
||||
];
|
||||
|
||||
const TAB_IDS = new Set(RUN_TABS.map((tab) => tab.id));
|
||||
|
||||
/** URL ids from before the split-pane layout that must keep resolving. */
|
||||
const LEGACY_TAB_IDS = new Set(["stages"]);
|
||||
/** URL ids for tabs that were folded into another. */
|
||||
const MOVED_TABS: Record<string, string> = { stages: "log", config: "debug" };
|
||||
|
||||
/** The task record as the task list serves it. */
|
||||
export interface TaskRecord {
|
||||
@@ -177,9 +176,7 @@ export function parseTaskId(raw: unknown): number | null {
|
||||
|
||||
export function initialTab(query: LocationQuery | undefined): string {
|
||||
const requested = String(query?.tab ?? "");
|
||||
// tab=stages named the rail before the split pane; the rail is now always
|
||||
// visible, so the URL resolves to the inspector's first tab.
|
||||
if (LEGACY_TAB_IDS.has(requested)) return "log";
|
||||
if (MOVED_TABS[requested]) return MOVED_TABS[requested];
|
||||
return TAB_IDS.has(requested) ? requested : RUN_TABS[0].id;
|
||||
}
|
||||
|
||||
|
||||
@@ -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> {
|
||||
|
||||
Reference in new issue
Block a user