81 lines
3.6 KiB
Vue
81 lines
3.6 KiB
Vue
<script setup lang="ts">
|
|
import { computed } from "vue";
|
|
import { ArrowUpRight } from "@lucide/vue";
|
|
|
|
import { ago, compact } from "@/lib/format";
|
|
import { cn } from "@/lib/utils";
|
|
import { stageStatusMeta } from "./stage-rail";
|
|
import KeyValueList from "./KeyValueList.vue";
|
|
import StageRail from "./StageRail.vue";
|
|
import { STATUS_FILL } from "@/lib/status";
|
|
import { useTaskRun } from "./use-task-run";
|
|
import { duration } from "./timeline-event";
|
|
|
|
/** The task's right rail: every attempt with its outcome, the selected
|
|
* attempt's stages, and the task's details. */
|
|
const run = useTaskRun();
|
|
|
|
const attempts = computed(() => [...(run.attempts?.attempts ?? [])].reverse());
|
|
const dot = (status?: string) => STATUS_FILL[stageStatusMeta(status).kind];
|
|
const details = computed(() => {
|
|
const task = run.task;
|
|
if (!task) return [];
|
|
const rows: { label: string; value: string; mono?: boolean; href?: string; arrow?: boolean }[] = [
|
|
{ label: "Workflow", value: task.workflow || "none" },
|
|
];
|
|
if (task.repo) rows.push({ label: "Repository", value: `${task.owner}/${task.repo}`, mono: true, href: task.repo_url });
|
|
if (task.issue_url && task.issue_number) rows.push({ label: "Issue", value: `#${task.issue_number}`, mono: true, href: task.issue_url, arrow: true });
|
|
if (task.tokens_used) rows.push({ label: "Tokens", value: compact(task.tokens_used), mono: true });
|
|
return rows;
|
|
});
|
|
const panel = "rounded-xl bg-card p-4 ring-1 ring-foreground/10";
|
|
const heading = "mb-2 text-[11px] font-medium tracking-[0.06em] text-fg-subtle uppercase";
|
|
</script>
|
|
|
|
<template>
|
|
<aside class="grid gap-4" aria-label="Task details">
|
|
<section v-if="attempts.length" :class="panel" aria-labelledby="rail-attempts">
|
|
<h2 id="rail-attempts" :class="heading">Attempts</h2>
|
|
<ul class="flex flex-col gap-0.5">
|
|
<li v-for="a in attempts" :key="a.attempt">
|
|
<button
|
|
type="button"
|
|
:aria-current="Number(a.attempt) === Number(run.attemptNumber) ? 'true' : undefined"
|
|
:class="
|
|
cn(
|
|
'flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-secondary',
|
|
Number(a.attempt) === Number(run.attemptNumber) && 'bg-secondary font-medium',
|
|
)
|
|
"
|
|
@click="run.selectAttempt(Number(a.attempt))"
|
|
>
|
|
<span class="size-2 shrink-0 rounded-full" :class="dot(a.status)" aria-hidden="true" />
|
|
<span class="flex-1">Attempt {{ a.attempt }}</span>
|
|
<span class="text-xs text-fg-subtle">{{ a.status ? stageStatusMeta(a.status).label : "" }}</span>
|
|
</button>
|
|
<p v-if="a.started_at" class="px-3 pb-1 pl-7 text-xs text-fg-subtle">
|
|
{{ ago(a.started_at) }}<template v-if="a.duration_ms"> · {{ duration(a.duration_ms) }}</template>
|
|
</p>
|
|
</li>
|
|
</ul>
|
|
</section>
|
|
|
|
<section :class="panel" aria-labelledby="rail-stages">
|
|
<h2 id="rail-stages" :class="heading">Stages</h2>
|
|
<StageRail :state="run.attempts" />
|
|
</section>
|
|
|
|
<section v-if="run.task" :class="panel" aria-labelledby="rail-details">
|
|
<h2 id="rail-details" :class="heading">Details</h2>
|
|
<KeyValueList :rows="details">
|
|
<template #value="{ row }">
|
|
<a v-if="row.href" :href="row.href" target="_blank" rel="noreferrer" class="inline-flex items-center gap-0.5 hover:underline"
|
|
>{{ row.value }}<ArrowUpRight v-if="row.arrow" class="size-3" aria-hidden="true"
|
|
/></a>
|
|
<template v-else>{{ row.value }}</template>
|
|
</template>
|
|
</KeyValueList>
|
|
</section>
|
|
</aside>
|
|
</template>
|