From 47518bc9135db35c6e3174e4c7447fed4a66a1bb Mon Sep 17 00:00:00 2001 From: yoniebans Date: Sat, 6 Jun 2026 21:31:39 +0200 Subject: [PATCH] fix(desktop): check backend updates when the connection becomes remote MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The poller starts at mount, before the gateway connects, so its initial checkBackendUpdates() ran while mode was still unset and no-op'd via the remote-mode guard — leaving the backend button empty until the user clicked it. Subscribe to $connection and re-check the backend when mode resolves to remote. --- apps/desktop/src/store/updates.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/apps/desktop/src/store/updates.ts b/apps/desktop/src/store/updates.ts index 80746bf4bf6..bc78e1ecfe2 100644 --- a/apps/desktop/src/store/updates.ts +++ b/apps/desktop/src/store/updates.ts @@ -383,6 +383,8 @@ function ingestProgress(payload: DesktopUpdateProgress): void { let pollerStarted = false let backgroundTimer: ReturnType | null = null let lastFocusAt = 0 +let connectionUnsub: (() => void) | null = null +let lastConnectionMode: string | undefined /** Wire up background polling + progress streaming. Idempotent. */ export function startUpdatePoller(): void { @@ -402,6 +404,19 @@ export function startUpdatePoller(): void { void refreshDesktopVersion() bridge.onProgress(ingestProgress) + // The poller starts at mount, before the gateway connects — so the first + // backend check above sees mode≠remote and no-ops. Re-check once the + // connection resolves to remote. + connectionUnsub = $connection.subscribe(conn => { + if (conn?.mode === lastConnectionMode) { + return + } + lastConnectionMode = conn?.mode + if (conn?.mode === 'remote') { + void checkBackendUpdates() + } + }) + window.addEventListener('focus', onFocus) backgroundTimer = setInterval(() => { void checkUpdates() @@ -415,6 +430,9 @@ export function stopUpdatePoller(): void { backgroundTimer = null } + connectionUnsub?.() + connectionUnsub = null + lastConnectionMode = undefined window.removeEventListener('focus', onFocus) pollerStarted = false }