Skip to content

fix(desktop): coalesce the update checks fired by window focus and visibility - #10250

Open
GuidoMaxier wants to merge 1 commit into
esengine:main-v2from
GuidoMaxier:fix/updater-event-throttle
Open

GuidoMaxier wants to merge 1 commit into
esengine:main-v2from
GuidoMaxier:fix/updater-event-throttle

Conversation

@GuidoMaxier

@GuidoMaxier GuidoMaxier commented Sep 13, 2026

Copy link
Copy Markdown

subscribeToUpdateRefresh in desktop/frontend/src/components/UpdateBanner.tsx subscribed focus and visibilitychange to a bare refresh(), so every toggle of the app window started a new CheckUpdate.

That check holds the bridge for seconds — 1.4–3.5 s in #10192's own measurements, 28.5 s in one of the breadcrumb windows reported on #10186 — so switching between windows queued one multi-second call per toggle. useUpdater only guards against superseding a check that is in flight (isBusyOperation); once a check finishes, the next window event starts another.

Change

Throttle the window-event path to 5 minutes. The hourly interval keeps its own schedule, so the periodic check is unaffected.

  • UPDATE_REFRESH_MIN_EVENT_INTERVAL_MS = 5 * 60 * 1000, exposed as an optional third parameter so callers and tests can tune it.
  • visibilitychange for a hidden window is still ignored, as before.
  • No Go side and no bridge-contract change: CheckUpdate itself behaves exactly as it did.

Test

desktop/frontend/src/__tests__/updater-shared-state.test.tsx already pinned the old behaviour:

window.dispatchEvent(new Event("focus"));
document.dispatchEvent(new Event("visibilitychange"));
ok(scheduledRefreshes === 2, "visible focus and visibility changes schedule update refreshes");

Two events produced two refreshes — the defect written down as an expectation. It now asserts coalescing inside the throttle window, a new refresh once that window elapses, and that cleanup still removes both listeners.

Verification

  • pnpm exec tsx src/__tests__/updater-shared-state.test.tsx → 54 passed, 0 failed
  • pnpm typecheck → 0 errors
  • pnpm test:typecheck → 0 errors
  • pnpm lint:hooks → clean

Refs #10192

Documentation-impact: none - the change is a client-side event throttle in UpdateBanner.tsx; the user-facing updater documentation describes when checks happen (at launch and periodically), and none of it documents a per-window-event refresh, so the existing docs remain correct.

Returning to the app window fired a fresh CheckUpdate on every focus and
visibilitychange, and each call holds the bridge for 1.4-3.5 s (28.5 s in one
breadcrumb window from esengine#10186). Toggling between windows therefore queued one
multi-second call per toggle.

Throttle only the window-event path to 5 minutes; the hourly interval keeps its
own schedule. The existing test pinned the old one-refresh-per-event behaviour,
so it now asserts coalescing, window expiry and listener cleanup.

Fixes esengine#10192
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) labels Sep 13, 2026
@GuidoMaxier

Copy link
Copy Markdown
Author

CI evidence. This is a fork pull request, so the checks of this PR stay in action_required until a maintainer approves them. I ran the same commit inside my fork instead: 30 jobs green on run 34790889950, including desktop-frontend, lint, lint-code, desktop, desktop-browser, desktop-browser-group (transcript / app-settings-motion), test (ubuntu/macos/windows), race, desktop-go, desktop-go-race, desktop-macos, desktop-windows and every windows-* job.

The only red job is desktop-windows-go (reasonix/desktop), which fails on the Windows runner of the fork with:

warning: bash sandbox requested but unavailable on this host; refusing to run unconfined.
The native Windows restricted-token/AppContainer sandbox is unavailable.

That job is not related to this diff. An unrelated branch (feat/es-spanish, the es-419 locale work in #9870) run in the same fork failed the same single job with the same message while every other job passed in both runs — see run 34788173613.

Local gates on this revision: pnpm exec tsx src/__tests__/updater-shared-state.test.tsx 54 passed / 0 failed, pnpm typecheck and pnpm test:typecheck 0 errors, pnpm lint:hooks clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant