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

Permissions in 0.2.6

  • 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

options.test.ts8.2 KB
// A chat's settings belong to its agent: switching agents never leaves the
// last agent's model in the picker, even when the new one's fail to load,
// and a draft whose agent is gone says so.
import assert from "node:assert/strict";
import test from "node:test";
import * as Effect from "effect/Effect";
import { HostCallFailed } from "divergence/effect";
import type { AgentInfo } from "divergence";
import { loadOptions } from "./data.ts";
import { renderComposer } from "./views/composer.tsx";
import { harness, chat, nodes } from "./ui-for-tests.test.ts";

test("a new agent's failed options leave none, not the last agent's", async () => {
  const h = harness((method) =>
    method === "host/chats.options" ? Effect.fail(new HostCallFailed({ method, code: -32603, message: "no catalog" })) : undefined,
  );
  h.controller.state.chats.c = chat({ id: "c", agentId: "codex" });
  const composer = h.controller.composer("c");
  composer.agentId = "codex";
  composer.options = [
    { id: "model", name: "Model", kind: "select", category: "model", value: "gpt", choices: [{ value: "gpt", name: "GPT" }] },
  ];
  h.controller.state.chats.c = chat({ id: "c", agentId: "opencode" });
  await Effect.runPromise(loadOptions(h.controller, "c"));
  assert.deepEqual(composer.options, []);
  assert.equal(composer.agentId, "opencode");
  assert.ok(h.notices.some((notice) => notice.includes("no catalog")), "the failure is said");
});

test("switching to an agent shows its own last options at once, never another agent's", async () => {
  const model = (value: string) => [{ id: "model", name: "Model", kind: "select" as const, category: "model" as const, value, choices: [] }];
  let release!: () => void;
  const late = new Promise<void>((resolve) => (release = resolve));
  const h = harness((method, params) => {
    if (method !== "host/chats.options") return undefined;
    const { chatId } = params as { chatId: string };
    if (chatId === "a") return Effect.succeed({ options: model("gpt") });
    if (chatId === "b") return Effect.succeed({ options: model("sonnet") });
    return Effect.promise(() => late).pipe(Effect.as({ options: model("gpt-fresh") }));
  });
  h.controller.state.chats.a = chat({ id: "a", agentId: "codex" });
  h.controller.state.chats.b = chat({ id: "b", agentId: "claude" });
  await Effect.runPromise(loadOptions(h.controller, "a"));
  await Effect.runPromise(loadOptions(h.controller, "b"));

  // A Claude draft switches to Codex: Codex's last answer shows while the host reads it.
  h.controller.state.chats.c = chat({ id: "c", agentId: "claude" });
  const composer = h.controller.composer("c");
  composer.agentId = "claude";
  composer.options = model("sonnet");
  h.controller.state.chats.c = chat({ id: "c", agentId: "codex" });
  const loading = Effect.runPromise(loadOptions(h.controller, "c"));
  assert.equal(composer.options[0]?.value, "gpt", "Codex's own list, not Claude's");
  release();
  await loading;
  assert.equal(composer.options[0]?.value, "gpt-fresh", "the host's answer replaces it");

  // An agent that never answered shows none, not the last agent's.
  h.controller.state.chats.c = chat({ id: "c", agentId: "opencode" });
  void Effect.runPromise(loadOptions(h.controller, "c"));
  assert.deepEqual(composer.options, []);
});

test("a draft whose agent was turned off asks for another", () => {
  const empty: Record<string, unknown> = {
    "host/chats.options": { options: [] },
    "host/chats.commands": { commands: [] },
    "host/chats.skills": { skills: [] },
  };
  const h = harness((method) => (method in empty ? Effect.succeed(empty[method]) : undefined));
  const draft = chat({ id: "d", agentId: "gone" });
  h.controller.state.chats.d = draft;
  h.controller.state.agentList = [{ id: "codex", name: "Codex", capabilities: {} } as AgentInfo];
  const picker = nodes(renderComposer(h.v, draft)).find((node) => node.id === "agent-d");
  assert.equal(picker?.placeholder, "Choose an agent");
});

test("an agent's options that arrive after a switch to another are dropped", async () => {
  let release!: () => void;
  const late = new Promise<void>((resolve) => (release = resolve));
  const h = harness((method, params) =>
    method === "host/chats.options" && (params as { chatId: string }).chatId === "c"
      ? Effect.promise(() => late).pipe(
          Effect.as({ options: [{ id: "model", name: "Model", kind: "select", category: "model", value: "old", choices: [] }] }),
        )
      : undefined,
  );
  h.controller.state.chats.c = chat({ id: "c", agentId: "codex" });
  const first = Effect.runPromise(loadOptions(h.controller, "c"));
  // The user picks another agent before Codex answered.
  h.controller.state.chats.c = chat({ id: "c", agentId: "opencode" });
  h.controller.composer("c").agentId = "opencode";
  h.controller.composer("c").loading = true;
  release();
  await first;
  assert.deepEqual(h.controller.composer("c").options, [], "Codex's model is not OpenCode's");
  assert.equal(h.controller.composer("c").loading, true, "OpenCode's own read is still on its way");
});

test("loading options is drawn at once and ends with the answer", async () => {
  let release!: () => void;
  const late = new Promise<void>((resolve) => (release = resolve));
  const h = harness((method) =>
    method === "host/chats.options"
      ? Effect.promise(() => late).pipe(
          Effect.as({ options: [{ id: "model", name: "Model", kind: "select", category: "model", value: "a1", choices: [] }] }),
        )
      : undefined,
  );
  h.controller.state.chats.c = chat({ id: "c", agentId: "codex" });
  const composer = h.controller.composer("c");
  const shown: [boolean, number][] = [];
  h.controller.view.update = () => void shown.push([composer.loading, composer.options.length]);
  const loading = Effect.runPromise(loadOptions(h.controller, "c"));
  assert.deepEqual(shown, [[true, 0]], "the loading state is drawn without a wait of the plugin's own");
  release();
  await loading;
  assert.deepEqual(shown.at(-1), [false, 1]);
});

test("commands the agent is slow to list never hold the composer loading", async () => {
  let release!: () => void;
  const late = new Promise<void>((resolve) => (release = resolve));
  const h = harness((method) => {
    if (method === "host/chats.options") return Effect.succeed({ options: [] });
    if (method === "host/chats.commands")
      return Effect.promise(() => late).pipe(Effect.as({ commands: [{ name: "init", description: "" }] }));
    return undefined;
  });
  h.controller.state.chats.c = chat({ id: "c", agentId: "codex" });
  const composer = h.controller.composer("c");
  await Effect.runPromise(loadOptions(h.controller, "c"));
  assert.equal(composer.loading, false, "Send is not blocked while commands wait for the agent");
  assert.deepEqual(composer.commands, []);
  release();
  await new Promise((resolve) => setTimeout(resolve, 20));
  assert.equal(composer.commands.length, 1, "commands apply when they arrive");
});

test("per-model reasoning levels keep the agent's own choices that no model lists", () => {
  const h = harness(() => undefined);
  h.controller.state.chats.c = chat({ id: "c", agentId: "claude" });
  const composer = h.controller.composer("c");
  const level = (value: string) => ({ value, name: value });
  composer.options = [
    {
      id: "model",
      name: "Model",
      kind: "select",
      category: "model",
      value: "big",
      choices: [
        { value: "big", name: "Big", reasoningLevels: [level("low"), level("high")] },
        { value: "small", name: "Small", reasoningLevels: [level("low")] },
        { value: "plain", name: "Plain" },
      ],
    },
    {
      id: "effort",
      name: "Effort",
      kind: "select",
      category: "reasoning",
      value: "default",
      choices: [{ value: "default", name: "Default" }, level("low"), level("high")],
    },
  ];
  const effort = () =>
    h.controller
      .visibleOptions(composer)
      .find((o) => o.id === "effort")
      ?.choices?.map((c) => c.value);
  assert.deepEqual(effort(), ["default", "low", "high"], "the agent's model-free choice stays first");
  composer.options[0]!.value = "small";
  assert.deepEqual(effort(), ["default", "low"]);
  composer.options[0]!.value = "plain";
  assert.equal(effort(), undefined, "a model without levels has no reasoning control");
});

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.