fix(#728): resolve theme color leakage for agent chat bubbles (#730)

Use MaterialTheme.colorScheme tokens for Assistant, System, and Tool bubbles so that all presets and dynamic colors render properly without theme bleed.
This commit is contained in:
M57 authored and GitHub committed 2026-07-27 15:42:57 +03:00
1 parent f45a68b0db
commit c7f7d1dd45
2 files changed
+5 -23

No files matched your search

@@ -75,7 +75,7 @@ val StatusGrey = Color(0xFF9E9E9E)
val StatusGreyDark = Color(0xFF1A1A24) val StatusGreyDark = Color(0xFF1A1A24)
val StatusGreyLight = Color(0xFFF5F5F5) val StatusGreyLight = Color(0xFFF5F5F5)
// ── Chat-specific colours (always brand-defined for consistency) ─────── // ── Chat-specific colours (default theme fallback tokens) ─────────────────
val AssistantBubble = Color(0xFF1C1C26) val AssistantBubble = Color(0xFF1C1C26)
val AssistantBubbleLight = Color(0xFFEDEAF4) val AssistantBubbleLight = Color(0xFFEDEAF4)
@@ -82,15 +82,10 @@ import coil.compose.AsyncImage
import com.m57.hermescontrol.R import com.m57.hermescontrol.R
import com.m57.hermescontrol.data.model.Attachment import com.m57.hermescontrol.data.model.Attachment
import com.m57.hermescontrol.data.remote.OkHttpProvider import com.m57.hermescontrol.data.remote.OkHttpProvider
import com.m57.hermescontrol.theme.AssistantBubble
import com.m57.hermescontrol.theme.AssistantBubbleLight
import com.m57.hermescontrol.theme.DarkOnSurface import com.m57.hermescontrol.theme.DarkOnSurface
import com.m57.hermescontrol.theme.HermesStatusColors import com.m57.hermescontrol.theme.HermesStatusColors
import com.m57.hermescontrol.theme.LightOnSurface import com.m57.hermescontrol.theme.LightOnSurface
import com.m57.hermescontrol.theme.LocalHermesStatusColors import com.m57.hermescontrol.theme.LocalHermesStatusColors
import com.m57.hermescontrol.theme.SystemMessageColor
import com.m57.hermescontrol.theme.ToolChipColor
import com.m57.hermescontrol.theme.ToolChipColorLight
import com.m57.hermescontrol.theme.onColorFor import com.m57.hermescontrol.theme.onColorFor
import com.m57.hermescontrol.ui.chat.components.ReasoningCard import com.m57.hermescontrol.ui.chat.components.ReasoningCard
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
@@ -345,21 +340,8 @@ private fun AssistantBubble(
onImageClick: (ImageViewerModel) -> Unit = {}, onImageClick: (ImageViewerModel) -> Unit = {},
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
val bubbleColor = if (isDarkTheme) AssistantBubble else AssistantBubbleLight val bubbleColor = MaterialTheme.colorScheme.surfaceVariant
val textColor = val textColor = MaterialTheme.colorScheme.onSurfaceVariant
if (bubbleColor.luminance() > 0.5f) {
if (MaterialTheme.colorScheme.onSurface.luminance() < 0.5f) {
MaterialTheme.colorScheme.onSurface
} else {
LightOnSurface
}
} else {
if (MaterialTheme.colorScheme.onSurface.luminance() > 0.5f) {
MaterialTheme.colorScheme.onSurface
} else {
DarkOnSurface
}
}
val clipboard = LocalClipboard.current val clipboard = LocalClipboard.current
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
var showCopyButton by remember { mutableStateOf(false) } var showCopyButton by remember { mutableStateOf(false) }
@@ -508,7 +490,7 @@ private fun SystemBubble(
style = style =
MaterialTheme.typography.bodySmall.copy( MaterialTheme.typography.bodySmall.copy(
fontStyle = FontStyle.Italic, fontStyle = FontStyle.Italic,
color = SystemMessageColor, color = MaterialTheme.colorScheme.onSurfaceVariant,
), ),
) )
@@ -1925,7 +1907,7 @@ private fun ToolBubble(
) { ) {
var expanded by remember { mutableStateOf(false) } var expanded by remember { mutableStateOf(false) }
var showRawJson by remember { mutableStateOf(false) } var showRawJson by remember { mutableStateOf(false) }
val chipColor = if (isDarkTheme) ToolChipColor else ToolChipColorLight val chipColor = MaterialTheme.colorScheme.surfaceContainerHigh
val contentColor = MaterialTheme.colorScheme.onSurfaceVariant val contentColor = MaterialTheme.colorScheme.onSurfaceVariant
val statusColors = LocalHermesStatusColors.current val statusColors = LocalHermesStatusColors.current