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.7
Permissions in 0.2.7
Files
chat-drag.test.ts4 KB
// Dragging chats between the sections of the list, against the fake host in
// testing.ts: what the rows, headings and dock say decides where the chat
// goes, and a release does what the list showed.
import assert from "node:assert/strict";
import { afterEach, mock, test } from "node:test";
import activate from "./main.ts";
import { fakeHost } from "./testing.ts";
afterEach(() => mock.timers.reset());
const day = (n: number) => `2026-10-0${n}T00:00:00.000Z`;
const CHAT = "divergence/chat";
type Target = { onOver: (e: unknown) => void; onDrop: (e: unknown) => void; zones?: string; reorder?: string };
// Two open chats and a checked-off one, and a task of two chats.
function setup() {
const fake = fakeHost(
[
{ id: "c1", title: "First", at: day(5) },
{ id: "c2", title: "Second", at: day(4) },
{ id: "d1", title: "Done", at: day(3), done: day(6) },
{ id: "t1", title: "Task one", at: day(2) },
{ id: "t2", title: "Task two", at: day(1) },
],
[{ id: "task", chats: ["t1", "t2"], title: "Task" }],
);
const target = (id: string) => fake.node(id)?.drop as Target;
const over = (id: string, chatId: string, zone: string | null) => target(id).onOver({ type: CHAT, data: { chatId }, zone });
const drop = (id: string, chatId: string, zone: string) => target(id).onDrop({ type: CHAT, data: { chatId }, zone });
const updates = () => fake.calls.filter((c) => c.method === "host/chats.update").map((c) => c.params);
const places = () => fake.calls.filter((c) => c.method === "host/layouts.place").map((c) => c.params);
return { fake, target, over, drop, updates, places };
}
test("a chat carried over a heading goes to the top of that section, and the drop checks it off there", async () => {
const { fake, over, drop, updates } = setup();
const dispose = activate(fake.api);
try {
await fake.settle();
over("row-c2", "c2", "into");
await fake.settle();
// A heading has one zone; it still moves the chat.
over("heading-settled", "c2", "into");
await fake.settle();
const list = fake.list();
assert.ok(list.indexOf("row-c2") === list.indexOf("heading-settled") + 1, "c2 heads Complete");
drop("heading-settled", "c2", "into");
await fake.settle();
assert.deepEqual(updates(), [{ chatId: "c2", completed: true }]);
} finally {
await dispose();
}
});
test("a carried row moves by halves and never joins the row it passes", async () => {
const { fake, target, over, drop, places } = setup();
const dispose = activate(fake.api);
try {
await fake.settle();
assert.equal(target("row-c1").zones, "bands", "at rest a row's middle takes a chat that joins");
over("row-c2", "c2", "before");
await fake.settle();
assert.equal(target("row-c1").reorder, "vertical", "while a row is carried, rows have two halves");
over("row-c1", "c2", "before");
await fake.settle();
assert.notEqual(fake.node("row-c1")?.background, "accent", "no row lights up to join");
// Let go over the middle of its own gap, as an older kernel reports it: it lands where the list shows it.
drop("row-c2", "c2", "into");
await fake.settle();
assert.deepEqual(places(), []);
const list = fake.list();
assert.ok(list.indexOf("row-c2") < list.indexOf("row-c1"), "c2 landed above c1");
} finally {
await dispose();
}
});
test("a chat of a task of several joins the row whose middle it is let go on, and the mark follows the pointer", async () => {
const { fake, over, drop, places } = setup();
const dispose = activate(fake.api);
try {
await fake.settle();
// Onto c1's middle, then off c2, which it never reached: c1 keeps its mark.
over("row-c1", "t2", "into");
over("row-c2", "t2", null);
await fake.settle();
assert.equal(fake.node("row-c1")?.background, "accent");
drop("row-c1", "t2", "into");
await fake.settle();
assert.deepEqual(
places().map((p) => (p as { target: unknown }).target),
[{ kind: "join", taskId: "t-c1" }],
);
} finally {
await dispose();
}
});
No comments yet.