The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop): cover stale gateway ref recovery
Joel4185428c2d4a
diff --git a/apps/desktop/src/app/gateway/hooks/use-gateway-request.test.ts b/apps/desktop/src/app/gateway/hooks/use-gateway-request.test.tsindex 32486daf495..b8aae689efb 100644--- a/apps/desktop/src/app/gateway/hooks/use-gateway-request.test.ts+++ b/apps/desktop/src/app/gateway/hooks/use-gateway-request.test.ts@@ -250,6 +250,24 @@ describe('useGatewayRequest', () => {expect(result.current.gateway).toBe(fakeGateway)})+ it('recovers when the gateway ref is stale but the active gateway is still open', async () => {+ const primary = makePrimaryGateway()+ primary.request.mockRejectedValueOnce(new Error('connection closed')).mockResolvedValueOnce({ recovered: true })++ setPrimaryGateway(primary as unknown as HermesGateway, 'default')+ $gateway.set(primary as unknown as HermesGateway)+ $gatewayState.set('open')++ const { result } = renderHook(() => useGatewayRequest())+ result.current.gatewayRef.current = null++ await act(async () => {+ await expect(result.current.requestGateway('session.resume')).resolves.toEqual({ recovered: true })+ })++ expect(primary.request).toHaveBeenCalledTimes(2)+ })+it.each([{ error: new Error('connection closed'), label: 'closed message' },{ error: new Error('ECONNRESET'), label: 'reset message' },