Improve tool cards and stream failure messaging
This commit is contained in:
1 parent
3153fd5b98
commit
38505e513a
2 files changed
+20
-3
No files matched your search
+14
-1
@@ -234,7 +234,20 @@ class RemoteOpenClawRepository(
|
|||||||
|
|
||||||
is SessionStreamEvent.Failed -> {
|
is SessionStreamEvent.Failed -> {
|
||||||
val dto = event.payload
|
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
|
// recoverable: will retry via outer while loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -278,14 +278,18 @@ private fun MessageBubble(
|
|||||||
style = MaterialTheme.typography.titleSmall,
|
style = MaterialTheme.typography.titleSmall,
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = displayText.ifBlank { "工具正在执行…" },
|
text = when (message.status) {
|
||||||
|
"tool-done" -> "工具执行完成"
|
||||||
|
"tool-error" -> "工具执行失败"
|
||||||
|
else -> displayText.ifBlank { "工具正在执行…" }
|
||||||
|
},
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
isToolResult -> {
|
isToolResult -> {
|
||||||
Text(
|
Text(
|
||||||
text = "工具结果",
|
text = if (message.status == "tool-error") "工具错误" else "工具结果",
|
||||||
style = MaterialTheme.typography.titleSmall,
|
style = MaterialTheme.typography.titleSmall,
|
||||||
)
|
)
|
||||||
Text(text = displayText, style = MaterialTheme.typography.bodyMedium)
|
Text(text = displayText, style = MaterialTheme.typography.bodyMedium)
|
||||||
|
|||||||
Reference in new issue
Block a user