// One global wmkit window manager for the whole app (mounted once by // EntityDesktop.svelte in App.svelte) — this is what lets an entity opened // from Knowledge Base, chat, or anywhere else land in the same floating // window layer, with several windows open side by side, rather than each // page owning its own single-entity sidebar/sheet. import { createManager, createDesktop, wmStore } from '@surdeddd/wmkit/svelte' export const wm = createManager({ defaultSize: { width: 480, height: 560 } }) export const dk = createDesktop(wm) export const wmState = wmStore(wm) // Opens a window for the entity, or focuses (and restores, if minimized) the // existing one — wm.open() throws if a window with this id already exists, // and slugs make natural, stable window ids (also dedupes "same entity // opened twice" into one window instead of stacking duplicates). export function openEntityWindow(slug: string | null): void { if (!slug) return if (wm.get(slug)) { wm.restore(slug) wm.focus(slug) return } wm.open({ id: slug, title: slug }) }