The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(service): update chat service tests for core rpc responses
Steven Enamakelf6b3974f9566
diff --git a/app/src/services/__tests__/chatService.test.ts b/app/src/services/__tests__/chatService.test.tsindex 57da923cb9..80512c950a 100644--- a/app/src/services/__tests__/chatService.test.ts+++ b/app/src/services/__tests__/chatService.test.ts@@ -406,13 +406,16 @@ describe('chatService.subscribeChatEvents', () => {bindMockSocket(socket);const attachments = [{ kind: 'image', media: { opaqueId: 'opaque-1' } }];mockCallCoreRpc.mockResolvedValue({- queued: true,- queue_mode: 'followup',- client_id: 'socket-1',- thread_id: 'thread-1',- request_id: 'request-1',- queue_depth: 1,- queued_attachments: attachments,+ result: {+ queued: true,+ queue_mode: 'followup',+ client_id: 'socket-1',+ thread_id: 'thread-1',+ request_id: 'request-1',+ queue_depth: 1,+ queued_attachments: attachments,+ },+ logs: ['accepted'],});await expect(@@ -424,10 +427,13 @@ describe('chatService.subscribeChatEvents', () => {const socket = createMockSocket();bindMockSocket(socket);mockCallCoreRpc.mockResolvedValue({- accepted: true,- client_id: 'socket-1',- thread_id: 'thread-1',- request_id: 'request-started',+ result: {+ accepted: true,+ client_id: 'socket-1',+ thread_id: 'thread-1',+ request_id: 'request-started',+ },+ logs: ['web channel request accepted'],});await expect(chatSendWithAck({ threadId: 'thread-1', message: 'hello' })).resolves.toEqual({@@ -450,6 +456,13 @@ describe('chatService.subscribeChatEvents', () => {it.each([{ accepted: false, client_id: 'socket-1', thread_id: 'thread-1', request_id: 'request-1' },{ accepted: true, client_id: 'socket-1', thread_id: 'thread-1', request_id: 42 },+ {+ accepted: true,+ queued: true,+ client_id: 'socket-1',+ thread_id: 'thread-1',+ request_id: 'request-1',+ },])('rejects malformed started-turn acknowledgements', async response => {const socket = createMockSocket();bindMockSocket(socket);diff --git a/app/src/services/chatService.ts b/app/src/services/chatService.tsindex 9742250611..99bb8a1065 100644--- a/app/src/services/chatService.ts+++ b/app/src/services/chatService.ts@@ -1010,12 +1010,12 @@ function isStartedChatAck(value: unknown): value is StartedChatAck {}function unwrapChatAck(value: unknown): unknown {- for (let depth = 0; depth < 4 && isRecord(value); depth += 1) {- if (Object.hasOwn(value, 'error')) {- throw new Error('Core returned an error while accepting the chat message');- }- if (!Object.hasOwn(value, 'result') && !Object.hasOwn(value, 'data')) break;- value = Object.hasOwn(value, 'result') ? value.result : value.data;+ if (+ isRecord(value) &&+ Object.hasOwn(value, 'result') &&+ Array.isArray(value.logs)+ ) {+ return value.result;}return value;}