The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): compress settle resumes under the caller's timeout and signal
Teknium14f5fb8a29bd
diff --git a/apps/desktop/src/api/canonical-protocol-wire.test.ts b/apps/desktop/src/api/canonical-protocol-wire.test.tsindex d2a7cdb636d..53d9e199cb5 100644--- a/apps/desktop/src/api/canonical-protocol-wire.test.ts+++ b/apps/desktop/src/api/canonical-protocol-wire.test.ts@@ -1,5 +1,5 @@// @vitest-environment node-import { expect, test } from 'vitest'+import { expect, test, vi } from 'vitest'import { HermesGateway } from './client'@@ -70,3 +70,31 @@ test('a legacy (non-canonical) dial strips canonical-only identity keys the servawait new Promise<void>(resolve => server.close(() => resolve()))}})++test('a compress settle resumes under the caller\'s original timeout and abort signal', async () => {+ // R4: the follow-up `session.resume` must not fall back to the default 120 s deadline+ // and ignore the caller's AbortSignal (a cancelled compress would otherwise hang).+ const { JsonRpcGatewayClient } = await import('@hermes/shared')+ const wire: Array<[string, unknown, AbortSignal | undefined]> = []++ const spy = vi.spyOn(JsonRpcGatewayClient.prototype, 'request').mockImplementation(async function (method: string, _params?: unknown, timeoutMs?: number, signal?: AbortSignal) {+ wire.push([method, timeoutMs, signal])++ return (method === 'session.mutate'+ ? { session_id: 's', revision: 5, operation: 'compress', target_session_id: 's', message_count: 2 }+ : { session_id: 's', revision: 4, execution_generation: 1, messages: [] }) as never+ })++ const client = new HermesGateway()+ Object.assign(client, { canonical: true })++ try {+ await client.request('session.resume', { session_id: 's' })+ const controller = new AbortController()+ await client.request('session.compress', { session_id: 's' }, 7_000, controller.signal)+ expect(wire.slice(1).map(([method, timeoutMs]) => [method, timeoutMs])).toEqual([['session.mutate', 7_000], ['session.resume', 7_000]])+ expect(wire[2][2]).toBe(controller.signal)+ } finally {+ spy.mockRestore()+ }+})diff --git a/apps/desktop/src/api/client.ts b/apps/desktop/src/api/client.tsindex 4eecf325988..b0b9c043333 100644--- a/apps/desktop/src/api/client.ts+++ b/apps/desktop/src/api/client.ts@@ -176,7 +176,9 @@ export class HermesGateway extends JsonRpcGatewayClient {try {const result = await super.request<T>(wireMethod, prepared, timeoutMs, signal)- const settled = this.protocol.settle(method, prepared, this.protocol.result(method, prepared, result), (m, p) => this.request(m, p)) as T+ // A settle follow-up (compress -> resume) inherits the caller's deadline and cancellation.+ const followUp = (m: string, p: Record<string, unknown>) => this.request(m, p, timeoutMs, signal)+ const settled = this.protocol.settle(method, prepared, this.protocol.result(method, prepared, result), followUp) as Tif (method === 'session.resume' || method === 'session.create' || method === 'session.activate') {// Prompts still open on the authority re-deliver like `open_requests` after a reconnect.