feat(webui): port the dashboard (Phases 3-5)
Every page from the deleted Preact dashboard, rebuilt in Vue 3 + shadcn-vue.
The navigation restructure landed earlier on this branch; this is the surfaces
behind it, and the two are now one app.
Dashboard, Tasks (list and detail), Configuration split six ways, Logs,
Inspector, Mappings, Bindings, Workflows, Skills, Curators, Channels, chat.
Components, not files: docs/prds/dashboard-port-brief.md requires one
component, one job, one file, with shared state in a module beside it. So a
page file composes and holds nothing, and a shape repeated across panes becomes
its own component (LogRow, PageHeader, PanelLoading, WorkflowBar).
Behaviour that had to survive, because each was a fix:
- Live activity's detail is clamped to one line with the payload on the title.
Unclamped, one row made the dashboard 7,481px tall.
- Each health card takes its own height. Equalising left a mostly-empty box
taking a quarter of the first screen once setup was done.
- Tasks: `tab`/`attempt` live in the query string and are written with
router.replace, so a tab click adds no history entry and does not remount.
The list's deep-link reveal honours prefers-reduced-motion.
- LOG_LEVELS is a wire contract (the server matches that CSV server-side), used
unchanged by both log panes.
- The chat panel's Phase 5 list: a FAB that is the only toggle, a morph whose
scale, radius and position interpolate together, no scrim, no close button,
Escape returning focus to the launcher, Stop only while streaming.
- Unconfigured is not broken. A 501 on /api/version or the log stream renders
what is true ("Not configured on this deployment") rather than blank, and a
read-only Configuration says so instead of offering controls that cannot work.
Three things the port decided rather than carried:
- Button gains an `attention` variant and Badge the five status tones, in the
project's own cva. The pill's dot did not come across: the Badge's shape is
the affordance, and the same tone now covers a trend indicator.
- The icon module is not ported. Its name-to-glyph lookup is the pattern
shadcn-vue's rules call out as wrong, so icons come from @lucide/vue at the
call site. The five bespoke glyphs have no consumer yet and become components
if a page draws them.
- The theme control left the topbar for /system/appearance, per the approved
navigation design. ThemeToggle.vue and Placeholder.vue are deleted rather
than orphaned: every route now resolves to a real page.
Also fixes the bundle freshness check failing on the first build after every
change. ui/dist is committed, so nothing ignores it and Tailwind's content
detection scanned it, making each build an input to the next.
This commit is contained in:
1 parent
5fe25045d1
commit
b9daa01b4b
276 files changed
+12888
-563
No files matched your search
@@ -0,0 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { RefreshCw } from "@lucide/vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { load } from "./state";
|
||||
|
||||
/** Read the list again, for an operator who does not want to wait for the
|
||||
* stream to invalidate it. */
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Button variant="outline" @click="load">
|
||||
<RefreshCw data-icon="inline-start" />
|
||||
Refresh
|
||||
</Button>
|
||||
</template>
|
||||
@@ -0,0 +1,52 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from "vue";
|
||||
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@/components/ui/sheet";
|
||||
import { ago } from "@/lib/format";
|
||||
import CapturePayload from "./CapturePayload.vue";
|
||||
import { selected, type Capture } from "./state";
|
||||
|
||||
/**
|
||||
* One capture's payload and headers, opened from its row. A side panel rather
|
||||
* than a taller row: a payload runs to thousands of characters, and the list
|
||||
* has to stay a list while it is read.
|
||||
*/
|
||||
|
||||
const open = computed({
|
||||
get: () => selected.value !== null,
|
||||
set: (value: boolean) => {
|
||||
if (!value) selected.value = null;
|
||||
},
|
||||
});
|
||||
|
||||
// What the panel renders. The list drops the selection as soon as this sheet
|
||||
// reports closed, and the panel stays mounted through the close animation, so
|
||||
// reading the shared ref would blank it halfway out. Nothing goes stale here:
|
||||
// a stored capture is never rewritten.
|
||||
const shown = ref<Capture | null>(null);
|
||||
watch(selected, (next) => {
|
||||
if (next) shown.value = next;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Sheet v-model:open="open">
|
||||
<SheetContent class="w-full gap-0 sm:max-w-2xl">
|
||||
<SheetHeader>
|
||||
<SheetTitle>{{ shown?.source || "Unknown source" }}</SheetTitle>
|
||||
<SheetDescription>
|
||||
{{ ago(shown?.received_at) }} · {{ shown?.content_type || "no content type" }}
|
||||
</SheetDescription>
|
||||
</SheetHeader>
|
||||
<Separator />
|
||||
<ScrollArea class="min-h-0 flex-1">
|
||||
<div class="flex flex-col gap-5 p-4">
|
||||
<CapturePayload label="Payload" :raw="shown?.body" />
|
||||
<CapturePayload label="Headers" :raw="shown?.headers" />
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
</template>
|
||||
@@ -0,0 +1,30 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
|
||||
import { prettyPrint } from "./capture-payload";
|
||||
|
||||
/**
|
||||
* One labelled block of a capture: its body or its headers, as text. Both are
|
||||
* stored as strings, valid JSON or not, so both go through the same reader.
|
||||
*/
|
||||
const props = defineProps<{ label: string; raw?: string }>();
|
||||
|
||||
const text = computed(() => prettyPrint(props.raw));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="min-w-0">
|
||||
<h3 class="mb-2 text-xs font-semibold tracking-[0.05em] text-fg-subtle uppercase">{{ label }}</h3>
|
||||
<!--
|
||||
Wrap rather than scroll sideways: a captured payload is mostly long
|
||||
unbroken tokens (URLs, hashes, base64), and one of those on a single line
|
||||
would push the panel's contents past its edge instead of being read.
|
||||
-->
|
||||
<p v-if="!text" class="text-sm text-fg-muted">(empty)</p>
|
||||
<pre
|
||||
v-else
|
||||
class="rounded-sm border border-border-strong bg-muted p-3 font-mono text-xs whitespace-pre-wrap wrap-break-word"
|
||||
>{{ text }}</pre
|
||||
>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,52 @@
|
||||
<script setup lang="ts">
|
||||
import { ChevronRight } from "@lucide/vue";
|
||||
import { computed } from "vue";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { TableCell, TableRow } from "@/components/ui/table";
|
||||
import { ago } from "@/lib/format";
|
||||
import { selected, type Capture } from "./state";
|
||||
|
||||
/**
|
||||
* One captured event. The row is the control, not a button sitting in one
|
||||
* cell: opening the payload is the row's whole job, and a keyboard user has to
|
||||
* reach what a mouse user clicks -- which is why it is focusable and both
|
||||
* Enter and Space open it.
|
||||
*/
|
||||
const props = defineProps<{ capture: Capture }>();
|
||||
|
||||
const isSelected = computed(() => selected.value?.id === props.capture.id);
|
||||
|
||||
// The name is set here because role="button" makes the cells presentational:
|
||||
// what a screen reader reads is this, not five unrelated columns.
|
||||
const label = computed(() => `View the payload received from ${props.capture.source || "an unknown source"}`);
|
||||
|
||||
function open(): void {
|
||||
selected.value = props.capture;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TableRow
|
||||
:data-state="isSelected ? 'selected' : undefined"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
aria-haspopup="dialog"
|
||||
:aria-label="label"
|
||||
class="cursor-pointer focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring"
|
||||
@click="open"
|
||||
@keydown.enter.prevent="open"
|
||||
@keydown.space.prevent="open"
|
||||
>
|
||||
<TableCell class="font-mono">{{ props.capture.source || "(unknown)" }}</TableCell>
|
||||
<TableCell :title="props.capture.received_at || ''">{{ ago(props.capture.received_at) }}</TableCell>
|
||||
<!-- A stored capture carries no claim from a binding, so this reads Unbound
|
||||
for every row: the column is where a claim would appear, not a state a
|
||||
reader can act on today. -->
|
||||
<TableCell><Badge variant="idle">Unbound</Badge></TableCell>
|
||||
<TableCell class="font-mono">{{ props.capture.content_type || "—" }}</TableCell>
|
||||
<TableCell class="text-right">
|
||||
<ChevronRight class="size-4 text-fg-subtle" />
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { streamKind, streamState } from "./state";
|
||||
|
||||
/**
|
||||
* The state of the stream that is supposed to be adding to this list. Without
|
||||
* it a list that has stopped updating looks exactly like a quiet one.
|
||||
*/
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Badge :variant="streamKind">{{ streamState }}</Badge>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
|
||||
import CapturesList from "./CapturesList.vue";
|
||||
|
||||
/** The captured events panel, with the note that qualifies everything inside
|
||||
* it: what an operator reads here has already been through redaction. */
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Recent captures</CardTitle>
|
||||
<CardDescription>Newest first. Headers and payloads are redacted before they are stored.</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<CapturesList />
|
||||
</CardContent>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import CaptureActions from "./CaptureActions.vue";
|
||||
import CaptureStatus from "./CaptureStatus.vue";
|
||||
|
||||
/** The page's title, and what belongs beside it: where the stream has got to,
|
||||
* and a way to ask for the list again. */
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mb-5 flex flex-wrap items-start justify-between gap-5">
|
||||
<div>
|
||||
<h1 class="text-3xl font-semibold tracking-[-0.03em]">Event inspector</h1>
|
||||
<p class="mt-2 text-sm text-fg-muted">Real inbound payloads archie has captured, most recent first.</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<CaptureStatus />
|
||||
<CaptureActions />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,66 @@
|
||||
<script setup lang="ts">
|
||||
import { Inbox, TriangleAlert } from "@lucide/vue";
|
||||
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Table, TableBody, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||
import CaptureRow from "./CaptureRow.vue";
|
||||
import { captures, enabled, error, loading } from "./state";
|
||||
|
||||
/**
|
||||
* The captures, or the one thing that stands in for them: a read that failed,
|
||||
* a deployment with no capture storage, a first read still in flight, or a
|
||||
* window with nothing in it yet.
|
||||
*/
|
||||
|
||||
// The receiver's path, held as a string rather than typed into the template:
|
||||
// its source segment is angle-bracketed, which a template parser reads as a
|
||||
// tag.
|
||||
const webhookHint = "Point a webhook at /webhooks/capture/<source> and it will show up here.";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- A failed read is about this page's request, not about capture, so it says
|
||||
what the server said rather than borrowing an empty state. -->
|
||||
<Alert v-if="error" variant="destructive">
|
||||
<TriangleAlert />
|
||||
<AlertTitle>Cannot reach archied</AlertTitle>
|
||||
<AlertDescription>{{ error }}</AlertDescription>
|
||||
</Alert>
|
||||
|
||||
<Empty v-else-if="!enabled">
|
||||
<EmptyHeader>
|
||||
<EmptyMedia variant="icon"><Inbox /></EmptyMedia>
|
||||
<EmptyTitle>Capture is not configured</EmptyTitle>
|
||||
<EmptyDescription>This deployment has no capture storage wired up.</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
|
||||
<div v-else-if="loading" class="flex flex-col gap-2">
|
||||
<Skeleton v-for="row in 5" :key="row" class="h-9 w-full" />
|
||||
</div>
|
||||
|
||||
<Empty v-else-if="!captures.length">
|
||||
<EmptyHeader>
|
||||
<EmptyMedia variant="icon"><Inbox /></EmptyMedia>
|
||||
<EmptyTitle>No captures yet</EmptyTitle>
|
||||
<EmptyDescription>{{ webhookHint }}</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
|
||||
<Table v-else>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Source</TableHead>
|
||||
<TableHead>Received</TableHead>
|
||||
<TableHead>Binding</TableHead>
|
||||
<TableHead>Content type</TableHead>
|
||||
<TableHead class="w-10"><span class="sr-only">Payload</span></TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<CaptureRow v-for="capture in captures" :key="capture.id" :capture="capture" />
|
||||
</TableBody>
|
||||
</Table>
|
||||
</template>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import CaptureDetailSheet from "./CaptureDetailSheet.vue";
|
||||
import CapturesCard from "./CapturesCard.vue";
|
||||
import CapturesHeader from "./CapturesHeader.vue";
|
||||
import { useCaptures } from "./state";
|
||||
|
||||
/**
|
||||
* Event inspector (t2db.2): the operator-facing half of capture. Recent
|
||||
* inbound events, newest first, with the full redacted payload explorable from
|
||||
* each row -- see docs/prds/event-capture-storage.md for what the backend
|
||||
* guarantees (retention, redaction, disk bounds). Composes the page; it holds
|
||||
* no state of its own.
|
||||
*/
|
||||
useCaptures();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CapturesHeader />
|
||||
<CapturesCard />
|
||||
<CaptureDetailSheet />
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
// prettyPrint indents valid JSON so a captured payload can be read as a
|
||||
// structure rather than a line. A payload that is not JSON is returned as it
|
||||
// arrived: the receiver stores whatever it is sent, JSON or not
|
||||
// (docs/prds/webhook-intake-security.md), and the non-JSON case is the one an
|
||||
// operator most needs to see.
|
||||
export function prettyPrint(raw: string | undefined): string {
|
||||
if (!raw) return "";
|
||||
try {
|
||||
return JSON.stringify(JSON.parse(raw), null, 2);
|
||||
} catch {
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import { computed, onMounted, onUnmounted, ref } from "vue";
|
||||
|
||||
import { api, subscribeEvents } from "@/lib/api";
|
||||
import type { StatusKind } from "@/lib/status";
|
||||
import type { StreamState } from "@/lib/stream-state";
|
||||
|
||||
/**
|
||||
* The event inspector's shared state.
|
||||
*
|
||||
* The list, the stream's state beside it and the sheet that shows one
|
||||
* capture's payload all read it, so it lives in a module rather than being
|
||||
* threaded down through a chain of props.
|
||||
*/
|
||||
|
||||
/**
|
||||
* One captured inbound event as the daemon stored it. Headers and body are
|
||||
* already redacted (webhookguard.RedactPayload runs before InsertCapture), so
|
||||
* what the page prints is what the store holds.
|
||||
*/
|
||||
export interface Capture {
|
||||
id: number;
|
||||
received_at?: string;
|
||||
source?: string;
|
||||
remote_addr?: string;
|
||||
content_type?: string;
|
||||
headers?: string;
|
||||
body?: string;
|
||||
authenticated?: boolean;
|
||||
}
|
||||
|
||||
interface CapturesResponse {
|
||||
captures?: Capture[];
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
// How many captures the list asks for. This is a recent-events window, not a
|
||||
// log: retention and the disk bound are the daemon's (see
|
||||
// docs/prds/event-capture-storage.md), so an operator looking for something
|
||||
// older is looking in the wrong place rather than scrolling further.
|
||||
const LIST_LIMIT = 100;
|
||||
|
||||
export const captures = ref<Capture[]>([]);
|
||||
export const enabled = ref(true);
|
||||
export const error = ref<string | null>(null);
|
||||
export const loading = ref(true);
|
||||
export const streamState = ref<StreamState | "connecting">("connecting");
|
||||
|
||||
/**
|
||||
* The open row's capture, or null. Held by value rather than by id: the list
|
||||
* is re-read on every capture event, so resolving an id again would close the
|
||||
* sheet under an operator reading a capture that has just aged out of the
|
||||
* window.
|
||||
*/
|
||||
export const selected = ref<Capture | null>(null);
|
||||
|
||||
/** The stream's state as a badge kind. A stream still connecting and one that
|
||||
* has given up are different answers, so they do not share a tone. */
|
||||
export const streamKind = computed<StatusKind>(() => {
|
||||
if (streamState.value === "live") return "ok";
|
||||
return streamState.value === "unavailable" ? "danger" : "warn";
|
||||
});
|
||||
|
||||
/**
|
||||
* load re-reads the list. It runs once on mount and again on every capture
|
||||
* event, so it deliberately never re-enters the loading state: the skeletons
|
||||
* are for a page with nothing on it yet, and a live refresh that put them back
|
||||
* would replace the rows an operator is reading several times a minute.
|
||||
*/
|
||||
export async function load(): Promise<void> {
|
||||
try {
|
||||
const res = await api.captures<CapturesResponse>(LIST_LIMIT);
|
||||
enabled.value = res.enabled !== false;
|
||||
captures.value = res.captures || [];
|
||||
error.value = null;
|
||||
} catch (err) {
|
||||
// The server's own message is the only part of a failure an operator can
|
||||
// act on, so it is what the list says instead of the captures.
|
||||
error.value = (err as Error).message || String(err);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handleEvent(raw: unknown): void {
|
||||
// The "capture" event on /events carries the id and source only, no payload
|
||||
// (see handleCapture), so it is an invalidation signal rather than data: it
|
||||
// says a capture exists, and the authoritative list -- the only place the
|
||||
// redacted payload lives -- is asked for again. Merging it into local state
|
||||
// instead would put a row in the list with nothing behind it.
|
||||
if ((raw as { kind?: string } | null)?.kind !== "capture") return;
|
||||
void load();
|
||||
}
|
||||
|
||||
let unsubscribe: (() => void) | undefined;
|
||||
|
||||
/** Owns the initial read and the live stream that invalidates it, for the
|
||||
* page's lifetime. */
|
||||
export function useCaptures(): void {
|
||||
onMounted(() => {
|
||||
void load();
|
||||
unsubscribe = subscribeEvents(handleEvent, (state) => {
|
||||
streamState.value = state;
|
||||
});
|
||||
});
|
||||
onUnmounted(() => unsubscribe?.());
|
||||
}
|
||||
Reference in new issue
Block a user