Official
settings
Built-in settings 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/settings@0.2.2
Permissions in 0.2.2
Files
agents-view.test.ts2.4 KB
// The Agents section's process pool pickers: they show the host's defaults
// until the user picks, and save through the settings update.
import assert from "node:assert/strict";
import test from "node:test";
import * as Effect from "effect/Effect";
import type { EffectViewContext } from "convergence/effect";
import type { SettingsPage } from "./controller.ts";
import { renderAgents } from "./views/agents.ts";
type Node = { id?: string; value?: string; options?: { value: string; label: string }[]; onChange?: (e: { value: string }) => void; children?: unknown };
const find = (node: unknown, id: string, out: Node[] = []): Node[] => {
if (!node || typeof node !== "object") return out;
if (Array.isArray(node)) {
for (const child of node) find(child, id, out);
return out;
}
const value = node as Node;
if (value.id === id) out.push(value);
find(value.children, id, out);
return out;
};
function render(settings: Record<string, unknown>) {
const patches: unknown[] = [];
const actions = {
state: { agents: [], settings, showRegistry: false },
updateSettings: (patch: unknown) => Effect.sync(() => void patches.push(patch)),
} as unknown as SettingsPage["Service"];
const ctx = { run: (effect: Effect.Effect<unknown>) => Effect.runSync(effect), update() {} } as unknown as EffectViewContext<object>;
return { tree: renderAgents(ctx, actions), patches };
}
test("the process pickers show the host defaults when nothing is saved", () => {
const { tree } = render({});
const [limit] = find(tree, "agent-process-limit");
const [idle] = find(tree, "agent-idle-minutes");
assert.equal(limit?.value, "20");
assert.deepEqual(limit?.options?.map((o) => o.value), ["5", "10", "20", "40"]);
assert.equal(idle?.value, "10");
assert.deepEqual(idle?.options?.map((o) => o.value), ["5", "10", "30", "60"]);
});
test("a saved value outside the presets stays listed, and a pick is saved as a setting", () => {
const { tree, patches } = render({ agentProcessLimit: 12, agentIdleMinutes: 30 });
const [limit] = find(tree, "agent-process-limit");
assert.equal(limit?.value, "12");
assert.deepEqual(limit?.options?.map((o) => o.value), ["5", "10", "12", "20", "40"]);
limit?.onChange?.({ value: "40" });
find(tree, "agent-idle-minutes")[0]?.onChange?.({ value: "5" });
assert.deepEqual(patches, [{ agentProcessLimit: 40 }, { agentIdleMinutes: 5 }]);
});
No comments yet.