Use local phase helpers in retry edge cases
This commit is contained in:
1 parent
7b56c88be9
commit
50601996af
3 files changed
+17
-4
No files matched your search
@@ -80,6 +80,16 @@ fun ChatMessage.isLocalFailure(): Boolean {
|
|||||||
return localMessagePhase() == LocalMessagePhase.Failed
|
return localMessagePhase() == LocalMessagePhase.Failed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun ChatMessage.isManualLocalProcessing(): Boolean {
|
||||||
|
return localMessagePhase() == LocalMessagePhase.ManualProcessing
|
||||||
|
}
|
||||||
|
|
||||||
|
fun ChatMessage.isAutoRetryCandidate(): Boolean {
|
||||||
|
return kind == MessageKind.Text &&
|
||||||
|
role == MessageRole.User &&
|
||||||
|
localMessagePhase() == LocalMessagePhase.Failed
|
||||||
|
}
|
||||||
|
|
||||||
fun textStatusForLocalPhase(
|
fun textStatusForLocalPhase(
|
||||||
phase: LocalMessagePhase,
|
phase: LocalMessagePhase,
|
||||||
fallback: String = "queued",
|
fallback: String = "queued",
|
||||||
|
|||||||
+6
-4
@@ -5,8 +5,10 @@ import androidx.compose.runtime.mutableStateOf
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import cn.xiaobai.openclawapp.data.LocalMessagePhase
|
import cn.xiaobai.openclawapp.data.LocalMessagePhase
|
||||||
import cn.xiaobai.openclawapp.data.attachmentStatusForLocalPhase
|
import cn.xiaobai.openclawapp.data.attachmentStatusForLocalPhase
|
||||||
|
import cn.xiaobai.openclawapp.data.isAutoRetryCandidate
|
||||||
import cn.xiaobai.openclawapp.data.isLocalFailure
|
import cn.xiaobai.openclawapp.data.isLocalFailure
|
||||||
import cn.xiaobai.openclawapp.data.isLocalPendingActive
|
import cn.xiaobai.openclawapp.data.isLocalPendingActive
|
||||||
|
import cn.xiaobai.openclawapp.data.isManualLocalProcessing
|
||||||
import cn.xiaobai.openclawapp.data.textStatusForLocalPhase
|
import cn.xiaobai.openclawapp.data.textStatusForLocalPhase
|
||||||
import cn.xiaobai.openclawapp.network.MobileGatewayApi
|
import cn.xiaobai.openclawapp.network.MobileGatewayApi
|
||||||
import cn.xiaobai.openclawapp.network.SessionSummaryDto
|
import cn.xiaobai.openclawapp.network.SessionSummaryDto
|
||||||
@@ -217,7 +219,7 @@ class RemoteOpenClawRepository(
|
|||||||
override fun sendMessage(sessionId: String, text: String) {
|
override fun sendMessage(sessionId: String, text: String) {
|
||||||
val currentMessages = messageStore[sessionId].orEmpty()
|
val currentMessages = messageStore[sessionId].orEmpty()
|
||||||
val hasQueuedUser = currentMessages.any {
|
val hasQueuedUser = currentMessages.any {
|
||||||
it.role == MessageRole.User && it.text == text && it.status == "queued"
|
it.role == MessageRole.User && it.text == text && it.isManualLocalProcessing()
|
||||||
}
|
}
|
||||||
if (hasQueuedUser) return
|
if (hasQueuedUser) return
|
||||||
|
|
||||||
@@ -473,7 +475,7 @@ class RemoteOpenClawRepository(
|
|||||||
|
|
||||||
suspend fun retryAutoRecoverableMessages(sessionId: String): Boolean {
|
suspend fun retryAutoRecoverableMessages(sessionId: String): Boolean {
|
||||||
val candidates = messageStore[sessionId].orEmpty()
|
val candidates = messageStore[sessionId].orEmpty()
|
||||||
.filter { it.id in autoRetryMessageIds && it.role == MessageRole.User && it.kind == MessageKind.Text && it.status == "send-failed" }
|
.filter { it.id in autoRetryMessageIds && it.isAutoRetryCandidate() }
|
||||||
.map { it.id }
|
.map { it.id }
|
||||||
if (candidates.isEmpty()) return false
|
if (candidates.isEmpty()) return false
|
||||||
|
|
||||||
@@ -949,13 +951,13 @@ class RemoteOpenClawRepository(
|
|||||||
return id.startsWith("local-") &&
|
return id.startsWith("local-") &&
|
||||||
role == MessageRole.User &&
|
role == MessageRole.User &&
|
||||||
kind == MessageKind.Text &&
|
kind == MessageKind.Text &&
|
||||||
(isLocalPendingActive() || status == "send-failed")
|
(isLocalPendingActive() || isLocalFailure())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ChatMessage.isRetainableLocalAttachmentMessage(): Boolean {
|
private fun ChatMessage.isRetainableLocalAttachmentMessage(): Boolean {
|
||||||
return id.startsWith("local-") &&
|
return id.startsWith("local-") &&
|
||||||
kind == MessageKind.Attachment &&
|
kind == MessageKind.Attachment &&
|
||||||
(isLocalPendingActive() || status == "upload-failed")
|
(isLocalPendingActive() || isLocalFailure())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun rebuildSessionSortKeysFromSnapshot(items: List<OverviewSessionSnapshot>) {
|
private fun rebuildSessionSortKeysFromSnapshot(items: List<OverviewSessionSnapshot>) {
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ Android/iOS App
|
|||||||
- [x] 已抽出本地 pending 派生状态:新增 `LocalMessagePhase` 与 `localMessagePhase()` / `isLocalPendingActive()`,开始统一 UI 与本地保留逻辑对 pending 状态的判断,减少散落的字符串分支
|
- [x] 已抽出本地 pending 派生状态:新增 `LocalMessagePhase` 与 `localMessagePhase()` / `isLocalPendingActive()`,开始统一 UI 与本地保留逻辑对 pending 状态的判断,减少散落的字符串分支
|
||||||
- [x] 缓存恢复逻辑也已开始接入派生状态:本地文本若在 `queue-draining` / `retrying-auto` 时被杀掉,重启后会统一恢复为可手动重试的 `send-failed`;附件同理会统一回落为 `upload-failed`
|
- [x] 缓存恢复逻辑也已开始接入派生状态:本地文本若在 `queue-draining` / `retrying-auto` 时被杀掉,重启后会统一恢复为可手动重试的 `send-failed`;附件同理会统一回落为 `upload-failed`
|
||||||
- [x] Repository 的核心写状态入口已开始复用派生状态映射:新增 `textStatusForLocalPhase()` / `attachmentStatusForLocalPhase()`,用于统一写入手动处理中、队列处理中、失败态、完成态,减少散落的状态字符串
|
- [x] Repository 的核心写状态入口已开始复用派生状态映射:新增 `textStatusForLocalPhase()` / `attachmentStatusForLocalPhase()`,用于统一写入手动处理中、队列处理中、失败态、完成态,减少散落的状态字符串
|
||||||
|
- [x] 又收了一轮边角判断:文本入队去重、auto-retry 候选过滤、本地 retainable/failure 判定开始复用派生状态辅助函数,继续减少裸 `status == ...` 分支
|
||||||
- [ ] 还没有完整的离线发送队列(当前已覆盖文本 + 附件,但还没有更完整的网络感知、后台 drain 与统一淘汰策略)
|
- [ ] 还没有完整的离线发送队列(当前已覆盖文本 + 附件,但还没有更完整的网络感知、后台 drain 与统一淘汰策略)
|
||||||
- [ ] 还没有真正基于网络恢复信号的自动补发
|
- [ ] 还没有真正基于网络恢复信号的自动补发
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user