fix(app-expo): allow read-aloud on other split segments while TTS paused

Match playback refs to the correct assistant segment so the interrupt overlay
does not block other bubbles, and preempt local playback when switching segments.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Kevin
2026-05-19 14:55:10 +08:00
parent b22f1cd4c4
commit 3921c5ec24
4 changed files with 114 additions and 43 deletions

View File

@@ -2,6 +2,8 @@ import {
assistantSegmentMessageId,
lastSegmentPreview,
normalizeAssistantContentForSplit,
parseAssistantSplitListKey,
playbackListKeyMatchesBubble,
splitMessageParts,
splitStreamingSegments,
} from '@/features/conversation/message-split';
@@ -75,6 +77,28 @@ describe('message-split', () => {
expect(assistantSegmentMessageId('uuid-a', 1)).toBe('uuid-a_seg_1');
});
it('playbackListKeyMatchesBubble aligns seg playback with part listKey', () => {
const uuid = '78b32c06-d2f9-453b-9cc4-354e68fbcb2d';
expect(
playbackListKeyMatchesBubble(
`${uuid}_seg_1`,
`${uuid}_part_1`,
uuid,
),
).toBe(true);
expect(
playbackListKeyMatchesBubble(
`${uuid}_seg_0`,
`${uuid}_part_1`,
uuid,
),
).toBe(false);
expect(parseAssistantSplitListKey(`${uuid}_part_0`)).toEqual({
messageId: uuid,
segmentIndex: 0,
});
});
it('normalizeAssistantContentForSplit maps fullwidth brackets', () => {
expect(normalizeAssistantContentForSplit('x')).toBe('[x]');
expect(normalizeAssistantContentForSplit('【x】')).toBe('[x]');