experiments in a post-browser web
10
fork

Configure Feed

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

fix(izui): fix transient detection race condition

The transient flag was being determined AFTER window creation, but by
that time the new window was already focused. This caused windows opened
via global hotkey (with Peek not focused) to incorrectly behave in
"active mode" instead of "transient mode".

Fix: Check focused window state BEFORE creating the new window.

Also removes escapeMode: 'close' from windows extension - it now relies
on proper IZUI transient detection via default 'auto' mode.

+12 -8
+10 -6
backend/electron/ipc.ts
··· 1548 1548 1549 1549 const { url, options } = msg; 1550 1550 1551 + // IMPORTANT: Determine transient state BEFORE creating the window 1552 + // A window is transient if opened when no Peek window was focused (e.g., via global hotkey) 1553 + // This must be checked before window creation because the new window will become focused 1554 + const focusedWindowBeforeCreate = BrowserWindow.getFocusedWindow(); 1555 + const isTransient = !focusedWindowBeforeCreate || focusedWindowBeforeCreate.isDestroyed(); 1556 + DEBUG && console.log('Transient detection:', { isTransient, focusedWindowId: focusedWindowBeforeCreate?.id }); 1557 + 1551 1558 // Check if window with this key already exists 1552 1559 if (options.key) { 1553 1560 const existingWindow = findWindowByKey(msg.source, options.key); ··· 1678 1685 1679 1686 await win.loadURL(loadUrl); 1680 1687 1681 - // Determine if this is a transient window (opened while no Peek window was focused) 1682 - // Used for escapeMode: 'auto' to decide between navigate and close behavior 1683 - const focusedWindow = BrowserWindow.getFocusedWindow(); 1684 - const isTransient = !focusedWindow || focusedWindow.isDestroyed(); 1685 - 1686 1688 // Add to window manager with modal parameter 1689 + // Note: isTransient was determined BEFORE window creation (at top of handler) 1690 + // to avoid the race condition where the new window becomes focused before we check 1687 1691 const windowParams = { 1688 1692 ...options, 1689 1693 address: url, 1690 1694 transient: isTransient 1691 1695 }; 1692 - DEBUG && console.log('Adding window to manager:', win.id, 'modal:', windowParams.modal, 'keepLive:', windowParams.keepLive); 1696 + DEBUG && console.log('Adding window to manager:', win.id, 'modal:', windowParams.modal, 'keepLive:', windowParams.keepLive, 'transient:', isTransient); 1693 1697 registerWindow(win.id, msg.source, windowParams); 1694 1698 1695 1699 // Set window mode based on URL
+2 -2
extensions/windows/background.js
··· 86 86 maximize: true, 87 87 // Don't use modal - we want windows view to stay open until ESC or selection 88 88 type: 'panel', 89 - // Always close on ESC (window switcher should dismiss easily) 90 - escapeMode: 'close', 89 + // Use default 'auto' escapeMode - IZUI will handle transient detection 90 + // (window switcher invoked via global hotkey will be transient, closing on ESC) 91 91 trackingSource: 'windows', 92 92 trackingSourceId: 'main' 93 93 };