Official
sidebar
Built-in sidebar 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/sidebar@0.2.7
Permissions in 0.2.7
Files
reopen.ts1.6 KB
// Reopen Closed Chat, which Cmd+Shift+T runs for a chat Cmd+W closed: the chat
// Close Chat put away comes back as it was and shows. A checked-off chat opens
// again; an archived draft or queued chat comes out of the archive into its old
// place (and the queue), leaving the notice that offered it back.
import * as Effect from "effect/Effect";
import { App } from "divergence/effect";
import type { Chat } from "divergence";
import type { ArchivedRow, SidebarState } from "./sections.ts";
import { completedOf } from "./sections.ts";
export const makeReopen = Effect.fn("Sidebar.reopening")(function* (
state: SidebarState,
bringBack: (row: ArchivedRow) => Effect.Effect<Chat | null>,
toggleCompleted: (chat: Chat) => Effect.Effect<void>,
) {
const app = yield* App;
// `chatId` names the chat to bring back; without one, the last chat Close Chat put away.
// A chat Close Chat did not change (it was in Complete already) only shows again.
const reopenChat = Effect.fn("Sidebar.reopenChat")(function* (chatId?: string) {
const at = chatId === undefined ? 0 : state.closed.findIndex((closed) => closed.chatId === chatId);
const closed = at < 0 ? undefined : state.closed[at];
if (closed) state.closed = state.closed.filter((other) => other !== closed);
const listed = state.chats.find((chat) => chat.id === (closed?.chatId ?? chatId));
const chat = closed?.row ? yield* bringBack(closed.row) : listed;
if (!chat) return;
if (closed && !closed.row && completedOf(state, chat)) yield* toggleCompleted(chat);
yield* app.select(chat.id, chat.workspaceId);
});
return { reopenChat };
});
No comments yet.