Refresh session preview on local pending states
This commit is contained in:
1 parent
7d7e0718f6
commit
439c0a4a7b
2 files changed
+24
-18
No files matched your search
+22
-17
@@ -144,24 +144,24 @@ class RemoteOpenClawRepository(
|
||||
val withoutThinking = currentMessages.filterNot { it.id.startsWith("local-thinking-") }
|
||||
val localUserId = "local-user-$sessionId-${withoutThinking.size + 1}"
|
||||
textRetryStore[localUserId] = TextRetryPayload(sessionId, text)
|
||||
messageStore = messageStore + (
|
||||
sessionId to (withoutThinking + listOf(
|
||||
ChatMessage(
|
||||
id = localUserId,
|
||||
role = MessageRole.User,
|
||||
text = text,
|
||||
createdAt = "现在",
|
||||
status = "queued",
|
||||
),
|
||||
ChatMessage(
|
||||
id = "local-thinking-$sessionId-${withoutThinking.size + 2}",
|
||||
role = MessageRole.Assistant,
|
||||
text = "",
|
||||
createdAt = "现在",
|
||||
status = "thinking",
|
||||
),
|
||||
))
|
||||
val next = withoutThinking + listOf(
|
||||
ChatMessage(
|
||||
id = localUserId,
|
||||
role = MessageRole.User,
|
||||
text = text,
|
||||
createdAt = "现在",
|
||||
status = "queued",
|
||||
),
|
||||
ChatMessage(
|
||||
id = "local-thinking-$sessionId-${withoutThinking.size + 2}",
|
||||
role = MessageRole.Assistant,
|
||||
text = "",
|
||||
createdAt = "现在",
|
||||
status = "thinking",
|
||||
),
|
||||
)
|
||||
messageStore = messageStore + (sessionId to next)
|
||||
updateSessionPreview(sessionId, previewMessage(next))
|
||||
}
|
||||
|
||||
override suspend fun updateDefaultAgent(agent: String) {
|
||||
@@ -427,6 +427,7 @@ class RemoteOpenClawRepository(
|
||||
toolCallId = dto.toolCallId,
|
||||
)
|
||||
messageStore = messageStore + (sessionId to next)
|
||||
updateSessionPreview(sessionId, previewMessage(next))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -519,6 +520,10 @@ class RemoteOpenClawRepository(
|
||||
streamScope.cancel()
|
||||
}
|
||||
|
||||
private fun previewMessage(messages: List<ChatMessage>): ChatMessage? {
|
||||
return messages.lastOrNull { !it.id.startsWith("local-thinking-") } ?: messages.lastOrNull()
|
||||
}
|
||||
|
||||
private fun updateSessionPreview(sessionId: String, lastMessage: ChatMessage?) {
|
||||
val preview = lastMessage?.toSessionPreview().orEmpty()
|
||||
val existing = sessions.firstOrNull { it.id == sessionId }
|
||||
|
||||
Reference in new issue
Block a user