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

Permissions in 0.2.6

  • 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.Open the chat search from the search button, and 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 sidebar, and its top controls in the title strip after the sidebar toggleSlots: lefttitle

Files

archive.test.ts12.5 KB
// Archiving a row and bringing it back with the notice's Undo, against the
// fake host in testing.ts.
import assert from "node:assert/strict";
import { afterEach, mock, test } from "node:test";
import activate from "./main.ts";
import { COLLAPSED_KEY } from "./sections.ts";
import { chatTab, fakeHost, type Pane } from "./testing.ts";

afterEach(() => mock.timers.reset());

const day = (n: number) => `2026-10-0${n}T00:00:00.000Z`;

test("an archived chat is offered back, and Undo puts it back where it was", async () => {
  const fake = fakeHost([
    { id: "c1", title: "First", at: day(3) },
    { id: "c2", title: "Second", at: day(2) },
    { id: "c3", title: "Third", at: day(1) },
  ]);
  const dispose = activate(fake.api);
  try {
    await fake.settle();
    assert.deepEqual(fake.list(), ["heading-open", "row-c1", "row-c2", "row-c3"]);
    assert.equal(fake.node("undo-archive"), undefined, "no notice before anything is archived");
    fake.action("row-c2", "Archive");
    await fake.settle();
    assert.deepEqual(fake.list(), ["heading-open", "row-c1", "row-c3"]);
    assert.equal(fake.toast()?.message, "Archived “Second”");
    await fake.clickToast();
    await fake.settle();
    assert.deepEqual(fake.calls.at(-1), { method: "host/chats.update", params: { chatId: "c2", archived: false } });
    // Coming back made it the newest chat; it takes its old place all the same.
    assert.deepEqual(fake.list(), ["heading-open", "row-c1", "row-c2", "row-c3"]);
    assert.equal(fake.toast(), undefined, "Undo takes the toast away");
  } finally {
    await dispose();
  }
});

test("a checked-off row comes back checked off, in its place in Complete", async () => {
  const fake = fakeHost([
    { id: "c1", title: "Open", at: day(3) },
    { id: "c2", title: "Done later", at: day(2), done: day(5) },
    { id: "c3", title: "Done first", at: day(1), done: day(4) },
  ]);
  // Complete unfolded, so its rows show.
  fake.storage.set(COLLAPSED_KEY, []);
  const dispose = activate(fake.api);
  try {
    await fake.settle();
    assert.deepEqual(fake.list(), ["heading-open", "row-c1", "heading-settled", "row-c2", "row-c3"]);
    // A checked-off row has no hover actions; its menu archives it.
    fake.click("row-c3", "onSecondaryClick");
    await fake.settle();
    (fake.node("row-menu")?.onChange as (e: { value: string }) => void)({ value: "row-menu-archive" });
    await fake.settle();
    await fake.clickToast();
    await fake.settle();
    assert.deepEqual(fake.calls.at(-1), { method: "host/chats.update", params: { chatId: "c3", archived: false, completed: true } });
    assert.deepEqual(fake.list(), ["heading-open", "row-c1", "heading-settled", "row-c2", "row-c3"]);
  } finally {
    await dispose();
  }
});

test("a pinned chat comes back pinned", async () => {
  const fake = fakeHost([
    { id: "c1", title: "First", at: day(3) },
    { id: "c2", title: "Second", at: day(2) },
  ]);
  const dispose = activate(fake.api);
  try {
    await fake.settle();
    fake.action("row-c2", "Pin");
    await fake.settle();
    assert.deepEqual(fake.list(), ["heading-pinned", "row-c2", "heading-open", "row-c1"]);
    fake.action("row-c2", "Archive");
    await fake.settle();
    assert.deepEqual(fake.list(), ["heading-open", "row-c1"], "archiving forgets the pin");
    await fake.clickToast();
    await fake.settle();
    assert.deepEqual(fake.list(), ["heading-pinned", "row-c2", "heading-open", "row-c1"]);
  } finally {
    await dispose();
  }
});

test("a task row comes back whole, named as it was", async () => {
  const fake = fakeHost(
    [
      { id: "a", title: "Plan", at: day(3) },
      { id: "b", title: "Build", at: day(2) },
      { id: "c", title: "Other", at: day(1) },
    ],
    [{ id: "t-ab", chats: ["a", "b"], title: "Release" }],
  );
  const dispose = activate(fake.api);
  try {
    await fake.settle();
    assert.deepEqual(fake.list(), ["heading-open", "row-a", "row-c"]);
    fake.action("row-a", "Archive");
    await fake.settle();
    assert.deepEqual(fake.list(), ["heading-open", "row-c"]);
    assert.equal(fake.toast()?.message, "Archived “Release”");
    await fake.clickToast();
    await fake.settle();
    const task = [...fake.tasks.values()].find((t) => (t.layout.root as Pane).tabs.length === 2)!;
    assert.deepEqual((task.layout.root as Pane).tabs, [chatTab("a"), chatTab("b")]);
    assert.equal(task.title, "Release");
    assert.deepEqual(fake.list(), ["heading-open", "row-a", "row-c"]);
    assert.equal(fake.node("row-a")?.label, "Release");
  } finally {
    await dispose();
  }
});

test("a chat archived out of a task goes back to its tab's place there", async () => {
  const fake = fakeHost(
    [
      { id: "a", title: "Plan", at: day(3) },
      { id: "b", title: "Build", at: day(2) },
      { id: "c", title: "Ship", at: day(1) },
    ],
    [{ id: "t-abc", chats: ["a", "b", "c"], title: "Release" }],
  );
  // With the task on screen its chats are listed under its row.
  fake.update({ chatId: "a", workspaceId: "w1" });
  const dispose = activate(fake.api);
  try {
    await fake.settle();
    assert.deepEqual(fake.list(), ["heading-open", "row-a", "child-a", "child-b", "child-c"]);
    fake.action("child-b", "Archive");
    await fake.settle();
    assert.deepEqual(fake.list(), ["heading-open", "row-a", "child-a", "child-c"]);
    assert.equal(fake.toast()?.message, "Archived “Build”");
    await fake.clickToast();
    await fake.settle();
    assert.deepEqual(fake.calls.at(-1), {
      method: "host/layouts.place",
      params: { tab: chatTab("b"), target: { kind: "strip", paneId: "pane-t-abc", index: 1 }, onScreen: "t-abc" },
    });
    assert.deepEqual((fake.tasks.get("t-abc")!.layout.root as Pane).tabs, [chatTab("a"), chatTab("b"), chatTab("c")]);
    assert.deepEqual(fake.list(), ["heading-open", "row-a", "child-a", "child-b", "child-c"]);
  } finally {
    await dispose();
  }
});

/// A chat left its task only by closing its tab, which sent it to Complete, or by a drag into the
/// list; each chat listed under a task offers it in its menu, and only there.
test("a chat listed under its task separates into a row of its own from its menu", async () => {
  const fake = fakeHost(
    [
      { id: "a", title: "Plan", at: day(3) },
      { id: "b", title: "Build", at: day(2) },
      { id: "c", title: "Ship", at: day(1) },
    ],
    [{ id: "t-abc", chats: ["a", "b", "c"], title: "Release" }],
  );
  fake.update({ chatId: "a", workspaceId: "w1" });
  const dispose = activate(fake.api);
  try {
    await fake.settle();
    const actions = fake.node("child-b")?.actions as { tooltip: string }[];
    assert.deepEqual(actions.map((a) => a.tooltip), ["Rename", "Archive"], "separating is not a hover action");
    fake.click("child-b", "onSecondaryClick");
    await fake.settle();
    (fake.node("row-menu")?.onChange as (e: { value: string }) => void)({ value: "row-menu-separate" });
    await fake.settle();
    assert.deepEqual(fake.calls.at(-1), {
      method: "host/layouts.place",
      params: { tab: chatTab("b"), target: { kind: "alone" }, onScreen: "t-abc" },
    });
    assert.deepEqual(fake.list(), ["heading-open", "row-a", "child-a", "child-c", "row-b"]);
  } finally {
    await dispose();
  }
});

/// A chat's tab carried from the title strip is a chat like a child row: let go anywhere on the
/// sidebar it leaves its task, the search field and New chat at the top included, since that is
/// where a tab carried left out of the title strip comes in. The pane it came from never tells the
/// sidebar the drag ended, so the sidebar's part of it ends when the pointer leaves the sidebar.
test("a chat's tab dragged anywhere onto the sidebar becomes a row of its own", async () => {
  const fake = fakeHost(
    [
      { id: "a", title: "Plan", at: day(3) },
      { id: "b", title: "Build", at: day(2) },
      { id: "c", title: "Solo", at: day(1) },
    ],
    [{ id: "t-ab", chats: ["a", "b"], title: "Release" }],
  );
  fake.update({ chatId: "a", workspaceId: "w1" });
  const dispose = activate(fake.api);
  try {
    await fake.settle();
    const carried = (chatId: string, zone: string | null) => ({ type: "divergence/chat", data: { chatId }, zone });
    const target = fake.node("sidebar");
    for (const id of ["chat-search-open", "new-chat", "chat-list"]) assert.ok(JSON.stringify(target).includes(`"id":"${id}"`), `the drop target holds ${id}`);
    fake.listDrop().onOver(carried("c", "inside"));
    fake.listDrop().onOver(carried("c", null));
    await fake.settle();
    fake.listDrop().onOver(carried("a", "inside"));
    fake.listDrop().onDrop(carried("a", "inside"));
    await fake.settle();
    assert.deepEqual(fake.calls.at(-1), {
      method: "host/layouts.place",
      params: { tab: chatTab("a"), target: { kind: "alone" }, onScreen: "t-ab" },
    });
    assert.deepEqual(fake.list(), ["heading-open", "row-a", "row-b", "row-c"]);
  } finally {
    await dispose();
  }
});

/// Checking off belongs to a task's row, so a chat listed under it checks off by leaving it for
/// Complete, as closing its tab does. A draft under the task has nothing to check off.
test("a started chat listed under its task checks off on its own into Complete", async () => {
  const fake = fakeHost(
    [
      { id: "a", title: "Plan", at: day(3) },
      { id: "b", title: "Build", at: day(2) },
      { id: "c", title: "Ship", at: day(1) },
    ],
    [{ id: "t-abc", chats: ["a", "b", "c"], title: "Release" }],
  );
  fake.update({ chatId: "a", workspaceId: "w1" });
  // Complete unfolded, so the chat checked off shows in it.
  fake.storage.set(COLLAPSED_KEY, []);
  const dispose = activate(fake.api);
  try {
    await fake.settle();
    fake.click("glyph-child-b");
    await fake.settle();
    assert.deepEqual(fake.calls.at(-1), { method: "host/layouts.close_tab", params: { tab: chatTab("b") } });
    assert.deepEqual(fake.list(), ["heading-open", "row-a", "child-a", "child-c", "heading-settled", "row-b"]);
  } finally {
    await dispose();
  }
});

test("a toast combines archives and dismissal leaves them archived", async () => {
  const fake = fakeHost([
    { id: "c1", title: "First", at: day(3) },
    { id: "c2", title: "Second", at: day(2) },
    { id: "c3", title: "Third", at: day(1) },
  ]);
  const dispose = activate(fake.api);
  try {
    await fake.settle();
    fake.action("row-c2", "Archive");
    await fake.settle();
    assert.equal(fake.node("undo-archive"), undefined, "the footer contains no archive notice");
    fake.action("row-c3", "Archive");
    await fake.settle();
    assert.equal(fake.toast()?.message, "Archived 2 chats");
    fake.dismissToast();
    await fake.settle();
    assert.deepEqual(fake.list(), ["heading-open", "row-c1"]);
    fake.action("row-c1", "Archive");
    await fake.settle();
    assert.equal(fake.toast()?.message, "Archived “First”");
  } finally {
    await dispose();
  }
});

test("Undo brings back every row the notice offers, and says which could not come back", async () => {
  const fake = fakeHost([
    { id: "c1", title: "First", at: day(3) },
    { id: "c2", title: "Second", at: day(2) },
  ]);
  const dispose = activate(fake.api);
  try {
    await fake.settle();
    fake.action("row-c1", "Archive");
    await fake.settle();
    fake.action("row-c2", "Archive");
    await fake.settle();
    fake.fail("host/chats.update", "the store is locked");
    await fake.clickToast();
    await fake.settle();
    assert.deepEqual(fake.notices, [
      "Could not restore “First”: the store is locked",
      "Could not restore “Second”: the store is locked",
    ]);
    assert.deepEqual(fake.list(), []);
  } finally {
    await dispose();
  }
});

test("an older runtime archives without showing a footer notice", async () => {
  const fake = fakeHost([{ id: "c1", title: "First", at: day(1) }]);
  delete fake.api.toast;
  delete fake.api.dismissToast;
  const dispose = activate(fake.api);
  try {
    await fake.settle();
    fake.action("row-c1", "Archive");
    await fake.settle();
    assert.deepEqual(fake.notices, []);
    assert.equal(fake.node("undo-archive"), undefined);
    assert.deepEqual(fake.list(), []);
  } finally {
    await dispose();
  }
});

test("a chat that could not be archived is not offered back", async () => {
  const fake = fakeHost([{ id: "c1", title: "First", at: day(3) }]);
  const dispose = activate(fake.api);
  try {
    await fake.settle();
    fake.fail("host/chats.update", "the store is locked");
    fake.action("row-c1", "Archive");
    await fake.settle();
    assert.deepEqual(fake.notices, ["Could not archive the chat: the store is locked"]);
    assert.equal(fake.node("undo-archive"), undefined);
    assert.deepEqual(fake.list(), ["heading-open", "row-c1"]);
  } finally {
    await dispose();
  }
});

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.