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

agents.test.ts6.2 KB
import assert from "node:assert/strict";
import test from "node:test";
import * as Effect from "effect/Effect";
import { HostCallFailed } from "divergence/effect";
import type { HostMethods } from "divergence";
import { onAgentsChanged } from "./events.ts";
import { preloadChats } from "./data.ts";
import { PresentationRoutes } from "./presentations.tsx";
import { chat, harness } from "./ui-for-tests.test.ts";

type ListedAgent = HostMethods["host/agents.all"]["result"]["agents"][number];
const enabled: ListedAgent = { id: "enabled", name: "Enabled", enabled: true, icon: "enabled-mark", capabilities: {} };
const disabled: ListedAgent = {
  id: "disabled",
  name: "Disabled",
  enabled: false,
  icon: "disabled-mark",
  capabilities: { images: false },
};
const option = { id: "model", name: "Model", kind: "select" as const, category: "model" as const, value: "model", choices: [] };

test("an agent readiness event owns only agent metadata and publishes after installation", async (ctx) => {
  const reply = Promise.withResolvers<{ agents: ListedAgent[] }>();
  const asked: string[] = [],
    updates: string[] = [];
  const original = chat({ id: "c", agentId: "disabled" });
  const workspace = { id: "w", name: "Original", path: "/original", position: 0 };
  const h = harness((method) => {
    asked.push(method);
    if (method === "host/agents.all") return Effect.promise(() => reply.promise);
    if (method === "host/chats.list") return Effect.succeed({ chats: [{ ...original, title: "Unrelated snapshot" }] });
    if (method === "host/workspaces.list")
      return Effect.succeed({ workspaces: [{ ...workspace, name: "Unrelated snapshot" }] });
    return undefined;
  });
  const c = h.controller;
  let navigation = 0,
    queues = 0,
    drafts = 0,
    nextId = 0;
  const view = (name: string) => ({ id: ++nextId, update: () => updates.push(name), remove() {} });
  c.settingsView = view("settings");
  c.sessionViews.push(view("session"));
  c.presentations = new PresentationRoutes(
    c,
    view("center"),
    view("cases"),
    view("title"),
    view("title-cases"),
    view("off-route"),
  );
  c.state.chats.c = original;
  c.state.workspaces.w = workspace;
  c.state.restored = { c: "A draft" };
  c.state.draftTitles.c = "Preserved title";
  c.composer("c").options = [option];
  c.emitDrafts = () => {
    drafts++;
  };
  ctx.mock.method(c, "followApp", () => {
    navigation++;
    return Effect.void;
  });
  ctx.mock.method(c, "pumpChatQueue", () => {
    queues++;
    return Effect.void;
  });
  Effect.runSync(c.app.update({ route: "chat", chatId: "c" }));
  try {
    await Effect.runPromise(onAgentsChanged(c));
    await h.settle();
    assert.deepEqual(asked, ["host/agents.all"], "agent readiness must not read chat or workspace catalogs");
    assert.deepEqual(updates, [], "old metadata must not be republished before the reply");
    reply.resolve({ agents: [enabled, disabled] });
    await h.settle();
    assert.strictEqual(c.state.chats.c, original);
    assert.strictEqual(c.state.workspaces.w, workspace);
    assert.equal(c.state.draftTitles.c, "Preserved title");
    assert.deepEqual([navigation, queues, drafts], [0, 0, 0]);
    assert.deepEqual(c.state.agentList, [enabled], "pickers retain only enabled agents");
    assert.strictEqual(c.state.agents.disabled, disabled, "disabled agents retain their names and marks");
    assert.strictEqual(c.state.agents.enabled, enabled);
    assert.equal(c.takesImages("c"), false, "selected-agent capabilities use the installed catalog");
    assert.deepEqual(updates.sort(), ["center", "session", "settings", "title"]);
    assert.deepEqual(h.notices, []);
  } finally {
    reply.resolve({ agents: [] });
    await h.close();
  }
});

test("agent catalog failures are reported without discarding good metadata at startup or readiness", async () => {
  for (const load of [preloadChats, onAgentsChanged]) {
    const asked: string[] = [];
    const h = harness((method) => {
      asked.push(method);
      if (method === "host/agents.all")
        return Effect.fail(new HostCallFailed({ method, code: -32603, message: "catalog unavailable" }));
      if (method === "host/chats.list") return Effect.succeed({ chats: [chat()] });
      if (method === "host/workspaces.list") return Effect.succeed({ workspaces: [] });
      return undefined;
    });
    h.controller.state.agents.enabled = enabled;
    h.controller.state.agentList = [enabled];
    try {
      await Effect.runPromise(load(h.controller));
      await h.settle();
      assert.deepEqual(h.notices, ["Agents could not be read: catalog unavailable"]);
      assert.strictEqual(h.controller.state.agents.enabled, enabled);
      assert.deepEqual(h.controller.state.agentList, [enabled]);
      if (load === preloadChats) {
        assert.ok(asked.includes("host/chats.list") && asked.includes("host/workspaces.list"));
        assert.ok(h.controller.state.chats.c, "startup still installs chat metadata when the agent read fails");
      } else assert.deepEqual(asked, ["host/agents.all"]);
    } finally {
      await h.close();
    }
  }
});

test("agent readiness retries only empty options that are not already loading", async () => {
  const options: string[] = [];
  const h = harness((method, params) => {
    if (method === "host/agents.all") return Effect.succeed({ agents: [enabled] });
    if (method === "host/chats.options") {
      options.push((params as { chatId: string }).chatId);
      return Effect.succeed({ options: [option] });
    }
    if (method === "host/chats.commands") return Effect.succeed({ commands: [] });
    if (method === "host/chats.skills") return Effect.succeed({ skills: [] });
    return undefined;
  });
  for (const id of ["empty", "ready", "loading"]) h.controller.state.chats[id] = chat({ id, agentId: enabled.id });
  h.controller.composer("empty").loading = false;
  h.controller.composer("ready").options = [option];
  h.controller.composer("loading").loading = true;
  try {
    await Effect.runPromise(onAgentsChanged(h.controller));
    await h.settle();
    assert.deepEqual(options, ["empty"]);
    assert.deepEqual(h.controller.composer("empty").options, [option]);
    assert.equal(h.controller.composer("loading").loading, true);
    assert.deepEqual(h.notices, []);
  } finally {
    await h.close();
  }
});

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.