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.6
Permissions in 0.2.6
Files
archived.ts3.5 KB
// Settings > Archived Chats: every archived chat, with Restore and Delete.
// The list is read each time the section opens and kept current by the
// host's chat events in between. Delete asks first, since a deleted chat
// cannot come back.
import * as Context from "effect/Context";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import { Host, Notify } from "divergence/effect";
import type { Chat, ViewHandle } from "divergence";
const makeArchivedChats = Effect.fn("ArchivedChats.make")(function* () {
const host = yield* Host;
const notify = yield* Notify;
// `chats` is null until the section is first opened; `error` says why the
// last read failed; `deleting` is the chat whose Delete waits for the
// user's answer.
const state = { chats: null as readonly Chat[] | null, error: null as string | null, deleting: null as Chat | null };
const views: ViewHandle[] = [];
const redraw = () => {
for (const view of views) view.update();
};
const load = Effect.fn("ArchivedChats.load")(function* () {
yield* host.call("host/chats.list", {}).pipe(
Effect.tap(({ chats }) =>
Effect.sync(() => {
state.chats = chats.filter((chat) => chat.archived);
state.error = null;
redraw();
}),
),
// The section says why, with Try again.
Effect.catch((error) =>
Effect.sync(() => {
state.error = error.message;
redraw();
}),
),
);
});
// A chat archived or brought back anywhere joins or leaves the list.
const chatChanged = (chat: Chat): Effect.Effect<void> =>
Effect.sync(() => {
if (!state.chats) return;
const rest = state.chats.filter((c) => c.id !== chat.id);
if (!chat.archived && rest.length === state.chats.length) return;
state.chats = chat.archived ? [chat, ...rest] : rest;
if (!chat.archived && state.deleting?.id === chat.id) state.deleting = null;
redraw();
});
const chatRemoved = (chatId: string): Effect.Effect<void> =>
Effect.sync(() => {
if (!state.chats) return;
state.chats = state.chats.filter((c) => c.id !== chatId);
if (state.deleting?.id === chatId) state.deleting = null;
redraw();
});
// A restored chat comes back to the sidebar as a row of its own.
const restore = Effect.fn("ArchivedChats.restore")(function* (chat: Chat) {
yield* host.call("host/chats.update", { chatId: chat.id, archived: false }).pipe(
Effect.flatMap(chatChanged),
Effect.catch((error) => notify.error(`Could not restore “${chat.title}”: ${error.message}`)),
);
});
// Delete asks first (`chat`), and the answer closes the question (`null`).
const askDelete = (chat: Chat | null): Effect.Effect<void> =>
Effect.sync(() => {
state.deleting = chat;
redraw();
});
const confirmDelete = Effect.fn("ArchivedChats.confirmDelete")(function* () {
const chat = state.deleting;
if (!chat) return;
yield* askDelete(null);
yield* host.call("host/chats.delete", { chatId: chat.id }).pipe(
Effect.andThen(chatRemoved(chat.id)),
Effect.catch((error) => notify.error(`Could not delete “${chat.title}”: ${error.message}`)),
);
});
return { state, views, load, chatChanged, chatRemoved, restore, askDelete, confirmDelete };
});
export class ArchivedChats extends Context.Service<ArchivedChats, Effect.Success<ReturnType<typeof makeArchivedChats>>>()(
"settings/ArchivedChats",
) {
static readonly layer = Layer.effect(ArchivedChats, makeArchivedChats());
}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.