Expose queue recovery status in chat
This commit is contained in:
1 parent
f62e23ffcc
commit
472bdef2a7
5 files changed
+13
No files matched your search
@@ -196,6 +196,8 @@ private fun OpenClawRoot(appState: OpenClawAppState) {
|
|||||||
streamStatus = appState.repository.streamStatusFor(activeSession.id),
|
streamStatus = appState.repository.streamStatusFor(activeSession.id),
|
||||||
pendingQueueStatus = appState.repository.pendingQueueStatus(activeSession.id).let { queue ->
|
pendingQueueStatus = appState.repository.pendingQueueStatus(activeSession.id).let { queue ->
|
||||||
when {
|
when {
|
||||||
|
queue.recoveryInFlight && queue.sessionCount > 0 -> "当前会话还有 ${queue.sessionCount} 条待发项,系统正在恢复并继续处理本地队列。"
|
||||||
|
queue.recoveryRecentlySkipped && queue.sessionCount > 0 -> "当前会话的待发队列刚刚已处理过一轮,本次先跳过重复恢复。"
|
||||||
queue.isDraining && queue.sessionCount > 0 -> "当前会话还有 ${queue.sessionCount} 条待发项,系统正在按本地队列继续处理。"
|
queue.isDraining && queue.sessionCount > 0 -> "当前会话还有 ${queue.sessionCount} 条待发项,系统正在按本地队列继续处理。"
|
||||||
queue.sessionCount > 0 -> "当前会话还有 ${queue.sessionCount} 条待发项未完成,可继续重试或等待下一次自动处理。"
|
queue.sessionCount > 0 -> "当前会话还有 ${queue.sessionCount} 条待发项未完成,可继续重试或等待下一次自动处理。"
|
||||||
else -> null
|
else -> null
|
||||||
|
|||||||
@@ -142,6 +142,8 @@ class OpenClawAppState(
|
|||||||
feedbackMessage = "已自动重试恢复的待发消息"
|
feedbackMessage = "已自动重试恢复的待发消息"
|
||||||
} else if (recovery.drained) {
|
} else if (recovery.drained) {
|
||||||
feedbackMessage = "已尝试继续处理当前会话的待发队列"
|
feedbackMessage = "已尝试继续处理当前会话的待发队列"
|
||||||
|
} else if (recovery.skipped) {
|
||||||
|
feedbackMessage = "当前会话刚刚处理过待发队列,这次先跳过重复恢复"
|
||||||
}
|
}
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
syncError = it.message ?: "会话消息加载失败"
|
syncError = it.message ?: "会话消息加载失败"
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ data class PendingQueueStatus(
|
|||||||
val totalCount: Int = 0,
|
val totalCount: Int = 0,
|
||||||
val sessionCount: Int = 0,
|
val sessionCount: Int = 0,
|
||||||
val isDraining: Boolean = false,
|
val isDraining: Boolean = false,
|
||||||
|
val recoveryInFlight: Boolean = false,
|
||||||
|
val recoveryRecentlySkipped: Boolean = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
enum class LocalMessagePhase {
|
enum class LocalMessagePhase {
|
||||||
|
|||||||
+6
@@ -104,6 +104,7 @@ class RemoteOpenClawRepository(
|
|||||||
private val streamRecoveryQueueDrainPending = mutableSetOf<String>()
|
private val streamRecoveryQueueDrainPending = mutableSetOf<String>()
|
||||||
private val queueRecoveryInFlightSessionIds = mutableSetOf<String>()
|
private val queueRecoveryInFlightSessionIds = mutableSetOf<String>()
|
||||||
private val queueRecoveryMarks = mutableMapOf<String, TimeMark>()
|
private val queueRecoveryMarks = mutableMapOf<String, TimeMark>()
|
||||||
|
private val queueRecoveryRecentlySkippedSessionIds = mutableSetOf<String>()
|
||||||
private val attachmentRetryStore = mutableMapOf<String, AttachmentRetryPayload>()
|
private val attachmentRetryStore = mutableMapOf<String, AttachmentRetryPayload>()
|
||||||
private val attachmentOpenStore = mutableMapOf<String, AttachmentOpenPayload>()
|
private val attachmentOpenStore = mutableMapOf<String, AttachmentOpenPayload>()
|
||||||
private val textRetryStore = mutableMapOf<String, TextRetryPayload>()
|
private val textRetryStore = mutableMapOf<String, TextRetryPayload>()
|
||||||
@@ -123,6 +124,8 @@ class RemoteOpenClawRepository(
|
|||||||
totalCount = pendingTextQueue.size + pendingAttachmentQueue.size,
|
totalCount = pendingTextQueue.size + pendingAttachmentQueue.size,
|
||||||
sessionCount = textItems.size + attachmentItems.size,
|
sessionCount = textItems.size + attachmentItems.size,
|
||||||
isDraining = sessionId?.let { it in drainingSessionIds } ?: drainingSessionIds.isNotEmpty(),
|
isDraining = sessionId?.let { it in drainingSessionIds } ?: drainingSessionIds.isNotEmpty(),
|
||||||
|
recoveryInFlight = sessionId?.let { it in queueRecoveryInFlightSessionIds } ?: queueRecoveryInFlightSessionIds.isNotEmpty(),
|
||||||
|
recoveryRecentlySkipped = sessionId?.let { it in queueRecoveryRecentlySkippedSessionIds } ?: queueRecoveryRecentlySkippedSessionIds.isNotEmpty(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -625,13 +628,16 @@ class RemoteOpenClawRepository(
|
|||||||
allowAutoRetry: Boolean = true,
|
allowAutoRetry: Boolean = true,
|
||||||
): PendingQueueRecoveryResult {
|
): PendingQueueRecoveryResult {
|
||||||
if (sessionId in queueRecoveryInFlightSessionIds) {
|
if (sessionId in queueRecoveryInFlightSessionIds) {
|
||||||
|
queueRecoveryRecentlySkippedSessionIds.add(sessionId)
|
||||||
return PendingQueueRecoveryResult(skipped = true)
|
return PendingQueueRecoveryResult(skipped = true)
|
||||||
}
|
}
|
||||||
val lastAttempt = queueRecoveryMarks[sessionId]
|
val lastAttempt = queueRecoveryMarks[sessionId]
|
||||||
if (lastAttempt != null && lastAttempt.elapsedNow() < 3.seconds) {
|
if (lastAttempt != null && lastAttempt.elapsedNow() < 3.seconds) {
|
||||||
|
queueRecoveryRecentlySkippedSessionIds.add(sessionId)
|
||||||
return PendingQueueRecoveryResult(skipped = true)
|
return PendingQueueRecoveryResult(skipped = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
queueRecoveryRecentlySkippedSessionIds.remove(sessionId)
|
||||||
queueRecoveryInFlightSessionIds.add(sessionId)
|
queueRecoveryInFlightSessionIds.add(sessionId)
|
||||||
queueRecoveryMarks[sessionId] = TimeSource.Monotonic.markNow()
|
queueRecoveryMarks[sessionId] = TimeSource.Monotonic.markNow()
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ Android/iOS App
|
|||||||
- [ ] 还没有完整的离线发送队列(当前已覆盖文本 + 附件,但还没有更完整的网络感知、后台 drain 与统一淘汰策略)
|
- [ ] 还没有完整的离线发送队列(当前已覆盖文本 + 附件,但还没有更完整的网络感知、后台 drain 与统一淘汰策略)
|
||||||
- [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 状态里会暴露“正在恢复中 / 刚因节流跳过”,聊天页和反馈文案能区分“真在跑”和“刚跑过所以先跳过”
|
||||||
- [ ] 还没有更完整的网络恢复策略(目前先基于会话 SSE 恢复触发,不含更底层网络监听或全局后台队列调度)
|
- [ ] 还没有更完整的网络恢复策略(目前先基于会话 SSE 恢复触发,不含更底层网络监听或全局后台队列调度)
|
||||||
|
|
||||||
### 4.2 附件后端主链路
|
### 4.2 附件后端主链路
|
||||||
|
|||||||
Reference in new issue
Block a user