| .. | .. |
|---|
| 1017 | 1017 | <String, dynamic>{'data': b64, 'mimeType': 'image/jpeg'} |
|---|
| 1018 | 1018 | ).toList(); |
|---|
| 1019 | 1019 | |
|---|
| 1020 | + // Create the first image message early so we have its ID for transcript reflection |
|---|
| 1021 | + final firstImageMsg = Message.image( |
|---|
| 1022 | + role: MessageRole.user, |
|---|
| 1023 | + imageBase64: encodedImages[0], |
|---|
| 1024 | + content: textCaption.isNotEmpty ? textCaption : (voiceB64 != null ? '🎤 ...' : ''), |
|---|
| 1025 | + status: MessageStatus.sent, |
|---|
| 1026 | + ); |
|---|
| 1027 | + |
|---|
| 1020 | 1028 | // Send everything as a single atomic bundle |
|---|
| 1021 | 1029 | _ws?.send({ |
|---|
| 1022 | 1030 | 'type': 'bundle', |
|---|
| 1023 | 1031 | 'caption': textCaption, |
|---|
| 1024 | 1032 | if (voiceB64 != null) 'audioBase64': voiceB64, |
|---|
| 1033 | + if (voiceB64 != null) 'voiceMessageId': firstImageMsg.id, |
|---|
| 1025 | 1034 | 'attachments': attachments, |
|---|
| 1026 | 1035 | 'sessionId': targetSessionId, |
|---|
| 1027 | 1036 | }); |
|---|
| 1028 | 1037 | |
|---|
| 1029 | | - // Show as combined image+caption bubbles (voice caption shows as text under image) |
|---|
| 1030 | | - final voiceLabel = voiceB64 != null ? '🎤 Voice caption' : ''; |
|---|
| 1031 | | - for (var i = 0; i < encodedImages.length; i++) { |
|---|
| 1032 | | - final captionText = i == 0 |
|---|
| 1033 | | - ? (textCaption.isNotEmpty ? textCaption : voiceLabel) |
|---|
| 1034 | | - : ''; |
|---|
| 1038 | + // Show as combined image+caption bubbles |
|---|
| 1039 | + ref.read(messagesProvider.notifier).addMessage(firstImageMsg); |
|---|
| 1040 | + for (var i = 1; i < encodedImages.length; i++) { |
|---|
| 1035 | 1041 | final message = Message.image( |
|---|
| 1036 | 1042 | role: MessageRole.user, |
|---|
| 1037 | 1043 | imageBase64: encodedImages[i], |
|---|
| 1038 | | - content: captionText, |
|---|
| 1044 | + content: '', |
|---|
| 1039 | 1045 | status: MessageStatus.sent, |
|---|
| 1040 | 1046 | ); |
|---|
| 1041 | 1047 | ref.read(messagesProvider.notifier).addMessage(message); |
|---|