refactor(ui): one key/value list for a task's inputs, outputs and details, sized to its content
This commit is contained in:
1 parent
3202386eaa
commit
d876c150eb
5 files changed
+120
-112
No files matched your search
@@ -0,0 +1,15 @@
|
||||
<script setup lang="ts" generic="Row extends { label: string; value?: string; mono?: boolean }">
|
||||
/** A list of labelled values: the labels in one column, the values in the other. */
|
||||
defineProps<{ rows: Row[] }>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<dl class="grid grid-cols-[6.5rem_1fr] gap-x-3 gap-y-2 text-xs">
|
||||
<template v-for="row in rows" :key="row.label">
|
||||
<dt class="leading-5 text-fg-subtle [overflow-wrap:anywhere]">{{ row.label }}</dt>
|
||||
<dd class="min-w-0 leading-5 [overflow-wrap:anywhere]" :class="row.mono && 'font-mono'">
|
||||
<slot name="value" :row="row">{{ row.value }}</slot>
|
||||
</dd>
|
||||
</template>
|
||||
</dl>
|
||||
</template>
|
||||
@@ -20,6 +20,7 @@ import { firstLine } from "./first-line";
|
||||
import { statusKind, statusLabel } from "@/lib/task-meta";
|
||||
import { cn } from "@/lib/utils";
|
||||
import DispatchLinks from "@/bindings/DispatchLinks.vue";
|
||||
import KeyValueList from "./KeyValueList.vue";
|
||||
import StartNewRun from "./StartNewRun.vue";
|
||||
import TaskRowActions from "./TaskRowActions.vue";
|
||||
import { shownActionIds } from "./task-actions";
|
||||
@@ -85,6 +86,7 @@ const HEAD_ACTIONS = ["archive", "merge"];
|
||||
const rows = (values?: Record<string, unknown>) =>
|
||||
Object.entries(values ?? {}).map(([label, value]) => ({
|
||||
label,
|
||||
mono: true,
|
||||
value: typeof value === "string" ? value : JSON.stringify(value),
|
||||
}));
|
||||
const sections = computed(() =>
|
||||
@@ -150,7 +152,7 @@ const headerActions = computed(() =>
|
||||
|
||||
<div
|
||||
v-if="sections.length || run.attempts?.called_by"
|
||||
class="mt-3 grid gap-4 rounded-xl bg-card p-4 ring-1 ring-foreground/10"
|
||||
class="mt-3 flex w-fit max-w-full flex-wrap gap-x-10 gap-y-4 rounded-xl bg-card p-4 ring-1 ring-foreground/10"
|
||||
>
|
||||
<p v-if="run.attempts?.called_by" class="text-xs text-fg-subtle">
|
||||
Called by
|
||||
@@ -158,14 +160,9 @@ const headerActions = computed(() =>
|
||||
>task #{{ run.attempts.called_by }}</RouterLink
|
||||
>
|
||||
</p>
|
||||
<section v-for="section in sections" :key="section.title" :aria-label="section.title">
|
||||
<section v-for="section in sections" :key="section.title" :aria-label="section.title" class="min-w-0">
|
||||
<h2 class="mb-2 text-[11px] font-medium tracking-[0.06em] text-fg-subtle uppercase">{{ section.title }}</h2>
|
||||
<dl class="grid grid-cols-[6.5rem_1fr] gap-x-3 gap-y-1.5 text-xs">
|
||||
<template v-for="row in section.rows" :key="row.label">
|
||||
<dt class="text-fg-subtle [overflow-wrap:anywhere]">{{ row.label }}</dt>
|
||||
<dd class="font-mono text-fg-muted [overflow-wrap:anywhere]">{{ row.value }}</dd>
|
||||
</template>
|
||||
</dl>
|
||||
<KeyValueList :rows="section.rows" class="text-fg-muted" />
|
||||
</section>
|
||||
</div>
|
||||
|
||||
|
||||
+19
-23
@@ -5,6 +5,7 @@ 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";
|
||||
@@ -16,6 +17,17 @@ 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>
|
||||
@@ -55,30 +67,14 @@ const heading = "mb-2 text-[11px] font-medium tracking-[0.06em] text-fg-subtle u
|
||||
|
||||
<section v-if="run.task" :class="panel" aria-labelledby="rail-details">
|
||||
<h2 id="rail-details" :class="heading">Details</h2>
|
||||
<dl class="grid grid-cols-[6.5rem_1fr] gap-x-3 gap-y-2 text-sm">
|
||||
<dt class="text-fg-subtle">Workflow</dt>
|
||||
<dd class="truncate text-xs leading-5">{{ run.task.workflow || "none" }}</dd>
|
||||
<template v-if="run.task.repo">
|
||||
<dt class="text-fg-subtle">Repository</dt>
|
||||
<dd class="truncate font-mono text-xs leading-5">
|
||||
<a v-if="run.task.repo_url" :href="run.task.repo_url" target="_blank" rel="noreferrer" class="hover:underline"
|
||||
>{{ run.task.owner }}/{{ run.task.repo }}</a
|
||||
><template v-else>{{ run.task.owner }}/{{ run.task.repo }}</template>
|
||||
</dd>
|
||||
<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>
|
||||
<template v-if="run.task.issue_url && run.task.issue_number">
|
||||
<dt class="text-fg-subtle">Issue</dt>
|
||||
<dd class="font-mono text-xs leading-5">
|
||||
<a :href="run.task.issue_url" target="_blank" rel="noreferrer" class="inline-flex items-center gap-0.5 hover:underline"
|
||||
>#{{ run.task.issue_number }}<ArrowUpRight class="size-3" aria-hidden="true"
|
||||
/></a>
|
||||
</dd>
|
||||
</template>
|
||||
<template v-if="run.task.tokens_used">
|
||||
<dt class="text-fg-subtle">Tokens</dt>
|
||||
<dd class="font-mono text-xs leading-5">{{ compact(run.task.tokens_used) }}</dd>
|
||||
</template>
|
||||
</dl>
|
||||
</KeyValueList>
|
||||
</section>
|
||||
</aside>
|
||||
</template>
|
||||
Reference in new issue
Block a user