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 convergence/chat@0.2.2
Permissions in 0.2.2
Files
session.test.ts10.1 KB
// The Session panel of the right rail, the subagent rows in the transcript
// and the title strip's failure mark, with the real chat modules.
import assert from "node:assert/strict";
import test from "node:test";
import * as Effect from "effect/Effect";
import type { AgentInfo, AppState, Chat } from "convergence";
import type { ChatView } from "./controller.ts";
import { applyEvent } from "./transcript.ts";
import { ago, optionLabel, sessionOpen, statusOf, when, working } from "./session.ts";
import { renderSessionPanel, renderSessionRail } from "./views/session.ts";
import { renderItems } from "./views/rows.ts";
import { renderTitle } from "./views/title.ts";
import { harness, nodes, tree, chat as makeChat, transcript as initial, taskEvent } from "./ui-for-tests.test.ts";
const texts = (node: unknown) =>
nodes(node).flatMap((n) => [n.text, n.label].filter((t): t is string => typeof t === "string" && t !== ""));
function setup(app: AppState) {
const h = harness();
const opened: string[] = [];
h.controller.openSubagent = (_chat, id) =>
Effect.sync(() => {
opened.push(id);
});
const chat = (h.controller.state.chats.c1 = makeChat({
id: "c1",
workspaceId: "w1",
agentId: "claude",
sessionId: "sess-123",
createdAt: "2026-10-11T09:30:00Z",
updatedAt: new Date(Date.now() - 5 * 60_000).toISOString(),
status: "running",
}));
h.controller.state.workspaces.w1 = { id: "w1", name: "nexus", path: "/p/nexus" } as never;
h.controller.state.agents.claude = {
id: "claude",
name: "Claude",
capabilities: { usageLimits: true, cancelTask: true },
status: { state: "ready" },
usageLimits: { windows: [{ id: "five_hour", label: "5 hours", usedPercent: 40, windowMinutes: 300 }] },
} as AgentInfo;
h.controller.state.composers.c1 = {
...h.controller.composer("c1"),
options: [
{
id: "model",
name: "Model",
kind: "select",
category: "model",
value: "opus",
choices: [{ value: "opus", name: "Opus 4.1" }],
},
{
id: "effort",
name: "Effort",
kind: "select",
category: "reasoning",
value: "high",
choices: [{ value: "high", name: "High" }],
},
{
id: "approval",
name: "Approval",
kind: "select",
category: "approval",
value: "ask",
choices: [{ value: "ask", name: "Ask every time" }],
},
],
};
const t = (h.controller.state.transcripts.c1 = initial());
t.usage = { usedTokens: 50_000, contextWindow: 200_000, inputTokens: 1200, outputTokens: 300 };
applyEvent(t, taskEvent({ id: "a", title: "Find the bug", name: "explorer", model: "opus", startedAt: new Date().toISOString() }));
applyEvent(t, taskEvent({ id: "b", title: "Read a file", parentTaskId: "a", status: "waiting" }));
applyEvent(t, taskEvent({ id: "c", title: "Write tests", status: "completed", usage: { usedTokens: 12_000 }, toolUses: 3 }));
const v: ChatView = { ...h.v, ctx: { ...h.v.ctx, app } };
return { h, v, chat, t, opened };
}
test("the panel shows while pinned or previewed, and never otherwise", () => {
assert.equal(sessionOpen({}), false);
assert.equal(sessionOpen({ shared: { rightPanel: "files" } }), false);
assert.equal(sessionOpen({ shared: { rightPanel: "chat" } }), true);
assert.equal(sessionOpen({ shared: { rightPanelPreview: "chat" } }), true);
const { v } = setup({ route: "chat", chatId: "c1", shared: { rightPanel: "git" } });
assert.equal(renderSessionPanel(v), null);
});
test("the session section names the agent, its options, workspace, status, id and times", () => {
const { v } = setup({ route: "chat", chatId: "c1", shared: { rightPanelPreview: "chat" } });
const panel = renderSessionPanel(v);
const words = texts(panel);
for (const expected of ["Session", "Claude", "Opus 4.1 · High", "Ask every time", "nexus", "Running", "sess-123", "5m ago"])
assert.ok(words.includes(expected), `shows ${expected}`);
assert.ok(nodes(panel).some((n) => n.id === "session-copy-id"), "the session id can be copied");
// The context window and the account's limits, with the same helpers as the meters.
assert.ok(words.includes("Context window") && words.includes("25%") && words.includes("150,000"));
assert.ok(words.includes("Usage limits") && words.includes("5 hours") && words.includes("40% used"));
assert.ok(nodes(panel).filter((n) => n.type === "progress").length >= 2);
});
test("subagents are listed nested under their parent; a row opens its tab", async () => {
const { h, v, opened } = setup({ route: "chat", chatId: "c1", shared: { rightPanel: "chat" } });
const panel = renderSessionPanel(v);
const rows = nodes(panel).filter((n) => n.type === "item" && String(n.id).startsWith("session-task-"));
assert.deepEqual(
rows.map((n) => n.label),
["Find the bug", "Read a file", "Write tests"],
);
const holders = nodes(panel).filter((n) => n.children?.some?.((child) => rows.includes(child)));
assert.deepEqual(
holders.map((n) => n.paddingLeft),
[0, 14, 0],
"a child sits one level in",
);
assert.match(String(rows[0].sublabel), /^explorer · Opus 4\.1/);
assert.equal(rows[1].sublabelTone, "warning", "one that waits on the user says so");
assert.match(String(rows[1].sublabel), /^Needs you/);
assert.match(String(rows[2].sublabel), /12k tok · 3 tools/);
rows[1].onClick();
await h.settle();
assert.deepEqual(opened, ["b"]);
});
test("without subagents or a context report the sections say so in one line", () => {
const { h, v } = setup({ route: "chat", chatId: "c1", shared: { rightPanel: "chat" } });
h.controller.state.transcripts.c1 = initial();
const words = texts(renderSessionPanel(v));
assert.ok(words.includes("No subagents in this chat."));
assert.ok(words.includes("The agent has not reported its context window yet."));
});
test("the rail icon counts working subagents and pins the panel", async () => {
const { h, v } = setup({ route: "chat", chatId: "c1", shared: {} });
const rail = tree(renderSessionRail(v));
assert.equal(rail.badge, "2", "running and waiting, not finished");
assert.equal(rail.active, false);
Effect.runSync(h.controller.app.update({ chatId: "c1", route: "chat" }));
rail.onClick();
await h.settle();
assert.equal(Effect.runSync(h.controller.app.state).shared?.rightPanel, "chat");
tree(renderSessionRail(v)).onClick();
await h.settle();
assert.equal(Effect.runSync(h.controller.app.state).shared?.rightPanel, null);
});
test("the title's subagent button opens the Session panel", async () => {
const { h, v, chat } = setup({ route: "chat", chatId: "c1", shared: {} });
Effect.runSync(h.controller.app.update({ chatId: "c1", route: "chat" }));
const button = nodes(renderTitle(v)).find((n) => n.id === `agents-${chat.id}`);
assert.equal(button?.label, "2 working");
button?.onClick();
await h.settle();
assert.equal(Effect.runSync(h.controller.app.state).shared?.rightPanel, "chat");
});
test("a failed chat's title reads like the sidebar: a danger dot and muted text", () => {
const { h, v } = setup({ route: "chat", chatId: "c1", shared: {} });
h.controller.state.chats.c1 = { ...(h.controller.state.chats.c1 as Chat), status: "failed" };
const all = nodes(renderTitle(v));
const failed = all.find((n) => n.type === "text" && n.text === "Failed");
assert.equal(failed?.tone, "muted");
assert.ok(all.some((n) => n.type === "icon" && n.name === "circle" && n.tone === "danger"));
assert.ok(!all.some((n) => n.type === "text" && n.tone === "danger"), "no red text");
});
test("a subagent in the transcript is one activity row that opens its tab", async () => {
const { h, v, chat, opened } = setup({ route: "chat", chatId: "c1", shared: {} });
const t = initial();
applyEvent(t, taskEvent({ id: "x", title: "Survey the code", name: "explorer", model: "opus", usage: { usedTokens: 2_000 } }));
const rows = renderItems(v, chat, t, t.items);
assert.equal(rows.length, 1);
const words = texts(rows[0]);
assert.ok(words.includes("explorer") && words.includes("Survey the code"));
assert.ok(words.some((w) => w.startsWith("Opus 4.1 · ") && w.endsWith("2.0k tok")), "model, time and tokens");
assert.ok(!nodes(rows[0]).some((n) => n.background === "card"), "no card");
const row = nodes(rows[0]).find((n) => typeof n.onClick === "function");
row?.onClick();
await h.settle();
assert.deepEqual(opened, ["x"]);
});
test("subagents started together fold into one row that stays visible while one needs the user", () => {
const { v, chat } = setup({ route: "chat", chatId: "c1", shared: {} });
const t = initial();
applyEvent(t, taskEvent({ id: "x", title: "One", status: "completed" }));
applyEvent(t, taskEvent({ id: "y", title: "Two", status: "waiting" }));
const [group] = renderItems(v, chat, t, t.items);
const words = texts(group);
assert.ok(words.includes("Kicked off 2 subagents"));
assert.ok(words.includes("Needs you"));
assert.ok(words.includes("One") && words.includes("Two"), "open while one is live");
});
test("helpers: option names, chat status, times and the working count", () => {
assert.equal(optionLabel({ value: "a", choices: [{ value: "a", name: "Alpha" }] }), "Alpha");
assert.equal(optionLabel({ value: "raw" }), "raw");
assert.equal(optionLabel({ value: null }), null);
assert.equal(optionLabel(undefined), null);
assert.deepEqual(statusOf({ status: "waiting_question" }), { label: "Needs you", tone: "warning", running: false });
assert.equal(statusOf({ status: "idle" }).label, "Not started");
assert.equal(statusOf({ status: "idle", sessionId: "s" }).label, "Idle");
assert.equal(statusOf({ status: "failed" }).tone, "danger");
const now = Date.parse("2026-10-11T12:00:00Z");
assert.equal(ago("2026-10-11T11:59:40Z", now), "just now");
assert.equal(ago("2026-10-11T09:00:00Z", now), "3h ago");
assert.equal(ago("2026-10-09T12:00:00Z", now), "2d ago");
assert.equal(ago("nope", now), null);
assert.equal(when(""), null);
assert.ok(when("2026-10-11T09:30:00Z")?.startsWith("Oct 11"));
const t = initial();
applyEvent(t, taskEvent({ id: "q", status: "queued" }));
applyEvent(t, taskEvent({ id: "r", status: "running" }));
assert.equal(working(t.items), 1, "a queued subagent is not working yet");
});Versions
| Version | Published | Plugin API | Size | Permissions | Status |
|---|---|---|---|---|---|
| 0.2.5latest | Nov 21, 2026 | >=2 <4 | 174.6 KB | 5 permissions | Listed |
| 0.2.4 | Oct 25, 2026 | >=2 <4 | 174.2 KB | 5 permissions | Listed |
| 0.2.3 | Oct 24, 2026 | >=2 <4 | 165.4 KB | 5 permissions | Listed |
| 0.2.2 | Oct 23, 2026 | >=2 <4 | 165 KB | 5 permissions | Listed |
| 0.2.1 | Oct 6, 2026 | >=2 <3 | 111.8 KB | 5 permissions | Listed |
| 0.2.0 | Oct 5, 2026 | >=2 <3 | 105.1 KB | 5 permissions | Listed |
No comments yet.