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.9

Permissions in 0.2.9

  • Control chats chats.controlHighCreates chats, sends prompts and cancels runs.Send prompts, answer agent questions, and create, change, fork, revert, stop and group chats
  • Run other plugins' commands commands.runHighRuns commands of other plugins.Run the sidebar's New chat command from the title bar, and its Close Chat and Reopen Closed Chat for Cmd+W and Cmd+Shift+T on a chat's only tab
  • Read chats chats.readMediumReads your transcripts and chat lists.Show workspaces, tasks, chats and transcripts, and follow them as agents work
  • Read files fs.readMediumReads files in the listed places.Suggest workspace files for @ mentionsPlaces: the open workspace
  • Show panels ui.slotsAlways grantedShows views in the listed parts of the window.Draw the chat grid, the title bar, and the Session panel with its rail buttonSlots: centertitlerailright

Files

folded-rows.test.ts9.3 KB
import assert from "node:assert/strict";
import test from "node:test";
import { renderItems, renderTool } from "./views/rows.tsx";
import { applyEvent } from "./transcript.ts";
import { chat, harness, item, nodes } from "./ui-for-tests.test.ts";
import { foldItems } from "./grouping.ts";
import { groupTasks } from "./subagents.ts";
import { entryId, moveWindow, noteWindows } from "./window.ts";

const normalized = (value: unknown) => JSON.parse(JSON.stringify(value, (_, value) => typeof value === "function" ? "handler" : value));

function foldFixture(count = 3) {
  const h = harness();
  h.controller.state.chats.a = chat({ id: "a", sessionId: "session-a", status: "running" });
  h.controller.state.workspaces.w = { id: "w", name: "Workspace", path: "/workspace", position: 0 };
  const t = h.controller.transcript("a");
  t.running = true;
  t.snapshot = { kind: "ready" };
  t.items = Array.from({ length: count }, (_, index) => item({ id: `t${index}`, role: "tool", call: {
    kind: "read", title: `Read /workspace/file-${index}.rs`, content: [{ type: "text", text: `result ${index}` }],
  } }));
  const draw = (keep = true, windowed = false) => renderItems(h.v, h.controller.state.chats.a!, t, t.items, [], keep,
    windowed ? { before: 0, after: 0, end: true } : undefined);
  const children = () => new Map(nodes(draw()).filter(({ id }) => id?.startsWith("fold-item-")).map((node) => [node.id.slice("fold-item-".length), node]));
  const equivalent = () => assert.deepEqual(normalized(draw()), normalized(draw(false)), "retained output matches fresh materialization");
  return { h, t, draw, children, equivalent };
}

test("a kept 250-tool fold reuses every unaffected child wrapper when its tail changes or grows", (context) => {
  const { h, t, children, equivalent } = foldFixture(250);
  context.after(h.close);
  const before = children();
  applyEvent(t, { event: "tool_call_updated", id: "t249", status: "failed", title: "Changed current tail" });
  const updated = children();
  for (let index = 0; index < 249; index++) assert.equal(updated.get(`t${index}`), before.get(`t${index}`));
  assert.notEqual(updated.get("t249"), before.get("t249"));
  equivalent();
  applyEvent(t, { event: "tool_call_started", id: "t250", name: "read", kind: "read", title: "New tail", status: "running" });
  const appended = children();
  for (let index = 0; index < 249; index++) assert.equal(appended.get(`t${index}`), updated.get(`t${index}`));
  assert.notEqual(appended.get("t249"), updated.get("t249"), "the former streaming tail is an affected child");
  assert.ok(appended.has("t250"));
  equivalent();
});

test("nested item and shared invalidations remain equivalent to unretained rendering", (context) => {
  const { h, t, draw, children, equivalent } = foldFixture();
  context.after(h.close);
  const update = (change: () => void, affected: readonly string[]) => {
    const before = children();
    change();
    const after = children();
    for (const [id, row] of before) {
      if (affected.includes(id)) assert.notEqual(after.get(id), row, id);
      else assert.equal(after.get(id), row, id);
    }
    equivalent();
  };
  update(() => applyEvent(t, { event: "tool_call_updated", id: "t0", kind: "edit", status: "completed",
    content: [{ type: "diff", path: "/workspace/a.rs", diff: "--- a\n+++ b\n-old\n+new\n+second" }] }), ["t0"]);
  assert.ok(nodes(draw()).some((node) => node.type === "text" && node.text === "+2"), "aggregate edit totals update");
  update(() => t.expanded.add("t0"), ["t0"]);
  assert.ok(nodes(draw()).some((node) => node.type === "diff"));
  update(() => applyEvent(t, { event: "tool_call_updated", id: "t1", kind: "execute", title: "Run current command",
    content: [{ type: "terminal", command: "echo current", output: "new output" }] }), ["t1"]);
  update(() => t.expanded.add("t1"), ["t1"]);
  assert.ok(nodes(draw()).some((node) => node.type === "code" && node.text === "new output"));
  update(() => { t.copied = "t0"; }, ["t0"]);
  update(() => t.checkpoints.add("t1"), ["t1"]);
  update(() => t.worked.set("t1", 1000), ["t1"]);
  update(() => { h.controller.state.workspaces.w = { ...h.controller.state.workspaces.w!, path: "/different-root" }; }, ["t0", "t1", "t2"]);
  update(() => { h.controller.state.agents.agent = { id: "agent", name: "Agent", capabilities: { rollback: true, fork: true, forkAt: true } } as never; }, ["t0", "t1", "t2"]);
  update(() => { h.renderers.push({ name: "test", kind: "read" } as never); }, ["t0", "t1", "t2"]);
  assert.ok(nodes(draw()).some((node) => node.type === "tool_view"));
  update(() => { t.running = false; }, ["t0", "t1", "t2"]);
});

test("a folded thought promotes and demotes its live body without redrawing unaffected siblings", (context) => {
  const { h, t, children, draw, equivalent } = foldFixture();
  context.after(h.close);
  t.items.push(item({ id: "thought", role: "reasoning", text: "Current thought\nMore detail" }));
  const before = children();
  assert.ok(nodes(draw()).some((node) => node.id === "md-thought"));
  applyEvent(t, { event: "reasoning_delta", itemId: "thought", text: " updated" });
  const updated = children();
  assert.equal(updated.get("t0"), before.get("t0"));
  assert.notEqual(updated.get("thought"), before.get("thought"));
  equivalent();
  applyEvent(t, { event: "tool_call_started", id: "next", kind: "read", name: "read", title: "Next tool", status: "running" });
  const demoted = children();
  assert.notEqual(demoted.get("thought"), updated.get("thought"));
  assert.equal(demoted.get("t0"), updated.get("t0"));
  assert.ok(!nodes(draw()).some((node) => node.id === "md-thought"));
  t.expanded.add("thought");
  equivalent();
  assert.ok(nodes(draw()).some((node) => node.id === "md-thought"));
});

test("closed, removed and regrouped fold children do not accumulate retained records", (context) => {
  const { h, t, children, equivalent } = foldFixture();
  context.after(h.close);
  const original = children();
  t.folds.set("tools-t0", false);
  assert.equal(children().size, 0);
  t.folds.set("tools-t0", true);
  const reopened = children();
  for (const [id, row] of original) assert.notEqual(reopened.get(id), row);
  const removed = t.items.splice(1, 1)[0]!;
  const without = children();
  assert.ok(!without.has("t1"));
  assert.equal(without.get("t0"), reopened.get("t0"));
  t.items.splice(1, 0, removed);
  const restored = children();
  assert.notEqual(restored.get("t1"), reopened.get("t1"));
  t.items.splice(1, 0, item({ id: "separator", role: "user", text: "Another turn" }));
  const regrouped = children();
  assert.notEqual(regrouped.get("t1"), restored.get("t1"), "a different fold owns the regrouped child");
  t.items.unshift(item({ id: "older", role: "tool", call: { kind: "read" } }));
  assert.notEqual(children().get("t0"), regrouped.get("t0"), "paging into a differently identified fold rebuilds its children");
  equivalent();
});

test("window eviction releases a fold's nested rows and keep=false never reuses them", (context) => {
  const { h, t, draw } = foldFixture(1);
  context.after(h.close);
  t.folds.set("tools-t0", true);
  t.items.push(...Array.from({ length: 1100 }, (_, index) => item({ id: `reply-${index}`, role: "assistant", text: `Reply ${index}` })));
  noteWindows();
  const entries = groupTasks(foldItems(t.items));
  const child = (keep = true) => nodes(draw(keep, true)).find((node) => node.id === "fold-item-t0");
  moveWindow(t, entries, 0, entryId);
  const before = child();
  assert.ok(before);
  moveWindow(t, entries, entries.length - 1, entryId);
  assert.equal(child(), undefined);
  moveWindow(t, entries, 0, entryId);
  const returned = child();
  assert.ok(returned);
  assert.notEqual(returned, before);
  assert.notEqual(child(false), child(false));
  assert.deepEqual(normalized(draw(true, true)), normalized(draw(false, true)));
});

test("retained and rebuilt child handlers still act on their own current call", (context) => {
  const { h, t, children, equivalent } = foldFixture();
  context.after(h.close);
  const first = children().get("t0")!;
  const action = (row: unknown) => nodes(row).find((node) => typeof node.onClick === "function")!.onClick;
  const retainedAction = action(first);
  applyEvent(t, { event: "tool_call_updated", id: "t2", title: "A sibling changed" });
  assert.equal(children().get("t0"), first);
  retainedAction();
  assert.ok(t.expanded.has("t0"));
  assert.ok(!t.expanded.has("t2"));
  t.expanded.delete("t0");
  t.items[0] = item({ id: "t0", role: "tool", call: { id: "replacement-call", kind: "execute", title: "Current replacement", input: { command: "echo replacement" } } });
  const changed = children().get("t0")!;
  assert.notEqual(changed, first);
  action(changed)();
  assert.ok(t.expanded.has("replacement-call"));
  assert.ok(!t.expanded.has("t0"), "the new handler does not capture the old call");
  equivalent();
});

test("a closed tool does not materialize its unshown body", (context) => {
  const { h, t } = foldFixture(1);
  context.after(h.close);
  let bodyReads = 0;
  const tool = item({ id: "body", role: "tool", call: { kind: "execute", content: [{
    type: "terminal", command: "echo result", get output() { bodyReads++; return "result"; },
  }] } });
  renderTool(h.v, t, tool, h.controller.state.chats.a!);
  assert.equal(bodyReads, 0);
  t.expanded.add("body");
  const opened = renderTool(h.v, t, tool, h.controller.state.chats.a!);
  assert.ok(bodyReads > 0);
  assert.ok(nodes(opened).some((node) => node.type === "code" && node.text === "result"));
});

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.2.9latestNov 21, 2026>=5 <6349 KB5 permissionsListed
0.2.8Nov 16, 2026>=5 <6348.6 KB5 permissionsListed
0.2.7Nov 11, 2026>=5 <6314.3 KB5 permissionsListed
0.2.6Nov 9, 2026>=5 <6306.2 KB5 permissionsListed
0.2.5Oct 27, 2026>=2 <4178.6 KB5 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.