From f831ccfc631c35d5550b7252cae49d120427bac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Jim=C3=A9nez=20Torres?= Date: Tue, 30 Dec 2025 11:42:55 +0100 Subject: [PATCH] fix(android): wrong text color in user chat bubbles --- .../clawdis/node/ui/chat/ChatMarkdown.kt | 5 +++-- .../clawdis/node/ui/chat/ChatMessageViews.kt | 20 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/apps/android/app/src/main/java/com/steipete/clawdis/node/ui/chat/ChatMarkdown.kt b/apps/android/app/src/main/java/com/steipete/clawdis/node/ui/chat/ChatMarkdown.kt index a11237a93..75dd3b10c 100644 --- a/apps/android/app/src/main/java/com/steipete/clawdis/node/ui/chat/ChatMarkdown.kt +++ b/apps/android/app/src/main/java/com/steipete/clawdis/node/ui/chat/ChatMarkdown.kt @@ -17,6 +17,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.text.AnnotatedString @@ -31,7 +32,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @Composable -fun ChatMarkdown(text: String) { +fun ChatMarkdown(text: String, textColor: Color) { val blocks = remember(text) { splitMarkdown(text) } val inlineCodeBg = MaterialTheme.colorScheme.surfaceContainerLow @@ -44,7 +45,7 @@ fun ChatMarkdown(text: String) { Text( text = parseInlineMarkdown(trimmed, inlineCodeBg = inlineCodeBg), style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.onSurface, + color = textColor, ) } is ChatMarkdownBlock.Code -> { diff --git a/apps/android/app/src/main/java/com/steipete/clawdis/node/ui/chat/ChatMessageViews.kt b/apps/android/app/src/main/java/com/steipete/clawdis/node/ui/chat/ChatMessageViews.kt index d7a99e8e2..435bacbdc 100644 --- a/apps/android/app/src/main/java/com/steipete/clawdis/node/ui/chat/ChatMessageViews.kt +++ b/apps/android/app/src/main/java/com/steipete/clawdis/node/ui/chat/ChatMessageViews.kt @@ -7,11 +7,9 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.MaterialTheme @@ -60,20 +58,21 @@ fun ChatMessageBubble(message: ChatMessage) { .background(bubbleBackground(isUser)) .padding(horizontal = 12.dp, vertical = 10.dp), ) { - ChatMessageBody(content = message.content) + val textColor = textColorOverBubble(isUser) + ChatMessageBody(content = message.content, textColor = textColor) } } } } @Composable -private fun ChatMessageBody(content: List) { +private fun ChatMessageBody(content: List, textColor: Color) { Column(verticalArrangement = Arrangement.spacedBy(10.dp)) { for (part in content) { when (part.type) { "text" -> { val text = part.text ?: continue - ChatMarkdown(text = text) + ChatMarkdown(text = text, textColor = textColor) } else -> { val b64 = part.base64 ?: continue @@ -131,7 +130,7 @@ fun ChatStreamingAssistantBubble(text: String) { color = MaterialTheme.colorScheme.surfaceContainer, ) { Box(modifier = Modifier.padding(horizontal = 12.dp, vertical = 10.dp)) { - ChatMarkdown(text = text) + ChatMarkdown(text = text, textColor = MaterialTheme.colorScheme.onSurface) } } } @@ -150,6 +149,15 @@ private fun bubbleBackground(isUser: Boolean): Brush { } } +@Composable +private fun textColorOverBubble(isUser: Boolean): Color { + return if (isUser) { + MaterialTheme.colorScheme.onPrimary + } else { + MaterialTheme.colorScheme.onSurface + } +} + @Composable private fun ChatBase64Image(base64: String, mimeType: String?) { var image by remember(base64) { mutableStateOf(null) }