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
newtab.test.ts5.4 KB
// The New tab page: what a strip's + opens and what the empty side split shows.
import assert from "node:assert/strict";
import test from "node:test";
import * as Effect from "effect/Effect";
import type { Layout, Tab } from "divergence/protocol";
import { noteTask, stepPane, stepTab, toggleSideSplit } from "./layout.ts";
import { NEW_TAB, renderNewTab } from "./newtab.tsx";
import { shortcutsOf } from "./shortcuts.ts";
import { renderTitle } from "./views/title.tsx";
import { chat, harness, nodes } from "./ui-for-tests.test.ts";
const page: Tab = { kind: "item", id: "item-new", owner: "chat", itemKind: `chat.${NEW_TAB}`, key: "k1", title: "New tab" };
/** A chat on screen, alone in its task's one pane, with `extra` tabs after it. */
function onScreen(extra: Tab[] = []) {
const made: { paneId: string }[] = [];
const h = Object.assign(
harness((method, params) => {
if (method !== "host/layouts.new_chat") return undefined;
made.push(params as { paneId: string });
return Effect.succeed({ chat: chat({ id: "n" }) });
}),
{ made },
);
const a = chat({ id: "a" });
h.controller.state.chats.a = a;
const tabs: Tab[] = [{ kind: "chat", chatId: "a" }, ...extra];
const root: Layout = { kind: "pane", id: "p1", tabs, active: tabs[tabs.length - 1]! };
noteTask(h.controller.state.layouts, { id: "t", layout: { root, focused: "p1" }, createdAt: "", updatedAt: "" });
Effect.runSync(h.controller.app.select("a", a.workspaceId));
return h;
}
const opened = (h: ReturnType<typeof harness>) => (h.controller.api as unknown as { layouts: { opened: unknown[] } }).layouts.opened;
test("a strip's + opens a New tab page in its own pane", async () => {
const h = onScreen();
const all = nodes(renderTitle({ ...h.v, ctx: { ...h.v.ctx, app: { route: "chat", chatId: "a" } } }));
const plus = all.find((node) => node.id === "strip-new-p1") as { onClick: () => void } | undefined;
assert.ok(plus, "the strip has its +");
plus.onClick();
await h.settle();
assert.deepEqual(opened(h), [{ kind: NEW_TAB, key: (opened(h)[0] as { key: string }).key, chatId: "a", where: { paneId: "p1" } }]);
await h.close();
});
test("the side split opens on a New tab page when it has nothing for the task on screen", async () => {
const h = onScreen();
const all = nodes(renderTitle({ ...h.v, ctx: { ...h.v.ctx, app: { route: "chat", chatId: "a" } } }));
assert.ok(all.some((node) => node.id === "side-split-toggle"), "its toggle shows with nothing in it");
await Effect.runPromise(toggleSideSplit(h.controller));
assert.equal((opened(h)[0] as { where: unknown }).where, "side");
assert.ok(!h.calls.some((call) => call.method === "host/layouts.update"), "it opens through the page, not an empty split");
await h.close();
});
test("the page lists the next steps with their keys, and a new chat takes the page's place", async () => {
const h = onScreen([page]);
h.controller.state.shortcuts = shortcutsOf([
{ id: "chat.newTab", labels: ["⌘T"] },
{ id: "terminal.new", labels: ["⌘J"] },
]);
const all = nodes(renderNewTab(h.v, "k1"));
for (const id of ["chat", "terminal", "changes", "files", "chats"]) assert.ok(all.some((node) => node.id === `new-tab-${id}`), id);
const text = JSON.stringify(renderNewTab(h.v, "k1"));
assert.ok(text.includes("⌘T") && text.includes("⌘J"), "each step shows its key");
(all.find((node) => node.id === "new-tab-chat") as unknown as { onClick: () => void }).onClick();
await h.settle();
assert.deepEqual(h.made.map((call) => call.paneId), ["p1"], "a new chat is made in the page's pane");
const closed = h.calls.find((call) => call.method === "host/layouts.close_tab");
assert.deepEqual((closed?.params as { tab: Tab } | undefined)?.tab, page, "and the page closes");
await h.close();
});
test("a step that opens a panel leaves the page where it is", async () => {
const h = onScreen([page]);
(nodes(renderNewTab(h.v, "k1")).find((node) => node.id === "new-tab-files") as unknown as { onClick: () => void }).onClick();
await h.settle();
assert.ok(h.calls.some((call) => call.method === "run_command" && (call.params as { id: string }).id === "files.toggle"));
assert.ok(!h.calls.some((call) => call.method === "host/layouts.close_tab"));
await h.close();
});
test("the tab and pane keys reach the side split and come back", async () => {
const item = (id: string): Tab => ({ kind: "item", id, owner: "tabs", itemKind: "tabs.file", key: id, title: id });
const h = onScreen();
h.controller.state.layouts.side = {
open: true,
width: 520,
remembered: [],
layout: { root: { kind: "pane", id: "s1", tabs: [item("x"), item("y")], active: item("x") }, focused: "s1" },
} as never;
const updates = () => h.calls.filter((call) => call.method === "host/layouts.update").map((call) => call.params as { paneId?: string; active?: Tab });
await Effect.runPromise(stepPane(h.controller, "right"));
assert.equal(updates().at(-1)?.paneId, "s1", "right of the task's last pane is the side split");
assert.equal(h.controller.state.layouts.sideFocused, true);
await Effect.runPromise(stepTab(h.controller, 1));
assert.deepEqual(updates().at(-1), { paneId: "s1", active: item("y"), focused: true, onScreen: "t" }, "the next tab is the side split's");
await Effect.runPromise(stepPane(h.controller, "left"));
assert.equal(h.controller.state.layouts.sideFocused, false, "left of the side split is the task again");
await h.close();
});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.