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
visible.ts1.6 KB
// Which tab is visible, for the divergence/tabs service's activeChanged.
// The tabs on screen are each the one its pane shows, as their views last
// drew: a tab coming on screen is the visible one, and the last going leaves
// none (a chat took its pane, or it closed).
import { activeTab } from "./tabs.ts";
import type { Tab, TabsState } from "./tabs.ts";
import type { TabRef } from "./controller.ts";
export const refOf = (tab: Tab): TabRef => ({ kind: tab.kind, path: tab.path, workspaceId: tab.workspaceId });
export function makeVisible(state: TabsState) {
// The service handle is set after the views register; until a provider
// handle exists there is nobody to tell.
let emit: ((tab: TabRef | null) => void) | undefined;
const announce = (tab: Tab | undefined) => {
emit?.(tab ? refOf(tab) : null);
};
const onScreen = new Set<string>();
// A runtime before `visible` never says a tab is on screen: closing then
// announces the tab the strip falls back to, as it always did.
let reportsVisible = false;
const visible = (tab: Tab, shown: boolean) => {
if (shown === onScreen.has(tab.id)) return;
if (shown) {
reportsVisible = true;
onScreen.add(tab.id);
state.active = tab.id;
announce(tab);
return;
}
onScreen.delete(tab.id);
if (!onScreen.size) announce(undefined);
};
const forget = (id: string) => {
if (onScreen.delete(id) && !onScreen.size) announce(undefined);
};
const closed = () => {
if (!reportsVisible) announce(activeTab(state));
};
const setEmit = (next: typeof emit) => {
emit = next;
};
return { announce, visible, forget, closed, setEmit };
}
No comments yet.