Conversation
…lling Two related fixes that both improve perceived freshness of the desktop client when the user has nexu in the background or returns to it: 1. Disable Chromium background throttling for the main window. The cold-start setup-animation video pauses the moment the user switches to another app because Chromium suspends background renderers and pauses muted hidden videos to save power. The user sees the animation freeze, comes back, and the cold-start hand-off looks broken. Adding the three command-line flags (disable-background-timer-throttling, disable-renderer-backgrounding, disable-backgrounding-occluded-windows) plus webPreferences backgroundThrottling: false keeps the renderer at full speed regardless of focus state. 2. Reduce the bottom-left credit balance polling interval from 60s to 15s, and rely on react-query's default focus refetch when the window comes back from background. Colleagues reported the balance feels stale and laggy. The previous 60s interval was an order of magnitude longer than every other poll in the app (sessions: 10s, channels: 3s, liveStatus: 3s). 15s + the default refetchOnWindowFocus means the value the user actually sees is always at most 15s old, with no extra background API traffic.
Switch to a per-call refetchInterval that returns 30s when the window is visible AND OS-focused, 60s otherwise. The 60s floor is a defensive backstop in case focus detection misbehaves (Electron windows can end up in odd states), so the balance still refreshes every minute no matter what. refetchIntervalInBackground: true is required to make the function fire while backgrounded.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
mrcfps
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two related fixes that both improve perceived freshness of the desktop client when the user has nexu in the background or returns to it.
Why
1. Setup-animation video freezes when window goes to background
The cold-start setup-animation pauses the moment the user switches to another app, then doesn't resume until they come back. The animation is supposed to play through and then loop infinitely until cold-start finishes — when it freezes mid-animation, the cold-start hand-off looks broken.
Root cause: Chromium suspends background renderers and pauses muted hidden videos to save power. None of the three relevant chromium switches are set in our main process bootstrap. The video element already uses
muted+playsInline+loop, so the markup is fine — the suspension happens at the renderer-process level.2. Bottom-left credit balance feels stale
Multiple colleagues reported that the credit balance shown in the bottom-left of the workspace updates very slowly. Tracing the data flow:
useDesktopRewardsStatuspolled the controller every 60 secondsgetDesktopRewardsStatusfetches from cloud each call (no cache)/api/v1/rewards/statusreturns the current balanceSo the only refresh mechanism was the 60s frontend polling. The previous 60s interval was an order of magnitude longer than every other poll in the app:
On top of that, react-query's
refetchIntervalInBackgrounddefault isfalse, so when the window was unfocused the polling stopped entirely — making the displayed balance arbitrarily stale by the time the user came back.How
1. Three Chromium command-line flags + window-level backup
Plus on the BrowserWindow:
The flags are applied app-wide;
backgroundThrottling: falseis the window-level backup. Together they keep the renderer running at full speed regardless of focus state, so the setup-animation video keeps playing when the user alt-tabs away.2. Per-call refetchInterval with a 60s defensive floor
visibilityState === "visible"ANDdocument.hasFocus() === truerefetchOnWindowFocus)Why a function instead of a number:
refetchIntervalcan only be one or the other.Why a 60s defensive floor instead of "no polling in background":
document.hasFocus()orvisibilityStatelies (occluded, fullscreen on another space, dock minimised, ...).refetchIntervalInBackground: trueis required for the function to get re-evaluated when backgrounded — without it, react-query stops calling it entirely.Net effect: the value the user actively sees is always ≤ 30s old, the worst case (focus detection broken) is ≤ 60s, and the moment the user returns to the window it snaps fresh.
Affected areas
Checklist
pnpm typecheck— not run locally (worktree without node_modules); changes are type-stable: 3 string-literal command-line switches, one boolean field onwebPreferences, and a function-formrefetchIntervalmatching react-query's documented signaturepnpm lint— not run locally for the same reasonpnpm test— N/Aanytypes introducedNotes for reviewers