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.7
Permissions in 0.2.7
Files
views/changes.tsx5 KB
// What ends a turn: one compact card with how long the run worked and how
// many files the turn changed with their lines. With changed files a click
// on the card opens the files under their folders, as a group of tool calls
// opens, and a click on a file opens what the turn did to it in a diff tab
// (`../changes.ts`).
import type { Chat, ChangedFile, Element, TurnSummary } from "divergence";
import type { ChatView } from "../controller.ts";
import type { Transcript } from "../state.ts";
import { byFolder, nameOf, openTurnDiff, totals } from "../changes.ts";
import { statsRow } from "./rows.tsx";
import { column, row, fill, HOVER, clickable, ROW_TEXT, RAISED, corner } from "./styles.tsx";
/** Whether a turn's summary is open: as the reader left it, else folded, so
* the list never takes the room under the reply unasked. */
export function changesOpen(t: Transcript, turn: TurnSummary): boolean {
return t.folds.get(`changes-${turn.itemId}`) ?? false;
}
// A file's row: its name under its folder, inset one step when it has one,
// and its lines at the end.
function fileRow(v: ChatView, chat: Chat, turn: TurnSummary, file: ChangedFile, nested: boolean): Element {
const name = nameOf(file.path);
const lines = file.added === undefined ? null : { added: file.added, removed: file.removed ?? 0 };
return (
<div {...row} {...clickable} cursor="pointer" id={`change-${turn.itemId}-${file.path}`} tooltip={file.path} gap="medium" paddingLeft={nested ? 20 : 6} paddingRight={6} paddingY={5} borderRadius="md" hover={HOVER} onClick={() => v.ctx.run(openTurnDiff(v.controller, chat.id, turn.itemId, file.path))}>
<icon name="file" small file={name} />
<div {...fill}><text style="body" {...ROW_TEXT} truncate text={name} /></div>
{statsRow(lines)}
</div>
);
}
function folderRow(folder: string): Element {
return (
<div {...row} gap="medium" paddingX={6} paddingY={5}>
<icon name="folder" small tone="faint" />
<div {...fill}><text style="body" {...ROW_TEXT} tone="muted" truncate text={folder} /></div>
</div>
);
}
/** The card that ends a turn, or null when there is nothing to say: the time
* the run that ended on `itemId` worked (known only for a run this plugin saw
* end) and the files the turn changed, side by side on one `muted` surface
* with the field corner, a filled button's look. Its text reads as the live
* "Working for" row does. With files the card opens and folds their list. */
export function turnCard(v: ChatView, chat: Chat, t: Transcript, itemId: string, worked: string | null, turn: TurnSummary | undefined): Element | null {
if (!worked && !turn) return null;
const count = turn?.files.length ?? 0;
const parts = (
<div {...row} gap="medium" padding={0} opacity={0.8}>
{worked ? <div id={`worked-${itemId}`} {...row} padding={0}><text style="body" {...ROW_TEXT} tone="foreground">{worked}</text></div> : null}
{worked && turn ? <div width={1} height={12} flexShrink={0} background="border" /> : null}
{turn ? <text style="body" {...ROW_TEXT} tone="foreground">{`${count} changed ${count === 1 ? "file" : "files"}`}</text> : null}
{turn ? statsRow(totals(turn.files)) : null}
</div>
);
// Its text starts where the reply's and a tool row's do, its fill where a tool row's does.
const card = { ...row, padding: 0, paddingX: 5, height: 22.5, flexShrink: 0, background: "muted", borderRadius: corner("field", 8) } as const;
if (!turn) return <div {...card}>{parts}</div>;
const key = `changes-${turn.itemId}`;
const open = changesOpen(t, turn);
return (
<div {...card} {...clickable} id={key} hover={HOVER} onClick={() => {
t.folds.set(key, !open);
v.controller.refresh(chat.id);
}}>
{parts}
</div>
);
}
// The open list of a turn's files: one block, as an open group of tool
// calls is.
function changesList(v: ChatView, chat: Chat, turn: TurnSummary): Element {
return (
<div {...column} padding={0} paddingBottom={4}>
<div {...column} id={`changes-scroll-${turn.itemId}`} gap={2} padding={5} maxHeight={400} background="card" borderRadius="md" {...RAISED} overflowY="scroll">
{byFolder(turn.files).flatMap(({ folder, files }) => [
folder ? folderRow(folder) : null,
...files.map((file) => fileRow(v, chat, turn, file, folder !== "")),
])}
</div>
</div>
);
}
/** A row with what ends its turn under it: the card, unless the row draws it
* itself (`card` null: a reply puts it in its action row), then the turn's
* files while their list is open. */
export function withTurnEnd(v: ChatView, chat: Chat, t: Transcript, rendered: Element | null, card: Element | null, turn: TurnSummary | undefined): Element | null {
const list = turn && changesOpen(t, turn) ? changesList(v, chat, turn) : null;
if (!card && !list) return rendered;
return (
<div {...column} padding={0}>
{rendered}
{card ? <div {...row} padding={0} paddingTop={8} paddingBottom={4}>{card}</div> : null}
{list}
</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.