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