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.
53 lines
2.0 KiB
TypeScript
53 lines
2.0 KiB
TypeScript
import type { ChatCommandSpec } from "./state";
|
|
|
|
/**
|
|
* The slash palette's arithmetic, kept out of the composer so it is decided in
|
|
* one place rather than reconstructed from DOM positions twice.
|
|
*/
|
|
|
|
/** The command token the caret sits in: a slash word at the start or after a space. */
|
|
const OPEN_TOKEN = /(?:^|\s)\/([^\s]*)$/;
|
|
const ANY_TOKEN = /(?:^|\s)\/[^\s]*$/;
|
|
|
|
/** How many matches the palette will show at once. */
|
|
const MAX_MATCHES = 8;
|
|
|
|
/**
|
|
* matchesFor returns the commands worth offering for the text before the
|
|
* caret, matched on the command and its description together so a word from
|
|
* either finds it.
|
|
*/
|
|
export function matchesFor(specs: ChatCommandSpec[], value: string, caret: number): ChatCommandSpec[] {
|
|
const match = value.slice(0, caret).match(OPEN_TOKEN);
|
|
if (!match) return [];
|
|
const query = match[1].toLowerCase();
|
|
return specs
|
|
.filter((spec) => `${spec.command} ${spec.description ?? ""}`.toLowerCase().includes(query))
|
|
.slice(0, MAX_MATCHES);
|
|
}
|
|
|
|
/**
|
|
* applyCommand replaces the token being completed with the chosen command and
|
|
* returns the cursor position just after it, ready for the next word.
|
|
*/
|
|
export function applyCommand(value: string, caret: number, command: string): { text: string; cursor: number } {
|
|
const before = value.slice(0, caret);
|
|
const after = value.slice(caret);
|
|
const start = before.search(ANY_TOKEN);
|
|
const tokenStart = start < 0 ? before.length : start + (before[start] === " " ? 1 : 0);
|
|
return {
|
|
text: `${before.slice(0, tokenStart)}${command} ${after}`,
|
|
cursor: tokenStart + command.length + 1,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* isExactCommand reports whether the composer already holds a command and
|
|
* nothing else. Enter then sends it rather than completing it, so a command
|
|
* typed in full is never re-entered by the palette that was offering it.
|
|
*/
|
|
export function isExactCommand(specs: ChatCommandSpec[], value: string): boolean {
|
|
const trimmed = value.trim();
|
|
return specs.some((spec) => spec.command === trimmed);
|
|
}
|