The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): give pooled remote dispatch probes the cold-start liveness budget
KoNit-K8ab08968f48d
diff --git a/apps/desktop/electron/remote-liveness.test.ts b/apps/desktop/electron/remote-liveness.test.tsindex 357902e2ed6..454274f9b6b 100644--- a/apps/desktop/electron/remote-liveness.test.ts+++ b/apps/desktop/electron/remote-liveness.test.ts@@ -3,6 +3,7 @@ import { describe, expect, it, vi } from 'vitest'import {ensureHealthyPooledRemoteBackendForDispatch,POOLED_REMOTE_DISPATCH_PROBE_TIMEOUT_MS,+ POWER_RESUME_REVALIDATION_HOLDOFF_MS,REMOTE_LIVENESS_FAILURE_LIMIT,REMOTE_LIVENESS_FAILURE_WINDOW_MS,REMOTE_LIVENESS_TIMEOUT_MS,@@ -260,6 +261,36 @@ describe('revalidateRemoteConnection', () => {})describe('ensureHealthyPooledRemoteBackendForDispatch', () => {+ it('covers quiet-box cold-start and stays below the power-resume holdoff', () => {+ expect(POOLED_REMOTE_DISPATCH_PROBE_TIMEOUT_MS).toBeGreaterThanOrEqual(REMOTE_LIVENESS_TIMEOUT_MS)+ expect(POOLED_REMOTE_DISPATCH_PROBE_TIMEOUT_MS).toBeGreaterThanOrEqual(8_000)+ expect(POWER_RESUME_REVALIDATION_HOLDOFF_MS).toBeGreaterThan(POOLED_REMOTE_DISPATCH_PROBE_TIMEOUT_MS)+ })++ it('returns a healthy cached descriptor without retiring or reconnecting', async () => {+ const healthy = { baseUrl: 'http://127.0.0.1:49525', mode: 'remote' }+ const connectionPromise = Promise.resolve(healthy)+ const retire = vi.fn()+ const reconnect = vi.fn()+ const probe = vi.fn().mockResolvedValue({ ok: true })++ await expect(+ ensureHealthyPooledRemoteBackendForDispatch({+ connectionPromise,+ currentConnectionPromise: () => connectionPromise,+ probe,+ reconnect,+ retire+ })+ ).resolves.toBe(healthy)++ expect(probe).toHaveBeenCalledWith(healthy, '/api/status', {+ timeoutMs: POOLED_REMOTE_DISPATCH_PROBE_TIMEOUT_MS+ })+ expect(retire).not.toHaveBeenCalled()+ expect(reconnect).not.toHaveBeenCalled()+ })+it('retires a dead cached descriptor and gives dispatch the replacement', async () => {const stale = { baseUrl: 'http://127.0.0.1:49525', mode: 'remote' }const replacement = { baseUrl: 'http://127.0.0.1:53968', mode: 'remote' }diff --git a/apps/desktop/electron/remote-liveness.ts b/apps/desktop/electron/remote-liveness.tsindex 91ad9959595..4a65b184ba2 100644--- a/apps/desktop/electron/remote-liveness.ts+++ b/apps/desktop/electron/remote-liveness.ts@@ -1,9 +1,9 @@export const REMOTE_LIVENESS_TIMEOUT_MS = 10_000// Dispatch is synchronous user intent: a cached descriptor must prove its-// forwarded endpoint is alive before it can be returned. Keep this probe much-// shorter than the background liveness budget so a dead tunnel reconnects-// promptly instead of making the click feel hung.-export const POOLED_REMOTE_DISPATCH_PROBE_TIMEOUT_MS = 2_500+// forwarded endpoint is alive before it can be returned. Reuse the background+// liveness budget so a quiet-box cold-start (~6-8s) can finish instead of+// failing the probe and kicking off a reconnect storm.+export const POOLED_REMOTE_DISPATCH_PROBE_TIMEOUT_MS = REMOTE_LIVENESS_TIMEOUT_MSexport const REMOTE_LIVENESS_FAILURE_LIMIT = 3// Even at the capped retry path, consecutive liveness observations are at most// about 48s apart (ticket mint + socket open + backoff + the next status probe).