experiments in a post-browser web
10
fork

Configure Feed

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

fix(context): resolve window ID from caller when null, set mode before loadURL

- context-get/context-set handlers now use calling window when windowId is null
(preload default), not just undefined
- Move win.loadURL() after mode/context setup in window-open handler to eliminate
race where page.js reads mode before backend sets it

+8 -7
+8 -7
backend/electron/ipc.ts
··· 1835 1835 DEBUG && console.log('Routing web page through peek://app/page:', url, '->', loadUrl); 1836 1836 } 1837 1837 1838 - await win.loadURL(loadUrl); 1839 - 1840 1838 // Add to window manager with modal parameter 1841 1839 // Note: isTransient was determined BEFORE window creation (at top of handler) 1842 1840 // to avoid the race condition where the new window becomes focused before we check ··· 1885 1883 const coordinator = getIzuiCoordinator(); 1886 1884 coordinator.pushWindow(win.id); 1887 1885 1888 - // Set window mode based on URL 1886 + // Set window mode based on URL — BEFORE loadURL so page.js can read it 1889 1887 // For page containers (peek://app/page), extract the actual URL 1890 1888 let modeUrl = url; 1891 1889 if (url.startsWith('peek://app/page')) { ··· 1948 1946 // Log the detected mode 1949 1947 const detectedMode = detectModeFromUrl(modeUrl); 1950 1948 DEBUG && console.log('Set window mode:', win.id, 'url:', modeUrl, 'mode:', detectedMode); 1949 + 1950 + // Load the URL AFTER mode/context is set, so page.js can read inherited mode 1951 + await win.loadURL(loadUrl); 1951 1952 1952 1953 // Track this load in history (skip internal peek:// URLs) 1953 1954 if (!url.startsWith('peek://')) { ··· 3418 3419 try { 3419 3420 let windowId = data.windowId; 3420 3421 3421 - // If no windowId provided, try to get from calling window 3422 - if (windowId === undefined) { 3422 + // If no windowId provided (or null from preload default), use calling window 3423 + if (windowId == null) { 3423 3424 const callingWin = BrowserWindow.fromWebContents(ev.sender); 3424 3425 windowId = callingWin?.id ?? null; 3425 3426 } ··· 3444 3445 let windowId = data.windowId; 3445 3446 let source = data.source; 3446 3447 3447 - // If no windowId provided, try to get from calling window 3448 - if (windowId === undefined) { 3448 + // If no windowId provided (or null from preload default), use calling window 3449 + if (windowId == null) { 3449 3450 const callingWin = BrowserWindow.fromWebContents(ev.sender); 3450 3451 windowId = callingWin?.id ?? null; 3451 3452 }