The dashboard talks only to the modules/chat API, which sends no slash commands, model list, voice support, attachments or any question other than an approval, so the UI built on those could never appear: - the slash command menu, Retry, Undo, Branch and Preview compression in the More menu, and the /model, /update and /new handling - the model picker, the update card and the api.update* calls - voice recording and the task tags nothing ever added - the questionnaire, picker and clarify cards, and the "Always this session" answer, so components/ui/questionnaire loses its last user - channel.ts, command-scroll.ts and turn.ts, which nothing imported - the old dock-storage migration and the second capitalised spelling of message and tool fields Tasks are gone from the binary too, so chat links and prompts speak of runs: the #N task-link step in the markdown renderer goes, since an agent already links pages through dashboard_navigate. state.ts keeps the shared state and actions; types.ts, stream.ts, transcript.ts, escape.ts and dock-window.ts hold the types, the stream reader, turn-to-message building, Escape layers and the dock's pointer and keyboard handling. ChatDock.vue drops from 560 lines to 307.
70 lines
2.9 KiB
TypeScript
70 lines
2.9 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
suggestionPage,
|
|
suggestionsForRoute,
|
|
type SuggestionRoute,
|
|
} from "../src/chat/suggestions.ts";
|
|
|
|
// One route per page the prompts distinguish, in the shape the page tag reads.
|
|
const pages: Array<[SuggestionRoute, string]> = [
|
|
[{ name: "run", path: "/runs/0b7f", params: { id: "0b7f" } }, "run"],
|
|
[{ name: "runs", path: "/runs" }, "runs"],
|
|
[{ name: "events", path: "/events" }, "events"],
|
|
[{ name: "workflows", path: "/workflows" }, "workflows"],
|
|
[{ name: "schedules", path: "/schedules" }, "schedules"],
|
|
[{ name: "org-schedules", path: "/org/schedules" }, "schedules"],
|
|
[{ name: "org-schedule-runs", path: "/org/schedules/7/runs", params: { id: "7" } }, "schedules"],
|
|
[{ name: "system-models", path: "/settings/models", meta: { settings: true, label: "Models" } }, "settings"],
|
|
[{ name: "settings-tools", path: "/settings/tools" }, "settings"],
|
|
[{ path: "/settings/secret-engines" }, "settings"],
|
|
[{ name: "dashboard", path: "/" }, "default"],
|
|
[{ name: "org-members", path: "/org/members" }, "default"],
|
|
[{ name: "not-found", path: "/nope" }, "default"],
|
|
[{}, "default"],
|
|
];
|
|
|
|
test("each page route resolves to its own prompt set", () => {
|
|
for (const [route, page] of pages) {
|
|
assert.equal(suggestionPage(route), page, JSON.stringify(route));
|
|
}
|
|
});
|
|
|
|
test("the prompts follow the page", () => {
|
|
const byPage = new Map<string, string[]>();
|
|
for (const [route, page] of pages) {
|
|
const prompts = suggestionsForRoute(route);
|
|
const seen = byPage.get(page);
|
|
if (seen) assert.deepEqual(prompts, seen, page);
|
|
else byPage.set(page, prompts);
|
|
}
|
|
const sets = [...byPage.values()];
|
|
for (let i = 0; i < sets.length; i++) {
|
|
for (let j = i + 1; j < sets.length; j++) {
|
|
assert.notDeepEqual(sets[i], sets[j], `pages ${[...byPage.keys()][i]} and ${[...byPage.keys()][j]} share a prompt set`);
|
|
}
|
|
}
|
|
});
|
|
|
|
test("every route yields distinct, well-formed prompts", () => {
|
|
for (const [route] of pages) {
|
|
const prompts = suggestionsForRoute(route);
|
|
assert.ok(prompts.length >= 2, JSON.stringify(route));
|
|
assert.equal(new Set(prompts).size, prompts.length, JSON.stringify(route));
|
|
for (const prompt of prompts) {
|
|
assert.ok(prompt.trim().length > 0, JSON.stringify(route));
|
|
assert.ok(!prompt.includes("undefined"), prompt);
|
|
}
|
|
}
|
|
});
|
|
|
|
test("settings is recognised by flag, by name and by path alike", () => {
|
|
const byFlag = suggestionsForRoute({ name: "system-status", path: "/settings/status", meta: { settings: true } });
|
|
const byName = suggestionsForRoute({ name: "settings-plugins", path: "/settings/plugins" });
|
|
const byPath = suggestionsForRoute({ path: "/settings/container-runtime" });
|
|
assert.deepEqual(byName, byFlag);
|
|
assert.deepEqual(byPath, byFlag);
|
|
assert.notDeepEqual(byFlag, suggestionsForRoute({ name: "dashboard", path: "/" }));
|
|
});
|