From 7c3815f39abf491925c20648d54453f3e8d4921d Mon Sep 17 00:00:00 2001 From: OpenClaw Date: Sat, 7 Mar 2026 08:50:16 +0800 Subject: [PATCH] Style tool results as readable output blocks --- .../openclawapp/feature/chat/ChatScreen.kt | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt index 37844fc..0e309f7 100644 --- a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt +++ b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt @@ -333,15 +333,30 @@ private fun MessageBubble( }, style = MaterialTheme.typography.titleSmall, ) - Text( - text = toolResultText, - style = MaterialTheme.typography.bodyMedium, - maxLines = if (expanded) Int.MAX_VALUE else 12, - overflow = TextOverflow.Ellipsis, - ) - if (shouldCollapseToolResult) { - TextButton(onClick = { expanded = !expanded }) { - Text(if (expanded) "收起" else "展开完整结果") + Column( + modifier = Modifier + .fillMaxWidth() + .clip(androidx.compose.foundation.shape.RoundedCornerShape(12.dp)) + .background( + if (message.status == "tool-error") { + MaterialTheme.colorScheme.error.copy(alpha = 0.08f) + } else { + MaterialTheme.colorScheme.surface.copy(alpha = 0.45f) + } + ) + .padding(12.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), + ) { + Text( + text = toolResultText, + style = MaterialTheme.typography.bodyMedium, + maxLines = if (expanded) Int.MAX_VALUE else 12, + overflow = TextOverflow.Ellipsis, + ) + if (shouldCollapseToolResult) { + TextButton(onClick = { expanded = !expanded }) { + Text(if (expanded) "收起" else "展开完整结果") + } } } }