Official
chat
Built-in chat UI (JavaScript UI plugin).
The app opens the listing; nothing installs until an agent in your Plugins workspace has read the files and you enable the plugin. In a terminal: dvg install divergence/chat@0.2.7
Permissions in 0.2.7
Files
terminal.test.ts6.8 KB
import test from "node:test";
import assert from "node:assert/strict";
import * as Effect from "effect/Effect";
import { ansiLines, terminalOutput } from "./terminal.tsx";
import { applyEvent } from "./transcript.ts";
import { openSubagent } from "./panes.ts";
import { renderSubagentPane, renderTask } from "./views/tasks.tsx";
import { chat, harness, nodes, taskEvent } from "./ui-for-tests.test.ts";
import { HostCallFailed } from "divergence/effect";
test("captured output keeps ANSI colours and whitespace while discarding control sequences", () => {
assert.deepEqual(ansiLines("\x1b[31;1mred\x1b[0m plain\n\x1b[38;2;1;2;3mrgb"), [
[{ text: "red", color: "danger", bold: true }, { text: " plain" }],
[{ text: "rgb", color: "#010203" }],
]);
assert.deepEqual(ansiLines("10%\r20%\x1b]0;title\x07\r\nend"), [[{ text: "20%" }], [{ text: "end" }]]);
});
test("opening a terminal opens its tab without reading subagent history", async () => {
const h = harness(),
c = chat();
h.controller.state.chats[c.id] = c;
const t = h.controller.transcript(c.id);
t.snapshot = { kind: "ready" };
applyEvent(
t,
taskEvent({
id: "build",
kind: "terminal",
command: "cargo build",
title: "Build",
output: "\x1b[32m done\x1b[0m\n",
status: "running",
}),
);
await Effect.runPromise(openSubagent(h.controller, c, "build"));
assert.deepEqual(
(h.controller.api as unknown as { layouts: { opened: unknown[] } }).layouts.opened,
[{ kind: "subagent", key: "build", chatId: c.id }],
);
assert.equal(
h.calls.some((call) => call.method === "host/chats.load_task"),
false,
);
const output = nodes(renderSubagentPane(h.v, c.id, "build"));
assert.ok(output.some((node) => node.text === "$ cargo build"));
assert.ok(output.some((node) => node.text === " done" && node.color === "success"));
// Lines wrap at the pane's edge instead of scrolling sideways one by one.
assert.ok(!output.some((node) => node.overflowX === "scroll" || node.whiteSpace === "nowrap"));
applyEvent(t, taskEvent({ id: "build", kind: "terminal", title: "Build", outputDelta: "more\n", status: "running" }));
assert.ok(nodes(renderSubagentPane(h.v, c.id, "build")).some((node) => node.text === "more"));
applyEvent(
t,
taskEvent({
id: "build",
kind: "terminal",
command: "cargo build",
title: "Build",
output: "done\n",
status: "completed",
}),
);
// Like a terminal, the pane is the command and its output, with no status header.
const done = nodes(renderSubagentPane(h.v, c.id, "build"));
assert.ok(done.some((node) => node.text === "done"));
assert.ok(!done.some((node) => node.text === "Completed" || node.text === "Running"));
await h.close();
});
test("a line of several styles wraps between its runs; a plain line is one text", () => {
const [plain, mixed] = terminalOutput("one long plain line\n\x1b[31merror\x1b[0m: details\n");
assert.equal(plain?.type, "text");
assert.equal(nodes(mixed)[0]?.flexWrap, "wrap");
assert.deepEqual(
nodes(mixed)
.filter((node) => node.type === "text")
.map((node) => node.text),
["error", ": details"],
);
});
test("a background command shows the terminal's mark in the chat and reads like a terminal pane in its tab", () => {
const h = harness(),
c = chat();
h.controller.state.chats[c.id] = c;
const t = h.controller.transcript(c.id);
t.snapshot = { kind: "ready" };
applyEvent(t, taskEvent({ id: "serve", kind: "terminal", command: "pnpm dev", title: "Dev server", output: "ready\n", status: "running" }));
const item = t.items.find((entry) => entry.id === "serve" || (entry as { task?: { id: string } }).task?.id === "serve");
assert.ok(item, "the command is in the transcript");
const rowNodes = nodes(renderTask(h.v, c, t, item as never));
assert.ok(rowNodes.some((node) => node.type === "icon" && node.name === "square-terminal"), "its row has the terminal mark");
assert.ok(!rowNodes.some((node) => node.type === "icon" && node.name === "bot"), "not the agent's");
const pane = nodes(renderSubagentPane(h.v, c.id, "serve"));
const prompt = pane.find((node) => node.text === "$ pnpm dev");
assert.ok(prompt && prompt.tone === undefined, "the command reads as typed, not as a muted label");
assert.ok(!pane.some((node) => node.paddingX === "medium"), "the tab keeps a terminal pane's small inset");
});
test("a command left running after the turn keeps the transcript's working row, counted as a command", async () => {
const { tree } = await import("./ui-for-tests.test.ts");
const { renderTranscript } = await import("./views/rows.tsx");
const h = harness(),
c = chat();
h.controller.state.chats[c.id] = c;
const t = h.controller.transcript(c.id);
t.snapshot = { kind: "ready" };
applyEvent(t, taskEvent({ id: "serve", kind: "terminal", command: "pnpm dev", title: "Dev server", status: "running" }));
t.running = false;
const working = () => nodes(tree(renderTranscript(h.v, c))).find((node) => node.type === "text" && /running|working/.test(String(node.text)))?.text;
assert.equal(working(), "1 command running", "an older host's transcript is counted by kind");
assert.equal(nodes(tree(renderTranscript(h.v, { ...c, working: { agents: 1, commands: 2 } }))).some((node) => node.text === "1 agent and 2 commands working"), true, "the host's count wins");
assert.equal(nodes(tree(renderTranscript(h.v, { ...c, working: { agents: 0, commands: 0 } }))).some((node) => /running|working/.test(String(node.text))), false, "and none means the turn is over");
await h.close();
});
test("a settled subagent's tab shows nothing while its transcript is read, and says so when the read fails", async () => {
let fail: (error: HostCallFailed) => void = () => {};
const h = harness((method) =>
method === "host/chats.load_task"
? Effect.callback<unknown, HostCallFailed>((resume) => {
fail = (error) => resume(Effect.fail(error));
})
: undefined,
),
c = chat();
h.controller.state.chats[c.id] = c;
const t = h.controller.transcript(c.id);
t.snapshot = { kind: "ready" };
applyEvent(t, taskEvent({ id: "helper", title: "Count the tests", status: "completed" }));
await Effect.runPromise(openSubagent(h.controller, c, "helper"));
const texts = () => nodes(renderSubagentPane(h.v, c.id, "helper")).map((node) => node.text);
assert.ok(!texts().includes("The subagent left no transcript."), "nothing is said while it reads");
fail(new HostCallFailed({ method: "host/chats.load_task", code: -32603, message: "the history cannot be aligned" }));
await new Promise((resolve) => setTimeout(resolve, 0));
assert.ok(!texts().includes("The subagent left no transcript."));
assert.ok(texts().includes("Could not read the subagent's transcript: the history cannot be aligned"), String(texts()));
});Versions
| Version | Published | Plugin API | Size | Permissions | Status |
|---|---|---|---|---|---|
| 0.2.9latest | Nov 21, 2026 | >=5 <6 | 349 KB | 5 permissions | Listed |
| 0.2.8 | Nov 16, 2026 | >=5 <6 | 348.6 KB | 5 permissions | Listed |
| 0.2.7 | Nov 11, 2026 | >=5 <6 | 314.3 KB | 5 permissions | Listed |
| 0.2.6 | Nov 9, 2026 | >=5 <6 | 306.2 KB | 5 permissions | Listed |
| 0.2.5 | Oct 27, 2026 | >=2 <4 | 178.6 KB | 5 permissions | Listed |
No comments yet.