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

Permissions in 0.2.7

  • 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.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.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.ts6.4 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, 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 { Upkeep } from "./upkeep.ts";
import { ArchivedChats } from "./archived.ts";
import { renderUpdatesButton } from "./views/upkeep.tsx";

// The sidebar draws, left of Options, every view a plugin publishes under a
// key starting with `sidebarButton.`.
const SIDEBAR_BUTTON = "sidebarButton.updates";
// Where versions before that published the button, as a footer row. The app
// keeps the shared state across restarts, so a settings plugin replaced while
// the app was closed left this key behind; it is cleared at the start.
const LEGACY_SIDEBAR_ITEM = "sidebarItem.updates";

const program = Effect.gen(function* () {
  const page = yield* SettingsPage;
  const onboarding = yield* Onboarding;
  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"] }));
  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 button in the sidebar's footer.
  const upkeep = yield* Upkeep;
  const button = yield* views.add("sidebar-item", { slot: "sidebar-item", render: (ctx) => renderUpdatesButton(ctx, upkeep), on: ["app_state"] });
  // Settings > Updates draws the same jobs.
  upkeep.views.push(button, ...page.views);
  // The sidebar keeps the button's room while the key holds the view, so it
  // holds it only while something is behind.
  const app = yield* App;
  yield* app.update({ shared: { [LEGACY_SIDEBAR_ITEM]: null } });
  let published: number | null = null;
  const publish = (any: boolean) => {
    const next = any ? button.id : null;
    if (next === published) return;
    published = next;
    Effect.runFork(app.update({ shared: { [SIDEBAR_BUTTON]: next } }));
  };
  yield* Effect.acquireRelease(Effect.sync(() => upkeep.watchers.push(publish)), () =>
    Effect.suspend(() => {
      upkeep.watchers.splice(upkeep.watchers.indexOf(publish), 1);
      return published === null ? Effect.void : app.update({ shared: { [SIDEBAR_BUTTON]: 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("inputs_changed", (event) => upkeep.inputsChanged(event.snapshot));
  yield* upkeep.followServices().pipe(
    Effect.ignore({ log: "Error", message: "settings: following the market and chat plugins stopped" }),
    Effect.forkScoped({ startImmediately: true }),
  );
  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* onboarding.initialize().pipe(Effect.forkScoped({ startImmediately: true }));
});

export default runPlugin(
  Layer.mergeAll(SettingsPage.layer, Onboarding.layer).pipe(
    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.