feat(ui): start tasks from the dashboard and slim it to activity and setup
This commit is contained in:
23 files changed
+297
-487
No files matched your search
@@ -1,46 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, ref } from "vue";
|
||||
import { Bell } from "@lucide/vue";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { api } from "@/lib/api";
|
||||
import { useSessionStore } from "@/stores/session";
|
||||
import { groupBySeverity, type AlertSeverity, type OperatorAlert } from "./alerts";
|
||||
import { useAlerts } from "./use-alerts";
|
||||
|
||||
const alerts = ref<OperatorAlert[]>([]);
|
||||
const failed = ref(false);
|
||||
const { alerts, failed, dismiss } = useAlerts();
|
||||
const open = ref(false);
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
alerts.value = (await api.alerts<{ alerts: OperatorAlert[] }>()).alerts;
|
||||
failed.value = false;
|
||||
} catch {
|
||||
failed.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
async function dismiss(alert: OperatorAlert) {
|
||||
alerts.value = alerts.value.filter((a) => a.id !== alert.id);
|
||||
try {
|
||||
await api.dismissAlert(alert.id);
|
||||
} catch {
|
||||
await load();
|
||||
}
|
||||
}
|
||||
|
||||
// The bell follows the event stream: the store records every alert change as
|
||||
// an event, so the newest alert event's id moving means the list moved. A
|
||||
// reconnect re-reads, since events may have been missed while it was down.
|
||||
const live = useSessionStore();
|
||||
const { activity, connectionRevision } = storeToRefs(live);
|
||||
watch(() => activity.value.find((event) => event.kind === "alert")?.id, load);
|
||||
watch(connectionRevision, load);
|
||||
onMounted(load);
|
||||
|
||||
const groups = computed(() => groupBySeverity(alerts.value));
|
||||
const tone: Record<AlertSeverity, "danger" | "warn" | "info"> = { action: "danger", warning: "warn", info: "info" };
|
||||
const label = computed(() =>
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { storeToRefs } from "pinia";
|
||||
import { onMounted, ref, watch } from "vue";
|
||||
|
||||
import { api } from "@/lib/api";
|
||||
import { useSessionStore } from "@/stores/session";
|
||||
import type { OperatorAlert } from "./alerts";
|
||||
|
||||
/**
|
||||
* The open alerts, following the event stream: the store records every alert
|
||||
* change as an event, so the newest alert event's id moving means the list
|
||||
* moved. A reconnect re-reads, since events may have been missed.
|
||||
*/
|
||||
export function useAlerts() {
|
||||
const alerts = ref<OperatorAlert[]>([]);
|
||||
const failed = ref(false);
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
alerts.value = (await api.alerts<{ alerts: OperatorAlert[] }>()).alerts;
|
||||
failed.value = false;
|
||||
} catch {
|
||||
failed.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
async function dismiss(alert: OperatorAlert) {
|
||||
alerts.value = alerts.value.filter((a) => a.id !== alert.id);
|
||||
try {
|
||||
await api.dismissAlert(alert.id);
|
||||
} catch {
|
||||
await load();
|
||||
}
|
||||
}
|
||||
|
||||
const { activity, connectionRevision } = storeToRefs(useSessionStore());
|
||||
watch(() => activity.value.find((event) => event.kind === "alert")?.id, load);
|
||||
watch(connectionRevision, load);
|
||||
onMounted(load);
|
||||
|
||||
return { alerts, failed, dismiss };
|
||||
}
|
||||
@@ -109,6 +109,10 @@ onUnmounted(() => document.removeEventListener("keydown", onGlobalKeydown));
|
||||
<CommandGroup v-if="showWorkflows" heading="Actions">
|
||||
<CommandItem value="New task" @select="newTask">New task</CommandItem>
|
||||
</CommandGroup>
|
||||
<CommandGroup heading="Views">
|
||||
<CommandItem value="Tasks in progress" @select="go('/tasks?status=running')">Tasks in progress</CommandItem>
|
||||
<CommandItem value="Tasks needing attention" @select="go('/tasks?status=needs_you')">Tasks needing attention</CommandItem>
|
||||
</CommandGroup>
|
||||
<CommandGroup heading="Pages">
|
||||
<CommandItem
|
||||
v-for="entry in pages"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { ref } from "vue";
|
||||
import AlertsBell from "@/alerts/AlertsBell.vue";
|
||||
import CommandPalette from "@/components/command-palette/CommandPalette.vue";
|
||||
import NewTaskButton from "@/tasks/NewTaskButton.vue";
|
||||
import NewTaskDialog from "@/tasks/NewTaskDialog.vue";
|
||||
import Brand from "./Brand.vue";
|
||||
import ConnectionPill from "./ConnectionPill.vue";
|
||||
import Nav from "./Nav.vue";
|
||||
@@ -21,7 +21,7 @@ const newTaskOpen = ref(false);
|
||||
<div class="flex shrink-0 items-center gap-2">
|
||||
<ConnectionPill />
|
||||
<CommandPalette :hidden="props.hidden" @new-task="newTaskOpen = true" />
|
||||
<NewTaskButton v-if="!props.hidden.includes('/workflows')" v-model:open="newTaskOpen" />
|
||||
<NewTaskDialog v-if="!props.hidden.includes('/workflows')" v-model:open="newTaskOpen" />
|
||||
<AlertsBell />
|
||||
<ProfileDropdown />
|
||||
</div>
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed } from "vue";
|
||||
import { AlignLeft } from "@lucide/vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { attentionStatusIds } from "@/lib/task-meta";
|
||||
import { headline } from "./headline";
|
||||
import { useTasksStore } from "@/stores/tasks";
|
||||
|
||||
const { error, summary } = storeToRefs(useTasksStore());
|
||||
|
||||
const text = computed(() => {
|
||||
const counts = summary.value?.statuses ?? {};
|
||||
const ids = attentionStatusIds();
|
||||
const attention = Object.entries(counts).reduce((sum, [s, n]) => (ids.has(s) ? sum + (n || 0) : sum), 0);
|
||||
return { ...headline(counts.running || 0, attention), urgent: attention > 0 };
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<header class="mb-4 flex min-h-9 flex-wrap items-center justify-between gap-x-4 gap-y-2">
|
||||
<div class="min-w-0">
|
||||
<h1 v-if="summary" class="text-xl font-semibold tracking-tight">
|
||||
{{ text.running }}<span class="text-fg-subtle"> · </span
|
||||
><span :class="text.urgent && 'text-warn'">{{ text.attention }}</span>
|
||||
</h1>
|
||||
<h1 v-else class="text-xl font-semibold tracking-tight">Dashboard</h1>
|
||||
<p v-if="error" class="mt-1 text-sm text-danger" role="alert">Cannot reach archied: {{ error }}</p>
|
||||
</div>
|
||||
<Button variant="outline" size="sm" as-child>
|
||||
<RouterLink to="/logs"><AlignLeft data-icon="inline-start" />Logs</RouterLink>
|
||||
</Button>
|
||||
</header>
|
||||
</template>
|
||||
@@ -4,39 +4,30 @@ import { computed } from "vue";
|
||||
|
||||
import { useTasksStore } from "@/stores/tasks";
|
||||
|
||||
import DashboardHero from "./DashboardHero.vue";
|
||||
import GatePulseCard from "./GatePulseCard.vue";
|
||||
import LiveActivityCard from "./LiveActivityCard.vue";
|
||||
import NeedsYouCard from "./NeedsYouCard.vue";
|
||||
import QuickTask from "./QuickTask.vue";
|
||||
import SetupPanel from "./SetupPanel.vue";
|
||||
import { setupPanelState } from "./setup-preference";
|
||||
import { useDashboard } from "./state";
|
||||
import ThroughputTiles from "./ThroughputTiles.vue";
|
||||
import TokenOutlookCard from "./TokenOutlookCard.vue";
|
||||
|
||||
/**
|
||||
* What needs you, first: the waiting tasks and live activity in the main
|
||||
* column, health and spend in the rail. Composes the panels; it holds no
|
||||
* state of its own.
|
||||
*/
|
||||
const { setup, summary } = storeToRefs(useTasksStore());
|
||||
/** Start work, then see what needs you and what is happening. Setup takes a
|
||||
* rail only while it is incomplete. */
|
||||
const { error, setup, summary } = storeToRefs(useTasksStore());
|
||||
useDashboard();
|
||||
|
||||
const setupIncomplete = computed(() => setupPanelState(setup.value).kind === "incomplete");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DashboardHero />
|
||||
<SetupPanel v-if="setupIncomplete" class="mb-4" />
|
||||
<ThroughputTiles v-if="summary" class="mb-4" />
|
||||
<div class="grid items-start gap-4 lg:grid-cols-[minmax(0,1fr)_380px]">
|
||||
<h1 class="sr-only">Dashboard</h1>
|
||||
<p v-if="error" class="mb-4 text-sm text-danger" role="alert">Cannot reach archied: {{ error }}</p>
|
||||
<div :class="setupIncomplete ? 'grid items-start gap-4 lg:grid-cols-[minmax(0,1fr)_320px]' : 'mx-auto max-w-5xl'">
|
||||
<div class="grid min-w-0 gap-4">
|
||||
<QuickTask />
|
||||
<NeedsYouCard />
|
||||
<LiveActivityCard v-if="summary" />
|
||||
</div>
|
||||
<div class="grid min-w-0 gap-4">
|
||||
<GatePulseCard />
|
||||
<TokenOutlookCard v-if="summary" />
|
||||
</div>
|
||||
<SetupPanel v-if="setupIncomplete" class="max-lg:-order-1" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,92 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed } from "vue";
|
||||
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { delivered } from "@/lib/delivered";
|
||||
import { STATUS_FILL } from "@/lib/status";
|
||||
import { passBar } from "./pass-bar";
|
||||
import { useTasksStore, type WorkflowStat } from "@/stores/tasks";
|
||||
|
||||
const { workflows } = storeToRefs(useTasksStore());
|
||||
|
||||
/** Sharer of runs: how much of the work that finished passed its gates. */
|
||||
const stats = computed(() => workflows.value?.workflows ?? []);
|
||||
|
||||
// A run that finished without opening a pull request (a no-change build, a
|
||||
// triage that needed no code) is delivered like a merge or a PR in review, so
|
||||
// both totals count it: the pass rate would otherwise read every `completed`
|
||||
// row as a failed gate.
|
||||
const totals = computed(() => ({
|
||||
runs: stats.value.reduce((a, w) => a + (w.runs || 0), 0),
|
||||
merged: stats.value.reduce(
|
||||
(a, w) => a + delivered(w) + (w.pr_open || 0),
|
||||
0,
|
||||
),
|
||||
}));
|
||||
|
||||
const pct = computed(() => {
|
||||
if (!totals.value.runs) return 0;
|
||||
return Math.round((totals.value.merged / totals.value.runs) * 100);
|
||||
});
|
||||
|
||||
/** One row's bar: the share of that gate's runs which got through, and whether
|
||||
* the gate is failing -- both decided in pass-bar.ts. */
|
||||
const rowBar = (stat: WorkflowStat) =>
|
||||
passBar(delivered(stat), stat.runs || 0);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card v-if="workflows && totals.runs">
|
||||
<CardHeader>
|
||||
<CardTitle>Quality gates</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<!--
|
||||
Two sections, read left to right: the rate on its own, and the
|
||||
per-workflow counts that explain it. Parked tasks are not listed
|
||||
here -- Throughput's Needs-you tile already speaks for them, from
|
||||
the statuses themselves.
|
||||
-->
|
||||
<div
|
||||
class="grid grid-cols-1 gap-6 md:grid-cols-[auto_minmax(0,1fr)]"
|
||||
>
|
||||
<div class="flex flex-col justify-center">
|
||||
<span class="text-3xl font-semibold">{{ pct }}%</span>
|
||||
<span class="text-xs text-fg-muted"
|
||||
>pass rate · {{ totals.runs }} runs</span
|
||||
>
|
||||
</div>
|
||||
<ul class="flex flex-col">
|
||||
<li
|
||||
v-for="(w, i) in stats.slice(0, 3)"
|
||||
:key="i"
|
||||
class="flex flex-col gap-1.5 border-b border-hairline py-2 last:border-b-0"
|
||||
>
|
||||
<span class="flex items-baseline justify-between gap-3 text-sm">
|
||||
<span class="truncate text-fg-muted">{{
|
||||
w.workflow || "workflow"
|
||||
}}</span>
|
||||
<span class="shrink-0 font-mono text-xs text-fg-subtle">{{
|
||||
delivered(w)
|
||||
}}/{{ w.runs || 0 }}</span>
|
||||
</span>
|
||||
<!-- The bar restates the counts as a length: a gate drifting down
|
||||
is visible before the two numbers are read. Its track carries
|
||||
the failure when there is no width to show. -->
|
||||
<span
|
||||
class="block h-1.5 overflow-hidden rounded-full"
|
||||
:class="STATUS_FILL[rowBar(w).track]"
|
||||
>
|
||||
<span
|
||||
class="block h-full rounded-full"
|
||||
:class="STATUS_FILL[rowBar(w).kind]"
|
||||
:style="`width:${rowBar(w).pct}%`"
|
||||
/>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -24,6 +24,8 @@ import {
|
||||
} from "@/components/ui/table";
|
||||
import { ago } from "@/lib/format";
|
||||
import { useSessionStore } from "@/stores/session";
|
||||
import { useTasksStore } from "@/stores/tasks";
|
||||
import { useAlerts } from "@/alerts/use-alerts";
|
||||
import ActivityRow from "./ActivityRow.vue";
|
||||
import { activityDetail } from "./activity-detail";
|
||||
import {
|
||||
@@ -43,6 +45,13 @@ import { describeTimelineEvent } from "@/tasks/timeline-event";
|
||||
*/
|
||||
|
||||
const router = useRouter();
|
||||
const { summary } = storeToRefs(useTasksStore());
|
||||
const running = computed(() => summary.value?.statuses?.running || 0);
|
||||
|
||||
// Open alerts lead the feed until resolved: a stream event scrolls away, the
|
||||
// condition it reported does not.
|
||||
const { alerts } = useAlerts();
|
||||
|
||||
const { activity } = storeToRefs(
|
||||
useSessionStore(),
|
||||
);
|
||||
@@ -51,6 +60,7 @@ const { activity } = storeToRefs(
|
||||
* own background work. */
|
||||
const filter = ref<ActivityFilter>("all");
|
||||
const shown = computed(() => filterActivity(activity.value, filter.value));
|
||||
const pinned = computed(() => (filter.value === "tasks" ? [] : alerts.value));
|
||||
const emptyTitle = computed(() =>
|
||||
activityEmptyTitle(shown.value.length, filter.value),
|
||||
);
|
||||
@@ -87,7 +97,7 @@ function openTask(taskID: number) {
|
||||
<template>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Live activity</CardTitle>
|
||||
<CardTitle>Activity<span v-if="running" class="font-normal text-fg-subtle"> · {{ running }} running</span></CardTitle>
|
||||
<CardAction class="flex items-center gap-2">
|
||||
<ToggleGroup type="single" variant="outline" size="sm" :model-value="filter" aria-label="Filter activity" @update:model-value="(value) => { if (value) filter = value as typeof filter; }">
|
||||
<ToggleGroupItem v-for="option in ACTIVITY_FILTERS" :key="option.value" :value="option.value">{{ option.label }}</ToggleGroupItem>
|
||||
@@ -102,7 +112,7 @@ function openTask(taskID: number) {
|
||||
region is the table's wrapper, so new rows are announced as they
|
||||
appear without a second hidden summary to keep in sync.
|
||||
-->
|
||||
<div role="region" aria-label="Live activity" aria-live="polite">
|
||||
<div role="region" aria-label="Activity" aria-live="polite">
|
||||
<!--
|
||||
The feed's height is bounded to the card, not the page: group rows
|
||||
multiply with the number of interleaved tasks, and an unbounded
|
||||
@@ -122,7 +132,23 @@ function openTask(taskID: number) {
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<TableRow v-if="!shown.length">
|
||||
<TableRow v-for="alert in pinned" :key="`alert:${alert.id}`">
|
||||
<TableCell class="font-medium">
|
||||
<span class="inline-flex items-center gap-1.5">
|
||||
<span class="size-1.5 rounded-full bg-warn" aria-hidden="true" />Alert
|
||||
<Badge v-if="alert.count > 1" variant="idle">×{{ alert.count }}</Badge>
|
||||
</span>
|
||||
</TableCell>
|
||||
<TableCell class="font-mono">—</TableCell>
|
||||
<TableCell class="w-[55%] max-w-0">
|
||||
<span class="flex items-center gap-3">
|
||||
<span class="min-w-0 flex-1 truncate" :title="alert.body || undefined">{{ alert.title }}</span>
|
||||
<RouterLink v-if="alert.link" :to="alert.link" class="shrink-0 text-warn hover:underline">Fix →</RouterLink>
|
||||
</span>
|
||||
</TableCell>
|
||||
<TableCell>{{ ago(alert.last_seen) }}</TableCell>
|
||||
</TableRow>
|
||||
<TableRow v-if="!shown.length && !pinned.length">
|
||||
<TableCell colspan="4">
|
||||
<Empty>
|
||||
<EmptyHeader>
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { NativeSelect, NativeSelectOption } from "@/components/ui/native-select";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { api } from "@/lib/api";
|
||||
import { useOrgStore } from "@/stores/org";
|
||||
import NewTaskDialog from "@/tasks/NewTaskDialog.vue";
|
||||
import { firstLine } from "@/tasks/first-line";
|
||||
import type { WorkflowDefinition } from "@/workflows/workflow-rows";
|
||||
import { declaredInputs } from "@/workflows/work-request";
|
||||
|
||||
/**
|
||||
* Start a task from a prompt. A workflow that needs more than the prompt (a
|
||||
* repository, a required input) opens the full form with the prompt carried
|
||||
* over, rather than being refused by the server.
|
||||
*/
|
||||
const router = useRouter();
|
||||
const prompt = ref("");
|
||||
const workflow = ref("");
|
||||
const definitions = ref<WorkflowDefinition[]>([]);
|
||||
const loadError = ref("");
|
||||
const error = ref("");
|
||||
const submitting = ref(false);
|
||||
const formOpen = ref(false);
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const list = await api.workflows<{ definitions?: WorkflowDefinition[] }>();
|
||||
definitions.value = (list?.definitions ?? []).filter((d) => d.enabled);
|
||||
workflow.value ||= definitions.value[0]?.id ?? "";
|
||||
} catch (err) {
|
||||
loadError.value = String((err as Error).message || err);
|
||||
}
|
||||
});
|
||||
|
||||
const org = useOrgStore();
|
||||
org.watchIdentities();
|
||||
const actor = computed(() => org.identities.find((i) => i.kind !== "system" && i.lifecycle === "active"));
|
||||
|
||||
const selected = computed(() => definitions.value.find((d) => d.id === workflow.value));
|
||||
const needsForm = computed(() => {
|
||||
const mode = selected.value?.repository ?? "required";
|
||||
return (mode !== "none" && mode !== "optional") || declaredInputs(selected.value).some((i) => i.required) || !actor.value;
|
||||
});
|
||||
|
||||
async function run() {
|
||||
if (!prompt.value.trim() || !workflow.value || submitting.value) return;
|
||||
if (needsForm.value) {
|
||||
formOpen.value = true;
|
||||
return;
|
||||
}
|
||||
submitting.value = true;
|
||||
error.value = "";
|
||||
try {
|
||||
const result = await api.workRequest<{ task_id: number }>({
|
||||
identity: actor.value!.id,
|
||||
repository: "",
|
||||
workflow: workflow.value,
|
||||
title: firstLine(prompt.value),
|
||||
instructions: prompt.value,
|
||||
inputs: {},
|
||||
});
|
||||
void router.push(`/tasks/${result.task_id}`);
|
||||
} catch (err) {
|
||||
error.value = String((err as Error).message || err);
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<form class="grid gap-1.5" @submit.prevent="run">
|
||||
<div class="flex gap-2 max-sm:flex-wrap">
|
||||
<Input v-model="prompt" class="min-w-0 flex-1" placeholder="Describe a task" aria-label="Task" />
|
||||
<NativeSelect v-model="workflow" aria-label="Workflow" class="font-mono text-[13px]" :disabled="!definitions.length">
|
||||
<NativeSelectOption v-for="d in definitions" :key="d.id" :value="d.id">{{ d.name || d.id }}</NativeSelectOption>
|
||||
</NativeSelect>
|
||||
<Button type="submit" :disabled="!prompt.trim() || !workflow || submitting">
|
||||
<Spinner v-if="submitting" data-icon="inline-start" />Run
|
||||
</Button>
|
||||
</div>
|
||||
<p v-if="loadError || error" class="text-sm text-danger" role="alert">{{ loadError || error }}</p>
|
||||
<p v-else-if="!definitions.length" class="text-xs text-fg-subtle">
|
||||
No enabled workflows. <RouterLink to="/workflows" class="underline">Enable one</RouterLink>
|
||||
</p>
|
||||
</form>
|
||||
<NewTaskDialog v-model:open="formOpen" :workflow="workflow" :instructions="prompt" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { storeToRefs } from "pinia";
|
||||
import { Check } from "@lucide/vue";
|
||||
import { Check, Circle } from "@lucide/vue";
|
||||
import { computed, ref, watch } from "vue";
|
||||
|
||||
import {
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import { setupPanelState, type SetupPanelState } from "./setup-preference";
|
||||
import { useTasksStore } from "@/stores/tasks";
|
||||
|
||||
@@ -39,34 +38,20 @@ const pct = computed(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card v-if="panel.kind === 'incomplete'">
|
||||
<Card v-if="panel.kind === 'incomplete'" size="sm">
|
||||
<CardHeader>
|
||||
<CardTitle>Setup</CardTitle>
|
||||
<CardAction>
|
||||
<span class="text-lg font-semibold text-link">{{ pct }}%</span>
|
||||
<span class="text-sm font-semibold text-link tabular-nums">{{ pct }}%</span>
|
||||
</CardAction>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Progress :model-value="pct" class="mb-4" />
|
||||
<ul class="flex flex-col gap-3">
|
||||
<li v-for="(step, i) in steps" :key="i" class="flex items-start gap-3">
|
||||
<span
|
||||
class="mt-px grid size-[18px] flex-none place-items-center rounded-full border-[1.5px] border-border-strong text-xs text-fg-subtle"
|
||||
:class="step.done ? 'border-transparent bg-ok-soft text-ok' : ''"
|
||||
>
|
||||
<Check v-if="step.done" class="size-3" />
|
||||
</span>
|
||||
<div>
|
||||
<div
|
||||
class="text-sm"
|
||||
:class="step.done ? 'text-fg-muted line-through' : ''"
|
||||
>
|
||||
{{ step.title }}
|
||||
</div>
|
||||
<div v-if="step.detail" class="mt-0.5 text-xs text-fg-subtle">
|
||||
{{ step.detail }}
|
||||
</div>
|
||||
</div>
|
||||
<ul class="grid gap-2 text-sm">
|
||||
<li v-for="(step, i) in steps" :key="i" class="flex items-center gap-2" :title="step.detail || undefined">
|
||||
<Check v-if="step.done" class="size-3.5 shrink-0 text-ok" aria-label="Done" />
|
||||
<Circle v-else class="size-3.5 shrink-0 text-fg-subtle" aria-label="To do" />
|
||||
<span :class="step.done ? 'text-fg-muted' : 'font-medium'">{{ step.title }}</span>
|
||||
<span v-if="!step.done && step.detail" class="ml-auto truncate text-xs text-fg-subtle">{{ step.detail }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</CardContent>
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed } from "vue";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { delivered } from "@/lib/delivered";
|
||||
import { compact } from "@/lib/format";
|
||||
import { attentionStatusIds } from "@/lib/task-meta";
|
||||
import { useTasksStore } from "@/stores/tasks";
|
||||
|
||||
const { summary } = storeToRefs(useTasksStore());
|
||||
|
||||
/** The throughput row: what is running, what needs a human, what shipped. */
|
||||
|
||||
const counts = computed(() => summary.value?.statuses ?? {});
|
||||
const tokensByDay = computed(() => summary.value?.tokens_by_day ?? []);
|
||||
const used = computed(() => tokensByDay.value.reduce((a, d) => a + (d.tokens || 0), 0));
|
||||
// Delivered work is out of archied's hands: merged, finished with no change to
|
||||
// make (`completed`), or open in review.
|
||||
const done = computed(() => delivered(counts.value) + (counts.value.pr_open || 0));
|
||||
// "Needs you" is the server's grouping (attentionStatusIds), the same one the
|
||||
// Tasks page's needs_you filter reads.
|
||||
const attention = computed(() => {
|
||||
const ids = attentionStatusIds();
|
||||
return Object.entries(counts.value).reduce((sum, [s, n]) => (ids.has(s) ? sum + (n || 0) : sum), 0);
|
||||
});
|
||||
const total = computed(() => Object.values(counts.value).reduce((a, b) => a + b, 0));
|
||||
|
||||
const cells = computed(() => [
|
||||
{ label: "Working now", value: counts.value.running || 0, sub: `${counts.value.queued || 0} waiting to start` },
|
||||
{
|
||||
label: "Needs attention",
|
||||
value: attention.value,
|
||||
sub: attention.value ? "Parked or awaiting a reply" : "Nothing is blocked",
|
||||
tone: attention.value ? ("warn" as const) : undefined,
|
||||
},
|
||||
{
|
||||
label: "Delivered",
|
||||
value: done.value,
|
||||
sub: total.value ? `${Math.round((done.value / total.value) * 100)}% of all tasks` : "No tasks yet",
|
||||
},
|
||||
{ label: "Tokens used", value: compact(used.value), sub: `Across ${tokensByDay.value.length} days` },
|
||||
]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<dl
|
||||
class="grid auto-cols-fr grid-flow-col divide-x divide-border rounded-lg border border-border bg-card max-md:grid-flow-row max-md:divide-x-0 max-md:divide-y"
|
||||
>
|
||||
<div v-for="cell in cells" :key="cell.label" class="min-w-0 px-4 py-3">
|
||||
<dt class="truncate text-xs text-fg-subtle">{{ cell.label }}</dt>
|
||||
<dd :class="cn('mt-1 truncate text-2xl font-semibold tabular-nums', cell.tone === 'warn' && 'text-warn')">{{ cell.value }}</dd>
|
||||
<dd class="mt-1 truncate text-xs text-fg-subtle">{{ cell.sub }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</template>
|
||||
@@ -1,45 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed } from "vue";
|
||||
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { compact } from "@/lib/format";
|
||||
import { useTasksStore } from "@/stores/tasks";
|
||||
|
||||
const { summary } = storeToRefs(useTasksStore());
|
||||
|
||||
const days = computed(() => summary.value?.tokens_by_day ?? []);
|
||||
// The API returns usage days newest first and omits days without usage.
|
||||
const week = computed(() => {
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
return Array.from({ length: 7 }, (_, i) => {
|
||||
const day = new Date(Date.parse(today) - (6 - i) * 86_400_000).toISOString().slice(0, 10);
|
||||
return { day, tokens: days.value.find((d) => d.day === day)?.tokens ?? 0 };
|
||||
});
|
||||
});
|
||||
const recent = computed(() => week.value.reduce((sum, day) => sum + day.tokens, 0));
|
||||
const maximum = computed(() => Math.max(1, ...week.value.map((day) => day.tokens)));
|
||||
const recorded = computed(() => week.value.filter((day) => days.value.some((d) => d.day === day.day)).length);
|
||||
const projected = computed(() => Math.round(recent.value / 7 * 30));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card v-if="days.length">
|
||||
<CardHeader>
|
||||
<CardTitle>Token outlook</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p class="text-xs text-fg-subtle">Today · UTC</p>
|
||||
<p class="mb-3 font-mono text-3xl font-semibold">{{ compact(week[6]?.tokens ?? 0) }}</p>
|
||||
<p class="text-sm">{{ compact(projected) }} over the next 30 days</p>
|
||||
<p class="mb-4 text-xs text-fg-subtle">At the last seven calendar days’ rate</p>
|
||||
<ul class="flex h-28 items-end gap-2" aria-label="Token usage over the last seven UTC days">
|
||||
<li v-for="day in week" :key="day.day" class="flex h-full min-w-0 flex-1 flex-col justify-end gap-1" :aria-label="`${day.day}: ${day.tokens} tokens`" :title="`${day.day}: ${day.tokens} tokens`">
|
||||
<span class="min-h-px rounded-sm bg-primary" :style="{ height: `${day.tokens / maximum * 80}%` }" aria-hidden="true" />
|
||||
<span class="text-center font-mono text-[10px] text-fg-subtle">{{ day.day.slice(5) }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-if="recorded < 7" class="mt-3 text-xs text-fg-subtle">Usage recorded on {{ recorded }} of the last seven days; missing days count as zero.</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -1,9 +0,0 @@
|
||||
const tasks = (n: number) => (n === 1 ? "1 task" : `${n} tasks`);
|
||||
|
||||
/** headline states what is running and what needs a human, for the header. */
|
||||
export function headline(running: number, attention: number): { running: string; attention: string } {
|
||||
return {
|
||||
running: running ? `${tasks(running)} running` : "Nothing is running",
|
||||
attention: attention ? `${tasks(attention)} need${attention === 1 ? "s" : ""} attention` : "Nothing needs attention",
|
||||
};
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
import type { StatusKind } from "@/lib/status";
|
||||
|
||||
/**
|
||||
* The bar under a quality-gate row.
|
||||
*
|
||||
* The rate above the rows says what the gates do overall; a row has to say
|
||||
* whether *this* gate is working. Two decisions live here, so the row and any
|
||||
* test read the same rule: the width is the share of that gate's runs which got
|
||||
* through, not a pass/fail flip, and a failing gate is red even when it
|
||||
* delivered nothing -- which is what carries the failure when the bar has no
|
||||
* width to show.
|
||||
*/
|
||||
|
||||
export interface PassBar {
|
||||
/** The share of the gate's runs that got through, 0-100. */
|
||||
pct: number;
|
||||
/** The fill's tone: passing, failing, or a gate that has run nothing. */
|
||||
kind: StatusKind;
|
||||
/** The track's tone: a failing gate with an empty fill draws the failure on
|
||||
* the track instead, rather than reading as a blank row. */
|
||||
track: StatusKind;
|
||||
}
|
||||
|
||||
export function passBar(delivered: number, runs: number): PassBar {
|
||||
const total = Math.max(0, Math.trunc(runs) || 0);
|
||||
if (!total) return { pct: 0, kind: "idle", track: "idle" };
|
||||
const through = Math.min(Math.max(Math.trunc(delivered) || 0, 0), total);
|
||||
if (through >= total) return { pct: 100, kind: "ok", track: "idle" };
|
||||
return {
|
||||
pct: Math.round((through / total) * 100),
|
||||
kind: "danger",
|
||||
track: "danger",
|
||||
};
|
||||
}
|
||||
+4
-16
@@ -10,15 +10,6 @@ export interface Summary {
|
||||
tokens_by_day?: Array<{ day: string; tokens?: number }>;
|
||||
}
|
||||
|
||||
export interface WorkflowStat {
|
||||
workflow?: string;
|
||||
runs?: number;
|
||||
merged?: number;
|
||||
completed?: number;
|
||||
pr_open?: number;
|
||||
parked?: number;
|
||||
}
|
||||
|
||||
/** An event off the live stream: the payload the detail column reads, plus
|
||||
* enough to point the row at the task it belongs to. */
|
||||
export interface ActivityEvent extends ActivityDetailInput {
|
||||
@@ -45,12 +36,11 @@ export function taskIDForEvent(event: ActivityEvent, bySource: Map<string, numbe
|
||||
return Number(bySource.get(`${event.repo}#${event.issue}`)) || 0;
|
||||
}
|
||||
|
||||
/** The board as the dashboard reads it: counts, setup progress, per-workflow
|
||||
* statistics and the recent tasks. The Tasks page pages its own list. */
|
||||
/** The board as the dashboard reads it: counts, setup progress and the
|
||||
* recent tasks. The Tasks page pages its own list. */
|
||||
export const useTasksStore = defineStore("tasks", () => {
|
||||
const summary = ref<Summary | null>(null);
|
||||
const setup = ref<Setup | null>(null);
|
||||
const workflows = ref<{ workflows?: WorkflowStat[] } | null>(null);
|
||||
// null means loading, [] means loaded.
|
||||
const tasks = ref<DashboardTask[] | null>(null);
|
||||
const error = ref<string | null>(null);
|
||||
@@ -59,10 +49,9 @@ export const useTasksStore = defineStore("tasks", () => {
|
||||
async function load(): Promise<void> {
|
||||
error.value = null;
|
||||
try {
|
||||
const [nextSummary, nextSetup, nextWorkflows, nextTasks] = await Promise.all([
|
||||
const [nextSummary, nextSetup, nextTasks] = await Promise.all([
|
||||
api.summary<Summary>(),
|
||||
api.setup<Setup>().catch(() => null),
|
||||
api.workflows<{ workflows?: WorkflowStat[] }>().catch(() => null),
|
||||
// Not defaulted to []: an empty list reads as "nothing needs you",
|
||||
// which a failed fetch must never claim.
|
||||
api.tasks<DashboardTask[]>(),
|
||||
@@ -75,7 +64,6 @@ export const useTasksStore = defineStore("tasks", () => {
|
||||
taskIDsBySource.value = map;
|
||||
summary.value = nextSummary;
|
||||
setup.value = nextSetup;
|
||||
workflows.value = nextWorkflows;
|
||||
tasks.value = nextTasks;
|
||||
} catch (err) {
|
||||
error.value = String((err as Error).message || err);
|
||||
@@ -88,5 +76,5 @@ export const useTasksStore = defineStore("tasks", () => {
|
||||
return taskIDForEvent(event, taskIDsBySource.value);
|
||||
}
|
||||
|
||||
return { summary, setup, workflows, tasks, error, load, taskIDFor };
|
||||
return { summary, setup, tasks, error, load, taskIDFor };
|
||||
});
|
||||
@@ -1,17 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { useRouter } from "vue-router";
|
||||
import { Plus } from "@lucide/vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import NewTaskForm from "./NewTaskForm.vue";
|
||||
|
||||
const props = defineProps<{ workflow?: string; instructions?: string }>();
|
||||
const router = useRouter();
|
||||
const open = defineModel<boolean>("open", { default: false });
|
||||
|
||||
@@ -23,14 +16,17 @@ function started(taskId: number) {
|
||||
|
||||
<template>
|
||||
<Dialog v-model:open="open">
|
||||
<DialogTrigger as-child>
|
||||
<Button size="sm"><Plus data-icon="inline-start" />New task</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent class="sm:max-w-[640px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>New task</DialogTitle>
|
||||
</DialogHeader>
|
||||
<NewTaskForm v-if="open" @started="started" @cancel="open = false" />
|
||||
<NewTaskForm
|
||||
v-if="open"
|
||||
:initial-workflow="props.workflow"
|
||||
:initial-instructions="props.instructions"
|
||||
@started="started"
|
||||
@cancel="open = false"
|
||||
/>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</template>
|
||||
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { firstLine } from "./first-line";
|
||||
import { computed, onMounted, ref, useId, watchEffect } from "vue";
|
||||
import { ChevronRight } from "@lucide/vue";
|
||||
import { RadioGroupItem, RadioGroupRoot } from "reka-ui";
|
||||
@@ -30,6 +31,8 @@ import {
|
||||
const props = defineProps<{
|
||||
/** Starts this workflow, with no chooser. */ workflow?: string;
|
||||
/** An unsaved definition of `workflow` to test-run instead of the stored one. */ draft?: string;
|
||||
/** Preselected in the chooser, as the dashboard's quick start hands over. */ initialWorkflow?: string;
|
||||
initialInstructions?: string;
|
||||
}>();
|
||||
const emit = defineEmits<{ started: [taskId: number]; cancel: [] }>();
|
||||
const uid = useId();
|
||||
@@ -57,9 +60,9 @@ identities.watchIdentities();
|
||||
const actors = computed(() => identities.identities.filter((i) => i.kind !== "system" && i.lifecycle === "active"));
|
||||
|
||||
const repository = ref("");
|
||||
const workflow = ref(props.workflow ?? "");
|
||||
const title = ref("");
|
||||
const instructions = ref("");
|
||||
const workflow = ref(props.workflow ?? props.initialWorkflow ?? "");
|
||||
const instructions = ref(props.initialInstructions ?? "");
|
||||
const title = ref(firstLine(instructions.value));
|
||||
const identity = ref("");
|
||||
// One text field per declared input, by input name: the chosen workflow's
|
||||
// declaration decides what is rendered and what the request carries.
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
/** firstLine is a prompt's first line, cut to a title's length. */
|
||||
export function firstLine(text: string): string {
|
||||
const line = text.trim().split("\n", 1)[0] ?? "";
|
||||
return line.length > 80 ? `${line.slice(0, 79)}…` : line;
|
||||
}
|
||||
Reference in new issue
Block a user