feat(webui): port the dashboard (Phase 3, first page)
The control room, on the primitives from the previous commit. Being the first page it also settles the shape of the rest: shadcn components for chrome, one feature folder per page, Lucide imported at the call site. Carried across deliberately, because each was a fix rather than a layout: - Live activity's detail is cut to one line and clamped again in the cell, so a long unbroken token (a path, a URL, a hash) cannot widen the column past the table. Unclamped, one agent_finish row made the dashboard 7,481px tall. - Each HEALTH card takes its own content height. Matching them was right while both held a checklist; once setup is done that card is a title and a line while Gate pulse carries a gauge and four rows, so equalising them left a mostly-empty box taking a quarter of the first screen. The task links are router paths now, not the `#/tasks` hashes the Preact build used. History routing means a hash is not a route any more, so one that survived here would navigate nowhere. Also in this change: - Button gains an `attention` variant, in the project's own cva. An action that exists because something needs a human has to look unlike one that is always present, and `destructive` would overstate it: nothing is broken, it is waiting. - The setup panel branches on the state machine rather than on "is setup present at all". Guarding on presence showed a 100% checklist with every step struck through where the complete state belongs.
This commit is contained in:
1 parent
c799e3209c
commit
1d054656a9
29 files changed
+968
-10
No files matched your search
@@ -14,6 +14,10 @@ export const buttonVariants = cva(
|
||||
ghost: 'hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground',
|
||||
destructive: 'bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30',
|
||||
link: 'text-primary underline-offset-4 hover:underline',
|
||||
// An action that exists because something needs a human has to look
|
||||
// unlike one that is always present. `destructive` would overstate it:
|
||||
// nothing is broken, it is waiting.
|
||||
attention: 'border-warn bg-warn-soft font-medium text-warn hover:bg-warn-soft/80',
|
||||
},
|
||||
size: {
|
||||
'default': 'h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="empty"
|
||||
:class="cn(
|
||||
'gap-4 rounded-xl border-dashed p-6 flex w-full min-w-0 flex-1 flex-col items-center justify-center text-center text-balance',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="empty-content"
|
||||
:class="cn(
|
||||
'gap-2.5 text-sm flex w-full max-w-sm min-w-0 flex-col items-center text-balance',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<p
|
||||
data-slot="empty-description"
|
||||
:class="cn(
|
||||
'text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary',
|
||||
$attrs.class ?? '',
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</p>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="empty-header"
|
||||
:class="cn(
|
||||
'gap-2 flex max-w-sm flex-col items-center',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import type { EmptyMediaVariants } from '.'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { emptyMediaVariants } from '.'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
variant?: EmptyMediaVariants['variant']
|
||||
}>(), {
|
||||
variant: 'default',
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="empty-icon"
|
||||
:data-variant="variant"
|
||||
:class="cn(emptyMediaVariants({ variant }), props.class)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="empty-title"
|
||||
:class="cn('text-sm font-medium tracking-tight cn-font-heading', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { VariantProps } from 'class-variance-authority'
|
||||
import { cva } from 'class-variance-authority'
|
||||
|
||||
export { default as Empty } from './Empty.vue'
|
||||
export { default as EmptyContent } from './EmptyContent.vue'
|
||||
export { default as EmptyDescription } from './EmptyDescription.vue'
|
||||
export { default as EmptyHeader } from './EmptyHeader.vue'
|
||||
export { default as EmptyMedia } from './EmptyMedia.vue'
|
||||
export { default as EmptyTitle } from './EmptyTitle.vue'
|
||||
|
||||
export const emptyMediaVariants = cva(
|
||||
'mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0',
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: 'bg-transparent',
|
||||
icon: 'bg-muted text-foreground flex size-8 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*=size-])]:size-4',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: 'default',
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
export type EmptyMediaVariants = VariantProps<typeof emptyMediaVariants>
|
||||
@@ -0,0 +1,38 @@
|
||||
<script setup lang="ts">
|
||||
import type { ProgressRootProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import {
|
||||
ProgressIndicator,
|
||||
ProgressRoot,
|
||||
} from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<ProgressRootProps & { class?: HTMLAttributes['class'] }>(),
|
||||
{
|
||||
modelValue: 0,
|
||||
},
|
||||
)
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ProgressRoot
|
||||
data-slot="progress"
|
||||
v-bind="delegatedProps"
|
||||
:class="
|
||||
cn(
|
||||
'bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
>
|
||||
<ProgressIndicator
|
||||
data-slot="progress-indicator"
|
||||
class="bg-primary size-full flex-1 transition-all"
|
||||
:style="`transform: translateX(-${100 - (props.modelValue ?? 0)}%);`"
|
||||
/>
|
||||
</ProgressRoot>
|
||||
</template>
|
||||
@@ -0,0 +1 @@
|
||||
export { default as Progress } from './Progress.vue'
|
||||
@@ -0,0 +1,29 @@
|
||||
<script setup lang="ts">
|
||||
import type { SeparatorProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { Separator } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = withDefaults(defineProps<
|
||||
SeparatorProps & { class?: HTMLAttributes['class'] }
|
||||
>(), {
|
||||
orientation: 'horizontal',
|
||||
decorative: true,
|
||||
})
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Separator
|
||||
data-slot="separator"
|
||||
v-bind="delegatedProps"
|
||||
:class="
|
||||
cn(
|
||||
'shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1 @@
|
||||
export { default as Separator } from './Separator.vue'
|
||||
@@ -0,0 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div data-slot="table-container" class="relative w-full overflow-x-auto">
|
||||
<table data-slot="table" :class="cn('w-full caption-bottom text-sm', props.class)">
|
||||
<slot />
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<tbody
|
||||
data-slot="table-body"
|
||||
:class="cn('[&_tr:last-child]:border-0', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</tbody>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<caption
|
||||
data-slot="table-caption"
|
||||
:class="cn('text-muted-foreground mt-4 text-sm', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</caption>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<td
|
||||
data-slot="table-cell"
|
||||
:class="cn('p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</td>
|
||||
</template>
|
||||
@@ -0,0 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { cn } from '@/lib/utils'
|
||||
import TableCell from './TableCell.vue'
|
||||
import TableRow from './TableRow.vue'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
colspan?: number
|
||||
}>(), {
|
||||
colspan: 1,
|
||||
})
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TableRow>
|
||||
<TableCell
|
||||
:class="
|
||||
cn(
|
||||
'p-4 whitespace-nowrap align-middle text-sm text-foreground',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
v-bind="delegatedProps"
|
||||
>
|
||||
<div class="flex items-center justify-center py-10">
|
||||
<slot />
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<tfoot
|
||||
data-slot="table-footer"
|
||||
:class="cn('bg-muted/50 border-t font-medium [&>tr]:last:border-b-0', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</tfoot>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<th
|
||||
data-slot="table-head"
|
||||
:class="cn('text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</th>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<thead
|
||||
data-slot="table-header"
|
||||
:class="cn('[&_tr]:border-b', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</thead>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<tr
|
||||
data-slot="table-row"
|
||||
:class="cn('hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors has-aria-expanded:bg-muted/50', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</tr>
|
||||
</template>
|
||||
@@ -0,0 +1,9 @@
|
||||
export { default as Table } from './Table.vue'
|
||||
export { default as TableBody } from './TableBody.vue'
|
||||
export { default as TableCaption } from './TableCaption.vue'
|
||||
export { default as TableCell } from './TableCell.vue'
|
||||
export { default as TableEmpty } from './TableEmpty.vue'
|
||||
export { default as TableFooter } from './TableFooter.vue'
|
||||
export { default as TableHead } from './TableHead.vue'
|
||||
export { default as TableHeader } from './TableHeader.vue'
|
||||
export { default as TableRow } from './TableRow.vue'
|
||||
@@ -0,0 +1,471 @@
|
||||
<script setup lang="ts">
|
||||
import { AlignLeft, Check, ListChecks, RefreshCw, Route, X } from "@lucide/vue";
|
||||
import { computed, onMounted, onUnmounted, ref } from "vue";
|
||||
import { RouterLink, useRouter } from "vue-router";
|
||||
|
||||
import Gauge from "@/base/Gauge.vue";
|
||||
import SegmentBar from "@/base/SegmentBar.vue";
|
||||
import StatTile from "@/base/StatTile.vue";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardAction, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||
import { api, subscribeEvents } from "@/lib/api";
|
||||
import { ago, compact } from "@/lib/format";
|
||||
import type { StatusKind } from "@/lib/status";
|
||||
import { activityDetail, type ActivityDetailInput } from "./activity-detail";
|
||||
import { dismissSetupComplete, setupPanelState, type Setup } from "./setup-preference";
|
||||
import { dashboardTaskTargets, type TaskTarget } from "./task-targets";
|
||||
|
||||
interface Summary {
|
||||
statuses?: Record<string, number>;
|
||||
tokens_by_day?: Array<{ tokens?: number }>;
|
||||
}
|
||||
|
||||
interface WorkflowStat {
|
||||
workflow?: string;
|
||||
runs?: number;
|
||||
merged?: 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. */
|
||||
interface ActivityEvent extends ActivityDetailInput {
|
||||
kind?: string;
|
||||
type?: string;
|
||||
task_id?: number | string;
|
||||
repo?: string;
|
||||
issue?: number | string;
|
||||
at?: string | number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The control room: what Archie is working on, what needs you, and what it is
|
||||
* spending.
|
||||
*/
|
||||
|
||||
const activity = ref<ActivityEvent[]>([]);
|
||||
const streamStateText = ref("connecting");
|
||||
const streamStateKind = ref<StatusKind>("idle");
|
||||
const taskIDsBySource = ref(new Map<string, number>());
|
||||
|
||||
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<TaskTarget[] | null>(null);
|
||||
const error = ref<string | null>(null);
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
// Bumped when the operator dismisses the setup card, so the panel state is
|
||||
// re-evaluated; the preference itself lives in storage, not in the component.
|
||||
const dismissals = ref(0);
|
||||
|
||||
onMounted(async () => {
|
||||
await load();
|
||||
unsubscribe = subscribeEvents(
|
||||
(event) => {
|
||||
const next = [event as ActivityEvent, ...activity.value];
|
||||
next.splice(50);
|
||||
activity.value = next;
|
||||
},
|
||||
(state) => {
|
||||
streamStateText.value = state;
|
||||
streamStateKind.value = state === "live" ? "ok" : "warn";
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
let unsubscribe: (() => void) | undefined;
|
||||
onUnmounted(() => unsubscribe?.());
|
||||
|
||||
async function load() {
|
||||
error.value = null;
|
||||
try {
|
||||
const [nextSummary, nextSetup, nextWorkflows, nextTasks] = await Promise.all([
|
||||
api.summary<Summary>(),
|
||||
api.setup<Setup>().catch(() => null),
|
||||
api.workflows<{ workflows?: WorkflowStat[] }>().catch(() => null),
|
||||
api.tasks<TaskTarget[]>().catch(() => []),
|
||||
]);
|
||||
const map = new Map<string, number>();
|
||||
for (const task of nextTasks as Array<TaskTarget & { owner?: string; repo?: string; issue_number?: number }>) {
|
||||
if (task.owner && task.repo && task.issue_number) {
|
||||
map.set(`${task.owner}/${task.repo}#${task.issue_number}`, Number(task.id));
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
function taskIDForEvent(event: ActivityEvent, bySource: Map<string, number>): number {
|
||||
if (Number(event.task_id) > 0) return Number(event.task_id);
|
||||
if (!event.repo || !event.issue) return 0;
|
||||
return Number(bySource.get(`${event.repo}#${event.issue}`)) || 0;
|
||||
}
|
||||
|
||||
/** The task an activity row opens, or 0. An event carries the id, or a
|
||||
* repo/issue pair the task list resolves. */
|
||||
const taskIDFor = (event: ActivityEvent): number => taskIDForEvent(event, taskIDsBySource.value);
|
||||
|
||||
function greeting(): string {
|
||||
const h = new Date().getHours();
|
||||
if (h < 5) return "Still up?";
|
||||
if (h < 12) return "Good morning";
|
||||
if (h < 18) return "Good afternoon";
|
||||
return "Good evening";
|
||||
}
|
||||
|
||||
function trendPct(series: number[]): number | null {
|
||||
if (series.length < 4) return null;
|
||||
const mid = Math.floor(series.length / 2);
|
||||
const older = series.slice(0, mid).reduce((a, b) => a + b, 0);
|
||||
const newer = series.slice(mid).reduce((a, b) => a + b, 0);
|
||||
if (!older) return null;
|
||||
return ((newer - older) / older) * 100;
|
||||
}
|
||||
|
||||
function openTask(taskID: number) {
|
||||
void router.push(`/tasks?task=${encodeURIComponent(taskID)}`);
|
||||
}
|
||||
|
||||
function handleDismissSetup() {
|
||||
dismissSetupComplete();
|
||||
dismissals.value += 1;
|
||||
}
|
||||
|
||||
const currentGreeting = computed(() => (setup.value?.operator ? `${greeting()}, ${setup.value.operator}` : greeting()));
|
||||
|
||||
const targets = computed(() => dashboardTaskTargets(tasks.value ?? []));
|
||||
|
||||
const setupPanel = computed(() => setupPanelState(setup.value));
|
||||
const setupSteps = computed(() => setup.value?.steps ?? []);
|
||||
const omitSetup = computed(() => setupPanel.value.kind === "omit" || setupPanel.value.kind === "dismissed");
|
||||
const setupPct = computed(() => {
|
||||
const steps = setup.value?.steps ?? [];
|
||||
if (!steps.length) return 0;
|
||||
return Math.round(((steps.length - setupPanel.value.remaining.length) / steps.length) * 100);
|
||||
});
|
||||
|
||||
const counts = computed(() => summary.value?.statuses ?? {});
|
||||
const tokensByDay = computed(() => summary.value?.tokens_by_day ?? []);
|
||||
const tokenSeries = computed(() => tokensByDay.value.map((d) => d.tokens || 0));
|
||||
|
||||
const workflowStats = computed(() => workflows.value?.workflows ?? []);
|
||||
const runTotals = computed(() => {
|
||||
const runs = workflowStats.value.reduce((a, w) => a + (w.runs || 0), 0);
|
||||
const merged = workflowStats.value.reduce((a, w) => a + (w.merged || 0) + (w.pr_open || 0), 0);
|
||||
const parked = workflowStats.value.reduce((a, w) => a + (w.parked || 0), 0);
|
||||
return { runs, merged, parked };
|
||||
});
|
||||
|
||||
const tokenTotals = computed(() => {
|
||||
const used = tokenSeries.value.reduce((a, b) => a + b, 0);
|
||||
const recent = tokenSeries.value.slice(-7).reduce((a, b) => a + b, 0);
|
||||
const perDay = tokensByDay.value.length ? used / tokensByDay.value.length : 0;
|
||||
return { used, recent, perDay, projected: Math.round(perDay * 30) };
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="mb-5 flex flex-wrap items-start justify-between gap-5">
|
||||
<div>
|
||||
<h1 class="text-3xl font-semibold tracking-[-0.03em]">{{ currentGreeting }}</h1>
|
||||
<p class="mt-2 text-sm text-fg-muted">
|
||||
Your agent's control room — what it is working on, what needs you, and what it is spending.
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<Button v-if="error" @click="load">
|
||||
<RefreshCw data-icon="inline-start" />
|
||||
Retry
|
||||
</Button>
|
||||
<template v-else-if="tasks !== null">
|
||||
<Button v-if="targets.attention.count > 0" variant="attention" as-child>
|
||||
<RouterLink :to="targets.attention.href">
|
||||
<ListChecks data-icon="inline-start" />
|
||||
{{ targets.attention.count }} need{{ targets.attention.count === 1 ? "s" : "" }} you
|
||||
</RouterLink>
|
||||
</Button>
|
||||
<Button v-if="targets.running.count > 0" variant="outline" as-child>
|
||||
<RouterLink :to="targets.running.href">
|
||||
<Route data-icon="inline-start" />
|
||||
{{ targets.running.count }} running
|
||||
</RouterLink>
|
||||
</Button>
|
||||
<Button variant="outline" as-child>
|
||||
<RouterLink to="/logs">
|
||||
<AlignLeft data-icon="inline-start" />
|
||||
Logs
|
||||
</RouterLink>
|
||||
</Button>
|
||||
<Button @click="load">
|
||||
<RefreshCw data-icon="inline-start" />
|
||||
Refresh
|
||||
</Button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
Health. Each card takes its own content height rather than the row's:
|
||||
matching them was right while both held a checklist, but once setup is
|
||||
done that card is a title and a line while Gate pulse carries a gauge and
|
||||
four rows, so equalising left a mostly-empty box taking a quarter of the
|
||||
first screen.
|
||||
-->
|
||||
<section class="mb-5">
|
||||
<div class="mb-3 flex items-baseline gap-3 pl-1">
|
||||
<h2 class="text-xs font-semibold tracking-[0.08em] text-fg-subtle uppercase">Health</h2>
|
||||
</div>
|
||||
<div
|
||||
class="grid items-start gap-4"
|
||||
:class="omitSetup ? 'grid-cols-1' : 'grid-cols-1 min-[1080px]:grid-cols-[minmax(0,1.6fr)_minmax(0,1fr)]'"
|
||||
>
|
||||
<Card v-if="setupPanel.kind === 'incomplete'">
|
||||
<CardHeader>
|
||||
<CardTitle>Finish setting up</CardTitle>
|
||||
<CardDescription>Archie needs these before it can work on its own.</CardDescription>
|
||||
<CardAction>
|
||||
<span class="text-lg font-semibold text-primary">{{ setupPct }}%</span>
|
||||
</CardAction>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Progress :model-value="setupPct" class="mb-4" />
|
||||
<ul class="flex flex-col gap-3">
|
||||
<li v-for="(step, i) in setupSteps" :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>
|
||||
</li>
|
||||
</ul>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card v-else-if="setupPanel.kind === 'complete'">
|
||||
<CardHeader>
|
||||
<CardTitle>Setup complete</CardTitle>
|
||||
<CardDescription>Archie is configured and ready to work.</CardDescription>
|
||||
<CardAction class="flex items-center gap-2">
|
||||
<Check class="size-4 text-ok" />
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
aria-label="Dismiss setup complete"
|
||||
@click="handleDismissSetup"
|
||||
>
|
||||
<X />
|
||||
</Button>
|
||||
</CardAction>
|
||||
</CardHeader>
|
||||
</Card>
|
||||
|
||||
<Card v-if="summary">
|
||||
<CardHeader>
|
||||
<CardTitle>Gate pulse</CardTitle>
|
||||
<CardDescription v-if="runTotals.runs">Work that passed its quality gates</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Empty v-if="!runTotals.runs">
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>No completed runs yet</EmptyTitle>
|
||||
<EmptyDescription>Once Archie finishes a task, its gate pass rate appears here.</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
<template v-else>
|
||||
<Gauge :value="(runTotals.merged / runTotals.runs) * 100" label="pass rate" />
|
||||
<ul class="mt-4 flex flex-col gap-2">
|
||||
<li
|
||||
v-for="(w, i) in workflowStats.slice(0, 3)"
|
||||
:key="i"
|
||||
class="flex items-center justify-between gap-3 rounded-sm bg-muted px-3 py-2 text-sm"
|
||||
>
|
||||
<span class="truncate text-fg-muted">{{ w.workflow || "workflow" }}</span>
|
||||
<Badge
|
||||
:variant="
|
||||
(w.merged || 0) === (w.runs || 0) ? 'ok' : (w.parked || 0) > 0 ? 'warn' : 'info'
|
||||
"
|
||||
>
|
||||
{{ w.merged || 0 }}/{{ w.runs || 0 }}
|
||||
</Badge>
|
||||
</li>
|
||||
<li
|
||||
v-if="runTotals.parked > 0"
|
||||
class="flex items-center justify-between gap-3 rounded-sm bg-muted px-3 py-2 text-sm"
|
||||
>
|
||||
<span class="truncate text-fg-muted">Parked, awaiting you</span>
|
||||
<Badge variant="warn">{{ runTotals.parked }}</Badge>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="summary" class="mb-5">
|
||||
<div class="mb-3 flex items-baseline gap-3 pl-1">
|
||||
<h2 class="text-xs font-semibold tracking-[0.08em] text-fg-subtle uppercase">Throughput</h2>
|
||||
<span class="text-xs text-fg-subtle">Across all repositories</span>
|
||||
</div>
|
||||
<div class="grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-4">
|
||||
<StatTile
|
||||
label="Working now"
|
||||
:value="counts.running || 0"
|
||||
:compare="`${counts.queued || 0} waiting to start`"
|
||||
:series="tokenSeries"
|
||||
/>
|
||||
<StatTile
|
||||
label="Needs you"
|
||||
:value="(counts.parked || 0) + (counts.waiting_human || 0)"
|
||||
:compare="counts.parked || counts.waiting_human ? 'Parked or awaiting a reply' : 'Nothing is blocked'"
|
||||
good-direction="down"
|
||||
/>
|
||||
<StatTile
|
||||
label="Delivered"
|
||||
:value="(counts.merged || 0) + (counts.pr_open || 0)"
|
||||
:compare="
|
||||
Object.values(counts).reduce((a, b) => a + b, 0)
|
||||
? `${Math.round((((counts.merged || 0) + (counts.pr_open || 0)) / Object.values(counts).reduce((a, b) => a + b, 0)) * 100)}% of all tasks`
|
||||
: 'No tasks yet'
|
||||
"
|
||||
/>
|
||||
<StatTile
|
||||
label="Tokens used"
|
||||
:value="compact(tokenTotals.used)"
|
||||
:compare="`Across ${tokensByDay.length || 0} days`"
|
||||
:trend="trendPct(tokenSeries)"
|
||||
good-direction="down"
|
||||
:series="tokenSeries"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="summary" class="mb-5">
|
||||
<div class="mb-3 flex items-baseline gap-3 pl-1">
|
||||
<h2 class="text-xs font-semibold tracking-[0.08em] text-fg-subtle uppercase">Right now</h2>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 gap-4 min-[1080px]:grid-cols-[minmax(0,1fr)_minmax(0,1.5fr)]">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Token outlook</CardTitle>
|
||||
<CardDescription v-if="tokensByDay.length">Next 30 days at the current rate</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Empty v-if="!tokensByDay.length">
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>Nothing spent yet</EmptyTitle>
|
||||
<EmptyDescription>Usage appears here once Archie runs its first task.</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
<template v-else>
|
||||
<div class="mb-1 text-3xl font-semibold tracking-[-0.03em]">{{ compact(tokenTotals.projected) }}</div>
|
||||
<div class="mb-4 text-xs text-fg-subtle">
|
||||
Based on {{ compact(Math.round(tokenTotals.perDay)) }} per day over {{ tokensByDay.length }} days
|
||||
</div>
|
||||
<SegmentBar
|
||||
:segments="[
|
||||
{ label: `Last 7 days (${compact(tokenTotals.recent)})`, value: tokenTotals.recent, kind: 'info' },
|
||||
{
|
||||
label: `Earlier (${compact(tokenTotals.used - tokenTotals.recent)})`,
|
||||
value: Math.max(tokenTotals.used - tokenTotals.recent, 0),
|
||||
kind: 'idle',
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Live activity</CardTitle>
|
||||
<CardDescription>Last 50, newest first</CardDescription>
|
||||
<CardAction>
|
||||
<Badge :variant="streamStateKind">{{ streamStateText }}</Badge>
|
||||
</CardAction>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Event</TableHead>
|
||||
<TableHead>Task</TableHead>
|
||||
<TableHead>Detail</TableHead>
|
||||
<TableHead>When</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<TableRow v-if="!activity.length">
|
||||
<TableCell colspan="4">
|
||||
<Empty>
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>Waiting for activity</EmptyTitle>
|
||||
<EmptyDescription>Events appear here as Archie works.</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow
|
||||
v-for="(event, i) in activity"
|
||||
v-else
|
||||
:key="i"
|
||||
:class="taskIDFor(event) > 0 ? 'cursor-pointer' : ''"
|
||||
:role="taskIDFor(event) > 0 ? 'link' : undefined"
|
||||
:tabindex="taskIDFor(event) > 0 ? 0 : undefined"
|
||||
:title="taskIDFor(event) > 0 ? 'Open task details' : undefined"
|
||||
@click="taskIDFor(event) > 0 && openTask(taskIDFor(event))"
|
||||
@keydown.enter.prevent="
|
||||
taskIDFor(event) > 0 && openTask(taskIDFor(event))
|
||||
"
|
||||
@keydown.space.prevent="
|
||||
taskIDFor(event) > 0 && openTask(taskIDFor(event))
|
||||
"
|
||||
>
|
||||
<TableCell class="font-medium">{{ event.kind || event.type || "event" }}</TableCell>
|
||||
<TableCell class="font-mono">
|
||||
{{ taskIDFor(event) > 0 ? `#${taskIDFor(event)}` : "—" }}
|
||||
</TableCell>
|
||||
<!--
|
||||
The detail is cut to one line by activityDetail and clamped
|
||||
again here so a long unbroken token (a path, a URL, a hash)
|
||||
cannot widen the column past the table. Unclamped, this made
|
||||
the dashboard 7,481px tall.
|
||||
-->
|
||||
<TableCell class="w-[55%] max-w-0">
|
||||
<span
|
||||
class="block truncate"
|
||||
:title="activityDetail(event).truncated ? activityDetail(event).full : undefined"
|
||||
>
|
||||
{{ activityDetail(event).text }}
|
||||
</span>
|
||||
</TableCell>
|
||||
<TableCell>{{ ago(event.at || Date.now()) }}</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -13,8 +13,10 @@
|
||||
// same height at the widths the table is used at.
|
||||
const CELL_LIMIT = 160;
|
||||
|
||||
/** An activity event, as far as this column reads it. */
|
||||
export interface ActivityEvent {
|
||||
/** An activity event, as far as this column reads it. Deliberately narrower
|
||||
* than the event the dashboard holds: this is the whole of what the cell
|
||||
* renders, so a caller can pass anything carrying either field. */
|
||||
export interface ActivityDetailInput {
|
||||
detail?: unknown;
|
||||
message?: unknown;
|
||||
}
|
||||
@@ -31,7 +33,7 @@ export interface ActivityDetail {
|
||||
* `text` is the single line the cell renders, `full` the untouched payload,
|
||||
* and `truncated` whether the two differ.
|
||||
*/
|
||||
export function activityDetail(event: ActivityEvent | undefined): ActivityDetail {
|
||||
export function activityDetail(event: ActivityDetailInput | undefined): ActivityDetail {
|
||||
const full = String(event?.detail || event?.message || "");
|
||||
if (!full) return { text: "", full: "", truncated: false };
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
export const SETUP_DISMISSAL_KEY = "archie.setup-complete.dismissed.v1";
|
||||
|
||||
/** One setup step as the daemon reports it. */
|
||||
export interface SetupStep {
|
||||
title: string;
|
||||
detail?: string;
|
||||
done: boolean;
|
||||
}
|
||||
|
||||
export interface Setup {
|
||||
steps: SetupStep[];
|
||||
operator?: string;
|
||||
}
|
||||
|
||||
/** The storage surface this needs, so it is testable without a browser. */
|
||||
export type SetupStorage = Pick<Storage, "getItem" | "removeItem" | "setItem">;
|
||||
|
||||
export interface SetupPanelState {
|
||||
kind: "omit" | "incomplete" | "complete" | "dismissed";
|
||||
remaining: SetupStep[];
|
||||
}
|
||||
|
||||
// setupPanelState reconciles persisted presentation state with current setup
|
||||
// truth. If setup later becomes incomplete, an old dismissal is cleared so the
|
||||
// operator cannot miss the new work.
|
||||
export function setupPanelState(
|
||||
setup: Setup | null | undefined,
|
||||
storage: SetupStorage | undefined = globalThis.localStorage,
|
||||
): SetupPanelState {
|
||||
if (!setup?.steps?.length) return { kind: "omit", remaining: [] };
|
||||
const remaining = setup.steps.filter((step) => !step.done);
|
||||
if (remaining.length) {
|
||||
storage?.removeItem?.(SETUP_DISMISSAL_KEY);
|
||||
return { kind: "incomplete", remaining };
|
||||
}
|
||||
if (storage?.getItem?.(SETUP_DISMISSAL_KEY) === "1") {
|
||||
return { kind: "dismissed", remaining: [] };
|
||||
}
|
||||
return { kind: "complete", remaining: [] };
|
||||
}
|
||||
|
||||
export function dismissSetupComplete(storage: SetupStorage | undefined = globalThis.localStorage): void {
|
||||
storage?.setItem?.(SETUP_DISMISSAL_KEY, "1");
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
const ATTENTION_STATUSES = new Set(["waiting_human", "parked"]);
|
||||
|
||||
/** The task fields these links are derived from. */
|
||||
export interface TaskTarget {
|
||||
id: number | string;
|
||||
status?: string;
|
||||
}
|
||||
|
||||
export interface TaskTargets {
|
||||
attention: { count: number; href: string };
|
||||
running: { count: number; href: string };
|
||||
}
|
||||
|
||||
// Dashboard task links are derived from the actual task list, not just count
|
||||
// aggregates, so a single item can open directly while a group opens a useful
|
||||
// filtered board.
|
||||
//
|
||||
// The hrefs are router paths, not the `#/tasks` hashes the Preact build used.
|
||||
// History routing means a hash is not a route any more, so one that survived
|
||||
// here would navigate nowhere.
|
||||
export function dashboardTaskTargets(tasks: TaskTarget[] = []): TaskTargets {
|
||||
const attention = tasks.filter((task) => ATTENTION_STATUSES.has(task.status ?? ""));
|
||||
const running = tasks.filter((task) => task.status === "running");
|
||||
return {
|
||||
attention: {
|
||||
count: attention.length,
|
||||
href:
|
||||
attention.length === 1
|
||||
? `/tasks?task=${encodeURIComponent(attention[0].id)}`
|
||||
: "/tasks?status=needs_you",
|
||||
},
|
||||
running: {
|
||||
count: running.length,
|
||||
href: "/tasks?status=running",
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
|
||||
import DashboardPage from "@/dashboard/DashboardPage.vue";
|
||||
import Placeholder from "@/views/Placeholder.vue";
|
||||
|
||||
// internal/gateway/dashboard_tools.go mirrors this table; its test parses this
|
||||
@@ -14,7 +15,7 @@ import Placeholder from "@/views/Placeholder.vue";
|
||||
// navPath the navigation entry this route keeps current
|
||||
// soon visible, greyed and non-navigable
|
||||
const routes = [
|
||||
{ path: "/", name: "dashboard", component: Placeholder, meta: { label: "Dashboard", description: "What Archie is working on, what needs you, and token spend." } },
|
||||
{ path: "/", name: "dashboard", component: DashboardPage, meta: { label: "Dashboard", description: "What Archie is working on, what needs you, and token spend." } },
|
||||
{ path: "/tasks", name: "tasks", component: Placeholder, meta: { label: "Tasks", description: "Issues Archie has picked up, and where each one stands." } },
|
||||
{ path: "/tasks/:id", name: "task-detail", component: Placeholder, meta: { label: "Task run", nav: false, navPath: "/tasks" } },
|
||||
{ path: "/workflows", name: "workflows", component: Placeholder, meta: { label: "Workflows", description: "The routed workflows and their run history.", section: "workflows" } },
|
||||
|
||||
Reference in new issue
Block a user