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 9e60d26..da13320 100644 --- a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/RemoteOpenClawRepository.kt +++ b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/RemoteOpenClawRepository.kt @@ -530,6 +530,22 @@ class RemoteOpenClawRepository( updateSessionPreview(sessionId, previewMessage(merged)) } + suspend fun fetchSessionBootstrap(sessionId: String): SessionDetailState { + val bootstrap = api.getSessionBootstrap(sessionId) + val timeline = bootstrap.messages.map { dto -> + MessageTimelineItem.RemoteMessage(dto.toDomainMessage()) + } + return reduceSessionDetailState( + SessionDetailState(sessionId = bootstrap.sessionId), + SessionDetailEvent.BootstrapLoaded( + sessionId = bootstrap.sessionId, + timeline = timeline, + operations = emptyList(), + loadedAtMs = bootstrap.serverTs, + ), + ) + } + suspend fun retryAutoRecoverableMessages(sessionId: String): Boolean { val candidates = messageStore[sessionId].orEmpty() .filter { it.id in autoRetryMessageIds && it.isAutoRetryCandidate() } diff --git a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/network/MobileGatewayApi.kt b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/network/MobileGatewayApi.kt index bb5613a..3a6d9a0 100644 --- a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/network/MobileGatewayApi.kt +++ b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/network/MobileGatewayApi.kt @@ -51,6 +51,13 @@ class MobileGatewayApi( }.body() } + suspend fun getSessionBootstrap(sessionId: String): SessionBootstrapResponseDto { + val encodedId = sessionId.encodeURLPathPart() + return client.get("${baseUrl.trimEnd('/')}/api/sessions/$encodedId/bootstrap") { + authHeader() + }.body() + } + suspend fun sendMessage(sessionId: String, message: String): SendMessageResponseDto { val encodedId = sessionId.encodeURLPathPart() return client.post("${baseUrl.trimEnd('/')}/api/sessions/$encodedId/messages") { diff --git a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/network/MobileGatewayDtos.kt b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/network/MobileGatewayDtos.kt index 4ce350a..823418e 100644 --- a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/network/MobileGatewayDtos.kt +++ b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/network/MobileGatewayDtos.kt @@ -74,6 +74,30 @@ data class UpdateDefaultAgentResponseDto( val updatedAt: String, ) +@Serializable +data class SessionBootstrapResponseDto( + val sessionId: String, + val messages: List = emptyList(), + val operations: List = emptyList(), + val streamState: String = "idle", + val serverTs: Long = 0, +) + +@Serializable +data class SessionBootstrapOperationDto( + val opId: String, + val sessionId: String, + val type: String, + val state: String, + val createdAtMs: Long, + val clientRequestId: String, + val payloadSummary: String, + val attemptCount: Int = 0, + val lastError: String? = null, + val correlationToken: String? = null, + val materializedMessageIds: List = emptyList(), +) + @Serializable data class UploadAttachmentResponseDto( @JsonNames("accepted", "accept") diff --git a/docs/MVP_PROGRESS.md b/docs/MVP_PROGRESS.md index 8b755c9..13c953f 100644 --- a/docs/MVP_PROGRESS.md +++ b/docs/MVP_PROGRESS.md @@ -463,3 +463,4 @@ Android/iOS App - 2026-03-07:同步反馈开始区分触发来源:把远端同步拆成 `Initial / Manual / Background` 三种触发语义,用户主动刷新成功时会明确提示“已同步最新状态”,后台静默刷新则尽量不打扰,避免轮询也频繁弹反馈,同时让手动操作的结果更可感知。 - 2026-03-07:开始统一发送反馈语言:聊天时间线里把文本/附件/工具的状态从泛化的“处理中 / 失败”细化成用户更能理解的产品文案,如“发送中 / 上传中 / 发送队列中 / 自动重试中 / 执行中 / 发送失败 / 上传失败 / 生成失败”,让用户更清楚当前到底卡在哪一环。 - 2026-03-07:正式启动“统一机制”重构 Phase 1:新增 `docs/UNIFIED_DELIVERY_ARCHITECTURE.md` 作为设计稿;App 新增 `UnifiedDeliveryModels.kt`,定义 `DeliveryOperation / SessionDetailState / SessionDetailEvent / reducer` 骨架;BFF 新增 `unified_models.py` 并预留 `/api/sessions/{session_id}/bootstrap` 响应模型与空接口,先把新主干立起来,后续再逐步把旧 pending/SSE/refresh 逻辑迁过去。 +- 2026-03-07:继续推进 Phase 1:BFF 已把 `/api/sessions/{session_id}/bootstrap` 接成真实数据骨架(当前返回 canonical messages + 空 operations + streamState/serverTs);App 已补上 `SessionBootstrapResponseDto`、`getSessionBootstrap()` 和 `fetchSessionBootstrap()` 入口,开始具备并行验证新 bootstrap 流程的能力,但尚未切换 UI 到新模型。