experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(tile): broadcast pubsub messages to v2 tile BrowserWindows

+31 -1
+23 -1
backend/electron/main.ts
··· 15 15 import { initCmd } from './cmd-glue.js'; 16 16 import { discoverExtensions, loadExtensionManifest, isBuiltinExtensionEnabled, getExternalExtensions, type ExtensionManifest, type ManifestCommand, type ManifestShortcut } from './extensions.js'; 17 17 import { initializeFeatures, type FeatureStartupResult } from './feature-startup.js'; 18 - import { getLoadedTileIds, getTileManifest } from './tile-launcher.js'; 18 + import { getLoadedTileIds, getTileManifest, getAllTileWindows } from './tile-launcher.js'; 19 19 import { initTray } from './tray.js'; 20 20 import { registerLocalShortcut, unregisterLocalShortcut, handleLocalShortcut, registerGlobalShortcut, unregisterGlobalShortcut, unregisterShortcutsForAddress } from './shortcuts.js'; 21 21 import { scopes, publish, subscribe, unsubscribe, hasSubscriber, setExtensionBroadcaster, getSystemAddress } from './pubsub.js'; ··· 201 201 } catch { 202 202 // Window may have been destroyed between check and send (during shutdown) 203 203 } 204 + } 205 + } 206 + 207 + // Broadcast to v2 tile BrowserWindows (launched by tile-launcher). 208 + // Without this, v2 tiles that subscribe to global pubsub events (editor:open, 209 + // item:created, etc.) never receive them, because they're not in 210 + // extensionWindows or the consolidated extension host. 211 + for (const tileWin of getAllTileWindows()) { 212 + try { 213 + const winOrigin = tileWin.webContents.getURL(); 214 + const winOriginPrefix = winOrigin.startsWith('peek://') 215 + ? new URL(winOrigin).origin 216 + : winOrigin; 217 + // Don't echo back to sender 218 + if (winOriginPrefix !== sourceOrigin) { 219 + tileWin.webContents.send(`pubsub:${topic}`, { 220 + ...(msg as object), 221 + source 222 + }); 223 + } 224 + } catch { 225 + // Window may have been destroyed between check and send 204 226 } 205 227 } 206 228 });
+8
backend/electron/tile-launcher.ts
··· 279 279 } 280 280 281 281 /** 282 + * Get all BrowserWindow instances for loaded tiles. 283 + * Used by the pubsub broadcaster to forward messages to v2 tile windows. 284 + */ 285 + export function getAllTileWindows(): BrowserWindow[] { 286 + return Array.from(tileWindows.values()).filter(win => !win.isDestroyed()); 287 + } 288 + 289 + /** 282 290 * Unload a tile — close its window and revoke tokens 283 291 */ 284 292 export function unloadTile(tileId: string, entryId: string): void {