From b3f009d644310688e5111ced08a35eb50b2593b9 Mon Sep 17 00:00:00 2001 From: OpenClaw Date: Sat, 7 Mar 2026 12:57:53 +0800 Subject: [PATCH] Align attachment queue drain states --- .../openclawapp/data/RemoteOpenClawRepository.kt | 9 +++++++-- .../xiaobai/openclawapp/feature/chat/ChatScreen.kt | 14 ++++++++++++++ docs/MVP_PROGRESS.md | 1 + 3 files changed, 22 insertions(+), 2 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 39b5c29..bd4cfa6 100644 --- a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/RemoteOpenClawRepository.kt +++ b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/RemoteOpenClawRepository.kt @@ -277,7 +277,7 @@ class RemoteOpenClawRepository( role = MessageRole.User, text = fileName, createdAt = "现在", - status = "uploading", + status = "queue-draining", kind = MessageKind.Attachment, contentType = contentType, sizeBytes = bytes.size, @@ -330,8 +330,13 @@ class RemoteOpenClawRepository( override suspend fun retryAttachment(sessionId: String, messageId: String) { val payload = attachmentRetryStore[messageId] ?: return val current = messageStore[sessionId].orEmpty() + val isQueueDrain = messageId in pendingAttachmentQueue val uploading = current.map { msg -> - if (msg.id == messageId) msg.copy(status = "uploading", retryable = false) else msg + if (msg.id == messageId) msg.copy( + status = if (isQueueDrain) "queue-draining" else "uploading", + retryable = false, + createdAt = "现在", + ) else msg } messageStore = messageStore + (sessionId to uploading) updateSessionPreview(sessionId, previewMessage(uploading)) 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 4c2bc68..5143b68 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 @@ -327,6 +327,7 @@ private fun MessageBubble( val toolResultText = if (shouldCollapseToolResult && !expanded) displayText.take(240).trimEnd() + "…" else displayText val displayStatus = when { animateText && visibleChars < message.text.length -> "streaming" + message.kind == MessageKind.Attachment && message.status == "queue-draining" -> "队列上传中" message.status == "queue-draining" -> "队列发送中" message.status == "retrying-auto" -> "自动重试中" message.status == "queued" -> "发送中" @@ -432,6 +433,19 @@ private fun MessageBubble( } } } + if (message.status == "queue-draining") { + Text( + text = "系统正在按本地待发队列继续上传这个附件…", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } else if (message.status == "uploading") { + Text( + text = "正在手动发起附件上传…", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } if (attachmentDetailsExpanded) { Column( modifier = Modifier diff --git a/docs/MVP_PROGRESS.md b/docs/MVP_PROGRESS.md index d93ef2d..1d4f7e9 100644 --- a/docs/MVP_PROGRESS.md +++ b/docs/MVP_PROGRESS.md @@ -199,6 +199,7 @@ Android/iOS App - [x] 已有保守版 queue drain:`openSession()` 会尝试继续发送当前会话的待发文本,`syncRemoteIfNeeded()` 会顺序尝试全局待发文本,失败即停 - [x] 聊天页已显式区分 queue drain 状态:队列自动处理中的文本会显示“队列发送中” - [x] pending queue 已开始同时覆盖文本与附件:附件待上传项也会独立持久化,并在重新进入会话或手动同步时继续尝试上传 +- [x] 附件上传状态已开始对齐队列语义:队列自动处理中的附件会显示“队列上传中”,与手动上传中的“上传中”分开 - [ ] 还没有完整的离线发送队列(当前已覆盖文本 + 附件,但还没有更完整的网络感知、后台 drain 与统一淘汰策略) - [ ] 还没有真正基于网络恢复信号的自动补发