The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): questions raised before a viewer attached now appear on open
Tekniumf08bdf739ae5
diff --git a/apps/desktop/src/api/canonical-attach-snapshot.test.ts b/apps/desktop/src/api/canonical-attach-snapshot.test.tsnew file mode 100644index 00000000000..a4644b6dd90--- /dev/null+++ b/apps/desktop/src/api/canonical-attach-snapshot.test.ts@@ -0,0 +1,45 @@+// @vitest-environment node+import { expect, test } from 'vitest'++import { HermesGateway } from './client'++// R6: a clarification raised before this viewer attached arrives only in the resume snapshot.+// The attach must deliver it to the question card and mark the session attached, so the+// answer goes straight out without another resume.+test('a cold attach delivers the snapshot prompt and marks the session attached', async () => {+ const wsPackage = 'ws'+ const { WebSocketServer } = await import(wsPackage)+ const server = new WebSocketServer({ host: '127.0.0.1', port: 0 })+ await new Promise<void>(resolve => server.once('listening', resolve))+ const sent: any[] = []+ server.on('connection', (socket: any) => {+ socket.on('message', (bytes: Buffer) => {+ const frame = JSON.parse(bytes.toString())+ sent.push(frame)+ const result = frame.method === 'session.resume'+ ? { session_id: 's', stored_session_id: 's', revision: 2, execution_generation: 5, running: true, messages: [],+ prompts: [{ kind: 'clarify', prompt_id: 'c1', execution_generation: 5, question: 'Which target?', choices: [] }] }+ : { status: 'resolved' }+ socket.send(JSON.stringify({ jsonrpc: '2.0', id: frame.id, result }))+ })+ })+ const client = new HermesGateway()+ const delivered: any[] = []+ client.onRequest(request => { delivered.push(request) })++ try {+ const address = server.address() as { port: number }+ await client.connect(`ws://127.0.0.1:${address.port}/api/ws?native_dial=fixture&ticket=one-use`)+ await client.request('session.resume', { session_id: 's' })+ expect(delivered.map(request => [request.method, request.id, request.replayed])).toEqual([['clarify', 'c1', true]])++ sent.length = 0+ await client.request('clarify.lock', { request_id: 'c1', question_id: 'c1', answer: 'prod' })+ expect(sent.map(frame => frame.method)).toEqual(['clarify.respond'])+ } finally {+ client.close()++ for (const socket of server.clients) { socket.terminate() }+ await new Promise<void>(resolve => server.close(() => resolve()))+ }+})diff --git a/apps/desktop/src/api/client.ts b/apps/desktop/src/api/client.tsindex 8df4e5fc668..72fc701e79c 100644--- a/apps/desktop/src/api/client.ts+++ b/apps/desktop/src/api/client.ts@@ -169,7 +169,7 @@ export class HermesGateway extends JsonRpcGatewayClient {// 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 T+ const settled = await this.protocol.settle(method, prepared, this.protocol.result(method, prepared, result), followUp) as Tif (method === 'session.resume' || method === 'session.create' || method === 'session.activate') {this.adoptAttachedSnapshot(settled as { session_id?: string; prompts?: Array<Record<string, unknown>> })