Official
palette
Built-in command palette (⌘⇧P) and chat search (⌘P).
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/palette@0.2.5
Permissions in 0.2.5
Files
main.ts2.7 KB
// Register the palette synchronously, then restore its recent-command ordering in the activation scope.
// Catalog loading and handlers use the same state layer as the pure overlay renderer.
import * as Effect from "effect/Effect";
import * as Stream from "effect/Stream";
import { Commands, Events, Views, runPlugin } from "divergence/effect";
import { controller } from "./controller.ts";
import { PaletteState } from "./state.ts";
import { render } from "./view.ts";
const program = Effect.gen(function* () {
const palette = yield* controller();
const views = yield* Views;
const commands = yield* Commands;
palette.state.view = yield* views.add("title", { slot: "title", render: (ctx) => render(palette, ctx), order: 1000, on: ["app_state"] });
yield* commands.register("palette.commands", palette.openCommands());
yield* commands.register("palette.chats", palette.openChats());
yield* Effect.forkScoped(palette.loadRecent(), { startImmediately: true });
const events = yield* Events;
// Subscribed before the first read, so no change between the two is lost.
yield* events.stream("chat_changed").pipe(
Stream.runForEach((event) => Effect.sync(() => palette.chats.changed(event.chat))),
Effect.forkScoped({ startImmediately: true }),
);
yield* events.stream("chat_removed").pipe(
Stream.runForEach((event) => Effect.sync(() => palette.chats.removed(event.chatId))),
Effect.forkScoped({ startImmediately: true }),
);
yield* events.stream("task_changed").pipe(
Stream.runForEach((event) => Effect.sync(() => palette.chats.taskChanged(event.task))),
Effect.forkScoped({ startImmediately: true }),
);
yield* events.stream("task_removed").pipe(
Stream.runForEach((event) => Effect.sync(() => palette.chats.taskRemoved(event.taskId))),
Effect.forkScoped({ startImmediately: true }),
);
yield* events.stream("workspaces_changed").pipe(
Stream.runForEach(() =>
palette.chats.load().pipe(Effect.ignore({ log: "Warn", message: "The palette could not reload its chats" })),
),
Effect.ignore({ log: "Warn", message: "The palette stopped following workspace changes" }),
Effect.forkScoped({ startImmediately: true }),
);
yield* palette.chats
.load()
.pipe(
Effect.ignore({ log: "Warn", message: "The palette could not load its chats" }),
Effect.forkScoped({ startImmediately: true }),
);
yield* events.stream("plugins_changed").pipe(
Stream.runForEach(() =>
palette.refresh().pipe(Effect.ignore({ log: "Warn", message: "The palette could not reload its commands" })),
),
Effect.ignore({ log: "Warn", message: "The palette stopped following plugin changes" }),
Effect.forkScoped({ startImmediately: true }),
);
});
export default runPlugin(PaletteState.layer, program);
No comments yet.