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

  • 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
  • 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

message-actions.test.ts6.2 KB
// Copy, Reply and Fork under messages, and where a fork may start.
import assert from "node:assert/strict";
import test from "node:test";
import * as Effect from "effect/Effect";
import { harness, nodes, chat as makeChat, transcript as initial } from "./ui-for-tests.test.ts";
import { renderItems, turnEnds } from "./views/rows.tsx";
import { renderTitle } from "./views/title.tsx";
import { sentAt } from "./time.ts";
import type { TranscriptItem } from "divergence";

const say = (id: string): TranscriptItem => ({ id, role: "user", blocks: [{ type: "text", text: id }] });
const reply = (id: string, text = `reply ${id}`): TranscriptItem => ({ id, role: "assistant", text });
const tool = (id: string): TranscriptItem =>
  ({ id, role: "tool", call: { id, name: "read", kind: "read", status: "completed", content: [], locations: [] } }) as never;

const conversation = () => [say("u1"), reply("a1"), tool("t1"), reply("a2"), say("u2"), reply("b1")];

test("each turn ends at its last reply, and a fork from it stops before the next message", () => {
  assert.deepEqual(Object.fromEntries(turnEnds(conversation(), false)), { a2: "u2", b1: null });
  // The turn still running has no end yet.
  assert.deepEqual(Object.fromEntries(turnEnds(conversation(), true)), { a2: "u2" });
  // A blank reply ends nothing; the reply before it does.
  assert.deepEqual(Object.fromEntries(turnEnds([say("u1"), reply("a1"), reply("a2", " \n")], false)), { a1: null });
});

const shownIds = (capabilities: Record<string, boolean>, running = false) => {
  const h = harness();
  const chat = makeChat({ agentId: "agent", sessionId: "s" });
  h.controller.state.chats[chat.id] = chat;
  h.controller.state.agents.agent = { id: "agent", name: "Agent", capabilities } as never;
  const t = initial(conversation());
  t.running = running;
  h.controller.state.transcripts[chat.id] = t;
  return nodes(renderItems(h.v, chat, t, t.items)).flatMap((node) => (node.id ? [node.id] : []));
};

test("copy sits under every message, reply under replies, fork only where the agent can fork", () => {
  const ids = shownIds({ fork: true });
  for (const id of ["copy-u1", "copy-a2", "reply-a2", "copy-u2", "copy-b1", "reply-b1"])
    assert.ok(ids.includes(id), id);
  // Under a prompt, Reply beside Revert would look like a second undo.
  assert.ok(!ids.includes("reply-u1") && !ids.includes("reply-u2"), "a prompt has no reply");
  assert.ok(!ids.includes("copy-a1"), "a reply in the middle of a turn has none");
  // Forking only whole conversations: the latest reply alone.
  assert.deepEqual(
    ids.filter((id) => id.startsWith("fork-")),
    ["fork-b1"],
  );
  assert.deepEqual(
    shownIds({ fork: true, forkAt: true }).filter((id) => id.startsWith("fork-")),
    ["fork-a2", "fork-b1"],
  );
  assert.deepEqual(
    shownIds({}).filter((id) => id.startsWith("fork-")),
    [],
  );
  // While the last turn runs its reply is not finished.
  const running = shownIds({ fork: true, forkAt: true }, true);
  assert.ok(running.includes("fork-a2") && !running.includes("fork-b1") && !running.includes("copy-b1"));
});

test("fork asks the host for a copy that stops before the next message, and opens it", async () => {
  const forks: unknown[] = [];
  const h = harness((method, params) => {
    if (method !== "host/chats.fork") return undefined;
    forks.push(params);
    return Effect.succeed(makeChat({ id: "copy", workspaceId: "w" }));
  });
  const chat = makeChat({ sessionId: "s" });
  h.controller.state.chats[chat.id] = chat;
  h.controller.state.agents.agent = { id: "agent", name: "Agent", capabilities: { fork: true, forkAt: true } } as never;
  const t = initial(conversation());
  t.running = false;
  h.controller.state.transcripts[chat.id] = t;
  const press = (id: string) => {
    const button = nodes(renderItems(h.v, chat, t, t.items)).find((node) => node.id === id);
    button?.onClick();
  };
  press("fork-a2");
  press("fork-b1");
  await h.settle();
  assert.deepEqual(forks, [{ chatId: "c", before: "u2" }, { chatId: "c" }]);
  assert.equal(h.controller.api.app.state().chatId, "copy", "the copy opens");
});

test("copy writes the message to the clipboard and shows a check", async () => {
  const h = harness();
  const chat = makeChat();
  h.controller.state.chats[chat.id] = chat;
  const t = initial(conversation());
  t.running = false;
  h.controller.state.transcripts[chat.id] = t;
  const find = (id: string) => nodes(renderItems(h.v, chat, t, t.items)).find((node) => node.id === id);
  find("copy-b1")?.onClick();
  await new Promise<void>((resolve) => setImmediate(resolve));
  assert.deepEqual(
    h.calls.filter((call) => call.method === "copy_text").map((call) => call.params),
    [{ text: "reply b1" }],
  );
  assert.equal(find("copy-b1")?.icon, "check");
  assert.equal(find("copy-a2")?.icon, "copy");
});

test("a message's action row says when it was sent, with the whole date and time on hover", () => {
  const h = harness();
  const chat = makeChat();
  h.controller.state.chats[chat.id] = chat;
  const sent = new Date(Date.now() - 60_000).toISOString();
  const t = initial([{ ...say("u1"), createdAt: sent }, { ...reply("a1"), createdAt: sent }, say("u2"), reply("b1")]);
  t.running = false;
  h.controller.state.transcripts[chat.id] = t;
  const shown = nodes(renderItems(h.v, chat, t, t.items));
  const expected = sentAt(sent)!;
  for (const id of ["sent-u1", "sent-a1"]) {
    const node = shown.find((n) => n.id === id);
    assert.equal(node?.tooltip, expected.full, id);
    assert.ok(nodes(node).some((n) => n.text === expected.label), id);
  }
  // Under your message the buttons always show; its time waits for the pointer.
  assert.equal(shown.find((n) => n.id === "sent-u1")?.visibility, "hidden");
  assert.ok(!shown.some((n) => n.id === "sent-u2" || n.id === "sent-b1"), "a message without a time shows none");
});

test("the title strip no longer has a fork button", () => {
  const h = harness();
  const chat = makeChat();
  h.controller.state.chats[chat.id] = chat;
  h.controller.state.agents.agent = { id: "agent", name: "Agent", capabilities: { fork: true } } as never;
  const v = { ...h.v, ctx: { ...h.v.ctx, app: { route: "chat", chatId: chat.id } } };
  const ids = nodes(renderTitle(v)).flatMap((node) => (node.id ? [node.id] : []));
  assert.ok(!ids.some((id) => id.startsWith("fork-")));
});

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.