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:
sam committed 2026-09-20 20:04:55 +10:00
1 parent 5fe25045d1
commit b9daa01b4b
276 files changed
+12888 -563

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
<script setup lang="ts">
import { Pause, Play, RefreshCw } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { loadLogs, paused } from "./state";
/**
* Freeze the tail, or read the history again.
*
* Pause is a state as much as an action, so the button carries it: while the
* list has stopped following the stream this is the only thing on the page
* that says so, and the emphasis marks it.
*/
function togglePause(): void {
paused.value = !paused.value;
}
</script>
<template>
<div class="flex flex-wrap items-center gap-2">
<Button :variant="paused ? 'default' : 'outline'" @click="togglePause">
<Play v-if="paused" data-icon="inline-start" />
<Pause v-else data-icon="inline-start" />
{{ paused ? "Resume" : "Pause" }}
</Button>
<Button variant="outline" @click="loadLogs">
<RefreshCw data-icon="inline-start" />
Refresh
</Button>
</div>
</template>
+93
View File
@@ -0,0 +1,93 @@
<script setup lang="ts">
import { computed, onUnmounted, ref, watch } from "vue";
import { Input } from "@/components/ui/input";
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { LOG_LEVELS } from "@/lib/log";
import { componentOptions, filters } from "./state";
/**
* The list's filters: level, component and a search over messages and fields.
*
* The level and component pair are two-way on the filter state, because a
* change to either is a new read; the search box commits after a pause,
* because a keystroke is not a request.
*/
// reka-ui refuses an empty string as a SelectItem value -- it is how the
// component spells "nothing selected". The wire wants an absent filter for
// "all", so the sentinel converts at this boundary and everything downstream
// (the filter state, the query string, the server) keeps the empty value.
const ALL = "__all__";
// LOG_LEVELS' values are a wire contract: the server matches that CSV
// server-side, so the labels are paired with them here and never rewritten.
const levelOptions = LOG_LEVELS.map((option) => ({ value: option.value || ALL, label: option.label }));
const componentSelectOptions = computed(() => [
{ value: ALL, label: "All components" },
...componentOptions.value.map((name) => ({ value: name, label: name })),
]);
const level = computed(() => filters.level || ALL);
const component = computed(() => filters.component || ALL);
function setLevel(value: unknown): void {
filters.level = value === ALL ? "" : String(value ?? "");
}
function setComponent(value: unknown): void {
filters.component = value === ALL ? "" : String(value ?? "");
}
// Seeded from the filter rather than from nothing: the filters outlive a visit
// to this page, and a box that came back empty while the list was still
// narrowed by its query would be claiming the list is unfiltered.
const search = ref(filters.q);
let searchTimer: ReturnType<typeof setTimeout> | undefined;
watch(search, (value) => {
clearTimeout(searchTimer);
searchTimer = setTimeout(() => {
filters.q = value;
}, 250);
});
onUnmounted(() => clearTimeout(searchTimer));
</script>
<template>
<div class="flex min-w-0 flex-wrap items-center gap-2">
<Select :model-value="level" @update:model-value="setLevel">
<SelectTrigger size="sm" class="w-44" aria-label="Level">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectItem v-for="option in levelOptions" :key="option.value" :value="option.value">
{{ option.label }}
</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
<Select :model-value="component" @update:model-value="setComponent">
<SelectTrigger size="sm" class="w-44" aria-label="Component">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectItem v-for="option in componentSelectOptions" :key="option.value" :value="option.value">
{{ option.label }}
</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
<Input
v-model="search"
type="search"
placeholder="Search messages and fields…"
class="min-w-0 flex-1 md:max-w-56"
/>
</div>
</template>
+50
View File
@@ -0,0 +1,50 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import LogRow from "@/base/LogRow.vue";
import { Skeleton } from "@/components/ui/skeleton";
import { entryKey } from "./log-entries";
import LogsEmpty from "./LogsEmpty.vue";
import { emptyDetail, emptyTitle, entries, loading, readError } from "./state";
/**
* The lines, or the one thing that stands in for them.
*
* Dense and monospace by design: the point of this page is scanning a lot of
* lines quickly.
*/
// Varied widths, so the placeholder reads as lines of a log rather than a
// table waiting to be filled.
const SKELETON_ROWS = ["w-11/12", "w-3/4", "w-5/6", "w-2/3", "w-11/12", "w-1/2", "w-5/6", "w-3/4"];
const scroller = ref<HTMLElement | null>(null);
// The tail follows the newest line, which is the last one. flush: 'post'
// scrolls after the new rows are in the DOM -- scrolling before that measures
// the height the list is about to replace.
watch(
entries,
() => {
const el = scroller.value;
if (el) el.scrollTop = el.scrollHeight;
},
{ flush: "post" },
);
</script>
<template>
<div ref="scroller" class="max-h-[62vh] overflow-y-auto font-mono text-xs">
<!-- A failed read is about this page's request, not about the log, so it
says what the server said rather than borrowing an empty state. -->
<LogsEmpty v-if="readError" title="Cannot read logs" :detail="readError" />
<div v-else-if="loading && !entries.length" class="flex flex-col gap-3 px-3 py-4">
<Skeleton v-for="(width, i) in SKELETON_ROWS" :key="i" class="h-3" :class="width" />
</div>
<LogsEmpty v-else-if="!entries.length" :title="emptyTitle" :detail="emptyDetail" />
<template v-else>
<LogRow v-for="entry in entries" :key="entryKey(entry)" :entry="entry" />
</template>
</div>
</template>
+17
View File
@@ -0,0 +1,17 @@
<script setup lang="ts">
import { Badge } from "@/components/ui/badge";
import { meta, streamKind, streamState } from "./state";
/**
* What the list is showing, and the state of the stream that is supposed to be
* adding to it. The two belong together: "Live only" says nothing on its own
* when the stream behind those lines has stopped.
*/
</script>
<template>
<div class="flex flex-wrap items-center gap-3">
<span class="min-w-0 break-words font-mono text-xs text-fg-subtle">{{ meta }}</span>
<Badge :variant="streamKind">{{ streamState }}</Badge>
</div>
</template>
+23
View File
@@ -0,0 +1,23 @@
<script setup lang="ts">
import { Card, CardContent, CardHeader } from "@/components/ui/card";
import LogFilters from "./LogFilters.vue";
import LogList from "./LogList.vue";
import LogStatus from "./LogStatus.vue";
/** The log surface: the filters and the stream's own state over the lines. */
</script>
<template>
<!-- gap-0 so the header's rule sits on the list rather than a card gap above
it; the rows carry their own separators. -->
<Card class="gap-0">
<CardHeader class="flex flex-wrap items-center justify-between gap-3 border-b">
<LogFilters />
<LogStatus />
</CardHeader>
<CardContent class="px-0">
<LogList />
</CardContent>
</Card>
</template>
+19
View File
@@ -0,0 +1,19 @@
<script setup lang="ts">
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
/**
* The list's nothing-to-show state: a title that names the situation and a
* line saying what to expect next. Which words those are is decided by
* logs-empty.ts, not here.
*/
defineProps<{ title: string; detail?: string }>();
</script>
<template>
<Empty>
<EmptyHeader>
<EmptyTitle>{{ title }}</EmptyTitle>
<EmptyDescription v-if="detail">{{ detail }}</EmptyDescription>
</EmptyHeader>
</Empty>
</template>
+15
View File
@@ -0,0 +1,15 @@
<script setup lang="ts">
import LogActions from "./LogActions.vue";
/** The page's title and what belongs beside it. */
</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]">Logs</h1>
<p class="mt-2 text-sm text-fg-muted">What Archie has been doing, newest last.</p>
</div>
<LogActions />
</div>
</template>
+16
View File
@@ -0,0 +1,16 @@
<script setup lang="ts">
import LogsHeader from "./LogsHeader.vue";
import LogStream from "./LogStream.vue";
import { useLogs } from "./state";
/**
* The daemon log: the history /api/logs serves with the live stream tailed
* onto it. Composes the page; it holds no state of its own.
*/
useLogs();
</script>
<template>
<LogsHeader />
<LogStream />
</template>
+62
View File
@@ -0,0 +1,62 @@
import type { LogEntry } from "@/lib/log";
/**
* What the log list is made of: the filters an entry survives, the key that
* makes one entry, and the merge of the durable history with the live tail.
* Pure, so the page's rendering has nothing to decide about entries.
*/
/** The filters the list is read through. All three narrow the read
* server-side as well as the live stream locally. */
export interface LogFilters {
level: string;
component: string;
q: string;
}
/**
* entryKey is the identity of a log line: its time, level, message and fields.
* The live stream repeats entries the history also carries, so both sides key
* on the same value and the duplicate is stored once.
*/
export function entryKey(entry: LogEntry): string {
return `${entry.time || ""}|${entry.level || ""}|${entry.message || entry.msg || ""}|${JSON.stringify(entry.fields || {})}`;
}
/**
* matchesFilters applies the filters to one entry. It runs over live entries as
* they arrive and again over the merged list, so the level CSV is matched part
* by part exactly as the server matches it (`splitCSV` in
* internal/webui/api_tasks_logs.go).
*/
export function matchesFilters(entry: LogEntry, filters: LogFilters): boolean {
if (filters.level && !filters.level.split(",").includes((entry.level || "").toUpperCase())) {
return false;
}
if (filters.component && entry.fields?.component !== filters.component) return false;
if (filters.q) {
const needle = filters.q.toLowerCase();
const hay = `${entry.message || entry.msg || ""} ${JSON.stringify(entry.fields || {})}`.toLowerCase();
if (!hay.includes(needle)) return false;
}
return true;
}
/**
* mergeEntries overlays the live tail on the durable history, keeps the last
* 1000 that pass the filters, and returns them oldest first.
*
* A key the history already holds keeps its position when the live entry
* replaces it, so a line both sources carry is not reordered; lines only ever
* seen live land at the end, where the newest ones belong.
*/
export function mergeEntries(
history: LogEntry[],
live: Map<string, LogEntry>,
filters: LogFilters,
): LogEntry[] {
const byID = new Map<string, LogEntry>();
for (const entry of history) byID.set(entryKey(entry), entry);
for (const [id, entry] of live) byID.set(id, entry);
return [...byID.values()].filter((entry) => matchesFilters(entry, filters)).slice(-1000);
}
+143
View File
@@ -0,0 +1,143 @@
import { computed, onMounted, onUnmounted, reactive, ref, watch } from "vue";
import { api, subscribeLogs } from "@/lib/api";
import type { LogEntry } from "@/lib/log";
import type { StatusKind } from "@/lib/status";
import type { StreamState } from "@/lib/stream-state";
import { entryKey, matchesFilters, mergeEntries, type LogFilters } from "./log-entries";
import { logsEmptyDetail, logsEmptyTitle } from "./logs-empty";
/**
* The log page's shared state.
*
* The filters, the stream's state and the list itself are read by different
* components, so it lives in a module rather than being threaded down through a
* chain of props.
*/
/** One page of the durable log, as GET /api/logs answers it. */
interface LogHistory {
entries?: LogEntry[];
components?: string[];
file?: string;
truncated?: boolean;
/** The process serving the request keeps no durable history. */
disabled?: boolean;
}
export const filters = reactive<LogFilters>({ level: "", component: "", q: "" });
/** The components the filter can name: those the server found, plus any the
* live stream has shown since. */
export const componentOptions = ref<string[]>([]);
export const paused = ref(false);
export const loading = ref(true);
export const readError = ref<string | null>(null);
export const streamState = ref<StreamState | "connecting">("connecting");
const historyEntries = ref<LogEntry[]>([]);
const durableUnavailable = ref(false);
const truncated = ref(false);
const logFile = ref("");
// Live entries are held in a plain Map so a line the stream repeats is stored
// once, and the tick is what makes that mutation visible to `entries` below --
// a Map is not something a computed can depend on by being read.
const liveEntries = new Map<string, LogEntry>();
const liveTick = ref(0);
export const entries = computed(() => {
void liveTick.value;
return mergeEntries(historyEntries.value, liveEntries, filters);
});
/** What the list is showing. Every string here is a statement about this
* process: a failed read, a read in flight, a deployment with no durable
* history, or the file the lines came from. */
export const meta = computed(() => {
if (readError.value) return "Cannot read logs";
if (loading.value) return "Refreshing…";
if (durableUnavailable.value) return "Live only";
if (truncated.value) return `showing the most recent matches from ${logFile.value}`;
return logFile.value;
});
/** The stream's state as a badge kind. Never `ok` for a stream that is still
* connecting, and never `warn` for one that has given up: the two are
* different answers, and stream-state.ts is what tells them apart. */
export const streamKind = computed<StatusKind>(() => {
if (streamState.value === "live") return "ok";
return streamState.value === "unavailable" ? "danger" : "warn";
});
/** Which of the nothing-to-show situations the list is in. */
export const emptyTitle = computed(() => logsEmptyTitle(durableUnavailable.value, streamState.value));
export const emptyDetail = computed(() => logsEmptyDetail(durableUnavailable.value, streamState.value));
export async function loadLogs(): Promise<void> {
loading.value = true;
readError.value = null;
try {
const res = await api.logs<LogHistory>({
level: filters.level,
component: filters.component,
q: filters.q,
limit: 500,
});
componentOptions.value = res.components ?? [];
durableUnavailable.value = !!res.disabled;
truncated.value = !!res.truncated;
logFile.value = res.file ?? "";
historyEntries.value = res.entries ?? [];
} 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 lines.
readError.value = (err as Error).message || String(err);
} finally {
loading.value = false;
}
}
function handleEntry(raw: unknown): void {
// Paused drops what arrives rather than buffering it: the list is a view of
// the stream, and resuming continues from where the stream is now instead of
// replaying the pause.
if (paused.value) return;
const entry = raw as LogEntry;
if (!matchesFilters(entry, filters)) return;
liveEntries.set(entryKey(entry), entry);
const component = entry.fields?.component;
if (typeof component === "string" && component && !componentOptions.value.includes(component)) {
componentOptions.value = [...componentOptions.value, component];
}
liveTick.value += 1;
}
let unsubscribe: (() => void) | undefined;
/** Owns the initial read, the re-reads a filter change causes, and the live
* stream, for the page's lifetime. */
export function useLogs(): void {
onMounted(() => {
// A mount opens a new stream against a fresh read, so the tail starts
// unpaused, connecting, and without the lines the previous visit's stream
// left behind. The filters are not reset: they are what the operator last
// asked to see, and the read below answers them again.
paused.value = false;
streamState.value = "connecting";
liveEntries.clear();
liveTick.value += 1;
void loadLogs();
unsubscribe = subscribeLogs(handleEntry, (state) => {
streamState.value = state;
});
});
onUnmounted(() => unsubscribe?.());
// Every filter is a server-side one -- the request carries it -- so a change
// to any of them is a new read, not a re-filter of what is already here.
watch(filters, () => void loadLogs());
}