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

turn-times.test.ts10.4 KB
// How long each run went and how it ended: the working row, the quiet line
// after the row a run ended on, a stopped run's notice, and errors.
import assert from "node:assert/strict";
import test from "node:test";
import * as Effect from "effect/Effect";
import type { TranscriptItem } from "divergence";
import { applyEvent, readRun, startRun, stoppedAfter, workedFor, workingFor } from "./transcript.ts";
import { renderItems, renderTranscript } from "./views/rows.tsx";
import { chat, harness, nodes, transcript as initial } from "./ui-for-tests.test.ts";

const ago = (ms: number) => new Date(Date.now() - ms).toISOString();
const at = (seconds: number) => new Date(Date.UTC(2026, 10, 3, 12, 0, seconds)).toISOString();
const say = (id: string, createdAt?: string): TranscriptItem => ({ id, createdAt, role: "user", blocks: [{ type: "text", text: id }] });
const reply = (id: string, createdAt?: string): TranscriptItem => ({ id, createdAt, role: "assistant", text: `reply ${id}` });
const notice = (id: string, text: string, createdAt?: string): TranscriptItem => ({ id, createdAt, role: "notice", text });
const idle = (items: TranscriptItem[] = []) => ({ ...initial(items), running: false });
const shownNodes = (t: ReturnType<typeof idle>) => {
  const h = harness();
  const c = chat();
  h.controller.state.chats[c.id] = c;
  h.controller.state.transcripts[c.id] = t;
  return nodes(renderItems(h.v, c, t, t.items));
};
const texts = (t: ReturnType<typeof idle>) => shownNodes(t).flatMap((node) => (typeof node.text === "string" ? [node.text] : []));

test("the working row counts from your message, a steer keeps that start, and the run says how long it worked", () => {
  const t = idle();
  const first = say("u1", ago(42_000));
  t.items.push(first);
  startRun(t, first);
  assert.equal(workingFor(t), "Working for 42s");
  applyEvent(t, { event: "text_delta", itemId: "a1", text: "Looking." });
  const steer = say("u2", ago(0));
  t.items.push(steer);
  startRun(t, steer);
  assert.equal(workingFor(t), "Working for 42s", "a steer joins the run going");
  applyEvent(t, { event: "text_delta", itemId: "a2", text: "Done." });
  applyEvent(t, { event: "run_finished", outcome: { status: "completed" } });
  assert.equal(t.started, undefined);
  assert.match(workedFor(t, t.items.at(-1)!) ?? "", /^Worked for 4[23]s$/);
  assert.equal(workedFor(t, t.items[1]!), null, "only the row the run ended on has the time");
  // A reply says it once, at the head of its own action row.
  assert.equal(texts(t).filter((text) => text.startsWith("Worked for")).length, 1);
  const line = shownNodes(t).find((node) => node.id === "worked-a2");
  assert.ok(nodes(line).some((node) => /^Worked for 4[23]s$/.test(String(node.text))));
  // A run that ended on a tool row says it in a line after that row.
  const tooled = idle([say("u1"), { id: "t1", role: "tool", call: { id: "t1", name: "read", title: "Read state.ts", kind: "read", status: "completed", content: [], locations: [] } } as never]);
  tooled.worked.set("t1", 3_000);
  assert.ok(texts(tooled).includes("Worked for 3s"));
  // The agent going on by itself starts a run of its own.
  applyEvent(t, { event: "run_started" });
  assert.equal(workingFor(t), "Working for 0s");
});

test("a stopped run says how long it went, measured live or read back from the two times", () => {
  const live = idle();
  const message = say("u1", ago(12_000));
  live.items.push(message);
  startRun(live, message);
  applyEvent(live, { event: "run_finished", outcome: { status: "cancelled" } });
  const stop = live.items.at(-1)!;
  assert.equal(stop.role === "notice" && stop.text, "Stopped.");
  assert.equal(stoppedAfter(live, stop), "You stopped after 12s");
  assert.equal(workedFor(live, stop), null, "the notice itself says the time");
  const shown = texts(live);
  assert.ok(shown.includes("You stopped after 12s") && !shown.includes("Stopped."));

  const stored = idle([say("u1", at(0)), reply("a1", at(3)), notice("n1", "Stopped.", at(12))]);
  assert.ok(texts(stored).includes("You stopped after 12s"));
  // Without both times only the stop itself is known.
  assert.ok(texts(idle([say("u1"), notice("n1", "Stopped.", at(12))])).includes("You stopped the agent."));
  assert.equal(stoppedAfter(stored, notice("elsewhere", "Stopped.", at(12))), "You stopped the agent.");
});

test("a turn read back from history shows no time, since nothing stored marks when it ended", () => {
  const t = idle([say("u1", at(0)), reply("a1", at(5))]);
  readRun(t);
  assert.equal(t.started, undefined);
  assert.ok(!texts(t).some((text) => text.startsWith("Worked for")));
});

test("a transcript read while its run goes counts from your last message, unless the run was seen starting", () => {
  const t = initial([say("u1", at(0)), reply("a1", at(3)), say("u2", at(60)), reply("a2", at(65))]);
  readRun(t);
  assert.equal(t.started, Date.parse(at(60)));
  t.started = 5;
  readRun(t);
  assert.equal(t.started, 5, "a run this plugin saw start keeps its start");
  const untimed = initial([say("u1"), reply("a1")]);
  readRun(untimed);
  assert.equal(workingFor(untimed), "Working…");
});

test("a transcript read back while its run goes counts from the message that started the run, not from a steer", async () => {
  const { loadTranscript } = await import("./data.ts");
  // The previous run stopped at 10s; the run going started with u2, and a steer joined it at 90s.
  const items = [say("u1", at(0)), reply("a1", at(3)), say("u2", at(60)), reply("a2", at(65)), say("steer", at(90))];
  const h = harness((method) =>
    method === "host/chats.transcript"
      ? Effect.succeed({ items, start: 0, pendingApprovals: [], pendingQuestions: [], plan: null, running: true })
      : undefined,
  );
  try {
    h.controller.state.chats.c = chat({ id: "c" });
    h.controller.scheduler.snapshots.c = { chatId: "c", lastRun: { stoppedAt: at(10) } } as never;
    await Effect.runPromise(loadTranscript(h.controller, "c", { history: false }));
    assert.equal(h.controller.state.transcripts.c!.started, Date.parse(at(60)));
    const never = initial([say("u1", at(0)), reply("a1", at(3)), say("steer", at(30))]);
    readRun(never, -Infinity);
    assert.equal(never.started, Date.parse(at(0)), "a chat that never ran before counts from its first message");
  } finally {
    await h.close();
  }
});

test("a run that ends right after your message says so, as the host's copy does", () => {
  const t = idle();
  const message = say("u1", ago(2_000));
  t.items.push(message);
  startRun(t, message);
  applyEvent(t, { event: "run_finished", outcome: { status: "completed" } });
  const end = t.items.at(-1)!;
  assert.match(end.role === "notice" ? end.text : "", /^The agent ended the turn without a reply\./);
  assert.equal(workedFor(t, end), null);
  // A failure's own message says how it ended, with no time beside it.
  const failed = idle();
  startRun(failed, message);
  failed.items.push(message, reply("a1"));
  applyEvent(failed, { event: "run_finished", outcome: { status: "failed", message: "Out of credits" } });
  assert.equal(workedFor(failed, failed.items.at(-1)!), null);
});

test("a failed run's message reads as an error, and decisions and held messages stay quiet", () => {
  const decision = { id: "a", decision: "allow", decidedBy: "guard" } as const;
  const t = idle([
    say("u1", at(0)),
    notice("n1", "Out of credits", at(4)),
    { id: "n2", role: "notice", text: "Allowed by guard", approval: decision },
    notice("n3", "The message is sent once the Codex update finishes."),
  ]);
  const h = harness();
  const c = chat();
  h.controller.state.chats[c.id] = c;
  const shown = nodes(renderItems(h.v, c, t, t.items));
  const errors = shown.filter((node) => node.type === "callout");
  assert.deepEqual(
    errors.map((node) => [node.tone, node.text]),
    [["danger", "Out of credits"]],
  );
  for (const quiet of ["Allowed by guard", "The message is sent once the Codex update finishes."])
    assert.ok(shown.some((node) => node.type === "text" && node.text === quiet), quiet);
});

test("the row a run ended on draws again when its time arrives, and the others are kept", () => {
  const h = harness();
  h.controller.api.toolRenderers = () => [];
  h.controller.state.chats.a = chat({ id: "a", sessionId: "s" });
  const t = h.controller.transcript("a");
  t.items = [say("u1", ago(5_000)), reply("a1", ago(4_000))];
  t.snapshot = { kind: "ready" };
  t.running = false;
  const rows = () => {
    const scroller = nodes(renderTranscript(h.v, h.controller.state.chats.a!)).find((node) => node.type === "scroller");
    return new Map((scroller?.items ?? []).map((row) => [String(row.id), row]));
  };
  const before = rows();
  t.worked.set("a1", 5_000);
  const after = rows();
  assert.equal(after.get("transcript-row-u1"), before.get("transcript-row-u1"));
  assert.notEqual(after.get("transcript-row-a1"), before.get("transcript-row-a1"));
  assert.ok(nodes(after.get("transcript-row-a1")).some((node) => node.text === "Worked for 5s"));
});

test("a /compact turn shows its compaction from when it begins and ends without a no-reply error", () => {
  const t = idle();
  const message = say("u1", ago(2_000));
  t.items.push(message);
  startRun(t, message);
  applyEvent(t, { event: "compacting" });
  const begun = t.items.at(-1)!;
  assert.equal(begun.role === "compaction" && begun.running, true);
  // Claude repeats the report with the summary's progress: still one row.
  applyEvent(t, { event: "compacting" });
  applyEvent(t, { event: "compacting" });
  assert.equal(t.items.length, 2);
  applyEvent(t, { event: "compacted", summary: "We said hi." });
  assert.equal(t.items.length, 2, "the compaction ends in the row it began in");
  assert.deepEqual({ ...t.items[1], createdAt: undefined }, { id: begun.id, createdAt: undefined, role: "compaction", summary: "We said hi." });
  applyEvent(t, { event: "run_finished", outcome: { status: "completed" } });
  assert.ok(!t.items.some((item) => item.role === "notice"), "compacting is the turn's answer");
  // One the run left unfinished goes with the run.
  startRun(t, message);
  applyEvent(t, { event: "compacting" });
  applyEvent(t, { event: "run_finished", outcome: { status: "failed", message: "too large" } });
  assert.ok(!t.items.some((item) => item.role === "compaction" && item.running));
  // The same notice on both sides of a dropped compaction reads once.
  startRun(t, message);
  applyEvent(t, { event: "compacting" });
  applyEvent(t, { event: "run_finished", outcome: { status: "failed", message: "too large" } });
  assert.equal(t.items.filter((item) => item.role === "notice").length, 1);
});

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.