Format session previews for attachment and tool events
This commit is contained in:
1 parent
f6159b0017
commit
3f607f6c1a
2 files changed
+19
-3
No files matched your search
+17
-1
@@ -400,7 +400,7 @@ class RemoteOpenClawRepository(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSessionPreview(sessionId: String, lastMessage: ChatMessage?) {
|
private fun updateSessionPreview(sessionId: String, lastMessage: ChatMessage?) {
|
||||||
val preview = lastMessage?.text?.trim().orEmpty()
|
val preview = lastMessage?.toSessionPreview().orEmpty()
|
||||||
val updatedAt = lastMessage?.createdAt ?: "刚刚"
|
val updatedAt = lastMessage?.createdAt ?: "刚刚"
|
||||||
sessions = sessions.map { session ->
|
sessions = sessions.map { session ->
|
||||||
if (session.id == sessionId) {
|
if (session.id == sessionId) {
|
||||||
@@ -483,6 +483,22 @@ class RemoteOpenClawRepository(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun ChatMessage.toSessionPreview(): String {
|
||||||
|
return when (kind) {
|
||||||
|
MessageKind.Attachment -> "[附件] $text"
|
||||||
|
MessageKind.Tool -> "[工具] ${toolName ?: text}"
|
||||||
|
MessageKind.ToolResult -> if (status == "tool-error") "[工具错误] ${linkedPreviewText(text)}" else "[工具结果] ${linkedPreviewText(text)}"
|
||||||
|
MessageKind.Thinking -> "[思考中] ${linkedPreviewText(text)}"
|
||||||
|
MessageKind.Text -> when {
|
||||||
|
role == MessageRole.System && status == "stream-failed" -> "[断流] ${linkedPreviewText(text)}"
|
||||||
|
role == MessageRole.System -> "[系统] ${linkedPreviewText(text)}"
|
||||||
|
else -> linkedPreviewText(text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun linkedPreviewText(value: String): String = value.trim().replace("\n", " ").take(80)
|
||||||
|
|
||||||
private fun cn.xiaobai.openclawapp.network.ChatMessageDto.toDomainMessage(): ChatMessage {
|
private fun cn.xiaobai.openclawapp.network.ChatMessageDto.toDomainMessage(): ChatMessage {
|
||||||
return ChatMessage(
|
return ChatMessage(
|
||||||
id = id,
|
id = id,
|
||||||
|
|||||||
+2
-2
@@ -125,7 +125,7 @@ fun SessionListScreen(
|
|||||||
Text("最近访问", style = MaterialTheme.typography.labelLarge)
|
Text("最近访问", style = MaterialTheme.typography.labelLarge)
|
||||||
Text(recentSession.title, style = MaterialTheme.typography.titleMedium)
|
Text(recentSession.title, style = MaterialTheme.typography.titleMedium)
|
||||||
Text(
|
Text(
|
||||||
recentSession.lastMessage,
|
recentSession.lastMessage.ifBlank { "暂无摘要" },
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
@@ -209,7 +209,7 @@ fun SessionListScreen(
|
|||||||
StatusPill(text = session.updatedAt, highlighted = true)
|
StatusPill(text = session.updatedAt, highlighted = true)
|
||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = session.lastMessage,
|
text = session.lastMessage.ifBlank { "暂无摘要" },
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user