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.5

Permissions in 0.2.5

  • Control chats chats.controlHighCreates chats, sends prompts and cancels runs.Send prompts, answer agent questions, and create, change, fork, revert, stop and group chats
  • Run other plugins' commands commands.runHighRuns commands of other plugins.Run the sidebar's New chat command from the title bar
  • Read chats chats.readMediumReads your transcripts and chat lists.Show workspaces, tasks, chats and transcripts, and follow them as agents work
  • Read files fs.readMediumReads files in the listed places.Suggest workspace files for @ mentionsPlaces: the open workspace
  • Show panels ui.slotsAlways grantedShows views in the listed parts of the window.Draw the chat grid, the title bar, and the Session panel with its rail buttonSlots: centertitlerailright

Files

views/panes.ts11.2 KB
// Panes rendering preserves the chat's retained tree and interaction keys.
import { html } from "convergence";
import { VISIBLE, reconcile as reconcileCycle, visible } from "../switcher.ts";
import type { Chat, Element } from "convergence";
import type { Pane } from "../state.ts";
import type { ChatView } from "../controller.ts";
import { selectedChat } from "../input-schema.ts";
import { renderTranscript, reading } from "./rows.ts";
import { dock, landingChips, landingHeadline, renderComposer, renderLanding, risingFrom, stageLook } from "./composer.ts";
import { column, row, fill, full } from "./styles.ts";
export function switcherRow(v: ChatView, id: string, chosen: boolean): Element | null {
  const chat = v.controller.state.chats[id];
  if (!chat) return null;
  const workspace = v.controller.state.workspaces[chat.workspaceId]?.name ?? "";
  return html`
      <item id=${`switch-${id}`} label=${v.controller.titleOf(chat)} sublabel=${workspace || undefined} selected=${chosen}
        busy=${v.controller.isRunning(chat)} icon="bot" iconSvg=${v.controller.state.agents[chat.agentId]?.icon}
        onClick=${() => {
          v.controller.state.switcher = { list: [id], selected: id };
          v.ctx.run(v.controller.commitSwitcher());
        }} />`;
}

export function renderSwitcher(v: ChatView): Element | null {
  // The list is checked against the chats the app still has: one closed
  // while the cycle is open must not leave a row behind.
  const open = reconcileCycle(v.controller.state.switcher, v.controller.state.chats);
  v.controller.state.switcher = open;
  const { rows } = open ? visible(open.list, open.selected, VISIBLE) : { rows: [] };
  const keys = {
    up: () => v.controller.switchBy(-1),
    left: () => v.controller.switchBy(-1),
    down: () => v.controller.switchBy(1),
    right: () => v.controller.switchBy(1),
    enter: () => v.ctx.run(v.controller.commitSwitcher()),
    escape: v.controller.closeSwitcher,
  };
  // The overlay draws the card around the column; only the rows are ours.
  return html`
      <overlay id="chat-switcher" open=${!!open} width=${544} hold="ctrl" onRelease=${() => v.ctx.run(v.controller.commitSwitcher())} onDismiss=${v.controller.closeSwitcher} keys=${keys}>
        <div ...${column} gap=${2} padding="small">
          <div ...${row} gap="small" padding="small" paddingX=${8} paddingY=${2}>
            <text style="section" size=${9.84} weight=${700} tone="muted">Recent chats</text>
          </div>
          ${rows.map((id) => switcherRow(v, id, id === open?.selected))}
        </div>
      </overlay>`;
}

// How far above the prompt box the blur starts, and the backdrop under the
// composer: no blur at its top, 8px at the pane's edge; the fade reaches the
// pane's colour where the controls under the prompt box start.
const FOOTER_LEAD = 16;
const FOOTER_BACKDROP = { blur: [0, 8], fade: [0, 1.35] };

// The pane shows its chat, not a skeleton waiting for its rows.
export function paneReady(c: ChatView["controller"], chatId: string): boolean {
  const chat = c.state.chats[chatId];
  if (!chat) return false;
  const t = c.transcript(chatId);
  const submitting = c.state.composers[chatId]?.submitting;
  return t.loaded || t.items.length > 0 || !!submitting || (!t.running && !chat.sessionId);
}

// One chat: the landing page while it is fresh, else its transcript with
// the composer floating over its bottom.
export function renderPane(v: ChatView, chatId: string): Element | null {
  const chat = v.controller.state.chats[chatId];
  if (!chat) return null;
  v.ctx.run(v.controller.ensureChat(chat.id));
  v.ctx.run(v.controller.ensureComposer(chat.id));
  const t = v.controller.transcript(chat.id);
  const submitting = v.controller.state.composers[chat.id]?.submitting;
  const landing = !t.items.length && !t.running && !submitting && (t.loaded || !chat.sessionId);
  // The page on screen sending its prompt is a departure: the page's
  // background fades, its headline and chip ride down with the prompt box
  // as they fade, and the sent text rises into its message.
  const pane = v.controller.state.panes[chat.id];
  if (pane) {
    if (pane.landing && !landing && submitting && v.controller.state.onScreen === chat.id) pane.departing = true;
    pane.landing = landing;
  }
  const departing = !landing && !!pane?.departing;
  // The landing page draws its own composer.
  const composer = () =>
    html`<div ...${column} gap="small" padding="small" paddingY="medium">${reading(v, [dock(chat, composerOf(v, chat), departing ? departingPage(v, chat) : [])])}</div>`;
  // The transcript scrolls under the composer. Over its bottom, from a
  // little above the prompt box down to the pane's edge, the blur grows
  // row by row and the chat fades into the pane, gone before the controls
  // under the prompt box.
  const footer = () =>
    html`<div ...${column} paddingTop=${FOOTER_LEAD} backdrop=${FOOTER_BACKDROP}>${composer()}</div>`;
  const body = landing
    ? renderLanding(v, chat, composerOf(v, chat))
    : html`
          <div ...${column} ...${fill} ...${full} padding="small">
            ${
              !t.loaded && !t.items.length && !submitting
                ? [renderSkeleton(v), composer()]
                : renderTranscript(v, chat, footer())
            }
          </div>`;
  // The landing page's stage runs to the pane's edges and draws its own
  // background; the transcript keeps the pane's inset, over grain.
  const grain = !landing && v.controller.api.settings.get("transcriptGrain") === true;
  return html`
      <div ...${column} ...${fill} ...${full} id=${`pane-${chat.id}`} padding=${landing ? undefined : "small"} position="relative" grain=${grain}>
        ${departing && pane ? fadingStage(v, pane) : null}
        ${body}
      </div>`;
}

// The page's headline and chip over the prompt box on its way down, where
// they sat above it on the page, taking no room; and, until the sent text
// has its message, where that text rises from.
function departingPage(v: ChatView, chat: Chat): (Element | null)[] {
  const fade = { to: { opacity: 0 }, duration: 160 };
  const t = v.controller.transcript(chat.id);
  const sent = t.items.some((item) => item.role === "user") || !!v.controller.composer(chat.id).outgoing?.preview;
  return [
    html`
      <div height=${0} position="relative">
        <div ...${column} position="absolute" left=${0} right=${0} bottom=${0} gap=${18.75} paddingBottom="small" alignItems="center">
          ${landingHeadline(v, chat, fade)}
          ${landingChips(v, chat, fade)}
        </div>
      </div>`,
    sent ? null : risingFrom(chat),
  ];
}

// The page's background, still running under the transcript as it fades;
// the departure ends with it.
function fadingStage(v: ChatView, pane: Pane): Element {
  const { ambient, grain } = stageLook(v);
  const onDone = () => {
    pane.departing = false;
    pane.view.update();
  };
  return html`
      <div id="landing-stage" position="absolute" left=${0} right=${0} top=${0} bottom=${0} background=${grain ? undefined : "stage"} grain=${grain} ambient=${ambient}
        motion=${{ to: { opacity: 0 }, duration: 240, onDone }} />`;
}

// The chat's composer view, which renders on its own as the user types; a
// pane drawn without one (as the tests draw it) draws the composer itself.
function composerOf(v: ChatView, chat: Chat): Element | null {
  const view = v.controller.state.panes[chat.id]?.composer;
  return view ? html`<view view=${view.id} fit />` : renderComposer(v, chat);
}

// The composer view of one chat.
export function renderComposerView(v: ChatView, chatId: string): Element | null {
  const chat = v.controller.state.chats[chatId];
  return chat ? renderComposer(v, chat) : null;
}

// A chat whose rows are on their way: the shapes of a conversation where
// they will be, in the same frame as the click, so the pane is never empty
// and nothing jumps when the rows come.
export function renderSkeleton(v: ChatView): Element {
  const line = (width: string) => html`<div width=${width} height=${9} borderRadius="sm" background="muted" />`;
  const activity = (width: string) => html`<div width=${width} height=${22} borderRadius="sm" background="muted" />`;
  return html`
      <div ...${column} ...${fill} ...${full} id="chat-skeleton" paddingY="large">
        ${reading(v, [
          html`<div ...${row} justifyContent="end"><div width="46%" height=${40} borderRadius="xl" background="muted" /></div>`,
          html`<div ...${column} gap=${9} paddingY="medium">${["94%", "88%", "63%"].map(line)}</div>`,
          html`<div ...${column} gap="small">${["34%", "41%"].map(activity)}</div>`,
          html`<div ...${column} gap=${9} paddingY="medium">${["91%", "76%"].map(line)}</div>`,
        ])}
      </div>`;
}

// The skeleton where the pane will be, with the pane's own insets.
const centerSkeleton = (v: ChatView) =>
  html`<div ...${column} ...${fill} ...${full} padding="small"><div ...${column} ...${fill} ...${full} padding="small">${renderSkeleton(v)}</div></div>`;

// Three frames at 60 Hz: a chat ready sooner replaces the last one directly.
const SKELETON_AFTER = 50;

// The shown chat's pane view, made the first time it shows.
export function renderCenter(v: ChatView): Element | null {
  const app = v.ctx.app;
  v.controller.keepTranscripts(v.ctx.state);
  // Kept panes render only when their chat changes, so the panes that
  // gain and lose the main prompt box render now.
  const mainPrompt = app.route === "chat" ? (app.chatId ?? null) : null;
  const was = v.controller.state.mainPrompt;
  if (was !== mainPrompt) {
    v.controller.state.mainPrompt = mainPrompt;
    for (const chatId of [was, mainPrompt]) {
      const pane = chatId ? v.controller.state.panes[chatId] : undefined;
      (pane?.composer ?? pane?.view)?.update();
    }
  }
  if (app.route !== "chat") {
    v.controller.state.preparedChat = null;
    return null;
  }
  if (!app.chatId) return html`<empty>Select a chat or press ⌘N to start one.</empty>`;
  if (!v.controller.state.chats[app.chatId]) {
    const selected = selectedChat.safeParse(app.shared?.selectedChat);
    if (selected.success && selected.data.id === app.chatId) v.controller.state.chats[app.chatId] = selected.data;
  }
  const chat = v.controller.state.chats[app.chatId];
  if (!chat) {
    v.ctx.run(v.controller.loadChat(app.chatId));
    return centerSkeleton(v);
  }
  v.ctx.run(v.controller.followApp());
  // The center keeps the chat it showed until the new one is ready, so a
  // switch is one step with nothing between. Only a chat that takes longer
  // than SKELETON_AFTER shows its skeleton; with no chat before, it shows
  // at once.
  const { state } = v.controller;
  const pane = state.panes[chat.id];
  const before = state.onScreen && state.onScreen !== chat.id ? state.panes[state.onScreen] : undefined;
  let shown = pane?.ready ? pane : undefined;
  if (!shown && before) {
    if (state.switching?.chatId !== chat.id) {
      state.switching = { chatId: chat.id, at: Date.now() };
      setTimeout(() => v.controller.center?.update(), SKELETON_AFTER);
    }
    if (Date.now() - state.switching.at < SKELETON_AFTER) shown = before;
  }
  shown ??= pane?.drawn ? pane : undefined;
  if (!shown) return centerSkeleton(v);
  if (shown.chatId === chat.id) state.switching = null;
  state.onScreen = shown.chatId;
  return html`<view view=${shown.view.id} />`;
}

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.2.5latestNov 21, 2026>=2 <4174.6 KB5 permissionsListed
0.2.4Oct 25, 2026>=2 <4174.2 KB5 permissionsListed
0.2.3Oct 24, 2026>=2 <4165.4 KB5 permissionsListed
0.2.2Oct 23, 2026>=2 <4165 KB5 permissionsListed
0.2.1Oct 6, 2026>=2 <3111.8 KB5 permissionsListed
0.2.0Oct 5, 2026>=2 <3105.1 KB5 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.