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 convergence/chat@0.2.2
Permissions in 0.2.2
Files
views/session.ts8.3 KB
// The Session panel of the right rail: the chat open in the center, its
// context window, the account's usage limits and its subagents. Rendering
// only reads state; handlers run controller effects.
// HTM whitespace is significant; keep these templates out of Prettier's HTML formatter.
import * as Effect from "effect/Effect";
import { html } from "convergence";
import type { Chat, ConfigOption, Element } from "convergence";
import type { ChatView } from "../controller.ts";
import type { TaskRow } from "../subagents.ts";
import { allTasks, metaLine, nameOf } from "../subagents.ts";
import { displayStatus, modelName } from "../workflows.ts";
import { ago, optionLabel, pinned, sessionOpen, statusOf, when, working } from "../session.ts";
import { contextDetails, limitRow, limitsNote } from "./usage.ts";
import { mark } from "./tasks.ts";
import { AGENT_MARK, column, fill, full, markIcon, markOf, row } from "./styles.ts";
// An item's side inset: the lines between the rows start where their marks do.
const INSET = 9;
// Each level of subagents steps in by a tree level.
const LEVEL = 14;
/// The chat in the center, while the center shows one.
function shownChat(v: ChatView): Chat | undefined {
const app = v.ctx.app;
return app.route === "chat" && app.chatId ? v.controller.state.chats[app.chatId] : undefined;
}
export function renderSessionRail(v: ChatView): Element | null {
const chat = shownChat(v);
const count = chat ? working(v.controller.state.transcripts[chat.id]?.items ?? []) : 0;
return html`
<button id="rail-session" icon="activity" variant="ghost" active=${pinned(v.ctx.app)}
tooltip=${count ? `Session: ${count} ${count === 1 ? "subagent" : "subagents"} working` : "Session"}
badge=${count ? String(count) : undefined} onClick=${() => v.ctx.run(v.controller.toggleSession())} />`;
}
export function renderSessionPanel(v: ChatView): Element | null {
if (!sessionOpen(v.ctx.app)) return null;
const chat = shownChat(v);
return html`
<div ...${column} ...${fill} ...${full} padding="small" paddingX="small">
<div ...${row} gap="small" padding="small" paddingY="small">
<text style="body" size=${13.125} weight=${600}>Session</text>
<spacer />
<button id="session-close" icon="x" variant="ghost" small tooltip="Close" onClick=${() => v.ctx.run(v.controller.closeSession())} />
</div>
${
chat
? html`
<div ...${column} ...${fill} gap="medium" padding="small" overflowY="scroll">
${sessionSection(v, chat)}
${contextSection(v, chat)}
${limitsSection(v, chat)}
${subagentsSection(v, chat)}
</div>`
: html`<div ...${column} gap="small" padding="medium"><text style="muted">Open a chat to see its session.</text></div>`
}
</div>`;
}
// A heading and its rows; a count at the heading's end when there is one.
function section(id: string, label: string, body: readonly (Element | null)[], count?: number): Element {
const heading = count
? html`<item heading id=${`session-${id}`} label=${label}><text style="body" size=${9.84} tone="muted">${String(count)}</text></item>`
: html`<item heading id=${`session-${id}`} label=${label} />`;
return html`<div ...${column} gap=${2}>${heading}${body}</div>`;
}
// One muted line where a section has nothing to show.
const note = (text: string) =>
html`<div ...${row} paddingX=${INSET} paddingY=${3}><text style="small" tone="muted">${text}</text></div>`;
// A line of the Session section: its name in a column of its own, the
// value, and a button at the end.
function field(id: string, name: string, value: readonly (Element | null)[], end?: Element): Element {
return html`
<div ...${row} id=${`session-${id}`} gap="small" paddingX=${INSET} paddingY=${3} minHeight=${24}>
<div ...${row} width=${84} flexShrink=${0}><text style="small" tone="muted">${name}</text></div>
<div ...${row} ...${fill} gap=${6}>${value}</div>
${end ?? null}
</div>`;
}
const plain = (text: string) => html`<text style="small" truncate>${text}</text>`;
function sessionSection(v: ChatView, chat: Chat): Element {
const c = v.controller;
const agent = c.state.agents[chat.agentId];
const composer = c.state.composers[chat.id];
const options = composer ? c.visibleOptions(composer) : [];
const chosen = (category: string) => optionLabel(options.find((option: ConfigOption) => option.category === category));
const model = [chosen("model"), chosen("reasoning")].filter(Boolean).join(" · ");
const approval = chosen("approval");
const workspace = c.state.workspaces[chat.workspaceId];
const status = statusOf(chat);
const created = when(chat.createdAt);
const active = ago(chat.updatedAt);
const sessionId = chat.sessionId;
const copy = (text: string) =>
c.kernel.call("copy_text", { text }).pipe(
Effect.andThen(c.notify.info("Copied the session id.")),
Effect.catch((error) => c.notify.error(`Copy failed: ${error.message}`)),
);
return section("info", "Session", [
field("agent", "Agent", [html`<icon name="bot" small tone="muted" svg=${agent?.icon} />`, plain(agent?.name ?? chat.agentId)]),
model ? field("model", "Model", [plain(model)]) : null,
approval ? field("approval", "Approval", [plain(approval)]) : null,
workspace ? field("workspace", "Workspace", [markIcon(markOf(workspace), 14, true), plain(workspace.name)]) : null,
field("status", "Status", [
status.running ? html`<spinner activity />` : html`<icon name="circle" small tone=${status.tone} />`,
plain(status.label),
]),
sessionId
? field(
"id",
"Session id",
[html`<text style="mono" size="xs" truncate>${sessionId}</text>`],
html`<button id="session-copy-id" icon="copy" variant="ghost" small tooltip="Copy session id" onClick=${() => v.ctx.run(copy(sessionId))} />`,
)
: null,
created ? field("created", "Created", [plain(created)]) : null,
active ? field("active", "Last active", [plain(active)]) : null,
]);
}
function contextSection(v: ChatView, chat: Chat): Element {
const usage = v.controller.state.transcripts[chat.id]?.usage;
return section("context", "Context window", [
usage?.contextWindow
? html`<div ...${column} paddingX=${INSET} paddingY=${4}>${contextDetails(usage)}</div>`
: note("The agent has not reported its context window yet."),
]);
}
function limitsSection(v: ChatView, chat: Chat): Element | null {
const agent = v.controller.state.agents[chat.agentId];
if (!agent?.capabilities?.usageLimits) return null;
const windows = agent.usageLimits?.windows ?? [];
return section("limits", "Usage limits", [
windows.length
? html`<div ...${column} gap="medium" paddingX=${INSET} paddingY=${4}>${windows.map(limitRow)}</div>`
: note(limitsNote(agent)),
]);
}
function subagentsSection(v: ChatView, chat: Chat): Element {
const rows = allTasks(v.controller.state.transcripts[chat.id]?.items ?? []);
const model = v.controller.state.composers[chat.id]?.options.find((option) => option.category === "model");
return section(
"subagents",
"Subagents",
rows.length ? rows.map((taskRow) => subagentRow(v, chat, taskRow, model)) : [note("No subagents in this chat.")],
rows.length,
);
}
// A subagent or a workflow: its status mark, title, and a line with its
// name, model, time, tokens and tool uses. A click opens its tab.
function subagentRow(v: ChatView, chat: Chat, { item, task, depth }: TaskRow, model: ConfigOption | undefined): Element {
const status = task.workflow ? displayStatus(item) : task.status;
const waiting = status === "waiting";
const meta = [task.name, metaLine({ ...task, model: modelName(model, task.model) ?? undefined }, Date.now())]
.filter(Boolean)
.join(" · ");
const sublabel = waiting ? ["Needs you", meta].filter(Boolean).join(" · ") : meta;
return html`
<div ...${column} paddingLeft=${depth * LEVEL}>
<item id=${`session-task-${task.id}`} label=${task.title || nameOf(task)} sublabel=${sublabel || undefined}
sublabelTone=${waiting ? "warning" : undefined} onClick=${() => v.ctx.run(v.controller.openSubagent(chat, task.id))}>
<slot name="leading">${mark(v, AGENT_MARK[status as keyof typeof AGENT_MARK])}</slot>
${task.workflow ? html`<icon name="workflow" small tone="muted" />` : null}
</item>
</div>`;
}Versions
| Version | Published | Plugin API | Size | Permissions | Status |
|---|---|---|---|---|---|
| 0.2.5latest | Nov 21, 2026 | >=2 <4 | 174.6 KB | 5 permissions | Listed |
| 0.2.4 | Oct 25, 2026 | >=2 <4 | 174.2 KB | 5 permissions | Listed |
| 0.2.3 | Oct 24, 2026 | >=2 <4 | 165.4 KB | 5 permissions | Listed |
| 0.2.2 | Oct 23, 2026 | >=2 <4 | 165 KB | 5 permissions | Listed |
| 0.2.1 | Oct 6, 2026 | >=2 <3 | 111.8 KB | 5 permissions | Listed |
| 0.2.0 | Oct 5, 2026 | >=2 <3 | 105.1 KB | 5 permissions | Listed |
No comments yet.