From 1d5dad314a3f4e4f5fca90151cabbfb79e9f4186 Mon Sep 17 00:00:00 2001 From: OpenClaw Date: Sat, 7 Mar 2026 14:31:29 +0800 Subject: [PATCH] Differentiate SSE reconnect from upstream recovery --- .../cn/xiaobai/openclawapp/data/RemoteOpenClawRepository.kt | 4 ++-- .../kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt | 2 ++ .../xiaobai/openclawapp/feature/sessions/SessionListScreen.kt | 3 ++- docs/MVP_PROGRESS.md | 2 ++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/RemoteOpenClawRepository.kt b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/RemoteOpenClawRepository.kt index 07ca3ee..0ca17e3 100644 --- a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/RemoteOpenClawRepository.kt +++ b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/RemoteOpenClawRepository.kt @@ -842,9 +842,9 @@ class RemoteOpenClawRepository( return@collect } streamRecoveryQueueDrainPending.add(sessionId) - streamStatusStore = streamStatusStore + (sessionId to "reconnecting") + streamStatusStore = streamStatusStore + (sessionId to "recovering") syncSessionStreamStatus(sessionId) - // recoverable: will retry via outer while loop + // recoverable upstream polling hiccup inside active SSE stream } } } diff --git a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt index d7a1023..90ec960 100644 --- a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt +++ b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt @@ -95,6 +95,7 @@ fun ChatScreen( Text( when { isSending -> "消息请求已提交,正在等待 SSE 首帧…" + streamStatus == "recovering" -> "上游消息轮询短暂异常,正在自动恢复…" streamStatus == "reconnecting" -> "SSE 连接中断,正在重连…" streamStatus == "failed" -> "SSE 已断开,请手动重试。" streamStatus == "connecting" -> "正在建立 SSE 连接…" @@ -108,6 +109,7 @@ fun ChatScreen( StatusPill( text = when { isLoading -> "同步中" + streamStatus == "recovering" -> "恢复中" streamStatus == "reconnecting" -> "重连中" streamStatus == "failed" -> "已断流" streamStatus == "connecting" -> "连接中" diff --git a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/sessions/SessionListScreen.kt b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/sessions/SessionListScreen.kt index b64b55d..3ce26cc 100644 --- a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/sessions/SessionListScreen.kt +++ b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/sessions/SessionListScreen.kt @@ -190,13 +190,14 @@ fun SessionListScreen( session.streamStatus?.let { streamStatus -> StatusPill( text = when (streamStatus) { + "recovering" -> "恢复中" "reconnecting" -> "重连中" "failed" -> "已断流" "connecting" -> "连接中" "live" -> "在线" else -> streamStatus }, - highlighted = streamStatus == "live", + highlighted = streamStatus == "live" || streamStatus == "recovering", ) } } diff --git a/docs/MVP_PROGRESS.md b/docs/MVP_PROGRESS.md index 7a4be63..9a6a664 100644 --- a/docs/MVP_PROGRESS.md +++ b/docs/MVP_PROGRESS.md @@ -210,6 +210,7 @@ Android/iOS App - [x] 已补第一版“网络恢复后继续处理待发队列”:当会话 SSE 从 recoverable failed / reconnecting 回到 live 时,会顺手尝试 auto-retry + drain 当前会话的文本/附件 pending - [x] 已给 session 级自动恢复补简易防重入/短节流:`openSession()` 和 SSE recovery 现在共用 `recoverPendingQueueForSession(...)`,避免短时间内对同一会话重复触发 queue recovery - [x] 已补 queue recovery 轻量可观测性:pending queue 状态里会暴露“正在恢复中 / 刚因节流跳过”,聊天页和反馈文案能区分“真在跑”和“刚跑过所以先跳过” +- [x] 已区分“SSE 传输层重连”和“BFF 上游轮询恢复中”:`run.failed(recoverable=true)` 不再一律显示成“SSE 连接中断”,而是显示为上游恢复中,减少会话详情页的假断流提示 - [x] 已开始收紧本地 pending 与远端消息的匹配条件:文本 pending 不再只看裸文本;附件 pending 除文件名外还会参考 `contentType/sizeBytes`,降低同文案/同文件名重发时的误合并风险 - [x] 已给附件 pending 增加本地匹配指纹:基于 `fileName/contentType/sizeBytes/bytes 前缀 hash` 生成轻量 fingerprint,并随 pending queue / message cache 持久化,进一步降低同名附件重传时的误匹配概率 - [x] 已给文本 pending 增加本地 client token:本地发送/失败回落/缓存恢复/队列持久化都会带上 token,文本 pending 与远端消息归并时优先参考 token,降低“同文案连续发送”时的误匹配概率 @@ -221,6 +222,7 @@ Android/iOS App - 附件消息进入了 BFF overlay - 但还没有真正桥接进 OpenClaw 原生历史 / 原生附件能力 +- [x] BFF 启动期已补一轮 redirect 自愈:`_load_attachment_index()` 恢复 redirect-only meta 时会检查目标 payload 是否仍存在;若目标已丢失,会直接清理历史 redirect 空壳,避免保留“结构可解析、读取必 404”的假入口 ### 4.3 附件交互动作