Improve tool cards and stream failure messaging

This commit is contained in:
OpenClaw committed 2026-03-07 08:41:54 +08:00
1 parent 3153fd5b98
commit 38505e513a
2 files changed
+20 -3

No files matched your search

@@ -234,7 +234,20 @@ class RemoteOpenClawRepository(
is SessionStreamEvent.Failed -> {
val dto = event.payload
if (!dto.recoverable) return@collect
if (!dto.recoverable) {
messageStore = messageStore + (
sessionId to (messageStore[sessionId].orEmpty() + ChatMessage(
id = "stream-failed-$sessionId",
role = MessageRole.System,
text = dto.message,
createdAt = "刚刚",
status = "stream-failed",
kind = MessageKind.Text,
))
)
updateSessionPreview(sessionId, messageStore[sessionId]?.lastOrNull())
return@collect
}
// recoverable: will retry via outer while loop
}
}
@@ -278,14 +278,18 @@ private fun MessageBubble(
style = MaterialTheme.typography.titleSmall,
)
Text(
text = displayText.ifBlank { "工具正在执行…" },
text = when (message.status) {
"tool-done" -> "工具执行完成"
"tool-error" -> "工具执行失败"
else -> displayText.ifBlank { "工具正在执行…" }
},
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
isToolResult -> {
Text(
text = "工具结果",
text = if (message.status == "tool-error") "工具错误" else "工具结果",
style = MaterialTheme.typography.titleSmall,
)
Text(text = displayText, style = MaterialTheme.typography.bodyMedium)