Polish chat message hierarchy

This commit is contained in:
OpenClaw committed 2026-03-07 15:18:38 +08:00
1 parent 6c387eab7c
commit 3b8d779138
3 files changed
+19 -15

No files matched your search

@@ -188,7 +188,6 @@ private fun OpenClawRoot(appState: OpenClawAppState) {
when { when {
activeSession != null -> ChatScreen( activeSession != null -> ChatScreen(
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
sessionTitle = activeSession.title,
messages = appState.repository.messagesFor(activeSession.id), messages = appState.repository.messagesFor(activeSession.id),
isSending = appState.sendingSessionId == activeSession.id, isSending = appState.sendingSessionId == activeSession.id,
isLoading = appState.isSyncing, isLoading = appState.isSyncing,
@@ -46,7 +46,6 @@ import kotlinx.coroutines.delay
@Composable @Composable
fun ChatScreen( fun ChatScreen(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
sessionTitle: String,
messages: List<ChatMessage>, messages: List<ChatMessage>,
isSending: Boolean, isSending: Boolean,
isLoading: Boolean, isLoading: Boolean,
@@ -89,7 +88,6 @@ fun ChatScreen(
verticalArrangement = Arrangement.spacedBy(12.dp), verticalArrangement = Arrangement.spacedBy(12.dp),
) { ) {
ChatHeader( ChatHeader(
sessionTitle = sessionTitle,
topStatus = topStatus, topStatus = topStatus,
onBack = onBack, onBack = onBack,
onRetry = onRetry, onRetry = onRetry,
@@ -267,7 +265,6 @@ private fun buildChatTopStatus(
@Composable @Composable
private fun ChatHeader( private fun ChatHeader(
sessionTitle: String,
topStatus: ChatTopStatus, topStatus: ChatTopStatus,
onBack: () -> Unit, onBack: () -> Unit,
onRetry: () -> Unit, onRetry: () -> Unit,
@@ -279,17 +276,10 @@ private fun ChatHeader(
) { ) {
Row( Row(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(12.dp), horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
) { ) {
Button(onClick = onBack) { Text("返回") } TextButton(onClick = onBack) { Text("返回") }
Text(
text = sessionTitle,
modifier = Modifier.weight(1f),
style = MaterialTheme.typography.titleMedium,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
TextButton(onClick = onRetry) { TextButton(onClick = onRetry) {
Text(topStatus.actionLabel) Text(topStatus.actionLabel)
} }
@@ -380,7 +370,12 @@ private fun MessageBubble(
val bubbleColor = when { val bubbleColor = when {
isSystemNotice -> MaterialTheme.colorScheme.surfaceContainerHigh isSystemNotice -> MaterialTheme.colorScheme.surfaceContainerHigh
message.role == MessageRole.User -> MaterialTheme.colorScheme.primaryContainer message.role == MessageRole.User -> MaterialTheme.colorScheme.primaryContainer
else -> MaterialTheme.colorScheme.surfaceContainerLow isToolResult && message.status == "tool-error" -> MaterialTheme.colorScheme.errorContainer.copy(alpha = 0.36f)
isToolResult -> MaterialTheme.colorScheme.surfaceContainer
isTool -> MaterialTheme.colorScheme.surfaceContainerLow
isAttachment && message.status == "upload-failed" -> MaterialTheme.colorScheme.errorContainer.copy(alpha = 0.24f)
isAttachment -> MaterialTheme.colorScheme.surfaceContainerLow
else -> MaterialTheme.colorScheme.surface
} }
var visibleChars by remember(message.id) { mutableIntStateOf(if (animateText) 0 else message.text.length) } var visibleChars by remember(message.id) { mutableIntStateOf(if (animateText) 0 else message.text.length) }
var expanded by remember(message.id) { mutableStateOf(false) } var expanded by remember(message.id) { mutableStateOf(false) }
@@ -431,7 +426,7 @@ private fun MessageBubble(
verticalArrangement = Arrangement.spacedBy(6.dp), verticalArrangement = Arrangement.spacedBy(6.dp),
horizontalAlignment = if (isSystemNotice) Alignment.CenterHorizontally else if (message.role == MessageRole.User) Alignment.End else Alignment.Start, horizontalAlignment = if (isSystemNotice) Alignment.CenterHorizontally else if (message.role == MessageRole.User) Alignment.End else Alignment.Start,
) { ) {
if (!isSystemNotice) { if (!isSystemNotice && message.role != MessageRole.User) {
Text( Text(
text = label, text = label,
style = MaterialTheme.typography.labelMedium, style = MaterialTheme.typography.labelMedium,
@@ -463,6 +458,7 @@ private fun MessageBubble(
) { ) {
when { when {
isThinking -> { isThinking -> {
StatusPill(text = "思考中", tone = StatusPillTone.Warning)
Row( Row(
horizontalArrangement = Arrangement.spacedBy(10.dp), horizontalArrangement = Arrangement.spacedBy(10.dp),
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
@@ -595,6 +591,13 @@ private fun MessageBubble(
style = if (isSystemNotice) MaterialTheme.typography.bodyMedium else MaterialTheme.typography.bodyLarge, style = if (isSystemNotice) MaterialTheme.typography.bodyMedium else MaterialTheme.typography.bodyLarge,
color = if (isSystemNotice) MaterialTheme.colorScheme.onSurfaceVariant else MaterialTheme.colorScheme.onSurface, color = if (isSystemNotice) MaterialTheme.colorScheme.onSurfaceVariant else MaterialTheme.colorScheme.onSurface,
) )
if (message.role == MessageRole.User && displayStatus == null) {
Text(
text = "已发送",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
if (message.retryable && localPhase == LocalMessagePhase.Failed && message.status == "send-failed") { if (message.retryable && localPhase == LocalMessagePhase.Failed && message.status == "send-failed") {
TextButton(onClick = { onRetryMessage(message.id) }) { TextButton(onClick = { onRetryMessage(message.id) }) {
Text("重试") Text("重试")
+2
View File
@@ -433,3 +433,5 @@ Android/iOS App
- 2026-03-07:会话列表做了一轮信息减法:去掉重复摘要,默认不再在主列表暴露 session id,更新时间从高亮 pill 降为普通辅助文本;最近访问卡和置顶操作也改轻,优先突出“标题 + 摘要 + 关键状态”。 - 2026-03-07:会话列表做了一轮信息减法:去掉重复摘要,默认不再在主列表暴露 session id,更新时间从高亮 pill 降为普通辅助文本;最近访问卡和置顶操作也改轻,优先突出“标题 + 摘要 + 关键状态”。
- 2026-03-07:开始统一状态视觉语义:`StatusPill` 新增 neutral/info/success/warning/error tone,列表流状态、聊天顶部状态、消息气泡状态都开始按“在线 / 处理中 / 失败 / 普通标签”区分,减少此前一套高亮样式混用时间、状态、标签造成的噪音。 - 2026-03-07:开始统一状态视觉语义:`StatusPill` 新增 neutral/info/success/warning/error tone,列表流状态、聊天顶部状态、消息气泡状态都开始按“在线 / 处理中 / 失败 / 普通标签”区分,减少此前一套高亮样式混用时间、状态、标签造成的噪音。
- 2026-03-07:聊天页消息前台状态文案先收敛到用户视角:把 queue-draining / retrying-auto / uploading / send-failed 等内部细状态,前台统一归并到“处理中 / 需重试 / 已完成”这一层,细分恢复机制不再在时间线里处处抢注意力。 - 2026-03-07:聊天页消息前台状态文案先收敛到用户视角:把 queue-draining / retrying-auto / uploading / send-failed 等内部细状态,前台统一归并到“处理中 / 需重试 / 已完成”这一层,细分恢复机制不再在时间线里处处抢注意力。
- 2026-03-07:继续收聊天时间线的“聊天产品感”:聊天页内部去掉重复会话标题,顶部动作区进一步压轻;消息气泡开始按“用户主色 / 助手中性 / 工具与附件中性容器 + 标签”分层,减少此前不同类型整块上色过多导致的彩虹感。
- 2026-03-07:继续统一消息卡片层级:用户消息不再重复显示角色标签,普通已发用户消息会补轻量“已发送”提示;thinking / tool / tool result / attachment 开始统一走标签 + 内容区的结构,而不是每种类型都靠大面积底色来强调。