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
Files
newtab.tsx3.7 KB
// The New tab page: what a strip's + opens, and what the side split shows when
// it is opened with nothing in it. It lists the useful next steps (a chat, a
// terminal, the changes to review, the files, another chat) with their keys;
// picking one that opens a tab takes this tab's place, as a browser's new tab
// gives way to the page it goes to.
import * as Effect from "effect/Effect";
import type { Element } from "divergence";
import type { Pane, Tab } from "divergence/protocol";
import type { Controller, ChatView } from "./controller.ts";
import { closeTab, newChatIn, panesOf, taskOnScreen } from "./layout.ts";
import { errorMessage } from "./data.ts";
import { column, fill, full } from "./views/styles.tsx";
/** The tab kind, as this plugin declares it. */
export const NEW_TAB = "new";
/** One step the page offers: the command whose key it shows, and whether it opens a tab in this one's place. */
interface Step {
readonly id: string;
readonly icon: string;
readonly label: string;
readonly command: string;
readonly replaces: boolean;
}
const STEPS: readonly Step[] = [
{ id: "chat", icon: "message-square", label: "New chat", command: "chat.newTab", replaces: true },
{ id: "terminal", icon: "square-terminal", label: "New terminal", command: "terminal.new", replaces: true },
{ id: "changes", icon: "git-branch", label: "Review changes", command: "git.toggle", replaces: false },
{ id: "files", icon: "files", label: "Browse files", command: "files.toggle", replaces: false },
{ id: "chats", icon: "search", label: "Go to a chat", command: "palette.chats", replaces: false },
];
/** Where a New tab page is: its tab and the pane that holds it, in the task on screen or the side split. */
function placeOf(c: Controller, key: string): { tab: Tab; pane: Pane } | null {
const roots = [taskOnScreen(c)?.layout.root, c.state.layouts.side?.layout?.root];
for (const root of roots) {
if (!root) continue;
for (const pane of panesOf(root)) {
const tab = pane.tabs.find((t) => t.kind === "item" && t.itemKind.endsWith(`.${NEW_TAB}`) && t.key === key);
if (tab) return { tab, pane };
}
}
return null;
}
/** Opens a New tab page: in a pane (a strip's +), in a new pane split off one (the side split's
* split buttons), or in the side split (its toggle with nothing to show). */
export const openNewTab = Effect.fn("Chat.openNewTab")(function* (c: Controller, paneId?: string, split?: "right" | "down") {
const chatId = c.api.app.state().chatId ?? undefined;
const where = paneId ? { paneId, ...(split ? { split } : {}) } : "side";
yield* Effect.tryPromise(() => c.api.layouts.open({ kind: NEW_TAB, key: crypto.randomUUID(), ...(chatId ? { chatId } : {}), where })).pipe(
Effect.catch((error) => c.notify.error(`Could not open a new tab: ${errorMessage(error)}`)),
);
});
const take = Effect.fn("Chat.takeNewTabStep")(function* (c: Controller, key: string, step: Step) {
const place = placeOf(c, key);
if (step.id === "chat" && place) yield* newChatIn(c, place.pane.id);
else yield* c.kernel.call("run_command", { id: step.command });
if (step.replaces && place) yield* closeTab(c, place.tab);
});
export function renderNewTab(v: ChatView, key: string): Element {
const c = v.controller;
const keys = c.state.shortcuts.keys;
return (
<div {...column} {...fill} {...full} id={`new-tab-${key}`} alignItems="center" justifyContent="center" padding="large">
<div {...column} gap={2} width="100%" maxWidth={320}>
{STEPS.map((step) => (
<item id={`new-tab-${step.id}`} icon={step.icon} label={step.label} onClick={() => v.ctx.run(take(c, key, step))}>
{keys[step.command] ? <text keys>{keys[step.command]}</text> : null}
</item>
))}
</div>
</div>
);
}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.