test(chat): #11471 regression coverage for error-path message_id + batch consume #2790
Reference in New Issue
Block a user
Delete Branch "fix/2759-rc3-11471-error-batch-consume"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to #2759 / #2776.
Researcher #11471 identified two completion-path gaps on the original #2759 implementation:
message_id. The current implementation already extractspayload.message_idand passes it toonSendComplete/onSendError; this PR adds regression tests proving token-specific error completion and fallback behavior whenmessage_idis absent.onSendComplete(m.messageId)for each; this PR adds a regression test proving a two-message batch completes both tokens.The #11470 safe no-messageId fallback (exact-one conservative) is already covered by existing
useChatSend.concurrentRepliestests and remains unchanged.Test plan
npx vitest run src/components/tabs/chat/hooks/__tests__/useChatSocket.test.tsx— 8/8 pass.npx vitest run src/components/tabs/chat— 340/340 pass.Refs #2759, Researcher #11471, CR2 #11470, CR2 #11466.
APPROVED on head
b1637193.This is test-only and the added cases are not tautological. The
ACTIVITY_LOGGEDerror test drives the actual socket handler branch withstatus: "error"and verifies bothonSendComplete(message_id)andonSendError(_, message_id), so it would catch a regression that drops message_id on the error path. The legacy no-messageId case explicitly omitsmessage_idand pins the coarse fallback argument asundefined.The batch-consume test is also meaningful: the mocked store now implements destructive
consumeAgentMessages, seeds two pending messages with distinctmessageIds, and verifies bothonAgentMessageandonSendCompletefire twice in order. That exercises the production loop over consumed messages, not just a mocked callback.No security or performance surface is changed. The mocking is scoped to the hook dependencies and does not hide the branches under review. CI/all-required is green on this head.
Post-merge audit on landed head
b16371930c0d3fc100f2c27702ee4435b31beb35(PR was already merged before my reviewer-2 pass completed): clean.I verified the change is test-only in
canvas/src/components/tabs/chat/hooks/__tests__/useChatSocket.test.tsxand the assertions are not tautological:status === "error"branch and verifiesmessage_idreaches bothonSendComplete("msg-a")andonSendError(..., "msg-a").message_idand pins the intendedundefinedfallback, preserving mixed-version behavior.consumeAgentMessages()implementation and seeds two distinctmessageIdvalues, proving the hook completes every consumed message rather than only the first.CI on the merged head was green for
CI / all-required,CI / Canvas (Next.js), andE2E Chat. No residual issue found.