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

Permissions in 0.2.4

  • Manage plugins plugins.manageOfficial onlyReloads and enables plugins. Only official plugins can have it.List, enable, disable and reload plugins, install updates, and quit to finish an update
  • Change app settings settings.writeHighChanges the app settings.Change the settings and the theme
  • Manage agents agents.manageHighEnables, disables and signs in agents, and changes their settings.Turn agents on and off, sign in to them and update them
  • Control chats chats.controlHighCreates chats, sends prompts and cancels runs.Import an agent's own sessions as chats, add project folders, and open the first chat and the changes saved in the first-run guide
  • Read chats chats.readMediumReads your transcripts and chat lists.List the workspaces an agent's sessions can be imported into, and hold an agent's update until its chats stop running
  • Read app settings settings.readLowReads the app settings.Show the settings, and the tools and rules of every plugin
  • Show panels ui.slotsAlways grantedShows views in the listed parts of the window.Draw settings, its list of sections in the sidebar's place, and the first-run guideSlots: centerleft

Files

main.ts5.9 KB
// Register the settings page, then the divergence/settings service, then
// the host events that change what the page shows. The page loads at
// activation, so Settings opens on its section at once.
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 { APP_SECTIONS } from "./model.ts";
import { Settings as SettingsService } from "./contract.ts";
import { renderSettings, renderSettingsSidebar } from "./views/page.tsx";
import { Onboarding } from "./onboarding.ts";
import { renderOnboarding } from "./views/onboarding.tsx";
import { ChatImport } from "./chat-import.ts";
import { Upkeep } from "./upkeep.ts";
import { ArchivedChats } from "./archived.ts";
import { renderUpdatesRow } from "./views/upkeep.tsx";

// 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.add("center", { slot: "center", render: (ctx) => renderSettings(ctx, page), on: [
        "app_state",
        "agents_changed",
        "plugins_changed",
        "updates_changed",
        "keybindings_changed",
        "plugin_settings_changed",
      ] }),
  );
  // Its list of sections, in the sidebar's place while Settings is open.
  page.views.push(
    yield* views.add("left", { slot: "left", render: (ctx) => renderSettingsSidebar(ctx, page), on: ["app_state", "plugins_changed", "updates_changed"] }),
  );
  onboarding.views.push(yield* views.add("center-2", { slot: "center", render: (ctx) => renderOnboarding(ctx, onboarding), on: ["app_state"] }));
  imports.views.push(...page.views, ...onboarding.views);
  const archived = yield* ArchivedChats;
  archived.views.push(...page.views);
  const commands = yield* Commands;
  yield* commands.register("settings.onboarding", onboarding.restart());
  for (const section of APP_SECTIONS) yield* commands.register(`settings.${section.id}`, page.showSection(section.id));
  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 with its cause, not
  // propagated (a bare `Effect.ignore` would drop it without a word).
  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({ log: "Error", message: `settings: handling ${name} failed` })), {
          startImmediately: true,
        }),
      ),
      Effect.ignore({ log: "Error", message: `settings: the ${name} events stopped` }),
      Effect.forkScoped({ startImmediately: true }),
    );
  // The update row in the sidebar's footer.
  const upkeep = yield* Upkeep;
  const row = yield* views.add("sidebar-item", { slot: "sidebar-item", render: (ctx) => renderUpdatesRow(ctx, upkeep), on: ["app_state"] });
  // Settings > Updates draws the same jobs.
  upkeep.views.push(row, ...page.views);
  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* follow("chat_changed", (event) => archived.chatChanged(event.chat));
  yield* follow("chat_removed", (event) => archived.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* page.load().pipe(
    Effect.ignore({ log: "Error", message: "settings: loading the page failed" }),
    Effect.forkScoped({ startImmediately: true }),
  );
  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 default runPlugin(
  Layer.mergeAll(SettingsPage.layer, Onboarding.layer).pipe(
    Layer.provideMerge(ChatImport.layer),
    Layer.provideMerge(Upkeep.layer),
    Layer.provideMerge(ArchivedChats.layer),
  ),
  program,
);

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.2.8latestNov 21, 2026>=5 <668.5 KB7 permissionsListed
0.2.7Nov 18, 2026>=5 <668 KB7 permissionsListed
0.2.6Nov 16, 2026>=5 <666.3 KB7 permissionsListed
0.2.5Nov 11, 2026>=5 <663.6 KB7 permissionsListed
0.2.4Nov 9, 2026>=5 <661.6 KB7 permissionsListed
0.2.3Oct 27, 2026>=2 <446.8 KB7 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.