[eric] windows: fix UA-spoof leak onto recreated main window + add diag logs across preload, createWindow, recreateMainWindow, resumeSession, launchAndSendFirstMessage, AgentChat, WebSocketManager so packaged-build stderr captures the chat-spawn crash trail

This commit is contained in:
Eric
2026-05-25 16:06:58 -07:00
parent e7a09c9568
commit d27f289cea
7 changed files with 50 additions and 5 deletions
+3
View File
@@ -1,5 +1,8 @@
const { contextBridge, ipcRenderer } = require('electron');
// eslint-disable-next-line no-console
console.log('[diag][preload] start, ua=', navigator.userAgent);
// Synchronous exposure. The previous async IIFE (await ipcRenderer.invoke) raced React mount: any code reading window.openswarm during the gap (BrowserCard's Electron-detection falling back to iframe mode, AgentChat's auth-token call throwing) saw undefined. sendSync blocks the renderer for one IPC round-trip during preload before any user-visible paint, so window.openswarm is guaranteed to exist before the first frontend bundle evaluates.
const port = ipcRenderer.sendSync('get-backend-port-sync');
const webviewPreloadPath = ipcRenderer.sendSync('get-webview-preload-path-sync');