Files
archie/ui/src/dashboard/LiveActivityCard.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

218 lines
8.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { storeToRefs } from "pinia";
import { computed, reactive, ref } from "vue";
import { useRouter } from "vue-router";
import { ChevronDown, ChevronRight } from "@lucide/vue";
import { Badge } from "@/components/ui/badge";
import {
Card,
CardAction,
CardContent,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import { ago } from "@/lib/format";
import { useSessionStore } from "@/stores/session";
import ActivityRow from "./ActivityRow.vue";
import { activityDetail } from "./activity-detail";
import {
ACTIVITY_FILTERS,
activityEmptyTitle,
filterActivity,
type ActivityFilter,
} from "./activity-filter";
import { groupActivity, type ActivityGroup } from "./activity-group";
/**
* The last 50 events, newest first, with the stream's own state on the card and
* the All / Tasks / System filter over it. The filter and the grouping rules
* live in activity-filter.ts and activity-group.ts and are tested there; this
* card only renders their result.
*/
const router = useRouter();
const { activity } = storeToRefs(
useSessionStore(),
);
/** Which view of the feed is showing: everything, task runs, or the daemon's
* own background work. */
const filter = ref<ActivityFilter>("all");
const shown = computed(() => filterActivity(activity.value, filter.value));
const emptyTitle = computed(() =>
activityEmptyTitle(shown.value.length, filter.value),
);
// Expansion is keyed on label:taskID, so a live run stays open as its events
// arrive, and a collapsed group re-collapses only when the run breaks.
const expanded = reactive(new Set<string>());
const groups = computed(() => groupActivity(shown.value));
function toggle(key: string) {
if (expanded.has(key)) expanded.delete(key);
else expanded.add(key);
}
function isOpen(group: ActivityGroup): boolean {
return expanded.has(group.key);
}
// The collapsed group row shows what its newest event would have shown, so
// expanding and collapsing moves no information.
function groupDetail(group: ActivityGroup) {
return activityDetail(group.representative);
}
function groupWhen(group: ActivityGroup) {
return group.representative.at ? ago(group.representative.at) : "\u2014";
}
function openTask(taskID: number) {
void router.push(`/tasks?task=${encodeURIComponent(taskID)}`);
}
</script>
<template>
<Card>
<CardHeader>
<CardTitle>Live activity</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>
</ToggleGroup>
</CardAction>
</CardHeader>
<CardContent>
<!--
role="region" names the table for landmark navigation; aria-live is
polite, not assertive, because rows arrive constantly while the stream
is live and an assertive region would talk over the operator. The live
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">
<!--
The feed's height is bounded to the card, not the page: group rows
multiply with the number of interleaved tasks, and an unbounded
table made the dashboard ~4,700px tall on a live instance. The
newest events stay visible at the top; the rest scroll inside the
card. The header stays put via sticky so the columns keep their
labels while scrolling.
-->
<div class="max-h-[28rem] overflow-y-auto">
<Table>
<TableHeader class="sticky top-0 z-10 bg-card">
<TableRow>
<TableHead>Event</TableHead>
<TableHead>Task</TableHead>
<TableHead>Detail</TableHead>
<TableHead>When</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow v-if="!shown.length">
<TableCell colspan="4">
<Empty>
<EmptyHeader>
<EmptyTitle>{{ emptyTitle }}</EmptyTitle>
</EmptyHeader>
</Empty>
</TableCell>
</TableRow>
<template v-if="shown.length">
<template v-for="group in groups" :key="group.key">
<!-- A singleton is exactly the row the raw feed would show. -->
<ActivityRow
v-if="group.count === 1"
:event="group.representative"
@open="openTask"
/>
<template v-else>
<!--
The group row keeps ActivityRow's link contract: when its
events resolve to a task, the row itself opens the task,
with the same focusable role="link" behaviour. The
disclosure button is a stop-propagated control inside the
first cell, so it never fights the row-level link.
-->
<TableRow
:class="group.taskID > 0 ? 'cursor-pointer' : ''"
:role="group.taskID > 0 ? 'link' : undefined"
:tabindex="group.taskID > 0 ? 0 : undefined"
:title="
group.taskID > 0 ? 'Open task details' : undefined
"
@click="group.taskID > 0 && openTask(group.taskID)"
@keydown.enter.prevent="
group.taskID > 0 && openTask(group.taskID)
"
@keydown.space.prevent="
group.taskID > 0 && openTask(group.taskID)
"
>
<TableCell class="font-medium">
<button
type="button"
class="inline-flex items-center gap-1 rounded hover:opacity-80"
:aria-expanded="isOpen(group)"
:aria-label="`${isOpen(group) ? 'Hide' : 'Show'} ${group.count} ${group.label} events`"
@click.stop="toggle(group.key)"
>
<ChevronDown
v-if="isOpen(group)"
class="size-3.5 shrink-0 text-fg-subtle"
/>
<ChevronRight
v-else
class="size-3.5 shrink-0 text-fg-subtle"
/>
{{ group.label }}
<Badge variant="idle">×{{ group.count }}</Badge>
</button>
</TableCell>
<TableCell class="font-mono">{{
group.taskID > 0 ? `#${group.taskID}` : "—"
}}</TableCell>
<TableCell class="w-[55%] max-w-0">
<span
class="block truncate"
:title="
groupDetail(group).truncated
? groupDetail(group).full
: undefined
"
>{{ groupDetail(group).text }}</span
>
</TableCell>
<TableCell>{{ groupWhen(group) }}</TableCell>
</TableRow>
<template v-if="isOpen(group)">
<ActivityRow
v-for="(event, i) in group.events"
:key="`${group.key}:${i}`"
:event="event"
@open="openTask"
/>
</template>
</template>
</template>
</template>
</TableBody>
</Table>
</div>
</div>
</CardContent>
</Card>
</template>