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
views/title.tsx6 KB
import type { PresentationLayout } from "../layout.ts";
// Title rendering preserves the chat's retained tree and interaction keys.
import { renderSwitcher } from "./panes.tsx";
import { workspacePicker } from "./composer.tsx";
import type { Chat, Element, OpenInApp, SubmitEvent, ValueEvent } from "divergence";
import { cancelRename, rename, startRename } from "../app-commands.ts";
import { NEW_CHAT, hint } from "../shortcuts.ts";
import type { ChatView } from "../controller.ts";
import { row, fill, titleChipAnchor, clickable, HOVER, TITLE_CONTROL } from "./styles.tsx";
import { openIn, shownApp } from "../open-in.ts";
import { drawsPanes, renderTaskTitle, sideToggle } from "./layout.tsx";
// A failed run reads like the other failure signals: a small danger mark,
// as the sidebar's status dot, beside muted text.
export function failedMark(): Element {
return (
<div {...row} gap={5}>
<icon name="circle" small tone="danger" />
<text style="body" size="sm" tone="muted">Failed</text>
</div>
);
}
/** "Open in": one click opens the chat's workspace folder in the app picked last, and the chevron beside it lists every
* app on this machine it can open in. Nothing shows on an older kernel, which cannot list them. */
export function openInControl(v: ChatView, chat: Chat | undefined): Element | null {
const c = v.controller;
const shown = shownApp(c);
if (!chat || !shown) return null;
const { apps } = c.state.openIn;
const open = (app: OpenInApp) => v.ctx.run(openIn(c, chat.workspaceId, app));
return (
<div {...row} gap={1} height={TITLE_CONTROL} flexShrink={0}>
<div id="open-in" {...row} {...clickable} label={`Open in ${shown.name}`} justifyContent="center" width={TITLE_CONTROL} height={TITLE_CONTROL} borderRadius="md" hover={HOVER} tooltip={`Open in ${shown.name}`} onClick={() => open(shown)}>
{shown.icon ? <image path={shown.icon} width={16} height={16} /> : <icon name="external-link" />}
</div>
<combobox id="open-in-apps" look="toolbar" value={shown.id} options={apps.map((app) => ({ value: app.id, label: app.name, ...(app.icon ? { image: app.icon } : null) }))} onChange={(e: { value?: string }) => {
const app = apps.find((candidate) => candidate.id === e.value);
if (app) open(app);
}}>
<div {...row} {...clickable} label="Choose app to open in" justifyContent="center" width={20} height={TITLE_CONTROL} borderRadius="md" hover={HOVER} tooltip="Open in…">
<icon name="chevron-down" small tone="muted" />
</div>
</combobox>
</div>
);
}
/** Runs the sidebar's New chat, as its key does: the title strip's + and the empty center's action. */
export const newChat = (v: ChatView) => v.ctx.run(v.controller.kernel.call("run_command", { id: NEW_CHAT }));
/// The title as a field (`/rename`, F2 or a double click on the title):
/// Enter saves it, Escape keeps the old.
export function renameField(v: ChatView, chatId: string): Element {
const renaming = v.controller.state.renaming;
return (
<div {...fill} maxWidth={360}>
<input id={`title-rename-${chatId}`} value={renaming?.text ?? ""} placeholder="Chat title" keys={["escape"]} onKey={() => v.ctx.run(cancelRename(v.controller))} onChange={(e: ValueEvent<string>) => {
if (renaming) renaming.text = e.value;
}} onSubmit={(e: SubmitEvent) => v.ctx.run(rename(v.controller, chatId, e.value))} />
</div>
);
}
export function renderTitle(v: ChatView): Element | null {
// The cycle still draws off the chat route: committing to a chat
// brings the route back with it, and an open cycle must never be
// left with no way to close it.
if (v.ctx.app.route !== "chat") return v.controller.state.switcher ? renderSwitcher(v) : null;
return renderChatTitle(v, v.ctx.app.chatId ?? null);
}
/** A retained complete title strip for one navigation context. */
export function renderTitlePresentation(v: ChatView, chatId: string, layout?: PresentationLayout): Element {
return renderChatTitle(v, chatId, v.ctx.app.route === "chat" && v.ctx.app.chatId === chatId, layout);
}
function renderChatTitle(v: ChatView, chatId: string | null, active = true, layout?: PresentationLayout): Element {
const chat = chatId ? v.controller.state.chats[chatId] : undefined;
// A task of more than one chat has a strip over each pane along the top
// instead of one title: the tabs carry each chat's title and status.
const home = chat ? v.controller.state.layouts.homes[chat.id] : undefined;
const task = layout ? layout.task : home ? v.controller.state.layouts.tasks[home] : undefined;
if (task && drawsPanes(v, task)) return renderTaskTitle(v, task, renderSwitcher(v), chatId ?? undefined, active, layout);
const title = <text style="heading" truncate text={chat ? v.controller.titleOf(chat) : "Chat"} />;
// The switcher goes over the window, not in the strip: the overlay
// takes no space here. No padding at the right end: the strip's own gap
// parts the last item from the kernel's buttons, as it parts the others.
return (
<div {...row} {...fill} gap={4} paddingLeft="small">
<button id="title-new-chat" icon="plus" variant="ghost" tooltip={hint(v.controller, "New chat", NEW_CHAT)} onClick={() => newChat(v)} />
{chat && v.controller.state.renaming?.chatId === chat.id
? renameField(v, chat.id)
: chat
? (
// A double click on the title renames the chat, and does not
// reach the strip, where it would zoom the window.
<div id={`title-${chat.id}`} minWidth={0} stopPropagation onDoubleClick={() => v.ctx.run(startRename(v.controller, chat.id))}>{title}</div>
)
: title}
{chat && v.controller.isRunning(chat) ? <text style="body" size="sm" tone="muted">Working…</text> : null}
{chat?.status === "failed" ? failedMark() : null}
<spacer />
{chat ? workspacePicker(v, chat, "title", titleChipAnchor) : null}
{openInControl(v, chat)}
{task ? sideToggle(v, task, layout) : null}
{renderSwitcher(v)}
</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.