Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(chatService): add test for invalid queue acknowledgement

Steven Enamakeld092a6124994
diff --git a/app/src/services/__tests__/chatService.test.ts b/app/src/services/__tests__/chatService.test.ts
index 3bbba663ab..9633bc1796 100644
--- a/app/src/services/__tests__/chatService.test.ts
+++ b/app/src/services/__tests__/chatService.test.ts
@@ -406,7 +406,12 @@ 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,
});
@@ -415,6 +420,16 @@ describe('chatService.subscribeChatEvents', () => {
).resolves.toEqual({ requestId: 'request-1', queuedAttachments: attachments });
});
+ it('rejects an invalid queue acknowledgement instead of trusting raw RPC data', async () => {
+ const socket = createMockSocket();
+ bindMockSocket(socket);
+ mockCallCoreRpc.mockResolvedValue({ request_id: 'request-1', queued_attachments: [] });
+
+ await expect(
+ chatSendWithAck({ threadId: 'thread-1', message: '', queueMode: 'followup' })
+ ).rejects.toThrow('invalid chat queue acknowledgement');
+ });
+
it('forwards speak_reply, source, session_id when provided', async () => {
const socket = createMockSocket();
bindMockSocket(socket);