Retry pending queue after SSE recovery
This commit is contained in:
1 parent
50601996af
commit
c5e85f1857
2 files changed
+11
-1
No files matched your search
+9
@@ -92,6 +92,7 @@ class RemoteOpenClawRepository(
|
||||
private var messageStore by mutableStateOf<Map<String, List<ChatMessage>>>(emptyMap())
|
||||
private var streamStatusStore by mutableStateOf<Map<String, String>>(emptyMap())
|
||||
private val sessionSortKeyStore = mutableMapOf<String, Long>()
|
||||
private val streamRecoveryQueueDrainPending = mutableSetOf<String>()
|
||||
private val attachmentRetryStore = mutableMapOf<String, AttachmentRetryPayload>()
|
||||
private val attachmentOpenStore = mutableMapOf<String, AttachmentOpenPayload>()
|
||||
private val textRetryStore = mutableMapOf<String, TextRetryPayload>()
|
||||
@@ -628,6 +629,11 @@ class RemoteOpenClawRepository(
|
||||
try {
|
||||
streamStatusStore = streamStatusStore + (sessionId to "live")
|
||||
syncSessionStreamStatus(sessionId)
|
||||
if (streamRecoveryQueueDrainPending.remove(sessionId)) {
|
||||
runCatching { retryAutoRecoverableMessages(sessionId) }
|
||||
runCatching { drainPendingTextQueue(sessionId) }
|
||||
runCatching { drainPendingAttachmentQueue(sessionId) }
|
||||
}
|
||||
sseStream.connect(sessionId).collect { event ->
|
||||
when (event) {
|
||||
is SessionStreamEvent.Snapshot -> {
|
||||
@@ -722,6 +728,7 @@ class RemoteOpenClawRepository(
|
||||
is SessionStreamEvent.Failed -> {
|
||||
val dto = event.payload
|
||||
if (!dto.recoverable) {
|
||||
streamRecoveryQueueDrainPending.remove(sessionId)
|
||||
streamStatusStore = streamStatusStore + (sessionId to "failed")
|
||||
syncSessionStreamStatus(sessionId)
|
||||
messageStore = messageStore + (
|
||||
@@ -737,6 +744,7 @@ class RemoteOpenClawRepository(
|
||||
updateSessionPreview(sessionId, previewMessage(messageStore[sessionId].orEmpty()))
|
||||
return@collect
|
||||
}
|
||||
streamRecoveryQueueDrainPending.add(sessionId)
|
||||
streamStatusStore = streamStatusStore + (sessionId to "reconnecting")
|
||||
syncSessionStreamStatus(sessionId)
|
||||
// recoverable: will retry via outer while loop
|
||||
@@ -746,6 +754,7 @@ class RemoteOpenClawRepository(
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
} catch (_: Throwable) {
|
||||
streamRecoveryQueueDrainPending.add(sessionId)
|
||||
streamStatusStore = streamStatusStore + (sessionId to "reconnecting")
|
||||
syncSessionStreamStatus(sessionId)
|
||||
delay(1500)
|
||||
|
||||
@@ -207,7 +207,8 @@ Android/iOS App
|
||||
- [x] Repository 的核心写状态入口已开始复用派生状态映射:新增 `textStatusForLocalPhase()` / `attachmentStatusForLocalPhase()`,用于统一写入手动处理中、队列处理中、失败态、完成态,减少散落的状态字符串
|
||||
- [x] 又收了一轮边角判断:文本入队去重、auto-retry 候选过滤、本地 retainable/failure 判定开始复用派生状态辅助函数,继续减少裸 `status == ...` 分支
|
||||
- [ ] 还没有完整的离线发送队列(当前已覆盖文本 + 附件,但还没有更完整的网络感知、后台 drain 与统一淘汰策略)
|
||||
- [ ] 还没有真正基于网络恢复信号的自动补发
|
||||
- [x] 已补第一版“网络恢复后继续处理待发队列”:当会话 SSE 从 recoverable failed / reconnecting 回到 live 时,会顺手尝试 auto-retry + drain 当前会话的文本/附件 pending
|
||||
- [ ] 还没有更完整的网络恢复策略(目前先基于会话 SSE 恢复触发,不含更底层网络监听或全局后台队列调度)
|
||||
|
||||
### 4.2 附件后端主链路
|
||||
|
||||
|
||||
Reference in new issue
Block a user