Official

sidebar

Built-in sidebar 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/sidebar@0.2.5

Permissions in 0.2.5

  • Control chats chats.controlHighCreates chats, sends prompts and cancels runs.Add and remove workspaces, and create, rename, check off and archive chats
  • Run other plugins' commands commands.runHighRuns commands of other plugins.Close the tab on screen with Cmd+W when its chat is part of a task
  • Read chats chats.readMediumReads your transcripts and chat lists.List workspaces and chats, and follow them as agents work
  • Show panels ui.slotsAlways grantedShows views in the listed parts of the window.Draw the sidebarSlots: left

Files

items.test.ts7.8 KB
// Rows other plugins put in the sidebar's footer: each publishes a view id
// under `sidebarItem.<plugin>` in the shared app state, and the sidebar
// draws it above Settings (the market's Marketplace row).
import assert from "node:assert/strict";
import { test } from "node:test";
import type { AppState } from "divergence";
import type { EffectViewContext } from "divergence/effect";
import type { Sidebar } from "./controller.ts";
import { initialState, listedChats, noteTask } from "./sections.ts";
import { renderSidebar, sidebarItems } from "./views.tsx";

test("published sidebar items are view ids in the order of their keys; cleared ones go", () => {
  assert.deepEqual(sidebarItems(undefined), []);
  assert.deepEqual(
    sidebarItems({
      rightPanel: "files",
      "sidebarItem.zeta": 9,
      "sidebarItem.market": 4,
      "sidebarItem.gone": null,
      openTab: { nonce: 1 },
    }),
    [4, 9],
  );
});

test("the footer draws each published item directly above Settings", () => {
  const state = initialState();
  state.loaded = true;
  const app: AppState = { route: "chat", shared: { "sidebarItem.market": 7 } };
  const ctx = { app, state: {}, plugin: "sidebar", update() {}, run() {} } as unknown as EffectViewContext<{
    cmd?: boolean;
  }>;
  const tree = renderSidebar(ctx, { state } as unknown as Sidebar["Service"]);
  type Node = { type?: string; id?: string; view?: number; children?: Node[] };
  const order: string[] = [];
  const walk = (node: Node | null | undefined) => {
    if (!node) return;
    if (node.type === "view") {
      // As tall as its row: a view that fills its place collapses to
      // nothing in the footer.
      assert.equal((node as { fit?: boolean }).fit, true);
      order.push(`view:${node.view}`);
    }
    if (node.id === "sidebar-settings") order.push("settings");
    for (const child of node.children ?? []) walk(child);
  };
  walk(tree as unknown as Node);
  assert.deepEqual(order, ["view:7", "settings"]);
});

test("the sidebar steps aside while Settings, which draws its own, is open", () => {
  const state = initialState();
  state.loaded = true;
  const ctx = { app: { route: "settings" }, state: {}, plugin: "sidebar", update() {}, run() {} } as unknown as EffectViewContext<{
    cmd?: boolean;
  }>;
  assert.equal(renderSidebar(ctx, { state } as unknown as Sidebar["Service"]), null);
});

// "Show more" on Complete used to put hundreds of rows in a scrolling
// column that laid out and drew every one of them in each frame of a
// scroll. The chats are one flat list of rows in a scroller that draws
// only the rows on screen, with selection belonging to the selected row.
test("the chats are rows of a list that opens at its start, even after Show more", () => {
  const state = initialState();
  state.loaded = true;
  state.chats = Array.from({ length: 300 }, (_, i) => ({
    id: `c${i}`,
    workspaceId: "ws",
    agentId: "agent",
    title: `Chat ${i}`,
    createdAt: "2026-01-01T00:00:00.000Z",
    updatedAt: "2026-01-02T00:00:00.000Z",
    archived: false,
    options: {},
    status: "idle",
  }));
  // Every one checked off: its task's, as the host keeps them.
  for (const chat of state.chats)
    noteTask(state, {
      id: chat.id,
      layout: {
        root: { kind: "pane", id: `pane-${chat.id}`, tabs: [{ kind: "chat", chatId: chat.id }], active: { kind: "chat", chatId: chat.id } },
        focused: `pane-${chat.id}`,
      },
      completedAt: "2026-01-03T00:00:00.000Z",
      createdAt: chat.createdAt,
      updatedAt: chat.updatedAt,
    });
  state.showAll.settled = true;
  const app: AppState = { route: "chat", chatId: "c7" };
  const ctx = { app, state: {}, plugin: "sidebar", update() {}, run() {} } as unknown as EffectViewContext<{
    cmd?: boolean;
  }>;
  type Node = { type?: string; id?: string; name?: string; selected?: boolean; followEnd?: boolean; children?: Node[]; items?: Node[] };
  const find = (node: Node | null | undefined, type: string): Node | undefined => {
    if (!node) return undefined;
    if (node.type === type) return node;
    for (const child of node.children ?? []) {
      const found = find(child, type);
      if (found) return found;
    }
    return undefined;
  };
  const list = find(renderSidebar(ctx, { state } as unknown as Sidebar["Service"]) as unknown as Node, "scroller");
  assert.equal(list?.followEnd, false);
  const items = list?.items ?? [];
  assert.equal(items[0]?.id, "heading-settled");
  assert.equal(items.find((item) => item.id === "row-c7")?.selected, true, "the selected chat owns its fill");
  assert.ok(items.filter((item) => item.id?.startsWith("row-")).every((item) => (item as { lift?: boolean }).lift === true), "every chat row is lifted, so the open one is raised");
  assert.equal(items.filter((item) => item.id?.startsWith("row-")).length, 300, "every chat is a row of its own");
  // Shown whole, Complete's rows end the list and only "Show less" stays
  // pinned at its foot.
  const pinned = items.at(-1);
  assert.equal(pinned?.type, "slot");
  assert.equal(pinned?.name, "footer");
  assert.deepEqual(pinned?.children?.flatMap((box) => box.children ?? []).map((row) => row.id), ["less-settled"]);

  noteTask(state, {
    id: "c7",
    layout: {
      root: { kind: "pane", id: "pane-c7", tabs: [{ kind: "chat", chatId: "c7" }, { kind: "chat", chatId: "c8" }], active: { kind: "chat", chatId: "c8" } },
      focused: "pane-c7",
    },
    completedAt: "2026-01-03T00:00:00.000Z",
    createdAt: "2026-01-01T00:00:00.000Z",
    updatedAt: "2026-01-02T00:00:00.000Z",
  });
  const taskCtx = { ...ctx, app: { ...app, chatId: "c8" } } as EffectViewContext<{ cmd?: boolean }>;
  const taskItems = find(renderSidebar(taskCtx, { state } as unknown as Sidebar["Service"]) as unknown as Node, "scroller")?.items ?? [];
  assert.equal(taskItems.find((item) => item.id === "row-c7")?.selected, false);
  assert.equal(taskItems.find((item) => item.id === "child-c8")?.selected, true, "an open task selects its active child");
});

// Holding Cmd shows, in place of each of the first nine rows' agent, the
// number that opens it with Cmd: the same rows, in the same order, that
// Cmd+1 to Cmd+9 open.
test("while Cmd is held the first nine rows show the number Cmd opens them with", () => {
  const state = initialState();
  state.loaded = true;
  state.chats = Array.from({ length: 12 }, (_, i) => ({
    id: `c${i}`,
    workspaceId: "ws",
    agentId: "agent",
    title: `Chat ${i}`,
    sessionId: "s",
    createdAt: "2026-01-01T00:00:00.000Z",
    updatedAt: `2026-01-02T00:00:${String(i).padStart(2, "0")}.000Z`,
    completedAt: i % 3 ? undefined : "2026-01-03T00:00:00.000Z",
    archived: false,
    options: {},
    status: "idle",
  }));
  type Node = { type?: string; id?: string; text?: string; children?: Node[]; items?: Node[] };
  const numbers = (cmd: boolean): Record<string, string> => {
    const ctx = {
      app: { route: "chat" },
      state: { cmd },
      plugin: "sidebar",
      update() {},
      run() {},
    } as unknown as EffectViewContext<{
      cmd?: boolean;
    }>;
    const found: Record<string, string> = {};
    const walk = (node: Node | null | undefined, row?: string) => {
      if (!node) return;
      const id = node.id?.startsWith("row-") ? node.id.slice(4) : row;
      const text = String(node.text ?? node.children?.[0] ?? "");
      if (node.type === "text" && id && /^[1-9]$/.test(text)) found[id] = text;
      for (const child of [...(node.children ?? []), ...(node.items ?? [])]) walk(child, id);
    };
    walk(renderSidebar(ctx, { state, ensurePreview() {} } as unknown as Sidebar["Service"]) as unknown as Node);
    return found;
  };
  assert.deepEqual(numbers(false), {});
  const expected = Object.fromEntries(
    listedChats(state)
      .slice(0, 9)
      .map((chat, i) => [chat.id, String(i + 1)]),
  );
  assert.equal(Object.keys(expected).length, 9);
  assert.deepEqual(numbers(true), expected);
});

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.2.7latestNov 21, 2026>=5 <6100.9 KB4 permissionsListed
0.2.6Nov 16, 2026>=5 <6100.6 KB4 permissionsListed
0.2.5Nov 11, 2026>=5 <665.1 KB4 permissionsListed
0.2.4Nov 9, 2026>=5 <660.4 KB4 permissionsListed
0.2.3Oct 27, 2026>=2 <426.1 KB3 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.