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 divergence/settings@0.2.3
Permissions in 0.2.3
Files
main.ts4.7 KB
// Register the settings page, then the divergence/settings service, then
// the host events that change what the page shows. The page loads the first
// time it is opened, not at activation.
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as Stream from "effect/Stream";
import { App, Commands, Events, Services, Settings, Views, runPlugin } from "divergence/effect";
import type { HostEvents } from "divergence";
import { SettingsPage } from "./controller.ts";
import { Settings as SettingsService } from "./contract.ts";
import { renderSettings } from "./views/page.ts";
import { Onboarding } from "./onboarding.ts";
import { renderOnboarding, renderOnboardingReturn } from "./views/onboarding.ts";
import { ChatImport } from "./chat-import.ts";
import { makeUpkeep } from "./upkeep.ts";
import { renderUpdatesRow } from "./views/upkeep.ts";
// The sidebar draws, above Settings, every view a plugin publishes under a
// key starting with `sidebarItem.`.
const SIDEBAR_ITEM = "sidebarItem.updates";
const program = Effect.gen(function* () {
const page = yield* SettingsPage;
const onboarding = yield* Onboarding;
const imports = yield* ChatImport;
const views = yield* Views;
page.views.push(
yield* views.slot("center", (ctx) => renderSettings(ctx, page), {
on: [
"app_state",
"agents_changed",
"plugins_changed",
"updates_changed",
"keybindings_changed",
"plugin_settings_changed",
],
}),
);
onboarding.views.push(yield* views.slot("center", (ctx) => renderOnboarding(ctx, onboarding), { on: ["app_state"] }));
onboarding.views.push(
yield* views.slot("title", (ctx) => renderOnboardingReturn(ctx, onboarding), { on: ["app_state"] }),
);
imports.views.push(...page.views, ...onboarding.views);
const commands = yield* Commands;
yield* commands.register("settings.onboarding", onboarding.restart());
const services = yield* Services;
yield* services.provide(SettingsService, {
showShortcuts: ({ query }) => page.showShortcuts(query),
});
const events = yield* Events;
// Every listener fires its effect as its own fork, as the original's
// async listeners did; a failure is logged, not propagated.
const follow = <E extends keyof HostEvents, R>(
name: E,
run: (event: HostEvents[E]) => Effect.Effect<void, unknown, R>,
) =>
events.stream(name).pipe(
Stream.runForEach((event) => Effect.forkScoped(run(event).pipe(Effect.ignore), { startImmediately: true })),
Effect.ignore,
Effect.forkScoped({ startImmediately: true }),
);
// The update row in the sidebar's footer.
const upkeep = yield* makeUpkeep();
const row = yield* views.slot("sidebar-item", (ctx) => renderUpdatesRow(ctx, upkeep), { on: ["app_state"] });
upkeep.views.push(row);
const app = yield* App;
yield* Effect.acquireRelease(app.update({ shared: { [SIDEBAR_ITEM]: row.id } }), () =>
app.update({ shared: { [SIDEBAR_ITEM]: null } }),
);
yield* follow("agents_changed", () => upkeep.agentsChanged());
yield* follow("updates_changed", () => upkeep.loadUpdates());
yield* follow("chat_changed", (event) => upkeep.chatChanged(event.chat));
yield* follow("chat_removed", (event) => upkeep.chatRemoved(event.chatId));
yield* upkeep.load().pipe(Effect.forkScoped({ startImmediately: true }));
yield* follow("keybindings_changed", () => page.loadKeys());
yield* follow("plugin_settings_changed", (event) =>
page.state.sections[event.plugin] ? page.loadSection(event.plugin) : Effect.void,
);
yield* follow("agents_changed", () => page.load());
yield* follow("plugins_changed", () => page.load());
// A plugin enabled or turned off, or a grant given or taken back.
yield* follow("access_changed", () => page.load());
yield* follow("workspaces_changed", () => page.load());
yield* follow("updates_changed", () => page.refreshUpdates());
yield* follow("agents_changed", () => onboarding.refresh());
yield* follow("workspaces_changed", () => onboarding.refresh());
yield* follow("plugins_changed", () => onboarding.refresh());
yield* follow("access_changed", () => onboarding.refresh());
yield* follow("agents_changed", () => imports.refresh());
yield* follow("workspaces_changed", () => imports.refresh());
const settings = yield* Settings;
yield* settings.changes.pipe(
Stream.runForEach(() => imports.refresh()),
Effect.forkScoped({ startImmediately: true }),
);
yield* imports.refresh().pipe(Effect.forkScoped({ startImmediately: true }));
yield* onboarding.initialize().pipe(Effect.forkScoped({ startImmediately: true }));
});
export const activate = runPlugin(
Layer.mergeAll(SettingsPage.layer, Onboarding.layer).pipe(Layer.provideMerge(ChatImport.layer)),
program,
);Versions
| Version | Published | Plugin API | Size | Permissions | Status |
|---|---|---|---|---|---|
| 0.2.8latest | Nov 21, 2026 | >=5 <6 | 68.5 KB | 7 permissions | Listed |
| 0.2.7 | Nov 18, 2026 | >=5 <6 | 68 KB | 7 permissions | Listed |
| 0.2.6 | Nov 16, 2026 | >=5 <6 | 66.3 KB | 7 permissions | Listed |
| 0.2.5 | Nov 11, 2026 | >=5 <6 | 63.6 KB | 7 permissions | Listed |
| 0.2.4 | Nov 9, 2026 | >=5 <6 | 61.6 KB | 7 permissions | Listed |
| 0.2.3 | Oct 27, 2026 | >=2 <4 | 46.8 KB | 7 permissions | Listed |
No comments yet.