diff --git a/apps/desktop/electron/main.cjs b/apps/desktop/electron/main.cjs index c28aea0bb1b..333e2b136a6 100644 --- a/apps/desktop/electron/main.cjs +++ b/apps/desktop/electron/main.cjs @@ -119,6 +119,20 @@ if (REMOTE_DISPLAY_REASON) { `[hermes] remote display detected (${REMOTE_DISPLAY_REASON}); disabling GPU hardware acceleration to prevent flicker` ) } + +// Keep the renderer running at full speed while the window is in the background +// or occluded. The chat transcript streams to screen through a +// requestAnimationFrame-gated flush; Chromium pauses rAF (and clamps timers) +// for backgrounded/occluded renderers, so without these the live answer stalls +// whenever the window loses focus (switching to your editor mid-turn, detached +// devtools, another window covering it) and only paints on refocus or refresh. +// `backgroundThrottling: false` on the BrowserWindow covers the blurred case; +// these process-level switches additionally stop Chromium from backgrounding or +// occlusion-throttling the renderer. Must run before app `ready`. +app.commandLine.appendSwitch('disable-renderer-backgrounding') +app.commandLine.appendSwitch('disable-backgrounding-occluded-windows') +app.commandLine.appendSwitch('disable-background-timer-throttling') + const SOURCE_REPO_ROOT = path.resolve(APP_ROOT, '../..') // Build-time install stamp -- the git ref this .exe was built against. @@ -4689,7 +4703,16 @@ function createWindow() { webviewTag: true, sandbox: true, nodeIntegration: false, - devTools: true + devTools: true, + // Keep timers + requestAnimationFrame running at full speed when the + // window is blurred/occluded. The chat transcript streams to the screen + // through a requestAnimationFrame-gated flush (useSessionStateCache), + // so with Chromium's default background throttling the live answer + // stalls whenever this window isn't focused (e.g. you switch to your + // editor mid-turn, or open detached devtools) and only appears once you + // refocus or refresh. A streaming chat app must render in the + // background, so opt out — matching the secondary windows above. + backgroundThrottling: false } })