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

  • 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

shortcuts.ts3.4 KB
// The keys beside controls ("Stop (⇧⌘C)") are the keys bound now, read from
// `kernel/commands` and written as the host writes them for this platform:
// macOS's symbols in their standard order there, "Ctrl+Shift+C" elsewhere.
// A key the user rebinds shows its new key, and a command with no key shows
// none.
import * as Effect from "effect/Effect";
import * as Stream from "effect/Stream";
import { Events } from "divergence/effect";
import type { CommandInfo } from "divergence";
import type { Controller } from "./controller.ts";
import { errorMessage } from "./data.ts";

export type Shortcuts = {
  /** The first key of each command that has one, as the keyboard shows it, by command id. */
  readonly keys: Readonly<Record<string, string>>;
  /** The host writes keys with macOS's symbols. */
  readonly mac: boolean;
};

export const NO_SHORTCUTS: Shortcuts = { keys: {}, mac: false };

/** The sidebar's New chat, which the title strip and the empty center run. */
export const NEW_CHAT = "sidebar.newChat";

export function shortcutsOf(commands: readonly Pick<CommandInfo, "id" | "labels">[]): Shortcuts {
  const keys: Record<string, string> = {};
  for (const command of commands) if (command.labels[0]) keys[command.id] = command.labels[0];
  // A plugin is not told the platform, but the host's labels say it: only
  // on macOS are they written with these symbols.
  return { keys, mac: commands.some((command) => command.labels.some((label) => /[⌘⌃⌥⇧↩⎋⇥⌫⌦]/.test(label))) };
}

/** What a control says with the key of `command`: "Stop (⇧⌘C)", or the words alone while no key runs it. */
export function hint(c: Controller, words: string, command: string): string {
  return withKey(words, c.state.shortcuts.keys[command]);
}

/**
 * What a control of the prompt says with the prompt's own key, which is not a command: Enter sends,
 * and the platform key with Enter queues.
 */
export function promptHint(c: Controller, words: string, key: "send" | "queue"): string {
  const mac = c.state.shortcuts.mac;
  return withKey(words, key === "send" ? (mac ? "↩" : "Enter") : mac ? "⌘↩" : "Ctrl+Enter");
}

const withKey = (words: string, key: string | undefined) => (key ? `${words} (${key})` : words);

/** Reads the keys bound now and draws again the views that show them. */
export const loadShortcuts = Effect.fn("Chat.loadShortcuts")(function* (c: Controller) {
  const { commands } = yield* c.kernel.call("commands", {});
  c.state.shortcuts = shortcutsOf(commands);
  // The title strip holds the panes' strips and their tab menus.
  c.presentations?.updateAllTitles();
  c.center?.update();
  for (const chatId of Object.keys(c.state.panes)) c.refreshComposer(chatId);
});

/**
 * Reads the keys at the start and again whenever they may have changed: `keybindings.json`, a plugin's
 * manifest, or a plugin turned on or off.
 */
export const followShortcuts = Effect.fn("Chat.followShortcuts")(function* (c: Controller) {
  const events = yield* Events;
  const load = Effect.forkIn(
    loadShortcuts(c).pipe(
      Effect.catch((error) => c.notify.error(`The keyboard shortcuts could not be read: ${errorMessage(error)}`)),
    ),
    c.scope,
    { startImmediately: true },
  );
  yield* load;
  for (const event of ["keybindings_changed", "plugins_changed", "access_changed"] as const)
    yield* events.stream(event).pipe(
      Stream.runForEach(() => load),
      Effect.forkScoped({ startImmediately: true }),
    );
});

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.2.9latestNov 21, 2026>=5 <6349 KB5 permissionsListed
0.2.8Nov 16, 2026>=5 <6348.6 KB5 permissionsListed
0.2.7Nov 11, 2026>=5 <6314.3 KB5 permissionsListed
0.2.6Nov 9, 2026>=5 <6306.2 KB5 permissionsListed
0.2.5Oct 27, 2026>=2 <4178.6 KB5 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.