experiments in a post-browser web
10
fork

Configure Feed

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

refactor(main): reloadExtension uses relaunchTile

+7 -19
+7 -19
backend/electron/main.ts
··· 20 20 import { discoverExtensions, loadExtensionManifest, isBuiltinExtensionEnabled, getExternalExtensions, type ExtensionManifest, type ManifestCommand, type ManifestShortcut } from './extensions.js'; 21 21 import { initializeFeatures, type FeatureStartupResult } from './feature-startup.js'; 22 22 import { ensureTileIpcHandlers } from './tile-compat.js'; 23 - import { getLoadedTileIds, getTileManifest, getAllTileWindows, unloadAllTiles } from './tile-launcher.js'; 23 + import { getLoadedTileIds, getTileManifest, getAllTileWindows, unloadAllTiles, relaunchTile } from './tile-launcher.js'; 24 24 import { initTray } from './tray.js'; 25 25 import { registerLocalShortcut, unregisterLocalShortcut, handleLocalShortcut, registerGlobalShortcut, unregisterGlobalShortcut, unregisterShortcutsForAddress } from './shortcuts.js'; 26 26 import { scopes, publish, subscribe, unsubscribe, hasSubscriber, setExtensionBroadcaster, getSystemAddress } from './pubsub.js'; ··· 1671 1671 } 1672 1672 1673 1673 /** 1674 - * Reload an extension by destroying and recreating its window 1675 - * Returns the new window on success, null on failure 1674 + * Reload an extension by closing and relaunching its tile window. 1675 + * Returns a truthy result on success, null on failure. 1676 1676 */ 1677 - export async function reloadExtension(extId: string): Promise<BrowserWindow | null> { 1677 + export async function reloadExtension(extId: string): Promise<object | null> { 1678 1678 DEBUG && console.log(`[ext:reload] Reloading extension: ${extId}`); 1679 1679 1680 1680 // Check if it's a consolidated extension (not supported for reload) ··· 1683 1683 return null; 1684 1684 } 1685 1685 1686 - // Destroy existing window if any 1687 - const existingEntry = extensionWindows.get(extId); 1688 - if (existingEntry) { 1689 - if (existingEntry.win && !existingEntry.win.isDestroyed()) { 1690 - existingEntry.win.destroy(); 1691 - } 1692 - extensionWindows.delete(extId); 1693 - } 1694 - 1695 - // Small delay to ensure cleanup 1696 - await new Promise(resolve => setTimeout(resolve, 100)); 1697 - 1698 - // For dev extensions, use loadDevExtension to ensure devtools opens 1686 + // For dev extensions, open devtools after relaunch 1699 1687 if (isDevExtension(extId)) { 1700 1688 return loadDevExtension(extId); 1701 1689 } 1702 1690 1703 - // For normal extensions, use createExtensionWindow 1704 - return createExtensionWindow(extId); 1691 + // Relaunch as v2 tile: re-read manifest, revoke old token, close old window, launch fresh. 1692 + return relaunchTile(extId); 1705 1693 } 1706 1694 1707 1695 /**