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.
42 lines
1.8 KiB
TypeScript
42 lines
1.8 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import type { Element, Root } from "hast";
|
|
|
|
import { parseMarkdown } from "../src/chat/markdown.ts";
|
|
|
|
function elements(tree: Root | Element, tag: string): Element[] {
|
|
const found: Element[] = [];
|
|
for (const child of tree.children) {
|
|
if (child.type !== "element") continue;
|
|
if (child.tagName === tag) found.push(child);
|
|
found.push(...elements(child, tag));
|
|
}
|
|
return found;
|
|
}
|
|
|
|
// Guards the chat renderer against script URLs and remote images.
|
|
test("parseMarkdown keeps only safe URLs", () => {
|
|
const cases = [
|
|
{ md: "[x](javascript:alert(1))", tag: "a", count: 0 },
|
|
{ md: "[x](https://example.com)", tag: "a", count: 1 },
|
|
{ md: "[x](//evil.example)", tag: "a", count: 0 },
|
|
{ md: ")", tag: "img", count: 0 },
|
|
{ md: "", tag: "img", count: 1 },
|
|
// Remote and remote-interpretable image URLs must not survive: the
|
|
// browser would fetch them, leaking data in the query string (#2073).
|
|
{ md: "", tag: "img", count: 0 },
|
|
{ md: "", tag: "img", count: 0 },
|
|
{ md: "", tag: "img", count: 0 },
|
|
// remark percent-encodes a backslash in a destination, so /\evil stays a
|
|
// same-origin path (/%5C...); SAFE_SRC still rejects a literal /\ form.
|
|
{ md: "", tag: "img", count: 1 },
|
|
// Allowed controls: same-origin root-relative path and inline data image.
|
|
{ md: "", tag: "img", count: 1 },
|
|
{ md: "<script>alert(1)</script>", tag: "script", count: 0 },
|
|
];
|
|
for (const { md, tag, count } of cases) {
|
|
assert.equal(elements(parseMarkdown(md), tag).length, count, md);
|
|
}
|
|
});
|