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

open-in.test.ts6.4 KB
// "Open in" in the title strip: the apps the kernel lists, the one picked
// last remembered in storage, and quiet on a kernel that cannot list them.
import assert from "node:assert/strict";
import test from "node:test";
import * as Effect from "effect/Effect";
import type { Layout } from "divergence/protocol";
import { KernelCallFailed } from "divergence/effect";
import { noteTask } from "./layout.ts";
import { loadOpenIn } from "./open-in.ts";
import { renderTitle } from "./views/title.tsx";
import { chat, harness, nodes } from "./ui-for-tests.test.ts";

const APPS = [
  { id: "zed", name: "Zed", icon: "/cache/dev.zed.Zed.png" },
  { id: "terminal", name: "Terminal", icon: "/cache/com.apple.Terminal.png" },
  { id: "file-manager", name: "Finder" },
];

/** A harness whose kernel lists `apps`, or knows no `open_in` methods at all when `apps` is null. */
function withApps(
  apps: readonly object[] | null,
  opened: (params: unknown) => Effect.Effect<unknown, KernelCallFailed> = () => Effect.succeed({}),
) {
  return harness(undefined, (method, params) => {
    if (!method.startsWith("open_in")) return undefined;
    if (apps === null)
      return Effect.fail(new KernelCallFailed({ method, message: `method not found: kernel/${method}` }));
    return method === "open_in.apps" ? Effect.succeed({ apps }) : opened(params);
  });
}

function title(h: ReturnType<typeof harness>) {
  return nodes(renderTitle({ ...h.v, ctx: { ...h.v.ctx, app: { route: "chat", chatId: "c" } } }));
}

test("an older kernel without open_in shows no Open in and says nothing", async () => {
  const h = withApps(null);
  h.controller.state.chats.c = chat();
  await Effect.runPromise(loadOpenIn(h.controller));
  assert.equal(
    title(h).find((node) => node.id === "open-in"),
    undefined,
  );
  assert.deepEqual(h.notices, []);
  await h.close();
});

test("one click opens the workspace in the app picked last, and the list opens another and remembers it", async () => {
  const h = withApps(APPS);
  h.controller.state.chats.c = chat({ workspaceId: "w1" });
  h.stored.openIn = "terminal";
  await Effect.runPromise(loadOpenIn(h.controller));
  const button = () => title(h).find((node) => node.id === "open-in");
  assert.equal(button()?.tooltip, "Open in Terminal", "the app picked last");
  assert.equal(button()?.label, "Open in Terminal", "the icon button names its action to assistive technology");
  assert.equal(nodes(button()).find((node) => node.type === "image")?.path, "/cache/com.apple.Terminal.png");
  button()?.onClick();
  await h.settle();
  const opens = () => h.calls.filter((call) => call.method === "open_in").map((call) => call.params);
  assert.deepEqual(opens(), [{ app: "terminal", workspaceId: "w1" }]);

  const list = title(h).find((node) => node.id === "open-in-apps");
  assert.equal(list?.value, "terminal", "the list checks the app the button opens");
  assert.equal(list?.children[0]?.label, "Choose app to open in", "the chevron names its menu to assistive technology");
  assert.deepEqual(
    (list?.options as { value: string; label: string; image?: string }[]).map((option) => [
      option.value,
      option.label,
      option.image,
    ]),
    [
      ["zed", "Zed", "/cache/dev.zed.Zed.png"],
      ["terminal", "Terminal", "/cache/com.apple.Terminal.png"],
      ["file-manager", "Finder", undefined],
    ],
  );
  list?.onChange({ value: "zed" });
  await h.settle();
  assert.deepEqual(opens()[1], { app: "zed", workspaceId: "w1" }, "picking an app opens it");
  assert.equal(h.stored.openIn, "zed", "and remembers it");
  assert.equal(button()?.tooltip, "Open in Zed");
  await h.close();
});

test("with nothing remembered, or an app that is gone, the button opens Finder", async () => {
  const h = withApps(APPS);
  h.controller.state.chats.c = chat();
  await Effect.runPromise(loadOpenIn(h.controller));
  assert.equal(title(h).find((node) => node.id === "open-in")?.tooltip, "Open in Finder");
  h.controller.state.openIn.chosen = "cursor";
  assert.equal(title(h).find((node) => node.id === "open-in")?.tooltip, "Open in Finder");
  const finder = withApps([{ id: "file-manager", name: "Finder" }]);
  finder.controller.state.chats.c = chat();
  await Effect.runPromise(loadOpenIn(finder.controller));
  const icon = nodes(title(finder).find((node) => node.id === "open-in"));
  assert.equal(icon.find((node) => node.type === "icon")?.name, "external-link", "an app without an icon");
  await Promise.all([h.close(), finder.close()]);
});

test("the app picked last is the default again after a restart", async () => {
  const first = withApps(APPS);
  first.controller.state.chats.c = chat();
  await Effect.runPromise(loadOpenIn(first.controller));
  title(first)
    .find((node) => node.id === "open-in-apps")
    ?.onChange({ value: "zed" });
  await first.settle();
  const restarted = withApps(APPS);
  restarted.stored.openIn = first.stored.openIn;
  restarted.controller.state.chats.c = chat();
  await Effect.runPromise(loadOpenIn(restarted.controller));
  assert.equal(title(restarted).find((node) => node.id === "open-in")?.tooltip, "Open in Zed");
  await Promise.all([first.close(), restarted.close()]);
});

test("an open that fails says why, and the app is still the one picked", async () => {
  const h = withApps(APPS, () =>
    Effect.fail(new KernelCallFailed({ method: "open_in", message: "Zed is not installed any more" })),
  );
  h.controller.state.chats.c = chat();
  await Effect.runPromise(loadOpenIn(h.controller));
  title(h)
    .find((node) => node.id === "open-in-apps")
    ?.onChange({ value: "zed" });
  await h.settle();
  assert.deepEqual(h.notices, ["Could not open in Zed: Zed is not installed any more"]);
  assert.equal(h.stored.openIn, "zed");
  await h.close();
});

test("in a task's strips Open in follows the split buttons at the end of the last strip", async () => {
  const h = withApps(APPS);
  const tab = { kind: "chat" as const, chatId: "c" };
  const root: Layout = { kind: "pane", id: "p1", tabs: [tab], active: tab };
  noteTask(h.controller.state.layouts, { id: "t", layout: { root, focused: "p1" }, createdAt: "", updatedAt: "" });
  h.controller.state.chats.c = chat();
  await Effect.runPromise(loadOpenIn(h.controller));
  const strip = title(h).find((node) => node.id === "strip-p1");
  const ids = nodes(strip)
    .map((node) => node.id)
    .filter((id) => typeof id === "string" && (id.startsWith("strip-split") || id === "open-in"));
  assert.deepEqual(ids, ["strip-split-right-p1", "strip-split-down-p1", "open-in"]);
  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.