-
Notifications
You must be signed in to change notification settings - Fork 3
Throttle polling when window is backgrounded #4816
Description
The app handles system suspend/resume via powerMonitor (pausing PTY health checks, disabling workspace polling, then refreshing on wake). But there's no detection or throttling when the window simply loses focus, gets minimized, or is obscured by other applications.
All main-process polling services — WorkspaceService (2s active), ProjectStatsService (5s), ProcessTreeCache (2.5s) — continue at full speed when the app is in the background. Since main process setInterval/setTimeout timers are not affected by Chromium's background tab throttling, IPC messages continue flowing to the renderer. The backgrounded renderer processes its IPC queue sluggishly (Chromium clamps timers to 1/sec, then 1/min after 5 minutes), so messages pile up. When the user refocuses the window, the renderer has to process the backlog, causing visible jank.
Desired behavior:
- Detect window blur/minimize → multiply polling intervals by ~5x
- Detect window focus/restore → reset to normal intervals and do one immediate poll to refresh stale UI
- Consider
powerMonitor.on('on-battery')to reduce polling frequency on battery power - The existing
setPollingEnabled()on WorkspaceClient provides the control surface — this just needs to be wired to window state events with a less binary approach (throttle rather than full pause)