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.
195 lines
5.3 KiB
TypeScript
195 lines
5.3 KiB
TypeScript
/**
|
|
* The task run page's model: what the page can show, the shapes it reads from
|
|
* the daemon, and the URL contract that carries the open tab and the pinned
|
|
* attempt.
|
|
*
|
|
* One task id, one page. The id rides in the path and the view state (`tab`,
|
|
* `attempt`) rides in the query string, so every view of this page is a deep
|
|
* link that survives a reload -- /tasks/42?tab=changes&attempt=2.
|
|
*
|
|
* The attempt is the unit of every panel. Nothing here merges two attempts:
|
|
* the rail, the log, the capture and the config are all selected by attempt,
|
|
* and the two views of the same task's attempts (the selector and the rail)
|
|
* come from a single response.
|
|
*/
|
|
import type { LocationQuery, LocationQueryRaw } from "vue-router";
|
|
|
|
import type { LogEntry } from "@/lib/log";
|
|
|
|
export interface TaskRunTab {
|
|
id: string;
|
|
label: string;
|
|
}
|
|
|
|
export const RUN_TABS: TaskRunTab[] = [
|
|
{ id: "stages", label: "Stages" },
|
|
{ id: "log", label: "Log" },
|
|
{ id: "changes", label: "Changed files" },
|
|
{ id: "config", label: "Configuration" },
|
|
{ id: "debug", label: "Debug" },
|
|
];
|
|
|
|
const TAB_IDS = new Set(RUN_TABS.map((tab) => tab.id));
|
|
|
|
/** The task record as the task list serves it. */
|
|
export interface TaskRecord {
|
|
id: number | string;
|
|
title?: string;
|
|
status?: string;
|
|
workflow?: string;
|
|
owner?: string;
|
|
repo?: string;
|
|
repo_url?: string;
|
|
issue_number?: number;
|
|
issue_url?: string;
|
|
pr_number?: number;
|
|
pr_url?: string;
|
|
actions?: string[];
|
|
}
|
|
|
|
/** One stage of one attempt, as `GET /api/tasks/{id}/attempts` returns it. */
|
|
export interface Stage {
|
|
seq?: number;
|
|
name?: string;
|
|
status?: string;
|
|
duration_ms?: number;
|
|
error?: string;
|
|
}
|
|
|
|
export interface Attempt {
|
|
attempt: number;
|
|
status?: string;
|
|
started_at?: string;
|
|
duration_ms?: number;
|
|
stages?: Stage[];
|
|
}
|
|
|
|
/**
|
|
* The run history. `current_attempt` is 0 on the wire for a task with no run
|
|
* at all, which is not an attempt number.
|
|
*/
|
|
export interface AttemptsState {
|
|
attempts?: Attempt[];
|
|
current_attempt?: number;
|
|
unattributed_events?: number;
|
|
}
|
|
|
|
/** One event off the task's stream, as much of it as this page reads. */
|
|
export interface TaskEvent {
|
|
kind?: string;
|
|
type?: string;
|
|
stage?: string;
|
|
workflow?: string;
|
|
attempt?: number;
|
|
at?: string;
|
|
detail?: string;
|
|
data?: Record<string, unknown>;
|
|
}
|
|
|
|
export interface LogFilters {
|
|
level: string;
|
|
stage: string;
|
|
}
|
|
|
|
/** The attempt log read's three outcomes: disabled, not found, or entries. */
|
|
export interface LogState {
|
|
found?: boolean;
|
|
disabled?: boolean;
|
|
attempt?: number;
|
|
entries?: LogEntry[];
|
|
}
|
|
|
|
export interface CaptureFile {
|
|
path?: string;
|
|
old_path?: string;
|
|
status?: string;
|
|
binary?: boolean;
|
|
additions?: number;
|
|
deletions?: number;
|
|
}
|
|
|
|
export interface CaptureTotals {
|
|
files?: number;
|
|
additions?: number;
|
|
deletions?: number;
|
|
}
|
|
|
|
/** One recorded change capture for an attempt. */
|
|
export interface Capture {
|
|
captured_after?: string;
|
|
captured_at?: string;
|
|
stage?: string;
|
|
owner?: string;
|
|
repo?: string;
|
|
repo_url?: string;
|
|
branch?: string;
|
|
base?: string;
|
|
head_sha?: string;
|
|
pr_number?: number;
|
|
pr_url?: string;
|
|
totals?: CaptureTotals;
|
|
files?: CaptureFile[];
|
|
truncated?: boolean;
|
|
}
|
|
|
|
export interface ChangesState {
|
|
found?: boolean;
|
|
captures?: Capture[];
|
|
}
|
|
|
|
/** The stored task record and its events, verbatim: nothing here projects it. */
|
|
export type DebugState = Record<string, unknown>;
|
|
|
|
export function parseTaskId(raw: unknown): number | null {
|
|
const value = String(raw ?? "").trim();
|
|
if (!/^\d+$/.test(value)) return null;
|
|
const n = Number(value);
|
|
return Number.isSafeInteger(n) && n > 0 ? n : null;
|
|
}
|
|
|
|
export function initialTab(query: LocationQuery | undefined): string {
|
|
const requested = String(query?.tab ?? "");
|
|
return TAB_IDS.has(requested) ? requested : RUN_TABS[0].id;
|
|
}
|
|
|
|
/**
|
|
* `?attempt=2` pins attempt 2. An absent, empty or non-numeric value follows
|
|
* whatever the server reports as current, and 0 is the wire's own spelling of
|
|
* "the current attempt" (taskLogTarget, internal/webui/api_tasks_logs.go), so
|
|
* it selects the current attempt rather than a nonexistent attempt 0.
|
|
*/
|
|
export function initialAttempt(query: LocationQuery | undefined): number | null {
|
|
const raw = query?.attempt;
|
|
if (raw == null || raw === "") return null;
|
|
const n = Number(raw);
|
|
return Number.isInteger(n) && n > 0 ? n : null;
|
|
}
|
|
|
|
/** The query string a tab and an attempt are addressed by. */
|
|
export function runQuery(tab: string, attempt: number | null): LocationQueryRaw {
|
|
const query: LocationQueryRaw = { tab: tab || RUN_TABS[0].id };
|
|
if (attempt) query.attempt = String(attempt);
|
|
return query;
|
|
}
|
|
|
|
export function attemptKey(id: number, attempt: number | null): string {
|
|
return `${id}|${Number(attempt) || 0}`;
|
|
}
|
|
|
|
export const EMPTY_LOG_FILTERS: LogFilters = { level: "", stage: "" };
|
|
|
|
/**
|
|
* The identity of a log read: a task, an attempt, and the filters that produced
|
|
* the response. Keying by task alone cannot represent two attempts -- the bug
|
|
* this replaces -- and keying without the filters would serve attempt 2's
|
|
* unfiltered log in answer to a filtered request.
|
|
*/
|
|
export function logCacheKey(
|
|
id: number,
|
|
attempt: number | null,
|
|
filters: LogFilters = EMPTY_LOG_FILTERS,
|
|
): string {
|
|
const applied = filters || EMPTY_LOG_FILTERS;
|
|
return [id, Number(attempt) || 0, applied.level || "", applied.stage || ""].join("|");
|
|
}
|