fix: voice messages show as compact pill instead of file attachment chip

Audio-only user messages (no text, only audio attachments) now render as
a clean "🎤 Sprachnachricht" pill instead of the ugly filename chip
(voice_1782170416740.m4a). Detects via attachments.all { kind == "audio" }
&& content.isBlank(). Regular file attachments are unaffected.
This commit is contained in:
Bruno Deanoz 2026-06-23 01:24:56 +02:00
parent fb6bc981d1
commit 1899f2cff1
3 changed files with 26 additions and 6 deletions

View file

@ -489,6 +489,8 @@ fun MessageRow(
) )
} }
val isVoiceOnly = hasAttachments && message.content.isBlank() && message.attachments.all { it.kind == "audio" }
Box( Box(
Modifier Modifier
.widthIn(max = 300.dp) .widthIn(max = 300.dp)
@ -499,12 +501,28 @@ fun MessageRow(
.border(1.2.dp, borderBrush, shape), .border(1.2.dp, borderBrush, shape),
) { ) {
Column { Column {
if (hasAttachments) AttachmentGrid(message.attachments, Modifier.padding(6.dp)) if (isVoiceOnly) {
if (message.content.isNotBlank()) { Row(
Text( Modifier.padding(horizontal = 16.dp, vertical = 12.dp),
message.content, color = cs.onBackground, fontSize = 16.sp, lineHeight = 26.sp, verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = if (hasAttachments) 4.dp else 13.dp, bottom = 13.dp), ) {
) Icon(KaizenIcons.Mic, null, tint = accent.primary.copy(alpha = 0.7f), modifier = Modifier.size(18.dp))
Spacer(Modifier.width(8.dp))
Text(
stringResource(R.string.chat_voice_message),
color = cs.onBackground.copy(alpha = 0.70f),
fontSize = 14.sp,
fontWeight = FontWeight.Medium,
)
}
} else {
if (hasAttachments) AttachmentGrid(message.attachments, Modifier.padding(6.dp))
if (message.content.isNotBlank()) {
Text(
message.content, color = cs.onBackground, fontSize = 16.sp, lineHeight = 26.sp,
modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = if (hasAttachments) 4.dp else 13.dp, bottom = 13.dp),
)
}
} }
} }
} }

View file

@ -20,6 +20,7 @@
<string name="chat_open_menu">Open menu</string> <string name="chat_open_menu">Open menu</string>
<string name="chat_stop">Stop response</string> <string name="chat_stop">Stop response</string>
<string name="chat_recording">Recording …</string> <string name="chat_recording">Recording …</string>
<string name="chat_voice_message">Voice message</string>
<string name="chat_mic_permission">Microphone access required</string> <string name="chat_mic_permission">Microphone access required</string>
<string name="chat_read_aloud">Read aloud</string> <string name="chat_read_aloud">Read aloud</string>
<string name="chat_tts_error">Read aloud failed</string> <string name="chat_tts_error">Read aloud failed</string>

View file

@ -22,6 +22,7 @@
<string name="chat_open_menu">Menü öffnen</string> <string name="chat_open_menu">Menü öffnen</string>
<string name="chat_stop">Antwort stoppen</string> <string name="chat_stop">Antwort stoppen</string>
<string name="chat_recording">Aufnahme läuft …</string> <string name="chat_recording">Aufnahme läuft …</string>
<string name="chat_voice_message">Sprachnachricht</string>
<string name="chat_mic_permission">Mikrofonzugriff wird benötigt</string> <string name="chat_mic_permission">Mikrofonzugriff wird benötigt</string>
<string name="chat_read_aloud">Vorlesen</string> <string name="chat_read_aloud">Vorlesen</string>
<string name="chat_tts_error">Vorlesen fehlgeschlagen</string> <string name="chat_tts_error">Vorlesen fehlgeschlagen</string>