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
Files
open-in.test.ts6.5 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 button keeps the app it opened before", 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, undefined, "the app that failed is not remembered");
assert.equal(title(h).find((node) => node.id === "open-in")?.tooltip, "Open in Finder");
await h.close();
});
test("in a task's strips Open in comes after the + 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-new") || id === "open-in"));
assert.deepEqual(ids, ["strip-new-p1", "open-in"]);
await h.close();
});Versions
| Version | Published | Plugin API | Size | Permissions | Status |
|---|---|---|---|---|---|
| 0.2.9latest | Nov 21, 2026 | >=5 <6 | 349 KB | 5 permissions | Listed |
| 0.2.8 | Nov 16, 2026 | >=5 <6 | 348.6 KB | 5 permissions | Listed |
| 0.2.7 | Nov 11, 2026 | >=5 <6 | 314.3 KB | 5 permissions | Listed |
| 0.2.6 | Nov 9, 2026 | >=5 <6 | 306.2 KB | 5 permissions | Listed |
| 0.2.5 | Oct 27, 2026 | >=2 <4 | 178.6 KB | 5 permissions | Listed |
No comments yet.