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.8
Permissions in 0.2.8
Files
session.ts2.9 KB
// The Session panel's data: when it shows, and how the chat open in the
// center reads (its options, status and times, its subagents). Pure: the
// views in views/session.ts draw what this returns.
import type { AppState, Chat, ConfigOption, TranscriptItem } from "divergence";
import { allTasks, counts } from "./subagents.ts";
/// The plugin the shell names in `rightPanel` and `rightPanelPreview`.
export const PANEL = "chat";
export const pinned = (app: AppState): boolean => app.shared?.rightPanel === PANEL;
/// Pinned as the docked column, or shown as the rail icon's fly-out.
export const sessionOpen = (app: AppState): boolean => pinned(app) || app.shared?.rightPanelPreview === PANEL;
/// The name of an option's chosen value ("Opus 4.1", "High"), else the
/// value itself; null without a value.
export function optionLabel(option: Pick<ConfigOption, "value" | "choices"> | undefined): string | null {
if (option?.value === undefined || option.value === null || option.value === "") return null;
return option.choices?.find((choice) => choice.value === option.value)?.name ?? String(option.value);
}
/// The chat's state as the sidebar names it, with the tone of its mark.
export function statusOf(chat: Pick<Chat, "status" | "sessionId">): {
label: string;
tone: "warning" | "info" | "danger" | "faint";
running: boolean;
} {
switch (chat.status) {
case "running":
return { label: "Running", tone: "info", running: true };
case "waiting_approval":
case "waiting_question":
return { label: "Needs you", tone: "warning", running: false };
case "failed":
return { label: "Failed", tone: "danger", running: false };
default:
return { label: chat.sessionId ? "Idle" : "Not started", tone: "faint", running: false };
}
}
const dateTime = new Intl.DateTimeFormat([], { month: "short", day: "numeric", hour: "numeric", minute: "2-digit" });
/// "Oct 11, 2:05 PM" in the user's locale and clock, as the transcript's message times read; null for a time that does
/// not parse.
export function when(iso: string | undefined): string | null {
const at = iso ? Date.parse(iso) : Number.NaN;
if (Number.isNaN(at)) return null;
return dateTime.format(at);
}
/// "just now", "5m ago", "3h ago", "2d ago"; null for a time that does not parse.
export function ago(iso: string | undefined, now = Date.now()): string | null {
const at = iso ? Date.parse(iso) : Number.NaN;
if (Number.isNaN(at)) return null;
const minutes = Math.floor(Math.max(0, now - at) / 60_000);
if (minutes < 1) return "just now";
if (minutes < 60) return `${minutes}m ago`;
const hours = Math.floor(minutes / 60);
return hours < 24 ? `${hours}h ago` : `${Math.floor(hours / 24)}d ago`;
}
/// Subagents at work in a transcript (running or waiting on the user):
/// the rail icon's badge and the title strip's "N working".
export const working = (items: readonly TranscriptItem[]): number => counts(allTasks(items).map((row) => row.task)).working;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.