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

Permissions in 0.2.8

  • 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

fold-window.test.ts9.1 KB
import assert from "node:assert/strict";
import test from "node:test";
import { renderItems } from "./views/rows.tsx";
import { taskBody } from "./views/tasks.tsx";
import { noteWindows, windows } from "./window.ts";
import { applyEvent } from "./transcript.ts";
import { chat, harness, item, nodes } from "./ui-for-tests.test.ts";
import type { TestNode } from "./ui-for-tests.test.ts";

const normalized = (value: unknown) => JSON.parse(JSON.stringify(value, (_, value) => typeof value === "function" ? "handler" : value));
const tools = (count: number, prefix = "t") => Array.from({ length: count }, (_, index) => item({
  id: `${prefix}${index}`, role: "tool", call: index % 4 === 1
    ? { kind: "edit", title: "Edit src/file.rs", content: [{ type: "diff", path: "src/file.rs", diff: "--- a\n+++ b\n-old\n+new" }] }
    : index % 4 === 2
      ? { kind: "execute", title: "cargo test", content: [{ type: "terminal", command: "cargo test", output: "one\ntwo\nthree", exitCode: 0 }] }
      : { kind: index % 4 === 0 ? "read" : "search", title: "Read src/file.rs", content: [{ type: "text", text: "result" }] },
}));

function fixture(count = 6000) {
  const h = harness(), c = chat({ id: "a", status: "running" }), t = h.controller.transcript(c.id);
  h.controller.state.chats.a = c;
  h.controller.state.workspaces.w = { id: "w", name: "Workspace", path: "/workspace", position: 0 };
  t.items = tools(count);
  t.running = true;
  const capable = (value: boolean) => Object.defineProperty(h.controller.api, "uiCapabilities", { configurable: true, value: value ? ["boundedDivRows"] : undefined });
  capable(true);
  const draw = (keep = true) => renderItems(h.v, c, t, t.items, [], keep);
  const scroll = (prefix = "t") => nodes(draw()).find((node) => node.id === `fold-scroll-tools-${prefix}0`)!;
  const children = (node: TestNode) => node.children.filter((child) => child.id?.startsWith("fold-item-"));
  const report = (first: number, prefix = "t") => (scroll(prefix).onRange as (event: { first: number; rows: number }) => void)({ first, rows: t.items.length });
  const visit = (first: number, prefix = "t") => { for (let i = 0; i < 30; i++) report(first, prefix); return scroll(prefix); };
  const range = (node: TestNode) => [Number(node.rowsBefore ?? 0), Number(node.rowsAfter ?? 0)];
  const equivalent = () => assert.deepEqual(normalized(draw()), normalized(draw(false)), "windowed retained output equals fresh output");
  return { h, c, t, capable, draw, scroll, children, report, visit, range, equivalent };
}

test("a large fold omits rows only with its own negotiated bounded-div capability", (context) => {
  const f = fixture();
  context.after(f.h.close);
  assert.equal(windows(), false, "the first bounded fold needs no unrelated scroller report");
  f.capable(false);
  const complete = f.scroll();
  assert.equal(f.children(complete).length, 6000);
  assert.equal(complete.onRange, undefined);
  assert.equal(complete.rowsBefore, undefined);
  assert.ok(nodes(complete).length > 50000, "the original full subtree exceeds the actual runtime node budget");
  f.capable(true);
  const bounded = f.scroll();
  assert.equal(bounded.id, complete.id);
  for (const prop of ["followEnd", "maxHeight", "overflowY", "padding", "gap", "background"]) assert.deepEqual(bounded[prop], complete[prop]);
  assert.equal(f.children(bounded).length, 240);
  assert.deepEqual(f.range(bounded), [5760, 0]);
  assert.ok(nodes(bounded).length < 5000);
  assert.equal(f.t.items.length, 6000, "every canonical item remains loaded");
  assert.deepEqual(f.children(bounded).map((node) => node.id), f.t.items.slice(5760).map((item) => `fold-item-${item.id}`));
  f.equivalent();
  noteWindows();
  f.capable(false);
  assert.equal(f.children(f.scroll()).length, 6000, "an outer scroller report never enables unsupported Div omission");
});

test("the actual fold callback reaches top middle and tail without repeating a settled update", (context) => {
  const f = fixture();
  context.after(f.h.close);
  let updates = 0;
  f.h.v.ctx.update = () => { updates++; };
  for (const first of [0, 3000, 5960]) {
    const scroll = f.visit(first), children = f.children(scroll), [before, after] = f.range(scroll);
    assert.equal(before! + children.length + after!, 6000);
    assert.ok(children.some((node) => node.id === `fold-item-t${first}`));
    assert.ok(children.length <= 440);
    const settled = updates;
    f.report(first);
    assert.equal(updates, settled, "an unchanged window does not schedule another render");
    f.equivalent();
  }
  assert.ok(updates > 0);
});

test("shared invalidation replacement snapshots and close/reopen preserve fold position", (context) => {
  const f = fixture();
  context.after(f.h.close);
  const middle = f.visit(3000), position = f.range(middle), child = f.children(middle)[0];
  f.h.controller.state.workspaces.w = { ...f.h.controller.state.workspaces.w!, path: "/changed" };
  assert.deepEqual(f.range(f.scroll()), position);
  assert.notEqual(f.children(f.scroll())[0], child, "shared inputs rebuild child elements while retaining list anchors");
  f.t.items = structuredClone(f.t.items);
  assert.deepEqual(f.range(f.scroll()), position, "stable IDs outlive snapshot object identity");
  f.t.folds.set("tools-t0", false);
  assert.equal(f.scroll(), undefined);
  f.t.folds.set("tools-t0", true);
  assert.deepEqual(f.range(f.scroll()), position);
  f.equivalent();
});

test("independent parent sibling and nested-subagent lists keep their own ranges", (context) => {
  const f = fixture(1500);
  context.after(f.h.close);
  f.t.items.push(item({ id: "separator", role: "user", text: "Next turn" }), ...tools(1500, "s"));
  f.t.folds.set("tools-t0", true);
  const parent = f.range(f.visit(100)), sibling = f.range(f.visit(800, "s"));
  let task = item({ id: "task", role: "task", items: tools(1500, "n") });
  let parentUpdates = 0, detailUpdates = 0;
  f.h.v.ctx.update = () => { parentUpdates++; };
  const detail = { ...f.h.v, ctx: { ...f.h.v.ctx, state: {}, update() { detailUpdates++; } } };
  const nested = () => nodes(taskBody(detail, f.c, f.t, task)).find((node) => node.id === "fold-scroll-tools-n0")!;
  for (let i = 0; i < 30; i++) (nested().onRange as (event: { first: number; rows: number }) => void)({ first: 400, rows: 1500 });
  const nestedRange = f.range(nested());
  assert.ok(detailUpdates > 0, "the detail view is invalidated by its own callback");
  assert.equal(parentUpdates, 0, "the parent need not render to service a detail range");
  assert.deepEqual(f.range(f.scroll()), parent);
  assert.deepEqual(f.range(f.scroll("s")), sibling);
  f.visit(1100);
  assert.deepEqual(f.range(nested()), nestedRange);
  assert.deepEqual(f.range(f.scroll("s")), sibling);
  task = item({ id: "task", role: "task", items: structuredClone(task.items) });
  assert.deepEqual(f.range(nested()), nestedRange);
});

test("streaming follows the tail only for a tail window and off-window expansion restores on return", (context) => {
  const f = fixture();
  context.after(f.h.close);
  applyEvent(f.t, { event: "tool_call_started", id: "next", name: "read", kind: "read", title: "Next call", status: "running" });
  assert.ok(f.children(f.scroll()).some((node) => node.id === "fold-item-next"));
  const middle = f.visit(3000), position = f.range(middle), old = f.children(middle).find((node) => node.id === "fold-item-t3002")!;
  nodes(old).find((node) => typeof node.onClick === "function")!.onClick();
  assert.ok(f.t.expanded.has("t3002"));
  assert.ok(nodes(f.scroll()).some((node) => node.type === "code" && node.text === "one\ntwo\nthree"));
  const expanded = f.children(f.scroll()).find((node) => node.id === old.id);
  applyEvent(f.t, { event: "tool_call_started", id: "later", name: "read", kind: "read", title: "Later call", status: "running" });
  const growing = f.scroll();
  assert.equal(f.range(growing)[0], position[0]);
  assert.equal(f.range(growing)[1], position[1]! + 1);
  assert.ok(!f.children(growing).some((node) => node.id === "fold-item-later"));
  f.visit(0);
  applyEvent(f.t, { event: "tool_call_updated", id: "t3002", content: [{ type: "terminal", command: "current command", output: "current output\nwith another line" }] });
  const returned = f.children(f.visit(3000)).find((node) => node.id === old.id)!;
  assert.notEqual(returned, expanded, "off-window retained wrappers were released");
  assert.ok(f.t.expanded.has("t3002"));
  assert.ok(nodes(returned).some((node) => node.type === "code" && node.text === "current output\nwith another line"));
  f.equivalent();
});

test("removal regrouping and paging preserve valid anchors without retaining missing children", (context) => {
  const f = fixture();
  context.after(f.h.close);
  const before = f.visit(3000), firstId = f.children(before)[0]!.id;
  f.t.items.splice(20, 1);
  assert.equal(f.children(f.scroll())[0]!.id, firstId);
  const removedIndex = f.t.items.findIndex((item) => `fold-item-${item.id}` === firstId);
  f.t.items.splice(removedIndex, 1);
  assert.ok(!f.children(f.scroll()).some((node) => node.id === firstId));
  f.t.items.unshift(...tools(100, "older"));
  const regrouped = nodes(f.draw()).find((node) => node.id === "fold-scroll-tools-older0")!;
  assert.ok(f.children(regrouped).some((node) => node.id === "fold-item-t5999"), "the genuinely new fold starts at its end");
  f.equivalent();
});

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.