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.
70 lines
2.1 KiB
TypeScript
70 lines
2.1 KiB
TypeScript
// 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;
|
|
}
|