Files
archie/ui/src/workflows/StepRun.vue
T
sam 493eb43944 fix(ui/topbar): replace Jump to with a command palette, drop filler chrome (#1650)
* fix(ui/topbar): replace Jump to with a command palette, drop filler chrome

Jump to opens a shadcn-vue Command dialog that finds pages, tasks and
workflows by name. The connection indicator shows only when the stream is
lost, the dead documentation link is gone, and the profile menu label has
no stray whitespace.

* fix(ui): trim stray whitespace from template text and drop em dashes from copy

Element text that started or ended with a line break rendered with leading
and trailing spaces. Also removes the unused 'soon' nav state and the nav
group components no route reaches.

* fix(ui): drop the space a hidden spinner left before button text

* fix(ui/status): one dense Status page, full-width settings, problems-only apply status

Status drops its tabs and the duplicate health card; services list only
what is wrong. Settings pages use the full width, the resizable sidebar
handle is gone, and apply status shows only processes that have not
applied a change. PageHeader puts the title and actions on one line.

* refactor(ui): use shadcn ToggleGroup and Badge, drop SegmentedControl and StatusPill

Status badges show only when a state needs attention: no Running, Enabled,
Active, Listening or live pills next to healthy rows. Removes the unused
pagination, radio-group and scroll-area components.

* fix(ui/history): use the shadcn Table with fixed columns so nothing is clipped

* fix(ui/workflows): apply ?workflow= only once the workflow is listed

Selecting it before the definitions loaded opened an empty canvas.

* refactor(ui/workflows): use shadcn Input, NativeSelect, Checkbox and Button in editors

Replaces hand-rolled inputs, selects, the repository mode switch and icon
buttons in the workflow editor, bind dialog, harness page, sources panel
and review gate. Adds the upstream shadcn-vue NativeSelect.

* style(ui): rounded-rectangle controls instead of pills

Halves the radius scale so inputs, selects and buttons stop reading as
pills, and badges and chips lose their full rounding.

* fix(ui/alerts): centre the bell's failed state and stop it contradicting Needs you

* fix(ui/tasks): one header line, aligned columns, no placeholder issue numbers

Tasks puts its filters beside the title and drops the stat tiles the
dashboard already shows. Sort headers align with their cells, chat tasks
no longer show their synthetic issue number, and Logs and the task
not-found page use the shared header.

* fix(ui/dashboard): shared header and cards, empty cards stay silent

Needs you uses the shadcn Card and drops its duplicate Open button; quality
gates and token outlook render only when there is something to show; the
throughput strip moves into the dashboard, its only user.

* refactor(ui/stores): one Pinia store per feature

Splits the site-wide control-plane store and the module-level refs into
settings, workflows, tasks, events, org and session stores. Identity
requests move into lib/api. Drops store fields nothing read: per-resource
stream state, the states map and loadApplyStatus.

* fix(ui/org): one header for the org area, sections drop their repeated titles

The org name is the page title with the admin's org switcher and New org
beside it; Members and Workspaces tables sit in cards like other pages.

* fix(ui/events): shadcn Tabs for the capture, map and bind steps

Replaces the numbered step strip with line tabs that carry each step's
count; the Listening pill is gone and Capture off shows only when it is.

* fix(ui/workflows): confirm a workflow delete in an AlertDialog, not window.confirm

* style(ui/settings): denser setting rows
2026-10-12 04:40:21 +11:00

143 lines
8.6 KiB
Vue

<script setup lang="ts">
import { Button } from "@/components/ui/button";
import { computed, onUnmounted, ref, watch } from "vue";
import { api } from "@/lib/api";
import { useLiveResource } from "@/stores/session";
import { Badge } from "@/components/ui/badge";
import ChangeCapture from "@/tasks/ChangeCapture.vue";
import TaskLogs from "@/tasks/TaskLogs.vue";
import { stageStatusMeta } from "@/tasks/stage-rail";
import { describeTimelineEvent, duration } from "@/tasks/timeline-event";
import type { ChangesState, LogState, TaskEvent, TaskRecord } from "@/tasks/task-run";
import type { StageRun } from "./workflow-graph";
const props = defineProps<{ task: TaskRecord; attempt: number; stage: StageRun; stages: StageRun[] }>();
const events = ref<TaskEvent[]>([]);
const changes = ref<ChangesState>();
const logs = ref<LogState | null>();
const activityError = ref("");
const changesError = ref("");
const expanded = ref(false);
const key = computed(() => `${props.task.id}/${props.attempt}/${props.stage.id ?? props.stage.name}`);
let generation = 0;
let timer: ReturnType<typeof setInterval> | undefined;
let loading = false;
let queued = false;
async function refresh(): Promise<void> {
if (!props.attempt) return;
if (loading) { queued = true; return; }
loading = true;
const current = generation;
const id = String(props.task.id);
const params = { attempt: props.attempt };
const results = await Promise.allSettled([
api.taskDebug<{ events?: TaskEvent[] }>(id, params),
api.taskChanges<ChangesState>(id, params),
api.taskLogs<LogState>(id, { ...params, stage: props.stage.name }),
]);
if (current !== generation) return;
const [activity, capture, log] = results;
activityError.value = activity.status === "rejected" ? "Could not load step activity" : "";
if (activity.status === "fulfilled") events.value = activity.value.events ?? [];
changesError.value = capture.status === "rejected" ? "Could not load captured changes" : "";
if (capture.status === "fulfilled") changes.value = capture.value;
logs.value = log.status === "fulfilled" ? log.value : null;
loading = false;
if (queued) { queued = false; void refresh(); }
}
watch(key, () => {
generation++;
loading = false;
queued = false;
events.value = [];
changes.value = undefined;
logs.value = undefined;
activityError.value = "";
changesError.value = "";
expanded.value = false;
void refresh();
}, { immediate: true });
watch(() => props.stage.status, (status) => {
clearInterval(timer);
void refresh();
// Logs can arrive between task events; read them while the stage is active.
if (status === "running") timer = setInterval(() => void refresh(), 2000);
}, { immediate: true });
useLiveResource("tasks", () => void refresh(), 300);
onUnmounted(() => { generation++; clearInterval(timer); });
const meta = computed(() => stageStatusMeta(props.stage.status));
const names = computed(() => new Set([props.stage.name, ...(props.stage.agents ?? []).map((agent) => agent.name.split("/").at(-1) ?? agent.name)]));
const nextStart = computed(() => props.stages.find((stage) => stage.name === props.stage.name && stage.started_at && props.stage.started_at && stage.started_at > props.stage.started_at)?.started_at);
function inWindow(at: string | number | Date | undefined): boolean {
if (!props.stage.started_at || !at) return props.stages.filter((stage) => stage.name === props.stage.name).length === 1;
const time = new Date(at).getTime();
return time >= Date.parse(props.stage.started_at) && (!props.stage.finished_at || time <= Date.parse(props.stage.finished_at)) && (!nextStart.value || time < Date.parse(nextStart.value));
}
const activity = computed(() => events.value.filter((event) => {
if (Number(event.attempt) !== props.attempt) return false;
if (event.data?.step_id != null) return Number(event.data.step_id) === props.stage.id;
return names.value.has(event.stage ?? "") && inWindow(event.at);
}).sort((a, b) => String(a.at ?? "").localeCompare(String(b.at ?? ""))));
const groups = computed(() => {
const agents = props.stage.agents ?? [];
const branches = new Set(["", ...agents.map((agent) => agent.name.includes("/") ? agent.name.split("/")[0]! : ""), ...activity.value.map((event) => String(event.data?.branch ?? ""))]);
return [...branches].map((branch) => ({
branch,
agents: agents.filter((agent) => (agent.name.includes("/") ? agent.name.split("/")[0] : "") === branch),
reports: activity.value.filter((event) => event.kind === "agent_finish" && String(event.data?.branch ?? "") === branch),
tools: activity.value.filter((event) => event.kind === "tool_call" && String(event.data?.branch ?? "") === branch),
})).filter((group) => group.agents.length || group.reports.length || group.tools.length);
});
const captures = computed(() => (changes.value?.captures ?? []).filter((capture) => capture.stage === props.stage.name && inWindow(capture.captured_at)));
const scopedLogs = computed(() => logs.value ? { ...logs.value, entries: (logs.value.entries ?? []).filter((entry) => inWindow(entry.time)) } : logs.value);
</script>
<template>
<div class="space-y-5 p-4 text-sm">
<div class="flex items-center gap-2">
<Badge :variant="meta.kind">{{ meta.label }}</Badge>
<span class="text-xs text-muted-foreground">{{ stage.duration_ms == null ? "Duration not recorded" : duration(stage.duration_ms) }}</span>
<span class="ml-auto text-xs text-muted-foreground">Attempt {{ attempt }}</span>
</div>
<p v-if="stage.error" class="rounded-md bg-danger-soft p-3 break-words whitespace-pre-wrap text-danger">{{ stage.error }}</p>
<p v-if="activityError" role="alert" class="text-danger">{{ activityError }}</p>
<section v-for="group in groups" :key="group.branch" class="space-y-3">
<h3 v-if="group.branch" class="font-medium">{{ group.branch }}</h3>
<p v-else-if="groups.length > 1" class="text-xs text-muted-foreground">Activity without branch attribution</p>
<div v-for="agent in group.agents" :key="agent.id" class="space-y-1">
<div class="flex items-center gap-2 text-xs"><span class="font-mono">{{ agent.name.split('/').at(-1) }}</span><Badge :variant="stageStatusMeta(agent.status).kind">{{ agent.status }}</Badge></div>
<p v-if="agent.detail" class="break-words whitespace-pre-wrap">{{ agent.detail }}</p>
</div>
<div v-for="(report, i) in group.reports" :key="i" class="space-y-1">
<p v-if="report.detail && !group.agents.some((agent) => agent.detail === report.detail)" class="break-words whitespace-pre-wrap">{{ report.detail }}</p>
<p class="text-xs text-muted-foreground">Agent's own report · {{ describeTimelineEvent(report).title }}</p>
</div>
<div v-if="group.tools.length" class="space-y-1">
<h4 class="text-xs font-medium text-muted-foreground">Tool calls · {{ group.tools.length }}</h4>
<ol class="divide-y divide-border rounded-md border border-border">
<li v-for="(tool, i) in expanded ? group.tools : group.tools.slice(0, 12)" :key="i" class="px-3 py-2">
<div class="flex justify-between gap-2 text-xs"><span class="font-mono">{{ tool.data?.tool }}</span><span :class="tool.data?.failed ? 'text-danger' : 'text-muted-foreground'">{{ tool.data?.failed ? 'Failed' : 'Returned' }}</span></div>
<p v-if="tool.detail" class="mt-1 break-words whitespace-pre-wrap text-xs text-muted-foreground">{{ tool.detail }}</p>
</li>
</ol>
<Button v-if="group.tools.length > 12" type="button" variant="link" size="xs" class="px-0" @click="expanded = !expanded">{{ expanded ? 'Show first 12' : `Show all ${group.tools.length}` }}</Button>
</div>
<p v-if="group.reports.length" class="text-xs text-muted-foreground">{{ group.reports.map((report) => describeTimelineEvent(report).detail).filter(Boolean).join(' · ') }}</p>
<p v-else-if="group.agents.length" class="text-xs text-muted-foreground">{{ group.agents.reduce((sum, agent) => sum + agent.tokens_used, 0).toLocaleString() }} tokens recorded</p>
</section>
<section class="space-y-3">
<h3 class="text-xs font-medium text-muted-foreground">Captured changes</h3>
<p v-if="changesError" role="alert" class="text-danger">{{ changesError }}</p>
<ChangeCapture v-for="(capture, i) in captures" :key="i" :capture="capture" :task="task" />
<p v-if="changes && !captures.length" class="text-xs text-muted-foreground">No changes captured for this step</p>
</section>
<section class="space-y-2">
<h3 class="text-xs font-medium text-muted-foreground">Log <span title="Only lines tagged with this stage are shown">· stage-tagged lines</span></h3>
<TaskLogs :state="scopedLogs" :attempt="attempt" :filterable="false" />
</section>
</div>
</template>