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

admission.test.ts9.8 KB
import assert from "node:assert/strict";
import test from "node:test";
import * as Effect from "effect/Effect";
import { HostCallFailed } from "divergence/effect";
import { followApp, prehydratePresentation } from "./panes.ts";
import { loadTranscript } from "./data.ts";
import * as Deferred from "effect/Deferred";
import { paneReady, renderPane } from "./views/panes.tsx";
import { renderTaskCenter } from "./views/layout.tsx";
import { chat, harness, item, nodes } from "./ui-for-tests.test.ts";

test("a provider session does not establish whether a stored chat has content", async () => {
  const h = harness();
  h.controller.state.chats.a = chat({ id: "a" });
  h.controller.state.panes.a = { chatId: "a", view: { id: 1, update() {}, remove() {} }, composer: { id: 2, update() {}, remove() {} } };
  const transcript = h.controller.transcript("a");
  assert.equal(paneReady(h.controller, "a"), false);
  assert.ok(!nodes(renderPane(h.v, "a")).some((node) => node.id === "landing-stage"));
  h.controller.state.chats.a = { ...h.controller.state.chats.a, sessionId: "session" };
  assert.equal(paneReady(h.controller, "a"), false);
  transcript.snapshot = { kind: "ready" };
  assert.equal(paneReady(h.controller, "a"), true);
  assert.ok(nodes(renderPane(h.v, "a")).some((node) => node.id === "landing-stage"), "an empty snapshot establishes the landing page");
  transcript.snapshot = { kind: "unread" };
  transcript.items = [item({ id: "saved", role: "assistant", text: "Stored content" })];
  assert.equal(paneReady(h.controller, "a"), true);
  transcript.items = [];
  h.controller.composer("a").submitting = true;
  assert.equal(paneReady(h.controller, "a"), true, "an active submission owns its visible state");
  await h.close();
});

test("split admission keeps complete content and never substitutes a drawn unread pane", async () => {
  const h = harness();
  for (const [index, id] of ["old", "cold"].entries()) {
    h.controller.state.chats[id] = chat({ id });
    h.controller.state.panes[id] = { chatId: id, view: { id: 40 + index, update() {}, remove() {} }, drawn: true, ready: id === "old" };
    const transcript = h.controller.transcript(id);
    transcript.snapshot = { kind: id === "old" ? "ready" : "unread" };
    if (id === "cold") transcript.loading = Deferred.makeUnsafe<void>();
  }
  const tabs = ["old", "cold"].map((chatId) => ({ kind: "chat" as const, chatId }));
  const pane = { kind: "pane" as const, id: "admission-pane", tabs, active: tabs[0]! };
  const task = { id: "admission-task", layout: { root: pane, focused: pane.id }, createdAt: "", updatedAt: "" };
  assert.ok(nodes(renderTaskCenter(h.v, task)).some((node) => node.type === "view" && node.view === 40));
  pane.active = tabs[1]!;
  const waiting = nodes(renderTaskCenter(h.v, task));
  assert.ok(waiting.some((node) => node.type === "view" && node.view === 40));
  assert.ok(!waiting.some((node) => node.type === "view" && node.view === 41));
  const fresh = { ...pane, id: "unread-new-split" };
  assert.ok(!nodes(renderTaskCenter(h.v, { ...task, layout: { root: fresh, focused: fresh.id } })).some((node) => node.type === "view" && node.view === 41));
  await h.close();
});


function snapshotHost(firstRead?: Deferred.Deferred<void>) {
  let fail = true;
  let reads = 0;
  let histories = 0;
  let prepares = 0;
  const rows = [item({ id: "saved", role: "assistant", text: "Stored content" })];
  const h = harness((method) => {
    if (method === "host/chats.transcript") {
      reads++;
      if (reads === 1 && firstRead)
        return Deferred.await(firstRead).pipe(Effect.andThen(Effect.fail(new HostCallFailed({ method, code: -32000, message: "The store is unavailable" }))));
      return fail
        ? Effect.fail(new HostCallFailed({ method, code: -32000, message: "The store is unavailable" }))
        : Effect.succeed({ items: rows, start: 0, pendingApprovals: [], pendingQuestions: [], plan: null, running: false });
    }
    if (method === "host/chats.load_history") {
      histories++;
      return Effect.succeed({});
    }
    if (method === "host/chats.prepare") {
      prepares++;
      return Effect.succeed({});
    }
    if (method === "host/security.pending") return Effect.succeed({ requests: [] });
    if (method === "host/chats.checkpoints") return Effect.succeed({ checkpoints: [] });
    if (method === "host/chats.options") return Effect.succeed({ options: [] });
    if (method === "host/chats.commands") return Effect.succeed({ commands: [] });
    if (method === "host/chats.skills") return Effect.succeed({ skills: [] });
    return undefined;
  });
  h.controller.state.chats.a = chat({ id: "a", sessionId: "session" });
  h.controller.state.chats.b = chat({ id: "b" });
  h.controller.transcript("b").snapshot = { kind: "ready" };
  return { ...h, succeed: () => { fail = false; }, fail: () => { fail = true; }, counts: () => ({ reads, histories, prepares }) };
}

test("a failed opening shows its retry action and retries once when the retained chat returns", async () => {
  const h = snapshotHost();
  Effect.runSync(h.controller.app.update({ route: "chat", chatId: "a" }));
  await Effect.runPromise(followApp(h.controller));
  await h.settle();
  const transcript = h.controller.transcript("a");
  assert.equal(transcript.snapshot.kind, "failed");
  assert.equal(paneReady(h.controller, "a"), true, "the failure is a complete destination outcome");
  let rendered = nodes(renderPane(h.v, "a"));
  assert.ok(rendered.some((node) => node.id === "transcript-retry-a"));
  assert.ok(rendered.some((node) => node.text?.includes("The store is unavailable")));
  assert.ok(!rendered.some((node) => node.id === "landing-stage" || node.id === "chat-skeleton"));
  for (let index = 0; index < 3; index++) await Effect.runPromise(followApp(h.controller));
  await h.settle();
  assert.deepEqual(h.counts(), { reads: 1, histories: 1, prepares: 1 }, "rendering a failure does not retry or repeat show effects");
  Effect.runSync(h.controller.app.update({ chatId: "b" }));
  await Effect.runPromise(followApp(h.controller));
  Effect.runSync(h.controller.app.update({ chatId: "a" }));
  await Effect.runPromise(followApp(h.controller));
  await h.settle();
  assert.equal(transcript.snapshot.kind, "failed");
  assert.deepEqual(h.counts(), { reads: 2, histories: 2, prepares: 3 }, "returning retries even when the agent's history is unchanged");
  await Effect.runPromise(followApp(h.controller));
  assert.equal(h.counts().reads, 2, "another failed attempt also waits for a user action");
  h.succeed();
  rendered = nodes(renderPane(h.v, "a"));
  rendered.find((node) => node.id === "transcript-retry-a")!.onClick();
  await h.settle();
  assert.equal(transcript.snapshot.kind, "ready");
  assert.deepEqual(transcript.items.map((row) => row.id), ["saved"]);
  assert.equal(h.counts().reads, 3);
  assert.ok(!nodes(renderPane(h.v, "a")).some((node) => node.id === "transcript-retry-a"));
  await h.close();
});

test("a failed refresh keeps retained rows visible and its retry replaces them only after a successful read", async () => {
  const h = snapshotHost();
  h.succeed();
  await Effect.runPromise(loadTranscript(h.controller, "a", { history: false }));
  const transcript = h.controller.transcript("a");
  const retained = transcript.items;
  h.fail();
  await Effect.runPromise(loadTranscript(h.controller, "a", { history: false }));
  assert.equal(transcript.snapshot.kind, "failed");
  assert.equal(transcript.items, retained);
  const rendered = nodes(renderPane(h.v, "a"));
  assert.ok(rendered.some((node) => node.type === "scroller"));
  assert.ok(rendered.some((node) => node.id === "transcript-retry-a"));
  assert.ok(!rendered.some((node) => node.id === "landing-stage" || node.id === "chat-skeleton"));
  h.succeed();
  rendered.find((node) => node.id === "transcript-retry-a")!.onClick();
  await h.settle();
  assert.equal(transcript.snapshot.kind, "ready");
  assert.deepEqual(transcript.items.map((row) => row.id), ["saved"]);
  await h.close();
});

test("selection retries failed prehydration without repeating selection effects during later renders", async () => {
  const h = snapshotHost();
  await Effect.runPromise(prehydratePresentation(h.controller, "a"));
  assert.deepEqual(h.counts(), { reads: 1, histories: 0, prepares: 0 });
  assert.deepEqual(h.focused, []);
  Effect.runSync(h.controller.app.update({ route: "chat", chatId: "a" }));
  h.succeed();
  await Effect.runPromise(followApp(h.controller));
  await h.settle();
  for (let index = 0; index < 3; index++) await Effect.runPromise(followApp(h.controller));
  assert.deepEqual(h.counts(), { reads: 2, histories: 1, prepares: 1 });
  assert.deepEqual(h.focused, ["prompt-a"]);
  assert.equal(h.controller.transcript("a").snapshot.kind, "ready");
  await h.close();
});


test("an unchanged history check followed by a failed snapshot still retries on return", async () => {
  const firstRead = Deferred.makeUnsafe<void>();
  const h = snapshotHost(firstRead);
  Effect.runSync(h.controller.app.update({ route: "chat", chatId: "a" }));
  await Effect.runPromise(followApp(h.controller));
  await h.settle();
  assert.equal(h.counts().histories, 1, "the unchanged history check completes before the snapshot fails");
  assert.equal(h.controller.composer("a").syncing, false);
  assert.equal(h.controller.transcript("a").snapshot.kind, "unread");
  await Effect.runPromise(Deferred.succeed(firstRead, undefined));
  await h.settle();
  assert.equal(h.controller.transcript("a").snapshot.kind, "failed");
  assert.ok(!nodes(renderPane(h.v, "a")).some((node) => node.id === "landing-stage"));
  Effect.runSync(h.controller.app.update({ chatId: "b" }));
  await Effect.runPromise(followApp(h.controller));
  Effect.runSync(h.controller.app.update({ chatId: "a" }));
  h.succeed();
  await Effect.runPromise(followApp(h.controller));
  await h.settle();
  assert.equal(h.counts().reads, 2);
  assert.equal(h.controller.transcript("a").snapshot.kind, "ready");
  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.