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 convergence/chat@0.2.3

Permissions in 0.2.3

  • 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

panes.test.ts10 KB
// Chat panes: a hidden pane waits to render until it shows, transcripts
// outlive a reload of this plugin, and a chat on its way shows a skeleton.
import assert from "node:assert/strict";
import test from "node:test";
import * as Deferred from "effect/Deferred";
import * as Effect from "effect/Effect";
import type { HostEvents } from "convergence";
import { onAgent } from "./events.ts";
import { ensureChat, ensurePane, followApp, removePane } from "./panes.ts";
import { loadOlder, loadTranscript } from "./data.ts";
import { HostCallFailed } from "convergence/effect";
import { initialTranscript } from "./state.ts";
import type { Transcript } from "./state.ts";
import { renderCenter, renderPane } from "./views/panes.ts";
import { chat, harness, item, nodes } from "./ui-for-tests.test.ts";

// What a composer reads as it is made: no options, commands or skills.
const composerReads = (method: string) =>
  method === "host/chats.options"
    ? Effect.succeed({ options: [] })
    : method === "host/chats.commands"
      ? Effect.succeed({ commands: [] })
      : method === "host/chats.skills"
        ? Effect.succeed({ skills: [] })
        : undefined;

const delta = (chatId: string): HostEvents["agent"] => ({
  event: "agent",
  chatId,
  kind: { event: "text_delta", itemId: `reply-${chatId}`, text: "more", mode: "append" },
});

test("a hidden pane renders once when it shows again, not on every event", async () => {
  const h = harness();
  const rendered: string[] = [];
  for (const id of ["a", "b"]) {
    h.controller.state.chats[id] = chat({ id, sessionId: `session-${id}` });
    h.controller.transcript(id);
    h.controller.state.panes[id] = { chatId: id, view: { id: 1, update: () => rendered.push(id), remove() {} } };
  }
  Effect.runSync(h.controller.app.update({ route: "chat", chatId: "a" }));
  for (let i = 0; i < 3; i++) {
    await Effect.runPromise(onAgent(h.controller, delta("b")));
    await Effect.runPromise(onAgent(h.controller, delta("a")));
  }
  assert.deepEqual(rendered, ["a", "a", "a"], "only the pane on screen renders");
  assert.equal(h.controller.state.panes.b?.stale, true);
  Effect.runSync(h.controller.app.update({ chatId: "b" }));
  await Effect.runPromise(ensurePane(h.controller, "b"));
  assert.deepEqual(rendered, ["a", "a", "a", "b"], "it renders once as it shows");
  assert.equal(h.controller.state.panes.b?.stale, false);
  await h.close();
});

test("moving the main prompt box to another chat renders the two composers, not the panes", async () => {
  const h = harness();
  const rendered: string[] = [];
  const handle = (name: string) => ({ id: 1, update: () => rendered.push(name), remove() {} });
  for (const id of ["a", "b"]) {
    h.controller.state.chats[id] = chat({ id, sessionId: `session-${id}` });
    h.controller.transcript(id);
    h.controller.state.panes[id] = { chatId: id, view: handle(`pane ${id}`), composer: handle(`composer ${id}`) };
  }
  h.controller.state.mainPrompt = "a";
  renderCenter({ ...h.v, ctx: { ...h.v.ctx, app: { route: "chat", chatId: "b" } } });
  // A pane carries the whole transcript: rendering the one the user left
  // made the switch to a new chat wait for its tree to be applied.
  assert.deepEqual(rendered.sort(), ["composer a", "composer b"]);
  assert.equal(h.controller.state.mainPrompt, "b");
  await h.close();
});

test("transcripts kept across a reload show at once and are read again", async () => {
  const before = harness();
  const kept: Transcript = {
    ...initialTranscript(),
    items: [item({ id: "u1", role: "user", text: "hello" })],
    loaded: true,
    // A read of the code that unloaded: it never ends now.
    loading: Deferred.makeUnsafe<void>(),
  };
  kept.expanded.add("u1");
  before.controller.state.transcripts.a = kept;
  // The center view's `ctx.state`, which the reload keeps.
  const state: { transcripts?: Record<string, Transcript> } = {};
  before.controller.keepTranscripts(state);
  await before.close();

  const asked: string[] = [];
  const after = harness((method) => {
    asked.push(method);
    if (method === "host/chats.transcript")
      return Effect.succeed({
        items: [item({ id: "u1", role: "user", text: "hello" }), item({ id: "a1", role: "assistant", text: "hi" })],
        pendingApprovals: [],
        pendingQuestions: [],
        plan: null,
        usage: {},
        running: false,
      });
    if (method === "host/security.pending") return Effect.succeed({ requests: [] });
    if (method === "host/chats.checkpoints") return Effect.succeed({ checkpoints: [] });
    return composerReads(method);
  });
  after.controller.state.chats.a = chat({ id: "a", sessionId: "session-a" });
  after.controller.keepTranscripts(state);
  const carried = after.controller.state.transcripts.a;
  assert.ok(carried);
  assert.deepEqual(
    carried.items.map((row) => row.id),
    ["u1"],
    "the rows show before any read",
  );
  assert.ok(carried.expanded.has("u1"), "what the user opened stays open");
  assert.equal(carried.loading, undefined, "a read of the old code is not waited for");
  assert.equal(carried.loaded, false);
  assert.ok(nodes(renderPane(after.v, "a")).every((node) => node.type !== "empty"));
  await Effect.runPromise(ensureChat(after.controller, "a"));
  await after.settle();
  assert.ok(asked.includes("host/security.pending"), "its security requests are read again");
  assert.ok(asked.includes("host/chats.transcript"), "its transcript is read again");
  assert.deepEqual(
    after.controller.state.transcripts.a?.items.map((row) => row.id),
    ["u1", "a1"],
  );
  assert.equal(after.controller.state.transcripts.a?.carried, false);
  await after.close();
});

test("a chat whose history is on its way shows a skeleton and its composer", async () => {
  // The transcript's read does not come back while the pane shows.
  const h = harness((method) => (method === "host/chats.transcript" ? Effect.never : composerReads(method)));
  h.controller.state.chats.a = chat({ id: "a", sessionId: "session-a" });
  const shown = nodes(renderPane(h.v, "a"));
  assert.ok(!shown.some((node) => node.type === "empty"), "no line of loading text");
  assert.ok(shown.some((node) => node.background === "muted" && node.borderRadius === "xl"), "the skeleton's message");
  assert.ok(shown.some((node) => node.id === "prompt-a"), "the composer takes typing at once");
  await h.close();
});

test("the host prepares a chat once each time it shows, and a failure is a notice", async () => {
  let fail = false;
  const prepared: unknown[] = [];
  const h = harness((method, params) => {
    if (method !== "host/chats.prepare") return composerReads(method);
    prepared.push(params);
    return fail ? Effect.fail(new HostCallFailed({ method, code: -32000, message: "no session" })) : Effect.succeed({});
  });
  for (const id of ["a", "b"]) {
    h.controller.state.chats[id] = chat({ id, sessionId: `session-${id}` });
    h.controller.transcript(id);
  }
  const prepares = () => prepared;
  Effect.runSync(h.controller.app.update({ route: "chat", chatId: "a" }));
  for (let i = 0; i < 3; i++) await Effect.runPromise(followApp(h.controller));
  await h.settle();
  assert.deepEqual(prepares(), [{ chatId: "a" }], "renders of the same chat prepare once");
  Effect.runSync(h.controller.app.update({ chatId: "b" }));
  fail = true;
  await Effect.runPromise(followApp(h.controller));
  await h.settle();
  assert.deepEqual(prepares(), [{ chatId: "a" }, { chatId: "b" }]);
  assert.ok(h.notices.some((notice) => notice.includes("no session")));
  await h.close();
});

test("a transcript opens on its newest page, reads older pages near its top, and is dropped when its pane goes", async () => {
  const all = Array.from({ length: 120 }, (_, n) => item({ id: `a${n}`, role: "assistant", text: `reply ${n}` }));
  const asked: { method: string; params: unknown }[] = [];
  const h = harness((method, params) => {
    asked.push({ method, params });
    if (method === "host/chats.transcript") {
      const { limit, before } = params as { limit?: number; before?: number };
      const end = before ?? all.length;
      const start = limit === undefined ? 0 : Math.max(0, end - limit);
      return Effect.succeed({
        items: all.slice(start, end),
        start,
        total: all.length,
        pendingApprovals: [],
        pendingQuestions: [],
        plan: null,
        usage: {},
        running: false,
      });
    }
    if (method === "host/chats.close") return Effect.succeed({});
    if (method === "host/chats.checkpoints") return Effect.succeed({ checkpoints: [] });
    return composerReads(method);
  });
  h.controller.state.chats.a = chat({ id: "a", sessionId: "session-a" });
  await Effect.runPromise(loadTranscript(h.controller, "a"));
  const ids = () => h.controller.state.transcripts.a?.items.map((row) => row.id) ?? [];
  assert.equal(ids().length, 50, "only the newest page");
  assert.deepEqual([ids()[0], ids().at(-1)], ["a70", "a119"]);

  const scroller = nodes(renderPane(h.v, "a")).find((node) => node.type === "scroller");
  assert.equal(typeof scroller?.onReachStart, "function", "the list asks for older rows near its top");
  await Effect.runPromise(loadOlder(h.controller, "a"));
  assert.deepEqual([ids().length, ids()[0], ids().at(-1)], [100, "a20", "a119"], "the page before it goes first");
  await Effect.runPromise(loadOlder(h.controller, "a"));
  await Effect.runPromise(loadOlder(h.controller, "a"));
  assert.equal(ids().length, 120);
  assert.equal(h.controller.state.transcripts.a?.start, 0);
  const reads = asked.filter((call) => call.method === "host/chats.transcript");
  assert.equal(reads.length, 3, "nothing is read before the first row");
  assert.equal(nodes(renderPane(h.v, "a")).find((node) => node.type === "scroller")?.onReachStart, undefined);

  // Another chat on screen, the pane goes: its transcript goes with it.
  Effect.runSync(h.controller.app.update({ route: "chat", chatId: "b" }));
  removePane(h.controller, "a");
  assert.equal(h.controller.state.transcripts.a, undefined);
  await new Promise((resolve) => setTimeout(resolve, 0));
  assert.ok(asked.some((call) => call.method === "host/chats.close"), "the host is told it closed");
  await h.close();
});

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.2.5latestNov 21, 2026>=2 <4174.6 KB5 permissionsListed
0.2.4Oct 25, 2026>=2 <4174.2 KB5 permissionsListed
0.2.3Oct 24, 2026>=2 <4165.4 KB5 permissionsListed
0.2.2Oct 23, 2026>=2 <4165 KB5 permissionsListed
0.2.1Oct 6, 2026>=2 <3111.8 KB5 permissionsListed
0.2.0Oct 5, 2026>=2 <3105.1 KB5 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.