Skip to content

The agent that grows with you

fix(desktop): isolate the poll-guard reset import + sort-imports lint

Teknium62534e2b5ac6
diff --git a/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsx b/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsx
index 627dcd3bc8b..135804bc8b5 100644
--- a/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsx
+++ b/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsx
@@ -371,6 +371,7 @@ describe('ConnectionSwitcher', () => {
// snapshot.
it('repaints the menu after a connections.save without reload (#95393)', async () => {
const before = registry([connection('local', 'This device', 'local'), connection('homelab', 'Homelab')])
+
const after = registry([
connection('local', 'This device', 'local'),
connection('homelab', 'Homelab'),
diff --git a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts
index 8aafeae3eeb..9e546d5ac99 100644
--- a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts
+++ b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts
@@ -7,7 +7,7 @@ import { HermesGateway } from '@/hermes'
import { translateNow } from '@/i18n'
import { desktopDefaultCwd } from '@/lib/desktop-fs'
import { reconnectBackoffDelayMs } from '@/lib/reconnect-backoff'
-import { withTimeout, BACKEND_BOOT_WAIT_TIMEOUT_MS } from '@/lib/with-timeout'
+import { BACKEND_BOOT_WAIT_TIMEOUT_MS, withTimeout } from '@/lib/with-timeout'
import {
$desktopBoot,
applyDesktopBootProgress,
diff --git a/apps/desktop/src/store/composer-status.test.ts b/apps/desktop/src/store/composer-status.test.ts
index f85c3ff7c41..d47103b0cbe 100644
--- a/apps/desktop/src/store/composer-status.test.ts
+++ b/apps/desktop/src/store/composer-status.test.ts
@@ -1,6 +1,5 @@
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-
import { JsonRpcGatewayError } from '@hermes/shared'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import {
$backgroundStatusBySession,
diff --git a/apps/desktop/src/store/composer-status.ts b/apps/desktop/src/store/composer-status.ts
index 6960f19230c..d93263cc5a7 100644
--- a/apps/desktop/src/store/composer-status.ts
+++ b/apps/desktop/src/store/composer-status.ts
@@ -1,6 +1,5 @@
-import { atom, computed } from 'nanostores'
-
import { JsonRpcGatewayError } from '@hermes/shared'
+import { atom, computed } from 'nanostores'
import { translateNow } from '@/i18n'
import { stableArray } from '@/lib/stable-array'
diff --git a/apps/desktop/src/store/connections.ts b/apps/desktop/src/store/connections.ts
index af4baa05f42..30ad08546e7 100644
--- a/apps/desktop/src/store/connections.ts
+++ b/apps/desktop/src/store/connections.ts
@@ -2,7 +2,7 @@ import { atom, computed } from 'nanostores'
import type { DesktopConnectionsRegistry } from '@/global'
import { persistStringRecord, storedStringRecord } from '@/lib/storage'
-import { isTimeoutError, withTimeout, BACKEND_BOOT_WAIT_TIMEOUT_MS } from '@/lib/with-timeout'
+import { BACKEND_BOOT_WAIT_TIMEOUT_MS, isTimeoutError, withTimeout } from '@/lib/with-timeout'
import { $connectionsRegistry } from '@/store/connection-registry-state'
import {
beginGatewaySwitch,
diff --git a/apps/desktop/src/store/gateway.ts b/apps/desktop/src/store/gateway.ts
index 570eaba70ff..6789df85d08 100644
--- a/apps/desktop/src/store/gateway.ts
+++ b/apps/desktop/src/store/gateway.ts
@@ -450,20 +450,28 @@ async function openSecondary(entry: Secondary): Promise<void> {
if (reopening) {
try {
const { reconcileBusyStatesOnReconnect, resetTileRuntimeBindings } = await import('@/store/session-states')
- const { resetBackgroundPollingGuard } = await import('@/store/composer-status')
resetTileRuntimeBindings({
connectionId: entry.connectionId || 'local',
profile: entry.profile
})
- // Runtime re-mint also invalidates the status-stack gone-latch: ids
- // the dead runtime 4001'd may be live again once tiles re-resume.
- resetBackgroundPollingGuard()
reconcileBusyAfterOpen = () => reconcileBusyStatesOnReconnect(entry.scope)
} catch {
// Best effort for partial test/HMR graphs. Production always loads the
// real store; a failed import must not make the transport unrecoverable.
}
+
+ try {
+ // Runtime re-mint also invalidates the status-stack gone-latch: ids
+ // the dead runtime 4001'd may be live again once tiles re-resume.
+ // Separate try: tests that mock only session-states must not lose the
+ // rebinding wiring to a failed composer-status import (and vice versa).
+ const { resetBackgroundPollingGuard } = await import('@/store/composer-status')
+
+ resetBackgroundPollingGuard()
+ } catch {
+ // Same best-effort contract as above.
+ }
}
// Registry-scoped entries dial through getConnectionFor when the bridge has