Differentiate manual sync feedback
This commit is contained in:
1 parent
1764e03263
commit
6bb2d939a6
3 files changed
+25
-24
No files matched your search
@@ -129,7 +129,7 @@ private fun OpenClawRoot(appState: OpenClawAppState) {
|
|||||||
|
|
||||||
LaunchedEffect(appState.isConfigured) {
|
LaunchedEffect(appState.isConfigured) {
|
||||||
if (appState.isConfigured) {
|
if (appState.isConfigured) {
|
||||||
appState.syncRemoteIfNeeded()
|
appState.syncRemoteIfNeeded(trigger = cn.xiaobai.openclawapp.app.SyncTrigger.Initial)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,7 +315,7 @@ private fun OpenClawRoot(appState: OpenClawAppState) {
|
|||||||
onRetry = {
|
onRetry = {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
appState.clearSyncError()
|
appState.clearSyncError()
|
||||||
appState.syncRemoteIfNeeded()
|
appState.syncRemoteIfNeeded(trigger = cn.xiaobai.openclawapp.app.SyncTrigger.Manual)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -336,7 +336,7 @@ private fun OpenClawRoot(appState: OpenClawAppState) {
|
|||||||
onRefreshOverview = {
|
onRefreshOverview = {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
appState.clearSyncError()
|
appState.clearSyncError()
|
||||||
appState.syncRemoteIfNeeded()
|
appState.syncRemoteIfNeeded(trigger = cn.xiaobai.openclawapp.app.SyncTrigger.Manual)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDisconnect = appState::disconnect,
|
onDisconnect = appState::disconnect,
|
||||||
@@ -358,7 +358,7 @@ private fun OpenClawRoot(appState: OpenClawAppState) {
|
|||||||
onRefreshOverview = {
|
onRefreshOverview = {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
appState.clearSyncError()
|
appState.clearSyncError()
|
||||||
appState.syncRemoteIfNeeded()
|
appState.syncRemoteIfNeeded(trigger = cn.xiaobai.openclawapp.app.SyncTrigger.Manual)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDisconnect = appState::disconnect,
|
onDisconnect = appState::disconnect,
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ import cn.xiaobai.openclawapp.network.MobileGatewayApi
|
|||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.coroutineScope
|
import kotlinx.coroutines.coroutineScope
|
||||||
|
|
||||||
|
enum class SyncTrigger {
|
||||||
|
Initial,
|
||||||
|
Manual,
|
||||||
|
Background,
|
||||||
|
}
|
||||||
|
|
||||||
class OpenClawAppState(
|
class OpenClawAppState(
|
||||||
private val preferences: AppPreferences = AppPreferences(),
|
private val preferences: AppPreferences = AppPreferences(),
|
||||||
) {
|
) {
|
||||||
@@ -103,7 +109,7 @@ class OpenClawAppState(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun syncRemoteIfNeeded() {
|
suspend fun syncRemoteIfNeeded(trigger: SyncTrigger = SyncTrigger.Initial) {
|
||||||
val remote = repository as? RemoteOpenClawRepository ?: return
|
val remote = repository as? RemoteOpenClawRepository ?: return
|
||||||
isSyncing = true
|
isSyncing = true
|
||||||
syncError = null
|
syncError = null
|
||||||
@@ -121,13 +127,22 @@ class OpenClawAppState(
|
|||||||
preferences.saveOverviewSnapshot(remote.exportOverviewSnapshot())
|
preferences.saveOverviewSnapshot(remote.exportOverviewSnapshot())
|
||||||
persistRecentMessageCache(remote)
|
persistRecentMessageCache(remote)
|
||||||
persistPendingSendQueue(remote)
|
persistPendingSendQueue(remote)
|
||||||
if (drainedText || drainedAttachments) {
|
when {
|
||||||
|
drainedText || drainedAttachments -> {
|
||||||
feedbackMessage = "已尝试继续处理本地待发队列"
|
feedbackMessage = "已尝试继续处理本地待发队列"
|
||||||
}
|
}
|
||||||
|
trigger == SyncTrigger.Manual -> {
|
||||||
|
feedbackMessage = "已同步最新状态"
|
||||||
|
}
|
||||||
|
}
|
||||||
isShowingCachedData = false
|
isShowingCachedData = false
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
syncError = it.message ?: "远程同步失败"
|
syncError = it.message ?: "远程同步失败"
|
||||||
feedbackMessage = "Remote 同步失败"
|
feedbackMessage = if (trigger == SyncTrigger.Background) {
|
||||||
|
syncError
|
||||||
|
} else {
|
||||||
|
"同步失败"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
isSyncing = false
|
isSyncing = false
|
||||||
}
|
}
|
||||||
@@ -135,22 +150,7 @@ class OpenClawAppState(
|
|||||||
suspend fun refreshOverviewSilently() {
|
suspend fun refreshOverviewSilently() {
|
||||||
val remote = repository as? RemoteOpenClawRepository ?: return
|
val remote = repository as? RemoteOpenClawRepository ?: return
|
||||||
if (isSyncing || sendingSessionId != null) return
|
if (isSyncing || sendingSessionId != null) return
|
||||||
|
syncRemoteIfNeeded(trigger = SyncTrigger.Background)
|
||||||
runCatching {
|
|
||||||
coroutineScope {
|
|
||||||
val statusDeferred = async { remote.refreshStatus() }
|
|
||||||
val agentsDeferred = async { remote.refreshAgents() }
|
|
||||||
val sessionsDeferred = async { remote.refreshSessions() }
|
|
||||||
statusDeferred.await()
|
|
||||||
agentsDeferred.await()
|
|
||||||
sessionsDeferred.await()
|
|
||||||
}
|
|
||||||
preferences.saveOverviewSnapshot(remote.exportOverviewSnapshot())
|
|
||||||
persistPendingSendQueue(remote)
|
|
||||||
isShowingCachedData = false
|
|
||||||
}.onFailure {
|
|
||||||
syncError = it.message ?: "远程同步失败"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun openSession(sessionId: String) {
|
suspend fun openSession(sessionId: String) {
|
||||||
@@ -223,7 +223,7 @@ class OpenClawAppState(
|
|||||||
serverConfig = serverConfig.copy(defaultAgent = agent)
|
serverConfig = serverConfig.copy(defaultAgent = agent)
|
||||||
preferences.saveServerConfig(serverConfig)
|
preferences.saveServerConfig(serverConfig)
|
||||||
repository.status = repository.status.copy(defaultAgent = agent)
|
repository.status = repository.status.copy(defaultAgent = agent)
|
||||||
syncRemoteIfNeeded()
|
syncRemoteIfNeeded(trigger = SyncTrigger.Manual)
|
||||||
feedbackMessage = "默认 Agent 已切换到 $agent"
|
feedbackMessage = "默认 Agent 已切换到 $agent"
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
syncError = it.message ?: "默认 Agent 切换失败"
|
syncError = it.message ?: "默认 Agent 切换失败"
|
||||||
|
|||||||
@@ -460,3 +460,4 @@ Android/iOS App
|
|||||||
- 2026-03-07:开始补主动自救能力:会话页新增常驻“刷新”入口,不再只有报错卡里才有重试;设置页新增“立即同步”入口,让用户能主动拉取状态 / agents / 会话列表,而不是只能等后台轮询或进详情页触发刷新。
|
- 2026-03-07:开始补主动自救能力:会话页新增常驻“刷新”入口,不再只有报错卡里才有重试;设置页新增“立即同步”入口,让用户能主动拉取状态 / agents / 会话列表,而不是只能等后台轮询或进详情页触发刷新。
|
||||||
- 2026-03-07:会话页补上真正的下拉刷新:基于 Material3 `PullToRefreshBox` 接 `onRetry`,让列表页除了常驻“刷新”按钮外,也支持更符合移动端习惯的手势刷新。
|
- 2026-03-07:会话页补上真正的下拉刷新:基于 Material3 `PullToRefreshBox` 接 `onRetry`,让列表页除了常驻“刷新”按钮外,也支持更符合移动端习惯的手势刷新。
|
||||||
- 2026-03-07:聊天页也补上下拉刷新:沿用同一套 `PullToRefreshBox + onRetry` 机制,让会话详情除了顶栏刷新/重连外,也支持直接下拉拉取最新消息与状态。
|
- 2026-03-07:聊天页也补上下拉刷新:沿用同一套 `PullToRefreshBox + onRetry` 机制,让会话详情除了顶栏刷新/重连外,也支持直接下拉拉取最新消息与状态。
|
||||||
|
- 2026-03-07:同步反馈开始区分触发来源:把远端同步拆成 `Initial / Manual / Background` 三种触发语义,用户主动刷新成功时会明确提示“已同步最新状态”,后台静默刷新则尽量不打扰,避免轮询也频繁弹反馈,同时让手动操作的结果更可感知。
|
||||||
Reference in new issue
Block a user