The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): scope version label to the active connection/profile
Willy Morinc3d5d4eca661
diff --git a/apps/desktop/e2e/connection-version-label.spec.ts b/apps/desktop/e2e/connection-version-label.spec.tsnew file mode 100644index 00000000000..3d91012b873--- /dev/null+++ b/apps/desktop/e2e/connection-version-label.spec.ts@@ -0,0 +1,238 @@+/**+ * The status bar's client version label follows the ACTIVE connection.+ *+ * Two loopback fake gateways registered in connections.json (v2): A is the+ * primary (reports 0.21.5), B is a second remote (reports 0.22.1, display+ * 0.22.1+72). The app boots on A, the user switches to B through the profile+ * rail, and the label must re-resolve to B's version instead of staying on A's.+ *+ * Version source: the dev build stamp has payload 'bootstrap' and no+ * displayVersion, so electron/app-version.ts lets the RUNTIME gateway version+ * (GET /api/health → displayVersion ?? version) win for appVersion.+ */++import * as fs from 'node:fs'+import * as http from 'node:http'+import { createRequire } from 'node:module'+import type { AddressInfo } from 'node:net'+import * as path from 'node:path'++import type { Page } from '@playwright/test'++import { buildAppEnv, createSandbox, launchDesktop } from './fixtures'+import { allowErrorBanners, expect, test } from './test'++interface FakeSocket {+ send: (data: string) => void+ on: (event: 'message', listener: (raw: unknown) => void) => void+ terminate: () => void+}++interface FakeSocketServer {+ clients: Set<FakeSocket>+ on: (event: 'connection', listener: (ws: FakeSocket) => void) => void+ close: () => void+}++// `ws` is a workspace dependency without bundled types; keep the surface we use typed here.+const { WebSocketServer } = createRequire(import.meta.url)('ws') as {+ WebSocketServer: new (options: { server: http.Server }) => FakeSocketServer+}++const outPath = (file: string): string =>+ process.env.HERMES_E2E_OUT ? path.join(process.env.HERMES_E2E_OUT, file) : test.info().outputPath(file)++interface FakeGateway {+ url: string+ hits: string[]+ close: () => Promise<void>+}++async function startFakeGateway(name: string, health: Record<string, unknown>): Promise<FakeGateway> {+ const hits: string[] = []++ const server = http.createServer((req, res) => {+ req.resume()+ const pathname = new URL(req.url ?? '/', 'http://x').pathname+ hits.push(`${req.method} ${req.url}`)+ res.setHeader('Content-Type', 'application/json')++ if (pathname === '/api/health') {+ return res.end(JSON.stringify(health))+ }++ if (pathname === '/api/status') {+ return res.end(JSON.stringify({ auth_required: false, version: health.version }))+ }++ if (pathname === '/api/profiles') {+ return res.end(+ JSON.stringify({ profiles: [{ name: 'default', is_default: true, active: true }], active: 'default' })+ )+ }++ if (pathname === '/api/profiles/active') {+ return res.end(JSON.stringify({ name: 'default', profile: 'default' }))+ }++ if (pathname.startsWith('/api/config')) {+ return res.end(JSON.stringify({}))+ }++ if (pathname === '/api/sessions') {+ return res.end(JSON.stringify({ sessions: [], total: 0 }))+ }++ res.statusCode = 404+ res.end(JSON.stringify({ error: 'not_found', gateway: name }))+ })++ const wss = new WebSocketServer({ server })+ wss.on('connection', ws => {+ hits.push('WS open')+ ws.send(+ JSON.stringify({+ jsonrpc: '2.0',+ method: 'event',+ params: { type: 'gateway.ready', payload: { change_events: true, heartbeat: false, replay_epoch: name } }+ })+ )+ ws.on('message', raw => {+ let msg: { id?: unknown; method?: string } = {}++ try {+ msg = JSON.parse(String(raw))+ } catch {+ return+ }++ if (msg.id !== undefined) {+ hits.push(`RPC ${msg.method}`)++ // A configured gateway, so no first-run onboarding overlay covers the rail.+ const result =+ msg.method === 'setup.status'+ ? { provider_configured: true, ready: true }+ : msg.method === 'setup.runtime_check'+ ? { ok: true, provider: 'fake', model: 'fake-model' }+ : msg.method === 'onboarding.state'+ ? { active: false, completed: true }+ : {}++ ws.send(JSON.stringify({ jsonrpc: '2.0', id: msg.id, result }))+ }+ })+ })+ await new Promise<void>(resolve => server.listen(0, '127.0.0.1', resolve))++ return {+ url: `http://127.0.0.1:${(server.address() as AddressInfo).port}`,+ hits,+ close: async () => {+ for (const client of wss.clients) {+ client.terminate()+ }++ wss.close()+ server.closeAllConnections()+ await new Promise<void>(resolve => server.close(() => resolve()))+ }+ }+}++const clientLabel = (page: Page) =>+ page.evaluate(() => {+ const text = document.body.innerText+ const match = text.match(/client v(\S+)/)++ return match ? match[1] : null+ })++test('client version label follows a switch to another connection', async () => {+ test.setTimeout(240_000)+ allowErrorBanners()+ const a = await startFakeGateway('A', { ok: true, status: 'ok', version: '0.21.5' })+ const b = await startFakeGateway('B', { ok: true, status: 'ok', version: '0.22.1', displayVersion: '0.22.1+72' })+ const sandbox = createSandbox('version-label')+ fs.writeFileSync(+ path.join(sandbox.userDataDir, 'connections.json'),+ JSON.stringify({+ version: 2,+ primary: 'gw-a',+ launchMode: 'primary',+ lastUsed: 'gw-a',+ connections: [+ { id: 'local', kind: 'local', label: 'This device' },+ {+ id: 'gw-a',+ kind: 'remote',+ label: 'Gateway A',+ url: a.url,+ authMode: 'token',+ token: { encoding: 'plain', value: 'tok-a' }+ },+ {+ id: 'gw-b',+ kind: 'remote',+ label: 'Gateway B',+ url: b.url,+ authMode: 'token',+ token: { encoding: 'plain', value: 'tok-b' }+ }+ ]+ }),+ { encoding: 'utf8', mode: 0o600 }+ )++ const { app, page } = await launchDesktop(buildAppEnv(sandbox, { HERMES_DESKTOP_DEV_SERVER: '' }))++ const dump = (tag: string) =>+ fs.writeFileSync(outPath(`${tag}.log`), [`A hits:`, ...a.hits, '', 'B hits:', ...b.hits].join('\n'))++ try {+ await expect.poll(() => clientLabel(page), { timeout: 90_000 }).toBe('0.21.5')+ await page.screenshot({ path: outPath('before-switch.png') })+ const before = await page.evaluate(() => (window as any).hermesDesktop.getVersion())+ expect(before.appVersion, 'unscoped getVersion resolves the primary (A)').toBe('0.21.5')++ // Real user switch: click Gateway B's default profile square on the rail.+ const bHitsBefore = b.hits.filter(h => h.startsWith('GET /api/health')).length+ await page.locator('[data-slot="profile-rail"]').getByRole('button', { name: 'default · Gateway B' }).click()++ // The window re-homed onto B: B's default becomes the rail's active entry+ // and A drops to an at-rest "default · Gateway A" door.+ await expect(+ page.locator('[data-slot="profile-rail"]').getByRole('button', { name: 'default · Gateway A' }),+ 'the window re-homed onto Gateway B'+ ).toBeVisible({ timeout: 60_000 })++ let label: null | string = null+ let scopedVersion: null | string = null++ try {+ await expect+ .poll(async () => (label = await clientLabel(page)), {+ message: 'status-bar client label follows the active connection',+ timeout: 20_000+ })+ .toBe('0.22.1+72')+ } finally {+ await page.screenshot({ path: outPath('after-switch.png') })+ // The preload half of the fix: a scoped getVersion must reach main.+ scopedVersion = (await page.evaluate(() => (window as any).hermesDesktop.getVersion({ connectionId: 'gw-b' })))+ .appVersion+ fs.writeFileSync(+ outPath('after-switch.txt'),+ `label after switch: ${label}\ngetVersion({connectionId:'gw-b'}).appVersion: ${scopedVersion}\nB /api/health hits before switch: ${bHitsBefore}, after: ${b.hits.filter(h => h.startsWith('GET /api/health')).length}\n`+ )+ }++ expect(scopedVersion, 'preload forwards the scope, so main resolves B for gw-b').toBe('0.22.1+72')+ } finally {+ dump('final')+ await app.close().catch(() => undefined)+ await a.close()+ await b.close()+ sandbox.cleanup()+ }+})diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex 42d569df916..f8bcd2e8a1b 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -17193,12 +17193,11 @@ async function detectRendererSkew() {return checkRendererSkew(resolveUpdateRoot())}-// Re-resolve the live Hermes version and push it into the native About panel-// just before showing it, so an in-place `hermes update` is reflected without-// an app restart. macOS only — `showAboutPanel()` is a no-op elsewhere, and the-// other platforms don't use this menu item.+// Re-resolve the focused window's live Hermes version just before showing the native About+// panel, so an in-place `hermes update` shows without a restart. macOS only (no-op elsewhere).function showAboutPanelFresh(): void {- void Promise.all([detectRendererSkew(), resolveHermesVersion()]).then(([skew, version]) => {+ const scope = windowConnectionRoutes.versionScopeFor(BrowserWindow.getFocusedWindow() ?? mainWindow)+ void Promise.all([detectRendererSkew(), resolveHermesVersion(scope)]).then(([skew, version]) => {const info: AppVersionInfo = appVersionInfo(INSTALL_STAMP, version, app.getVersion())// The product name already identifies canary and commit builds. Never pass// through empty/placeholder: the panel would render the bundle's 0.0.0 (#124581).diff --git a/apps/desktop/electron/preload-version-scope.test.ts b/apps/desktop/electron/preload-version-scope.test.tsnew file mode 100644index 00000000000..c9fc481c2b1--- /dev/null+++ b/apps/desktop/electron/preload-version-scope.test.ts@@ -0,0 +1,35 @@+import { expect, it, vi } from 'vitest'++const host = vi.hoisted(() => ({+ exposeInMainWorld: vi.fn(),+ invoke: vi.fn().mockResolvedValue({ appVersion: '1.0.0' }),+ send: vi.fn(),+ sendSync: vi.fn((): unknown => ({}))+}))++vi.mock('electron', () => ({+ contextBridge: { exposeInMainWorld: host.exposeInMainWorld },+ ipcRenderer: { invoke: host.invoke, send: host.send, sendSync: host.sendSync, on: vi.fn(), removeListener: vi.fn() },+ webFrame: {},+ webUtils: {}+}))++type VersionBridge = { getVersion: (scope?: { connectionId?: string; profile?: string }) => Promise<unknown> }++async function bridge(): Promise<VersionBridge> {+ await import('./preload')+ const registration = host.exposeInMainWorld.mock.calls.find(([name]): boolean => name === 'hermesDesktop')++ return registration![1] as VersionBridge+}++// The renderer scopes the version request to the selected connection/profile;+// dropping it here makes main answer from the primary route instead.+it('forwards the connection/profile scope to hermes:version', async (): Promise<void> => {+ const exposed = await bridge()+ host.invoke.mockClear()++ await exposed.getVersion({ connectionId: 'remote-box', profile: 'work' })++ expect(host.invoke).toHaveBeenCalledExactlyOnceWith('hermes:version', { connectionId: 'remote-box', profile: 'work' })+})diff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.tsindex 7237b4c0721..552d7f59976 100644--- a/apps/desktop/electron/preload.ts+++ b/apps/desktop/electron/preload.ts@@ -668,7 +668,7 @@ contextBridge.exposeInMainWorld('hermesDesktop', {return () => ipcRenderer.removeListener('hermes:bootstrap:event', listener)},- getVersion: () => ipcRenderer.invoke('hermes:version'),+ getVersion: (scope?: { connectionId?: string; profile?: string }) => ipcRenderer.invoke('hermes:version', scope),relaunchApp: () => ipcRenderer.invoke('hermes:app:relaunch'),getMachineProfile: () => ipcRenderer.invoke('hermes:machine:profile'),getRemoteDisplayReason: () => ipcRenderer.invoke('hermes:get-remote-display-reason'),diff --git a/apps/desktop/electron/window-connection-route.test.ts b/apps/desktop/electron/window-connection-route.test.tsindex f08ac1b2a03..8f564c8c44c 100644--- a/apps/desktop/electron/window-connection-route.test.ts+++ b/apps/desktop/electron/window-connection-route.test.ts@@ -8,7 +8,8 @@ import {normalizeWindowConnectionRoute,registrySshPoolScopeByConnectionId,registrySshScopeForWindowRoute,- WindowConnectionRouteRegistry+ WindowConnectionRouteRegistry,+ windowRouteVersionScope} from './window-connection-route'test('normalizes an exact registry-scoped connection and profile', () => {@@ -203,3 +204,27 @@ test('falls back to the canonical profile when the applied window had no route tregistryScoped: false})})++test('about-panel version scope follows the window route, not the primary', () => {+ assert.deepEqual(windowRouteVersionScope({ connectionId: 'remote-a', profile: 'work', registryScoped: true }), {+ connectionId: 'remote-a',+ profile: 'work'+ })+ // Legacy/profile-only route: profile only, no registry pin.+ assert.deepEqual(windowRouteVersionScope({ connectionId: 'x', profile: 'work', registryScoped: false }), {+ profile: 'work'+ })+ // No recorded route: unscoped (primary), same as before.+ assert.deepEqual(windowRouteVersionScope(null), {})+})++test('about-panel scope uses the focused window route and falls back to the primary', () => {+ const routes = new WindowConnectionRouteRegistry()+ routes.set(7, { connectionId: 'remote-a', profile: 'work', registryScoped: true })+ const window = (id: number, destroyed = false) => ({ isDestroyed: () => destroyed, webContents: { id } })++ assert.deepEqual(routes.versionScopeFor(window(7)), { connectionId: 'remote-a', profile: 'work' })+ assert.deepEqual(routes.versionScopeFor(window(7, true)), {})+ assert.deepEqual(routes.versionScopeFor(window(8)), {})+ assert.deepEqual(routes.versionScopeFor(null), {})+})diff --git a/apps/desktop/electron/window-connection-route.ts b/apps/desktop/electron/window-connection-route.tsindex c9c73716f89..dfdae96acca 100644--- a/apps/desktop/electron/window-connection-route.ts+++ b/apps/desktop/electron/window-connection-route.ts@@ -114,4 +114,30 @@ export class WindowConnectionRouteRegistry {delete(webContentsId: number): void {this.routes.delete(webContentsId)}++ /** Version scope for a window's route; a missing or destroyed window means the primary. */+ versionScopeFor(win: { isDestroyed: () => boolean; webContents: { id: number } } | null): VersionScope {+ return win && !win.isDestroyed() ? windowRouteVersionScope(this.routes.get(win.webContents.id)) : {}+ }+}++export interface VersionScope {+ connectionId?: string+ profile?: string+}++/**+ * The gateway scope a window-level query (e.g. the native About panel version)+ * should use for a window. Only a registry-scoped route pins a connection;+ * a legacy route contributes its profile; no route means the primary.+ */+export function windowRouteVersionScope(route: WindowConnectionRoute | null | undefined): VersionScope {+ if (!route) {+ return {}+ }++ return {+ ...(route.registryScoped && route.connectionId ? { connectionId: route.connectionId } : {}),+ ...(route.profile ? { profile: route.profile } : {})+ }}diff --git a/apps/desktop/src/store/updates-version-scope.test.ts b/apps/desktop/src/store/updates-version-scope.test.tsnew file mode 100644index 00000000000..f8789b2ee4b--- /dev/null+++ b/apps/desktop/src/store/updates-version-scope.test.ts@@ -0,0 +1,190 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'++import { setApiRequestConnection, setApiRequestProfile } from '@/api/client'+import type { DesktopVersionInfo } from '@/global'++const storage = new Map<string, string>()++vi.mock('@/lib/storage', () => ({+ persistBoolean: (key: string, value: boolean) => {+ storage.set(key, String(value))+ },+ persistString: (key: string, value: null | string) => {+ if (value === null) {+ storage.delete(key)+ } else {+ storage.set(key, value)+ }+ },+ // store/session persists its exact owner hints through the JSON helpers.+ readJson: (key: string) => {+ const value = storage.get(key)++ try {+ return value === undefined ? null : JSON.parse(value)+ } catch {+ return null+ }+ },+ writeJson: (key: string, value: unknown) => {+ if (value === null) {+ storage.delete(key)+ } else {+ storage.set(key, JSON.stringify(value))+ }+ },+ storedBoolean: (key: string, fallback: boolean) => {+ const value = storage.get(key)++ return value === undefined ? fallback : value === 'true'+ },+ storedString: (key: string) => storage.get(key) ?? null+}))++// Import-safety stubs: updates.ts pulls these modules in at load time.+vi.mock('@/store/notifications', () => ({ notify: vi.fn(), dismissNotification: vi.fn() }))++// The real connections store drags in the profile/gateway-switch graph.+const { atom: registryAtom } = await import('nanostores')+const $mockConnectionsRegistry = registryAtom<unknown>(null)++vi.mock('@/store/connections', () => ({+ $connectionsRegistry: $mockConnectionsRegistry,+ refreshConnectionsRegistry: () => Promise.resolve($mockConnectionsRegistry.get())+}))++vi.mock('@/hermes', () => ({ checkHermesUpdate: vi.fn(), updateHermes: vi.fn(), getActionStatus: vi.fn() }))+vi.mock('@/store/gateway-reconnect', () => ({ reconnectGateway: vi.fn() }))++const { refreshDesktopVersion, $desktopVersion, startUpdatePoller, stopUpdatePoller } = await import('./updates')++const { setConnection } = await import('./session')++const setRemote = (on: boolean) =>+ setConnection({+ baseUrl: 'http://box:9119',+ isFullscreen: false,+ mode: on ? 'remote' : 'local',+ nativeOverlayWidth: 0,+ token: 't',+ wsUrl: 'ws://box:9119',+ logs: [],+ windowButtonPosition: null+ })++describe('desktop version follows the request scope', () => {+ let getVersion: ReturnType<typeof vi.fn>++ const info = (appVersion: string): DesktopVersionInfo =>+ ({ appVersion, electronVersion: '40', nodeVersion: '26', platform: 'linux', hermesRoot: '' }) as DesktopVersionInfo++ beforeEach(() => {+ setRemote(false)+ setApiRequestConnection(null)+ setApiRequestProfile(null)+ $desktopVersion.set(null)+ getVersion = vi.fn().mockResolvedValue(info('1.0.0'))+ // Same minimal window the startUpdatePoller suite installs (siblings delete it).+ ;(globalThis as unknown as { window: unknown }).window = {+ hermesDesktop: {+ getVersion,+ updates: { check: vi.fn().mockResolvedValue({ supported: false }), onProgress: vi.fn(() => () => {}) }+ },+ addEventListener: vi.fn(),+ removeEventListener: vi.fn()+ }+ stopUpdatePoller()+ })++ afterEach(() => {+ stopUpdatePoller()+ delete (globalThis as unknown as { window?: unknown }).window+ setApiRequestConnection(null)+ setApiRequestProfile(null)+ $desktopVersion.set(null)+ })++ it('re-fetches when switching from a remote connection back to local', async () => {+ setRemote(true)+ setApiRequestConnection('remote-box')+ startUpdatePoller()+ await vi.waitFor(() => expect(getVersion).toHaveBeenCalled())+ getVersion.mockClear()+ getVersion.mockResolvedValue(info('0.22.1+72'))++ setApiRequestConnection('local')+ setRemote(false)++ await vi.waitFor(() => expect(getVersion).toHaveBeenCalledWith(expect.objectContaining({ connectionId: 'local' })))+ await vi.waitFor(() => expect($desktopVersion.get()?.appVersion).toBe('0.22.1+72'))+ })++ it('re-fetches when only the profile changes on the same connection', async () => {+ setApiRequestConnection('remote-box')+ setRemote(true)+ startUpdatePoller()+ await vi.waitFor(() => expect(getVersion).toHaveBeenCalled())+ getVersion.mockClear()++ setApiRequestProfile('work')++ await vi.waitFor(() =>+ expect(getVersion).toHaveBeenCalledWith(expect.objectContaining({ connectionId: 'remote-box', profile: 'work' }))+ )+ })++ it('keeps the newest reply when two same-scope requests resolve out of order', async () => {+ setApiRequestConnection('remote-box')+ setRemote(true)++ let releaseOld: (value: DesktopVersionInfo) => void = () => {}+ getVersion.mockReset()+ getVersion+ .mockImplementationOnce(() => new Promise<DesktopVersionInfo>(resolve => (releaseOld = resolve)))+ .mockResolvedValueOnce(info('newer'))++ const older = refreshDesktopVersion()+ expect(await refreshDesktopVersion()).toEqual(info('newer'))++ releaseOld(info('older'))+ expect(await older).toBeNull()+ expect($desktopVersion.get()?.appVersion).toBe('newer')+ })++ it('drops a reply whose scope changed in flight even when nothing re-requests', async () => {+ setApiRequestConnection('remote-box')+ setRemote(true)++ let release: (value: DesktopVersionInfo) => void = () => {}+ getVersion.mockReset()+ getVersion.mockImplementationOnce(() => new Promise<DesktopVersionInfo>(resolve => (release = resolve)))++ const pending = refreshDesktopVersion()+ setApiRequestProfile('work')+ release(info('old-profile'))++ expect(await pending).toBeNull()+ expect($desktopVersion.get()).toBeNull()+ })++ it('ignores a slower reply from a request superseded by a profile switch', async () => {+ setApiRequestConnection('remote-box')+ setRemote(true)+ startUpdatePoller()+ await vi.waitFor(() => expect(getVersion).toHaveBeenCalled())++ let releaseOld: (value: DesktopVersionInfo) => void = () => {}+ getVersion.mockReset()+ getVersion+ .mockImplementationOnce(() => new Promise<DesktopVersionInfo>(resolve => (releaseOld = resolve)))+ .mockResolvedValue(info('new-profile'))++ const stale = refreshDesktopVersion()+ setApiRequestProfile('work')+ await vi.waitFor(() => expect($desktopVersion.get()?.appVersion).toBe('new-profile'))++ releaseOld(info('old-profile'))+ expect(await stale).toBeNull()+ expect($desktopVersion.get()?.appVersion).toBe('new-profile')+ })+})diff --git a/apps/desktop/src/store/updates.ts b/apps/desktop/src/store/updates.tsindex 4696e9a532b..2955d968290 100644--- a/apps/desktop/src/store/updates.ts+++ b/apps/desktop/src/store/updates.ts@@ -7,7 +7,7 @@ import { updateDebt } from '@hermes/shared'import { atom } from 'nanostores'import { CANONICAL_GATEWAY_PROTOCOL } from '@/api/canonical-protocol'-import { connectionScoped, profileScoped } from '@/api/client'+import { $apiRequestScope, connectionScoped, profileScoped } from '@/api/client'import type {DesktopUpdateApplyOptions,DesktopUpdateApplyResult,@@ -463,6 +463,17 @@ export function requestActiveUpdate(): void {openUpdateOverlayFor(target)}+// Only the newest getVersion may publish, and only while the request scope+// (connection + profile) is unchanged. A profile switch moves $apiRequestScope+// without replacing $connection, so the connection identity alone is not enough.+let versionRequestSeq = 0++function versionScopeKey(): string {+ const { connectionId, profile } = $apiRequestScope.get()++ return `${connectionKey($connection.get())}|${connectionId ?? ''}|${profile ?? ''}`+}+/** Refresh the active gateway version and the desktop's build metadata. */export async function refreshDesktopVersion(): Promise<DesktopVersionInfo | null> {if (typeof window === 'undefined') {@@ -475,10 +486,13 @@ export async function refreshDesktopVersion(): Promise<DesktopVersionInfo | null// mid-reload, or the bridge not yet ready on first paint) would surface// as an unhandled promise rejection in the renderer. Swallow it.try {- const connection = $connection.get()+ const seq = ++versionRequestSeq+ const scope = versionScopeKey()const next = await window.hermesDesktop?.getVersion?.({ ...connectionScoped(), ...profileScoped() })- if ($connection.get() !== connection) {+ // Superseded, or the scope moved while in flight: the scope listener has+ // already asked again for the new target.+ if (seq !== versionRequestSeq || versionScopeKey() !== scope) {return null}@@ -1308,6 +1322,8 @@ let pollerStarted = falselet backgroundTimer: ReturnType<typeof setInterval> | null = nulllet connectionUnsub: (() => void) | null = nulllet lastConnectionKey: string | undefined+let versionScopeUnsub: (() => void) | null = null+let lastVersionScopeKey: string | undefined// mode alone can't tell two remote backends apart — switching directly from// remote profile A to remote profile B leaves mode === 'remote' both times.@@ -1352,6 +1368,7 @@ export function startUpdatePoller(): void {pollerStarted = truerunPassiveChecks()+ lastVersionScopeKey = versionScopeKey()void refreshDesktopVersion()bridge.onProgress(ingestProgress)@@ -1373,6 +1390,27 @@ export function startUpdatePoller(): void {}})+ // The reported version belongs to the request scope, local or remote. Watch+ // both stores: a profile switch changes $apiRequestScope but not $connection.+ const onVersionScope = (): void => {+ const key = versionScopeKey()++ if (key === lastVersionScopeKey) {+ return+ }++ lastVersionScopeKey = key+ void refreshDesktopVersion()+ }++ const unsubScope = $apiRequestScope.listen(onVersionScope)+ const unsubConnection = $connection.listen(onVersionScope)++ versionScopeUnsub = () => {+ unsubScope()+ unsubConnection()+ }+window.addEventListener('focus', onFocus)backgroundTimer = setInterval(runPassiveChecks, BACKGROUND_UPDATE_CHECK_MS)}@@ -1385,7 +1423,11 @@ export function stopUpdatePoller(): void {connectionUnsub?.()connectionUnsub = null+ versionScopeUnsub?.()+ versionScopeUnsub = nulllastConnectionKey = undefined+ lastVersionScopeKey = undefined+ versionRequestSeq++window.removeEventListener('focus', onFocus)pollerStarted = false}