feat(webui): port the shared primitives (Phase 2)

The Preact tree's ui/src/base/ was deleted with the dashboard. This rebuilds
what depended on it, on the shadcn layer rather than as new bespoke markup.

Badge and Card come from the shadcn-vue CLI, so they match the already-vendored
components, and the composed pieces sit on top of them:

- Badge gains the five status variants the pills used, over the palette's status
  tokens. The pill's dot did not come across: the Badge's own shape is the
  affordance, and the same variant now covers a trend indicator, where a dot
  reads as noise.
- base/StatTile.vue uses full Card composition instead of dumping everything
  into one content slot, with base/Sparkline.vue and the goodDirection logic
  that says whether "up" is good news.
- base/Gauge.vue and base/SegmentBar.vue, both of them: the original exported
  two components from one file and budget composition uses the second.
- base/LogRow.vue over lib/log.ts, which holds the LOG_LEVELS wire contract
  (the server matches that CSV server-side, so it is not a display choice).
- lib/status.ts, so status colour has one home: a task state, a gate result, a
  log level and a trend all draw from the same five kinds.

Two deliberate departures:

The icon module is not ported. Its name-to-glyph string lookup is the pattern
shadcn-vue's rules call out as wrong, and nothing consumes the five bespoke
glyphs anyway: the navigation is text with tooltips. Icons come from @lucide/vue
at the call site, and the five become components if a page draws them.

The gauge's aria-label announces the rounded percentage. It announced the raw
one, so a screen reader read 71.38461538461539% where the screen showed 71%
(bead 86au).

Also lands the four modules the checklist marks copy-verbatim, which encode
bugs fixed just before the delete: dashboard/activity-detail, chat/
command-scroll, workflows/workflow-rows and logs/logs-empty.
This commit is contained in:
sam committed 2026-09-20 19:38:17 +10:00
1 parent ff8369c5ac
commit 25650a4b7d
23 files changed
+740 -16

No files matched your search

+22 -15
View File
@@ -118,23 +118,30 @@ does not show up as a broken page.
## Phase 2 — Shared primitives
| Was | Becomes |
| Was | Is |
|---|---|
| `base/pill.jsx` | `Badge`, with the status-token variants from `pill.css` |
| `base/statTile.jsx` | `Card` composition **plus** its `Sparkline` (inline SVG polyline with its own min/max/step math) and trend-arrow logic, where `goodDirection` distinguishes "up is good" from "up is bad" |
| `base/icons.jsx` | `lucide-vue-next` for most, but `dashboard`, `mappings`, `bindings`, `curators` and `memory` are bespoke glyphs with no 1:1 Lucide equivalent. Swapping them changes the drawing — a design call, not a rename |
| `base/gauge.jsx` | bespoke SVG, port as-is — **exports two components**, `Gauge` and `SegmentBar` (proportional multi-segment bar plus legend, used for budget composition). Easy to port only the one the filename names |
| `base/log-row.jsx` | bespoke, port as-is; see the `LOG_LEVELS` wire contract above |
| `base/format.jsx` | genuinely pure, port as-is |
| `base/task-meta.jsx` | **not** a plain module: module-level mutable cache, async fetch, and the boot-time re-render trigger above |
| `base/pill.jsx` | `Badge`, with five status variants (`ok`, `warn`, `danger`, `info`, `idle`) over the palette's status tokens |
| `base/statTile.jsx` | `base/StatTile.vue`: full `Card` composition (`CardHeader`, `CardTitle`, `CardDescription`, `CardAction`, `CardContent`), `base/Sparkline.vue`, and the `goodDirection` trend logic |
| `base/icons.jsx` | **Not ported as a module.** Its string-keyed lookup is the pattern shadcn-vue's rules name as wrong, so icons come from `@lucide/vue` at the call site |
| `base/gauge.jsx` | `base/Gauge.vue` and `base/SegmentBar.vue`, both ported. The gauge's `aria-label` announces the rounded percentage, which closes `86au` |
| `base/log-row.jsx` | `base/LogRow.vue` over `lib/log.ts` (`LOG_LEVELS`, `levelKind`, `shortTime`, `fmtValue`) |
| `base/format.jsx` | `lib/format.ts` (`ago`, `compact`) |
| `base/task-meta.jsx` | `lib/task-meta.ts`; Vue's reactivity replaces the manual boot-time re-render the Preact module needed |
- [ ] **Copy verbatim.** These five are framework-free and need only a rename:
`dashboard/activity-detail.js`, `chat/command-scroll.js`,
`workflows/workflow-rows.js`, `base/stream-state.js`,
`logs/logs-empty.js`. Each encodes a bug fixed today; re-deriving them by
hand is how the bugs come back.
- [ ] `base/uuid.jsx` → `src/lib/uuid.ts`.
- [ ] `routing.jsx` is superseded by vue-router. Do not port it.
Two decisions worth not re-litigating:
- The pill's dot did not come across to `Badge`. The Badge's own shape is the
affordance, and the same variant now covers things that are not status pills
(a trend indicator), where a dot reads as noise.
- The five bespoke glyphs (`dashboard`, `mappings`, `bindings`, `curators`,
`memory`) are not drawn yet because nothing consumes them: the navigation is
text with tooltips. If a page needs one, it becomes its own component at that
point rather than a glyph table waiting for a caller.
- [x] **Copy verbatim.** `dashboard/activity-detail.ts`, `chat/command-scroll.ts`,
`workflows/workflow-rows.ts`, `logs/logs-empty.ts`, and `lib/stream-state.ts`.
- [x] `base/uuid.jsx` → `src/lib/uuid.ts`.
- [x] `routing.jsx` is superseded by vue-router. Not ported.
## Phase 3 — Pages
+1 -1
View File
@@ -1,2 +1,2 @@
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){:root,:host{--shimmer-angle:20deg}*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-x-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-content:"";--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0;--scroll-fade-t:0;--scroll-fade-b:0;--scroll-fade-s:0;--scroll-fade-e:0;--scroll-fade-mask:initial;--shimmer-image:initial;--shimmer-text-fill:initial}}}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-wght-normal.woff2)format("woff2-variations");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-vietnamese-wght-normal.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-wght-normal.woff2)format("woff2-variations");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@layer theme{:root,:host{--font-sans:"Geist Variable", sans-serif;--spacing:.25rem;--container-xs:20rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-tight:-.025em;--tracking-wide:.025em;--tracking-widest:.1em;--radius-xs:.125rem;--radius-md:10px;--blur-xl:24px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:"Geist Variable", sans-serif;--default-mono-font-family:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkitLine truncated
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){:root,:host{--shimmer-angle:20deg}*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-x-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:"";--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0;--scroll-fade-t:0;--scroll-fade-b:0;--scroll-fade-s:0;--scroll-fade-e:0;--scroll-fade-mask:initial;--shimmer-image:initial;--shimmer-text-fill:initial}}}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-wght-normal.woff2)format("woff2-variations");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-vietnamese-wght-normal.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-wght-normal.woff2)format("woff2-variations");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@layer theme{:root,:host{--font-sans:"Geist Variable", sans-serif;--spacing:.25rem;--container-xs:20rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25 / 1.875);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-tight:-.025em;--tracking-wide:.025em;--tracking-widest:.1em;--leading-snug:1.375;--radius-xs:.125rem;--radius-md:10px;--radius-4xl:2rem;--blur-xl:24px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:"Geist Variable", sans-serif;--default-mono-font-family:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-featureLine truncated
+75
View File
@@ -0,0 +1,75 @@
<script setup lang="ts">
import { computed } from "vue";
/**
* Arc gauge for a single headline percentage.
*
* A percentage that decides whether you need to act deserves more than a line
* of text: the arc is readable at a glance from across a room, which a number
* is not. Colour follows the value, so "is this bad" is answered before the
* digits are read.
*/
const props = withDefaults(defineProps<{ value: number | string; label: string; size?: number }>(), {
size: 168,
});
const pct = computed(() => Math.max(0, Math.min(100, Number(props.value) || 0)));
const rounded = computed(() => Math.round(pct.value));
const stroke = computed(() => (pct.value >= 90 ? "var(--ok)" : pct.value >= 70 ? "var(--warn)" : "var(--danger)"));
// 240-degree arc, opening downward, so the value reads left-to-right.
const R = 62;
const SWEEP = 240;
const START = 150;
const circumference = 2 * Math.PI * R * (SWEEP / 360);
function arc(from: number, deg: number): string {
const cx = props.size / 2;
const cy = props.size / 2;
const a0 = (from * Math.PI) / 180;
const a1 = ((from + deg) * Math.PI) / 180;
const large = deg > 180 ? 1 : 0;
return [
`M ${cx + R * Math.cos(a0)} ${cy + R * Math.sin(a0)}`,
`A ${R} ${R} 0 ${large} 1 ${cx + R * Math.cos(a1)} ${cy + R * Math.sin(a1)}`,
].join(" ");
}
</script>
<template>
<div class="relative grid place-items-center">
<!--
The label announces the rounded value. It used to announce the raw one, so
a screen reader read "71.38461538461539%" before the same figure was
shown rounded.
-->
<svg
class="block w-full max-w-[200px]"
:viewBox="`0 0 ${props.size} ${props.size * 0.78}`"
role="img"
:aria-label="`${props.label}: ${rounded}%`"
>
<path
:d="arc(START, SWEEP)"
fill="none"
stroke="var(--border)"
stroke-width="12"
stroke-linecap="round"
/>
<path
:d="arc(START, SWEEP)"
fill="none"
:stroke="stroke"
stroke-width="12"
stroke-linecap="round"
:stroke-dasharray="circumference"
:stroke-dashoffset="circumference * (1 - pct / 100)"
class="transition-[stroke-dashoffset] duration-[600ms] ease-[cubic-bezier(0.4,0,0.2,1)]"
/>
</svg>
<div class="absolute top-[52%] -translate-y-1/2 text-center">
<div class="text-2xl font-semibold tracking-[-0.03em]">{{ rounded }}%</div>
<div class="text-xs text-fg-muted">{{ props.label }}</div>
</div>
</div>
</template>
+33
View File
@@ -0,0 +1,33 @@
<script setup lang="ts">
import { fmtValue, LEVEL_COLOR, levelKind, shortTime, type LogEntry } from "@/lib/log";
/**
* Shared log-entry rendering. Both the daemon-wide log page and a task's own
* attempt log render the same entry shape, so the row lives here rather than
* being duplicated a second time.
*/
const props = defineProps<{ entry: LogEntry }>();
const fields = () => Object.entries(props.entry.fields ?? {});
</script>
<template>
<div
class="grid grid-cols-[62px_52px_1fr] items-baseline gap-3 border-b border-border px-1 py-2 hover:bg-accent"
>
<span class="font-mono text-fg-subtle">{{ shortTime(props.entry.time) }}</span>
<span class="text-[10px] font-semibold tracking-[0.04em]" :class="LEVEL_COLOR[levelKind(props.entry.level)]">
{{ (props.entry.level || "info").toUpperCase() }}
</span>
<span class="flex min-w-0 flex-wrap items-baseline gap-2">
<span class="break-words text-foreground">{{ props.entry.message || props.entry.msg || "" }}</span>
<span
v-for="[k, v] in fields()"
:key="k"
class="max-w-full truncate rounded-sm bg-muted px-2 text-fg-muted"
>
<span class="text-fg-subtle after:opacity-60 after:content-['=']">{{ k }}</span>{{ fmtValue(v) }}
</span>
</span>
</div>
</template>
+46
View File
@@ -0,0 +1,46 @@
<script setup lang="ts">
import { computed } from "vue";
import { STATUS_FILL, type StatusKind } from "@/lib/status";
/**
* Segmented proportional bar with a legend.
*
* Used for budget composition -- what is spent, committed and still free --
* because three related quantities are easier to compare in one bar than in
* three separate numbers.
*/
const props = defineProps<{
segments: Array<{ label: string; value: number; kind?: StatusKind }>;
}>();
const total = computed(() => props.segments.reduce((a, s) => a + (s.value || 0), 0) || 1);
const partWidth = (value: number) => `${((value / total.value) * 100).toFixed(1)}%`;
const fill = (kind?: StatusKind) => STATUS_FILL[kind ?? "idle"];
</script>
<template>
<div>
<div class="flex h-[10px] gap-[2px] overflow-hidden rounded-full bg-border">
<span
v-for="s in props.segments.filter((s) => s.value > 0)"
:key="s.label"
class="block h-full"
:class="fill(s.kind)"
:style="`width:${partWidth(s.value)}`"
:title="`${s.label}: ${s.value}`"
/>
</div>
<div class="mt-3 flex flex-wrap gap-4">
<span
v-for="s in props.segments"
:key="s.label"
class="inline-flex items-center gap-2 text-xs text-fg-muted"
>
<span class="size-2 rounded-full" :class="fill(s.kind)" />
{{ s.label }}
</span>
</div>
</div>
</template>
+45
View File
@@ -0,0 +1,45 @@
<script setup lang="ts">
import { computed } from "vue";
/**
* Inline SVG sparkline. Shows shape, not exact values: the tile's headline
* number carries the precision.
*/
const props = withDefaults(
defineProps<{ series: number[]; stroke?: string; width?: number; height?: number }>(),
{ stroke: "var(--ok)", width: 220, height: 34 },
);
const points = computed(() => {
const max = Math.max(...props.series, 1);
const min = Math.min(...props.series, 0);
const span = max - min || 1;
const step = props.series.length > 1 ? props.width / (props.series.length - 1) : props.width;
return props.series
.map(
(v, i) =>
`${(i * step).toFixed(1)},${(props.height - ((v - min) / span) * props.height).toFixed(1)}`,
)
.join(" ");
});
</script>
<template>
<svg
class="mt-3 block h-[34px] w-full"
:viewBox="`0 0 ${props.width} ${props.height}`"
preserveAspectRatio="none"
aria-hidden="true"
>
<polyline
:points="points"
fill="none"
:stroke="props.stroke"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
vector-effect="non-scaling-stroke"
/>
</svg>
</template>
+63
View File
@@ -0,0 +1,63 @@
<script setup lang="ts">
import { TrendingDown, TrendingUp } from "@lucide/vue";
import { computed } from "vue";
import { Badge } from "@/components/ui/badge";
import { Card, CardAction, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import Sparkline from "./Sparkline.vue";
/**
* A KPI tile: label, big value, trend against a stated comparison window, and
* a sparkline. The comparison line is not decoration -- a number without a
* baseline cannot be acted on, so `compare` is required.
*
* trend > 0 renders as an increase. `goodDirection` says whether that is good,
* because rising latency and rising success rate are not the same news.
*
* The headline value is rendered whatever its type, including 0 and "": a tile
* that showed a label and a comparison line with no number above them read as
* a broken dashboard on every fresh install.
*/
const props = withDefaults(
defineProps<{
label: string;
value: string | number;
unit?: string;
trend?: number | null;
compare: string;
series?: number[];
goodDirection?: "up" | "down";
}>(),
{ series: () => [], goodDirection: "up" },
);
const dir = computed(() => (props.trend == null ? null : props.trend >= 0 ? "up" : "down"));
const good = computed(() => (dir.value == null ? null : dir.value === props.goodDirection));
const trendIcon = computed(() => (dir.value === "up" ? TrendingUp : TrendingDown));
const trendLabel = computed(() => `${Math.abs(props.trend ?? 0).toFixed(1)}%`);
</script>
<template>
<Card>
<CardHeader>
<CardTitle>{{ props.label }}</CardTitle>
<CardDescription v-if="props.compare">{{ props.compare }}</CardDescription>
<CardAction v-if="dir">
<Badge :variant="good ? 'ok' : 'danger'">
<component :is="trendIcon" />
{{ trendLabel }}
</Badge>
</CardAction>
</CardHeader>
<CardContent>
<div class="text-3xl font-semibold tracking-[-0.03em]">
{{ props.value }}<span v-if="props.unit" class="ml-1 text-lg text-fg-muted">{{ props.unit }}</span>
</div>
<Sparkline
v-if="props.series.length > 1"
:series="props.series"
:stroke="good === false ? 'var(--danger)' : 'var(--ok)'"
/>
</CardContent>
</Card>
</template>
+41
View File
@@ -0,0 +1,41 @@
// Keeping the arrow-key selection visible in the command palette.
//
// The palette caps its height and scrolls, so once the matches run past the
// visible rows the selection walked off-screen and the highlight was invisible
// (archie-core-ifay). Browsers have scrollIntoView, but the decision is pure
// arithmetic and worth testing on its own, so the effect only applies what
// this returns.
/** The palette's scroll geometry and the selected option's position in it. */
export interface CommandScrollGeometry {
scrollTop: number;
viewportHeight: number;
optionTop: number;
optionHeight: number;
}
/**
* commandScrollTop returns the scrollTop that brings the selected option fully
* into view, or the current scrollTop when it is already visible. Mirrors
* `scrollIntoView({ block: "nearest" })`: it moves the minimum distance, and
* scrolls up for an option above the viewport, down for one below.
*/
export function commandScrollTop({
scrollTop,
viewportHeight,
optionTop,
optionHeight,
}: CommandScrollGeometry): number {
// An option taller than the viewport cannot be shown whole. Align its top,
// which holds the command itself; aligning the bottom would scroll the name
// out of sight and leave only the tail of its description.
if (optionHeight >= viewportHeight) return optionTop;
if (optionTop < scrollTop) return optionTop;
const optionBottom = optionTop + optionHeight;
const viewportBottom = scrollTop + viewportHeight;
if (optionBottom > viewportBottom) return optionBottom - viewportHeight;
return scrollTop;
}
+27
View File
@@ -0,0 +1,27 @@
<script setup lang="ts">
import type { PrimitiveProps } from 'reka-ui'
import type { HTMLAttributes } from 'vue'
import type { BadgeVariants } from '.'
import { reactiveOmit } from '@vueuse/core'
import { Primitive } from 'reka-ui'
import { cn } from '@/lib/utils'
import { badgeVariants } from '.'
const props = defineProps<PrimitiveProps & {
variant?: BadgeVariants['variant']
class?: HTMLAttributes['class']
}>()
const delegatedProps = reactiveOmit(props, 'class')
</script>
<template>
<Primitive
data-slot="badge"
:data-variant="variant"
:class="cn(badgeVariants({ variant }), props.class)"
v-bind="delegatedProps"
>
<slot />
</Primitive>
</template>
+35
View File
@@ -0,0 +1,35 @@
import type { VariantProps } from 'class-variance-authority'
import { cva } from 'class-variance-authority'
export { default as Badge } from './Badge.vue'
export const badgeVariants = cva(
'h-5 gap-1 rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-3! group/badge inline-flex w-fit shrink-0 items-center justify-center overflow-hidden whitespace-nowrap focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none',
{
variants: {
variant: {
default: 'bg-primary text-primary-foreground [a]:hover:bg-primary/80',
secondary: 'bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80',
destructive: 'bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20',
outline: 'border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground',
ghost: 'hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50',
link: 'text-primary underline-offset-4 hover:underline',
// Status. The five semantic kinds the dashboard's pills used, and the
// only place status colour is decided: a task state, a gate result, a
// log level and a trend all draw from the same ramp, so the same
// colour always means the same thing. Soft background over the solid
// tone rather than white text, which would not hold contrast on the
// lighter kinds.
ok: 'bg-ok-soft text-ok',
warn: 'bg-warn-soft text-warn',
danger: 'bg-danger-soft text-danger',
info: 'bg-info-soft text-info',
idle: 'bg-idle-soft text-idle',
},
},
defaultVariants: {
variant: 'default',
},
},
)
export type BadgeVariants = VariantProps<typeof badgeVariants>
+21
View File
@@ -0,0 +1,21 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'
const props = withDefaults(defineProps<{
class?: HTMLAttributes['class']
size?: 'default' | 'sm'
}>(), {
size: 'default',
})
</script>
<template>
<div
data-slot="card"
:data-size="size"
:class="cn('ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-xl py-4 text-sm ring-1 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl group/card flex flex-col', props.class)"
>
<slot />
</div>
</template>
+17
View File
@@ -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="card-action"
:class="cn('col-start-2 row-span-2 row-start-1 self-start justify-self-end', props.class)"
>
<slot />
</div>
</template>
+17
View File
@@ -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="card-content"
:class="cn('px-4 group-data-[size=sm]/card:px-3', 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="card-description"
:class="cn('text-muted-foreground text-sm', props.class)"
>
<slot />
</div>
</template>
+17
View File
@@ -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="card-footer"
:class="cn('bg-muted/50 rounded-b-xl border-t p-4 group-data-[size=sm]/card:p-3 flex items-center', props.class)"
>
<slot />
</div>
</template>
+17
View File
@@ -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="card-header"
:class="cn('gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]', props.class)"
>
<slot />
</div>
</template>
+17
View File
@@ -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="card-title"
:class="cn('text-base leading-snug font-medium group-data-[size=sm]/card:text-sm cn-font-heading', props.class)"
>
<slot />
</div>
</template>
+7
View File
@@ -0,0 +1,7 @@
export { default as Card } from './Card.vue'
export { default as CardAction } from './CardAction.vue'
export { default as CardContent } from './CardContent.vue'
export { default as CardDescription } from './CardDescription.vue'
export { default as CardFooter } from './CardFooter.vue'
export { default as CardHeader } from './CardHeader.vue'
export { default as CardTitle } from './CardTitle.vue'
+43
View File
@@ -0,0 +1,43 @@
// Live activity's detail column.
//
// The daemon puts whatever a stage produced into an event's detail, so the
// column holds anything from "session-memory" to a few thousand characters of
// agent transcript. Printed raw, one agent_finish row was taller than six
// viewports and the table stopped being scannable (archie-core-qo7f).
//
// The rule is one line in the cell, the whole payload still available. The cut
// happens here rather than in CSS because the row also needs to know whether
// there is more to show.
// Long enough for a useful parked reason, short enough that every row is the
// 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 {
detail?: unknown;
message?: unknown;
}
/** The cell's content: the rendered line, the payload, and whether they differ. */
export interface ActivityDetail {
text: string;
full: string;
truncated: boolean;
}
/**
* activityDetail returns `{ text, full, truncated }` for one event:
* `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 {
const full = String(event?.detail || event?.message || "");
if (!full) return { text: "", full: "", truncated: false };
// The first line that says something: agent output often opens with blanks.
const firstLine = full.split("\n").map((line) => line.trim()).find(Boolean) || "";
const clipped = firstLine.length > CELL_LIMIT ? `${firstLine.slice(0, CELL_LIMIT).trimEnd()}…` : firstLine;
return { text: clipped, full, truncated: clipped !== full };
}
+63
View File
@@ -0,0 +1,63 @@
import type { StatusKind } from "./status";
/**
* Log-entry vocabulary shared by the daemon-wide log page and a task's own
* attempt log, which render the same entry shape from internal/logging.
*/
/**
* The level filter vocabulary. Server-side level filtering takes a CSV of
* levels (`splitCSV` in internal/webui/api_tasks_logs.go), so the combined
* options are a wire concern too, not a display choice.
*/
export const LOG_LEVELS = [
{ value: "", label: "All levels" },
{ value: "ERROR", label: "Errors" },
{ value: "WARN,ERROR", label: "Warnings and errors" },
{ value: "INFO,WARN,ERROR", label: "Info and above" },
{ value: "DEBUG", label: "Debug only" },
];
/** The kinds a log level uses. Never `ok`: a log line is not a pass. */
export type LevelKind = Exclude<StatusKind, "ok">;
/** One entry as internal/logging serialises it. */
export interface LogEntry {
time: string | number | Date;
level?: string | null;
message?: string;
msg?: string;
fields?: Record<string, unknown>;
}
/** The level label's colour, by kind. One place, so two log panes agree. */
export const LEVEL_COLOR: Record<LevelKind, string> = {
danger: "text-danger",
warn: "text-warn",
info: "text-info",
idle: "text-idle",
};
export function levelKind(level: string | null | undefined): LevelKind {
switch ((level || "").toUpperCase()) {
case "ERROR":
return "danger";
case "WARN":
return "warn";
case "DEBUG":
return "idle";
default:
return "info";
}
}
export function fmtValue(v: unknown): string {
if (v == null) return "";
return typeof v === "object" ? JSON.stringify(v) : String(v);
}
export function shortTime(value: string | number | Date): string {
const d = value instanceof Date ? value : new Date(value);
if (Number.isNaN(d.getTime())) return "--:--:--";
return d.toTimeString().slice(0, 8);
}
+18
View File
@@ -0,0 +1,18 @@
/**
* Status vocabulary. The one place status colour is decided: a task state, a
* gate result, a log level and a budget segment all draw from the same five
* kinds, so the same colour always means the same thing wherever it appears.
*/
export type StatusKind = "ok" | "warn" | "danger" | "info" | "idle";
/**
* The filled colour, for marks that carry the kind as a shape rather than as
* text: a bar segment, a legend dot.
*/
export const STATUS_FILL: Record<StatusKind, string> = {
ok: "bg-ok",
warn: "bg-warn",
danger: "bg-danger",
info: "bg-info",
idle: "bg-idle",
};
+29
View File
@@ -0,0 +1,29 @@
// What the logs list says when it has nothing to show.
//
// Three different situations produced one message, which is how the page ended
// up promising that "live daemon logs will appear here" while the stream that
// would deliver them had already given up (archie-core-c5bz).
/**
* logsEmptyTitle names the situation: a dead stream, a deployment with no
* durable history, or filters that match nothing.
*/
export function logsEmptyTitle(durableUnavailable: boolean, streamState: string): string {
if (streamState === "unavailable") return "Log stream unavailable";
if (durableUnavailable) return "No logs yet";
return "Nothing matches";
}
/**
* logsEmptyDetail says what to expect next, and never promises live logs from
* a stream that has stopped.
*/
export function logsEmptyDetail(durableUnavailable: boolean, streamState: string): string {
if (streamState === "unavailable") {
return "The daemon is not serving /api/logs/stream. Reload once it is reachable.";
}
if (durableUnavailable) {
return "This deployment keeps no durable history. Live daemon logs appear here while the page is open.";
}
return "Try a wider level or clear the search.";
}
+69
View File
@@ -0,0 +1,69 @@
// Merging workflow definitions with their run statistics.
//
// The rows used to come from the definition list alone, so a workflow that had
// run but was no longer in that list (or a definitions fetch that came back
// empty while the stats fetch succeeded) produced no rows at all. The page then
// showed "No workflow runs yet" directly above the stage tables listing those
// very runs (archie-core-rcbf).
//
// A run is evidence the workflow exists. Anything with either a definition or
// statistics gets a row.
/** A workflow's run statistics, as the stats endpoint reports them. */
export interface WorkflowStats {
workflow: string;
runs?: number;
merged?: number;
avg_tokens?: number;
avg_steps?: number;
origin?: string;
}
/** A workflow definition, as the definitions endpoint reports it. */
export interface WorkflowDefinition {
id: string;
name?: string;
origin?: string;
enabled?: boolean;
}
/** One table row: a definition, its statistics, or both. */
export interface WorkflowRow {
id: string;
name?: string;
workflow: string;
runs?: number;
merged?: number;
avg_tokens?: number;
avg_steps?: number;
origin?: string;
}
/**
* workflowRows returns one row per known workflow, definitions first and in
* their declared order, then any workflow seen only in the statistics.
*/
export function workflowRows(
workflows: WorkflowStats[] | null | undefined,
definitions: WorkflowDefinition[] | null | undefined,
): WorkflowRow[] {
const stats = new Map((workflows || []).map((w) => [w.workflow, w]));
const rows: WorkflowRow[] = [];
const claimed = new Set<string>();
for (const definition of definitions || []) {
claimed.add(definition.id);
rows.push({
...definition,
...(stats.get(definition.id) || { workflow: definition.id, runs: 0, merged: 0 }),
});
}
for (const workflow of workflows || []) {
if (claimed.has(workflow.workflow)) continue;
// No definition to describe it, so the id is the only name it has.
rows.push({ id: workflow.workflow, name: workflow.workflow, ...workflow });
}
return rows;
}