Official
tabs
The tabbed detail pane beside the chat: files to edit and diffs (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/tabs@0.2.7
Permissions in 0.2.7
Files
diagrams.ts1.3 KB
// A diagram's source is kept with its tab in the plugin's storage, so the
// tab draws it again after a restart, and goes when the tab closes.
import * as Effect from "effect/Effect";
import { Storage } from "divergence/effect";
import { diagramKey, storedDiagram } from "./tabs.ts";
import type { Tab, TabsState } from "./tabs.ts";
export const makeDiagrams = Effect.fn("Tabs.makeDiagrams")(function* (state: TabsState, redraw: () => void) {
const storage = yield* Storage;
const keep = (tab: Tab) =>
storage
.set(diagramKey(tab.id), { source: tab.source, language: tab.language, title: tab.title })
.pipe(Effect.ignore({ log: "Warn", message: "Could not keep the diagram's source" }));
const restore = Effect.fn("Tabs.restoreDiagram")(function* (tab: Tab) {
const kept = yield* storage
.get(diagramKey(tab.id), storedDiagram)
.pipe(Effect.catch((error) => Effect.as(Effect.logWarning(`tabs: could not read a diagram's source: ${error.message}`), undefined)));
if (kept) Object.assign(tab, kept);
else state.contents[tab.id] = { error: "This diagram is no longer available." };
redraw();
});
const drop = (id: string) => storage.set(diagramKey(id), null).pipe(Effect.ignore({ log: "Warn", message: "Could not drop the diagram's source" }));
return { keep, restore, drop };
});
No comments yet.