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 convergence/sidebar@0.2.2
Permissions in 0.2.2
Files
items.test.ts1.9 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 "convergence";
import type { EffectViewContext } from "convergence/effect";
import type { Sidebar } from "./controller.ts";
import { initialState } from "./sections.ts";
import { renderSidebar, sidebarItems } from "./views.ts";
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<{
queueDraft?: 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"]);
});
No comments yet.