Unify cache recovery with local message phases

This commit is contained in:
OpenClaw committed 2026-03-07 13:24:26 +08:00
1 parent a6119aeb46
commit 85b974b900
3 files changed
+21 -3

No files matched your search

@@ -75,3 +75,7 @@ fun ChatMessage.isLocalPendingActive(): Boolean {
LocalMessagePhase.ManualProcessing,
)
}
fun ChatMessage.isLocalFailure(): Boolean {
return localMessagePhase() == LocalMessagePhase.Failed
}
@@ -3,6 +3,7 @@ package cn.xiaobai.openclawapp.data
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import cn.xiaobai.openclawapp.data.isLocalFailure
import cn.xiaobai.openclawapp.data.isLocalPendingActive
import cn.xiaobai.openclawapp.network.MobileGatewayApi
import cn.xiaobai.openclawapp.network.SessionSummaryDto
@@ -834,7 +835,19 @@ class RemoteOpenClawRepository(
autoRetryMessageIds.add(domain.id)
domain.copy(status = "send-failed", retryable = true)
}
domain.role == MessageRole.User && domain.kind == MessageKind.Text && domain.status == "send-failed" -> {
domain.role == MessageRole.User && domain.kind == MessageKind.Text && domain.isLocalPendingActive() -> {
textRetryStore[domain.id] = TextRetryPayload(sessionId, domain.text)
pendingTextQueue[domain.id] = PendingTextSend(
messageId = domain.id,
sessionId = sessionId,
text = domain.text,
createdAt = domain.createdAt,
autoRetryEligible = false,
)
autoRetryMessageIds.remove(domain.id)
domain.copy(status = "send-failed", retryable = true)
}
domain.role == MessageRole.User && domain.kind == MessageKind.Text && domain.isLocalFailure() -> {
textRetryStore[domain.id] = TextRetryPayload(sessionId, domain.text)
pendingTextQueue[domain.id] = PendingTextSend(
messageId = domain.id,
@@ -846,7 +859,7 @@ class RemoteOpenClawRepository(
autoRetryMessageIds.remove(domain.id)
domain.copy(retryable = true)
}
domain.kind == MessageKind.Attachment && (domain.status == "uploading" || domain.status == "queue-draining" || domain.status == "upload-failed") -> {
domain.kind == MessageKind.Attachment && (domain.isLocalPendingActive() || domain.isLocalFailure()) -> {
domain.copy(
status = "upload-failed",
retryable = attachmentRetryStore.containsKey(domain.id) || pendingAttachmentQueue.containsKey(domain.id),
@@ -914,7 +927,7 @@ class RemoteOpenClawRepository(
addAll(pendingThinking)
}
}.onEach { msg ->
if (!msg.id.startsWith("local-") && msg.role == MessageRole.User && msg.status != "send-failed") {
if (!msg.id.startsWith("local-") && msg.role == MessageRole.User && !msg.isLocalFailure()) {
textRetryStore.remove(msg.id)
}
}
+1
View File
@@ -203,6 +203,7 @@ Android/iOS App
- [x] 已修复 `RemoteOpenClawRepository` 的 JVM 重载撞签名:原先两个 `rebuildSessionSortKeys(List<...>)` 因泛型擦除冲突,现已拆成 `rebuildSessionSortKeysFromSnapshot(...)` / `rebuildSessionSortKeysFromSessions(...)`
- [x] 已补本地 pending 保留逻辑:refresh / SSE snapshot 不再只保留 `queued` 文本;`queue-draining` / `retrying-auto` / 本地附件 pending 也会保留,避免队列处理中消息被快照冲掉
- [x] 已抽出本地 pending 派生状态:新增 `LocalMessagePhase` 与 `localMessagePhase()` / `isLocalPendingActive()`,开始统一 UI 与本地保留逻辑对 pending 状态的判断,减少散落的字符串分支
- [x] 缓存恢复逻辑也已开始接入派生状态:本地文本若在 `queue-draining` / `retrying-auto` 时被杀掉,重启后会统一恢复为可手动重试的 `send-failed`;附件同理会统一回落为 `upload-failed`
- [ ] 还没有完整的离线发送队列(当前已覆盖文本 + 附件,但还没有更完整的网络感知、后台 drain 与统一淘汰策略)
- [ ] 还没有真正基于网络恢复信号的自动补发