Tighten pending message merge matching
This commit is contained in:
1 parent
472bdef2a7
commit
39f16a8119
2 files changed
+21
-16
No files matched your search
+20
-16
@@ -656,7 +656,8 @@ class RemoteOpenClawRepository(
|
|||||||
private fun clearPendingTextMessage(sessionId: String, text: String) {
|
private fun clearPendingTextMessage(sessionId: String, text: String) {
|
||||||
val targetId = pendingTextQueue.values
|
val targetId = pendingTextQueue.values
|
||||||
.filter { it.sessionId == sessionId && it.text == text }
|
.filter { it.sessionId == sessionId && it.text == text }
|
||||||
.minByOrNull { it.createdAt }
|
.sortedBy { it.createdAt }
|
||||||
|
.firstOrNull()
|
||||||
?.messageId
|
?.messageId
|
||||||
?: return
|
?: return
|
||||||
pendingTextQueue.remove(targetId)
|
pendingTextQueue.remove(targetId)
|
||||||
@@ -664,6 +665,19 @@ class RemoteOpenClawRepository(
|
|||||||
autoRetryMessageIds.remove(targetId)
|
autoRetryMessageIds.remove(targetId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun matchesPendingLocalText(local: ChatMessage, remote: ChatMessage): Boolean {
|
||||||
|
return remote.role == MessageRole.User &&
|
||||||
|
remote.kind == MessageKind.Text &&
|
||||||
|
remote.text == local.text
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun matchesPendingLocalAttachment(local: ChatMessage, remote: ChatMessage): Boolean {
|
||||||
|
return remote.kind == MessageKind.Attachment &&
|
||||||
|
remote.text == local.text &&
|
||||||
|
(local.contentType == null || remote.contentType == local.contentType) &&
|
||||||
|
(local.sizeBytes == null || remote.sizeBytes == local.sizeBytes)
|
||||||
|
}
|
||||||
|
|
||||||
private fun subscribeSessionStream(sessionId: String) {
|
private fun subscribeSessionStream(sessionId: String) {
|
||||||
streamJob?.cancel()
|
streamJob?.cancel()
|
||||||
streamStatusStore = streamStatusStore + (sessionId to "connecting")
|
streamStatusStore = streamStatusStore + (sessionId to "connecting")
|
||||||
@@ -933,14 +947,10 @@ class RemoteOpenClawRepository(
|
|||||||
when {
|
when {
|
||||||
local.isRetainableLocalTextMessage() -> {
|
local.isRetainableLocalTextMessage() -> {
|
||||||
textRetryStore.putIfAbsent(local.id, TextRetryPayload(sessionId, local.text))
|
textRetryStore.putIfAbsent(local.id, TextRetryPayload(sessionId, local.text))
|
||||||
remoteMessages.none { remote ->
|
remoteMessages.none { remote -> matchesPendingLocalText(local, remote) }
|
||||||
remote.role == MessageRole.User && remote.text == local.text
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
local.isRetainableLocalAttachmentMessage() -> {
|
local.isRetainableLocalAttachmentMessage() -> {
|
||||||
remoteMessages.none { remote ->
|
remoteMessages.none { remote -> matchesPendingLocalAttachment(local, remote) }
|
||||||
remote.kind == MessageKind.Attachment && remote.text == local.text
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
@@ -957,20 +967,14 @@ class RemoteOpenClawRepository(
|
|||||||
val pendingThinking = localPending.filter { it.id.startsWith("local-thinking-") }
|
val pendingThinking = localPending.filter { it.id.startsWith("local-thinking-") }
|
||||||
|
|
||||||
val unmatchedPendingUsers = pendingUsers.filter { pending ->
|
val unmatchedPendingUsers = pendingUsers.filter { pending ->
|
||||||
remoteMessages.none { remote ->
|
remoteMessages.none { remote -> matchesPendingLocalText(pending, remote) }
|
||||||
remote.role == MessageRole.User && remote.text == pending.text
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
val unmatchedPendingAttachments = pendingAttachments.filter { pending ->
|
val unmatchedPendingAttachments = pendingAttachments.filter { pending ->
|
||||||
remoteMessages.none { remote ->
|
remoteMessages.none { remote -> matchesPendingLocalAttachment(pending, remote) }
|
||||||
remote.kind == MessageKind.Attachment && remote.text == pending.text
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val hasPendingUserReachedRemote = activePendingUsers.any { pending ->
|
val hasPendingUserReachedRemote = activePendingUsers.any { pending ->
|
||||||
remoteMessages.any { remote ->
|
remoteMessages.any { remote -> matchesPendingLocalText(pending, remote) }
|
||||||
remote.role == MessageRole.User && remote.text == pending.text
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
val shouldKeepThinking = pendingThinking.isNotEmpty() && (
|
val shouldKeepThinking = pendingThinking.isNotEmpty() && (
|
||||||
unmatchedPendingUsers.any { it.isLocalPendingActive() } ||
|
unmatchedPendingUsers.any { it.isLocalPendingActive() } ||
|
||||||
|
|||||||
@@ -210,6 +210,7 @@ Android/iOS App
|
|||||||
- [x] 已补第一版“网络恢复后继续处理待发队列”:当会话 SSE 从 recoverable failed / reconnecting 回到 live 时,会顺手尝试 auto-retry + drain 当前会话的文本/附件 pending
|
- [x] 已补第一版“网络恢复后继续处理待发队列”:当会话 SSE 从 recoverable failed / reconnecting 回到 live 时,会顺手尝试 auto-retry + drain 当前会话的文本/附件 pending
|
||||||
- [x] 已给 session 级自动恢复补简易防重入/短节流:`openSession()` 和 SSE recovery 现在共用 `recoverPendingQueueForSession(...)`,避免短时间内对同一会话重复触发 queue recovery
|
- [x] 已给 session 级自动恢复补简易防重入/短节流:`openSession()` 和 SSE recovery 现在共用 `recoverPendingQueueForSession(...)`,避免短时间内对同一会话重复触发 queue recovery
|
||||||
- [x] 已补 queue recovery 轻量可观测性:pending queue 状态里会暴露“正在恢复中 / 刚因节流跳过”,聊天页和反馈文案能区分“真在跑”和“刚跑过所以先跳过”
|
- [x] 已补 queue recovery 轻量可观测性:pending queue 状态里会暴露“正在恢复中 / 刚因节流跳过”,聊天页和反馈文案能区分“真在跑”和“刚跑过所以先跳过”
|
||||||
|
- [x] 已开始收紧本地 pending 与远端消息的匹配条件:文本 pending 不再只看裸文本;附件 pending 除文件名外还会参考 `contentType/sizeBytes`,降低同文案/同文件名重发时的误合并风险
|
||||||
- [ ] 还没有更完整的网络恢复策略(目前先基于会话 SSE 恢复触发,不含更底层网络监听或全局后台队列调度)
|
- [ ] 还没有更完整的网络恢复策略(目前先基于会话 SSE 恢复触发,不含更底层网络监听或全局后台队列调度)
|
||||||
|
|
||||||
### 4.2 附件后端主链路
|
### 4.2 附件后端主链路
|
||||||
|
|||||||
Reference in new issue
Block a user