fix(core): correlate AI voice send receipts

Wait for the canonical self group-message event after AI voice synthesis instead of interpreting undocumented response fields as a message sequence.

Correlate receipts by exact media UUID, buffer response races, and claim each semantic message identity only once across concurrent calls and duplicate multi-process pushes. Reject missing identifiers, invalid sequences, bounded-buffer overflow, and receipt timeouts with explicit diagnostics.

Keep fetchAiVoice focused on returning the media node and add regression coverage for race ordering, unrelated events, identical concurrent audio, duplicate pushes, malformed receipts, and timeout cleanup.

Fixes #250
This commit is contained in:
DrSmoothl committed 2026-07-20 14:02:48 +08:00
1 parent 06c26dee87
commit 297f0428cc
3 files changed
+328 -9

No files matched your search

@@ -33,11 +33,13 @@ describe('FetchAiVoice namespace', () => {
});
describe('deserialize', () => {
it('returns the first msgInfoBody index when present', () => {
it('returns the first msgInfoBody index', () => {
const node = { fileUuid: 'uuid', subType: 1 };
expect(FetchAiVoice.deserialize({} as any, {
field2: 319,
field3: 20,
msgInfo: { msgInfoBody: [{ index: node }] },
} as any)).toMatchObject(node);
} as any)).toEqual(node);
});
it('returns null when msgInfo is empty / missing', () => {
@@ -54,9 +56,13 @@ describe('FetchAiVoice namespace', () => {
expect(sender.sendRawPacket.mock.calls[0]![0]).toBe('OidbSvcTrpcTcp.0x929b_0');
});
it('returns the parsed index node', async () => {
it('returns the parsed media node', async () => {
const node = { fileUuid: 'uuid', subType: 1 };
const sender = makeSender({ msgInfo: { msgInfoBody: [{ index: node }] } } as any);
const sender = makeSender({
field2: 319,
field3: 20,
msgInfo: { msgInfoBody: [{ index: node }] },
} as any);
const out = await FetchAiVoice.invoke(sender, { groupId: 1, voiceId: 'v', text: 't', chatType: 1, sessionId: 1 });
expect(out).toMatchObject(node);
});