Introduce explicit app routes

This commit is contained in:
OpenClaw committed 2026-03-07 15:38:55 +08:00
1 parent 6543f83b3a
commit dc7083507d
4 files changed
+207 -197

No files matched your search

@@ -3,10 +3,13 @@ package cn.xiaobai.openclawapp
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.NavigationBar import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
@@ -16,7 +19,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import cn.xiaobai.openclawapp.app.MainTab import cn.xiaobai.openclawapp.app.AppRoute
import cn.xiaobai.openclawapp.app.OpenClawAppState import cn.xiaobai.openclawapp.app.OpenClawAppState
import cn.xiaobai.openclawapp.data.ServerConfig import cn.xiaobai.openclawapp.data.ServerConfig
import cn.xiaobai.openclawapp.feature.chat.ChatScreen import cn.xiaobai.openclawapp.feature.chat.ChatScreen
@@ -24,6 +27,7 @@ import cn.xiaobai.openclawapp.feature.config.ServerConfigScreen
import cn.xiaobai.openclawapp.feature.sessions.SessionListScreen import cn.xiaobai.openclawapp.feature.sessions.SessionListScreen
import cn.xiaobai.openclawapp.feature.settings.SettingsScreen import cn.xiaobai.openclawapp.feature.settings.SettingsScreen
import cn.xiaobai.openclawapp.feature.status.StatusScreen import cn.xiaobai.openclawapp.feature.status.StatusScreen
import cn.xiaobai.openclawapp.platform.PlatformBackHandler
import cn.xiaobai.openclawapp.platform.rememberAttachmentOpener import cn.xiaobai.openclawapp.platform.rememberAttachmentOpener
import cn.xiaobai.openclawapp.platform.rememberAttachmentPicker import cn.xiaobai.openclawapp.platform.rememberAttachmentPicker
import cn.xiaobai.openclawapp.platform.rememberAttachmentSaver import cn.xiaobai.openclawapp.platform.rememberAttachmentSaver
@@ -77,9 +81,10 @@ fun App() {
} }
} }
@OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
private fun OpenClawRoot(appState: OpenClawAppState) { private fun OpenClawRoot(appState: OpenClawAppState) {
val activeSession = appState.activeSessionId?.let(appState.repository::findSession) val activeSession = (appState.currentRoute as? AppRoute.Chat)?.sessionId?.let(appState.repository::findSession)
val coroutineScope = rememberCoroutineScope() val coroutineScope = rememberCoroutineScope()
val pickAttachment = rememberAttachmentPicker( val pickAttachment = rememberAttachmentPicker(
onPicked = { picked -> onPicked = { picked ->
@@ -107,6 +112,10 @@ private fun OpenClawRoot(appState: OpenClawAppState) {
appState.feedbackMessage = message appState.feedbackMessage = message
} }
PlatformBackHandler(enabled = appState.currentRoute is AppRoute.Chat) {
appState.navigateBack()
}
LaunchedEffect(appState.feedbackMessage) { LaunchedEffect(appState.feedbackMessage) {
if (appState.feedbackMessage != null) { if (appState.feedbackMessage != null) {
delay(2200) delay(2200)
@@ -129,24 +138,67 @@ private fun OpenClawRoot(appState: OpenClawAppState) {
} }
Scaffold( Scaffold(
topBar = {
when (val route = appState.currentRoute) {
is AppRoute.Chat -> {
CenterAlignedTopAppBar(
title = {
Text(activeSession?.title ?: "会话")
},
navigationIcon = {
TextButton(onClick = appState::closeChat) {
Text("返回")
}
},
actions = {
TextButton(onClick = { pickAttachment() }) {
Text("附件")
}
TextButton(onClick = {
activeSession?.id?.let { sessionId ->
coroutineScope.launch {
appState.clearSyncError()
appState.openSession(sessionId)
}
}
}) {
Text(if (appState.repository.streamStatusFor(route.sessionId) == "failed") "重连" else "刷新")
}
},
)
}
AppRoute.Sessions -> {
CenterAlignedTopAppBar(title = { Text("会话") })
}
AppRoute.Status -> {
CenterAlignedTopAppBar(title = { Text("状态") })
}
AppRoute.Settings -> {
CenterAlignedTopAppBar(title = { Text("设置") })
}
}
},
bottomBar = { bottomBar = {
if (activeSession == null) { if (appState.currentRoute !is AppRoute.Chat) {
NavigationBar { NavigationBar {
NavigationBarItem( NavigationBarItem(
selected = appState.selectedTab == MainTab.Sessions, selected = appState.currentRoute == AppRoute.Sessions,
onClick = { appState.selectedTab = MainTab.Sessions }, onClick = { appState.navigateTo(AppRoute.Sessions) },
icon = { Text("💬") }, icon = { Text("💬") },
label = { Text("会话") }, label = { Text("会话") },
) )
NavigationBarItem( NavigationBarItem(
selected = appState.selectedTab == MainTab.Status, selected = appState.currentRoute == AppRoute.Status,
onClick = { appState.selectedTab = MainTab.Status }, onClick = { appState.navigateTo(AppRoute.Status) },
icon = { Text("📡") }, icon = { Text("📡") },
label = { Text("状态") }, label = { Text("状态") },
) )
NavigationBarItem( NavigationBarItem(
selected = appState.selectedTab == MainTab.Settings, selected = appState.currentRoute == AppRoute.Settings,
onClick = { appState.selectedTab = MainTab.Settings }, onClick = { appState.navigateTo(AppRoute.Settings) },
icon = { Text("⚙️") }, icon = { Text("⚙️") },
label = { Text("设置") }, label = { Text("设置") },
) )
@@ -167,88 +219,91 @@ private fun OpenClawRoot(appState: OpenClawAppState) {
) )
} }
when { when (val route = appState.currentRoute) {
activeSession != null -> ChatScreen( is AppRoute.Chat -> {
modifier = Modifier.fillMaxSize(), val session = activeSession ?: return@Column
sessionTitle = activeSession.title, ChatScreen(
messages = appState.repository.messagesFor(activeSession.id), modifier = Modifier.fillMaxSize(),
isSending = appState.sendingSessionId == activeSession.id, sessionTitle = session.title,
isLoading = appState.isSyncing, messages = appState.repository.messagesFor(session.id),
errorMessage = appState.syncError, isSending = appState.sendingSessionId == session.id,
streamStatus = appState.repository.streamStatusFor(activeSession.id), isLoading = appState.isSyncing,
pendingQueueStatus = appState.repository.pendingQueueStatus(activeSession.id).let { queue -> errorMessage = appState.syncError,
when { streamStatus = appState.repository.streamStatusFor(session.id),
queue.recoveryInFlight && queue.sessionCount > 0 -> "当前会话还有 ${queue.sessionCount} 条待发项,系统正在恢复并继续处理本地队列。" pendingQueueStatus = appState.repository.pendingQueueStatus(session.id).let { queue ->
queue.recoveryRecentlySkipped && queue.sessionCount > 0 -> "当前会话的待发队列刚刚已处理过一轮,本次先跳过重复恢复。" when {
queue.isDraining && queue.sessionCount > 0 -> "当前会话还有 ${queue.sessionCount} 条待发项,系统正在按本地队列继续处理。" queue.recoveryInFlight && queue.sessionCount > 0 -> "当前会话还有 ${queue.sessionCount} 条待发项,系统正在恢复并继续处理本地队列。"
queue.sessionCount > 0 -> "当前会话还有 ${queue.sessionCount} 条待发项未完成,可继续重试或等待下一次自动处理。" queue.recoveryRecentlySkipped && queue.sessionCount > 0 -> "当前会话的待发队列刚刚已处理过一轮,本次先跳过重复恢复。"
else -> null queue.isDraining && queue.sessionCount > 0 -> "当前会话还有 ${queue.sessionCount} 条待发项,系统正在按本地队列继续处理。"
} queue.sessionCount > 0 -> "当前会话还有 ${queue.sessionCount} 条待发项未完成,可继续重试或等待下一次自动处理。"
}, else -> null
cacheNotice = if (appState.isShowingCachedData) {
"当前展示的是本地缓存${appState.cacheSavedAt?.let { "(保存于 $it)" } ?: ""},正在等待最新数据。"
} else null,
onBack = appState::closeChat,
onRetry = {
coroutineScope.launch {
appState.clearSyncError()
appState.openSession(activeSession.id)
}
},
onSend = { text ->
coroutineScope.launch {
appState.sendMessage(activeSession.id, text)
}
},
onSendAttachmentStub = {
pickAttachment()
},
onRetryAttachment = { messageId ->
coroutineScope.launch {
appState.retryAttachment(activeSession.id, messageId)
}
},
onRetryMessage = { messageId ->
coroutineScope.launch {
appState.retryMessage(activeSession.id, messageId)
}
},
onCopyAttachmentName = { fileName ->
copyToClipboard(fileName)
},
onOpenAttachment = { messageId ->
coroutineScope.launch {
runCatching {
appState.repository.ensureAttachmentOpenPayload(activeSession.id, messageId)
}.onSuccess { payload ->
if (payload != null) {
openAttachment(payload)
} else {
appState.feedbackMessage = "当前附件暂无可打开内容"
}
}.onFailure {
appState.feedbackMessage = it.message ?: "打开附件失败"
} }
} },
}, cacheNotice = if (appState.isShowingCachedData) {
onDownloadAttachment = { messageId -> "当前展示的是本地缓存${appState.cacheSavedAt?.let { "(保存于 $it)" } ?: ""},正在等待最新数据。"
coroutineScope.launch { } else null,
runCatching { onBack = appState::closeChat,
appState.repository.ensureAttachmentOpenPayload(activeSession.id, messageId) onRetry = {
}.onSuccess { payload -> coroutineScope.launch {
if (payload != null) { appState.clearSyncError()
saveAttachment(payload) appState.openSession(session.id)
} else {
appState.feedbackMessage = "当前附件暂无可下载内容"
}
}.onFailure {
appState.feedbackMessage = it.message ?: "下载附件失败"
} }
} },
}, onSend = { text ->
) coroutineScope.launch {
appState.sendMessage(session.id, text)
}
},
onSendAttachmentStub = {
pickAttachment()
},
onRetryAttachment = { messageId ->
coroutineScope.launch {
appState.retryAttachment(session.id, messageId)
}
},
onRetryMessage = { messageId ->
coroutineScope.launch {
appState.retryMessage(session.id, messageId)
}
},
onCopyAttachmentName = { fileName ->
copyToClipboard(fileName)
},
onOpenAttachment = { messageId ->
coroutineScope.launch {
runCatching {
appState.repository.ensureAttachmentOpenPayload(session.id, messageId)
}.onSuccess { payload ->
if (payload != null) {
openAttachment(payload)
} else {
appState.feedbackMessage = "当前附件暂无可打开内容"
}
}.onFailure {
appState.feedbackMessage = it.message ?: "打开附件失败"
}
}
},
onDownloadAttachment = { messageId ->
coroutineScope.launch {
runCatching {
appState.repository.ensureAttachmentOpenPayload(session.id, messageId)
}.onSuccess { payload ->
if (payload != null) {
saveAttachment(payload)
} else {
appState.feedbackMessage = "当前附件暂无可下载内容"
}
}.onFailure {
appState.feedbackMessage = it.message ?: "下载附件失败"
}
}
},
)
}
appState.selectedTab == MainTab.Sessions -> SessionListScreen( AppRoute.Sessions -> SessionListScreen(
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
sessions = appState.repository.sessions, sessions = appState.repository.sessions,
recentSession = appState.repository.recentSession(), recentSession = appState.repository.recentSession(),
@@ -269,12 +324,12 @@ private fun OpenClawRoot(appState: OpenClawAppState) {
}, },
) )
appState.selectedTab == MainTab.Status -> StatusScreen( AppRoute.Status -> StatusScreen(
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
status = appState.repository.status, status = appState.repository.status,
) )
appState.selectedTab == MainTab.Settings -> SettingsScreen( AppRoute.Settings -> SettingsScreen(
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
serverConfig = appState.serverConfig, serverConfig = appState.serverConfig,
currentModel = appState.repository.status.currentModel, currentModel = appState.repository.status.currentModel,
@@ -13,8 +13,9 @@ import cn.xiaobai.openclawapp.network.MobileGatewayApi
class OpenClawAppState( class OpenClawAppState(
private val preferences: AppPreferences = AppPreferences(), private val preferences: AppPreferences = AppPreferences(),
) { ) {
var selectedTab by mutableStateOf(MainTab.Sessions) var currentRoute by mutableStateOf<AppRoute>(AppRoute.Sessions)
var activeSessionId by mutableStateOf<String?>(null) val activeSessionId: String?
get() = (currentRoute as? AppRoute.Chat)?.sessionId
var serverConfig by mutableStateOf(preferences.loadServerConfig()) var serverConfig by mutableStateOf(preferences.loadServerConfig())
var feedbackMessage by mutableStateOf<String?>(null) var feedbackMessage by mutableStateOf<String?>(null)
var themeMode by mutableStateOf(preferences.loadThemeMode()) var themeMode by mutableStateOf(preferences.loadThemeMode())
@@ -78,8 +79,7 @@ class OpenClawAppState(
fun disconnect() { fun disconnect() {
isConfigured = false isConfigured = false
activeSessionId = null currentRoute = AppRoute.Sessions
selectedTab = MainTab.Sessions
syncError = null syncError = null
configError = null configError = null
serverConfig = serverConfig.copy(token = "") serverConfig = serverConfig.copy(token = "")
@@ -88,6 +88,19 @@ class OpenClawAppState(
feedbackMessage = "连接已断开" feedbackMessage = "连接已断开"
} }
fun navigateTo(route: AppRoute) {
currentRoute = route
}
fun navigateBack(): Boolean {
return if (currentRoute is AppRoute.Chat) {
currentRoute = AppRoute.Sessions
true
} else {
false
}
}
suspend fun syncRemoteIfNeeded() { suspend fun syncRemoteIfNeeded() {
val remote = repository as? RemoteOpenClawRepository ?: return val remote = repository as? RemoteOpenClawRepository ?: return
isSyncing = true isSyncing = true
@@ -130,7 +143,7 @@ class OpenClawAppState(
suspend fun openSession(sessionId: String) { suspend fun openSession(sessionId: String) {
repository.markSessionOpened(sessionId) repository.markSessionOpened(sessionId)
activeSessionId = sessionId currentRoute = AppRoute.Chat(sessionId)
val remote = repository as? RemoteOpenClawRepository ?: return val remote = repository as? RemoteOpenClawRepository ?: return
isSyncing = true isSyncing = true
runCatching { runCatching {
@@ -153,7 +166,7 @@ class OpenClawAppState(
} }
fun closeChat() { fun closeChat() {
activeSessionId = null navigateBack()
} }
suspend fun sendMessage(sessionId: String, text: String) { suspend fun sendMessage(sessionId: String, text: String) {
@@ -289,10 +302,11 @@ class OpenClawAppState(
} }
} }
enum class MainTab { sealed interface AppRoute {
Sessions, data object Sessions : AppRoute
Status, data object Status : AppRoute
Settings, data object Settings : AppRoute
data class Chat(val sessionId: String) : AppRoute
} }
enum class AppThemeMode(val label: String) { enum class AppThemeMode(val label: String) {
@@ -38,7 +38,6 @@ import cn.xiaobai.openclawapp.data.LocalMessagePhase
import cn.xiaobai.openclawapp.data.MessageKind import cn.xiaobai.openclawapp.data.MessageKind
import cn.xiaobai.openclawapp.data.MessageRole import cn.xiaobai.openclawapp.data.MessageRole
import cn.xiaobai.openclawapp.data.localMessagePhase import cn.xiaobai.openclawapp.data.localMessagePhase
import cn.xiaobai.openclawapp.platform.PlatformBackHandler
import cn.xiaobai.openclawapp.ui.EmptyStateCard import cn.xiaobai.openclawapp.ui.EmptyStateCard
import cn.xiaobai.openclawapp.ui.StatusPill import cn.xiaobai.openclawapp.ui.StatusPill
import cn.xiaobai.openclawapp.ui.StatusPillTone import cn.xiaobai.openclawapp.ui.StatusPillTone
@@ -55,18 +54,14 @@ fun ChatScreen(
streamStatus: String?, streamStatus: String?,
pendingQueueStatus: String?, pendingQueueStatus: String?,
cacheNotice: String?, cacheNotice: String?,
onBack: () -> Unit,
onRetry: () -> Unit, onRetry: () -> Unit,
onSend: (String) -> Unit, onSend: (String) -> Unit,
onSendAttachmentStub: () -> Unit,
onRetryAttachment: (String) -> Unit, onRetryAttachment: (String) -> Unit,
onRetryMessage: (String) -> Unit, onRetryMessage: (String) -> Unit,
onCopyAttachmentName: (String) -> Unit, onCopyAttachmentName: (String) -> Unit,
onOpenAttachment: (String) -> Unit, onOpenAttachment: (String) -> Unit,
onDownloadAttachment: (String) -> Unit, onDownloadAttachment: (String) -> Unit,
) { ) {
PlatformBackHandler(onBack = onBack)
var input by remember { mutableStateOf("") } var input by remember { mutableStateOf("") }
val listState = rememberLazyListState() val listState = rememberLazyListState()
@@ -91,13 +86,7 @@ fun ChatScreen(
modifier = modifier.padding(16.dp), modifier = modifier.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(12.dp), verticalArrangement = Arrangement.spacedBy(12.dp),
) { ) {
ChatHeader( ChatStatusBanner(topStatus = topStatus)
sessionTitle = sessionTitle,
topStatus = topStatus,
onBack = onBack,
onRetry = onRetry,
onSendAttachmentStub = onSendAttachmentStub,
)
if (messages.isEmpty() && !isLoading) { if (messages.isEmpty() && !isLoading) {
EmptyStateCard( EmptyStateCard(
@@ -170,7 +159,7 @@ fun ChatScreen(
onValueChange = { input = it }, onValueChange = { input = it },
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),
label = { Text("输入消息") }, label = { Text("输入消息") },
placeholder = { Text("给 OpenClaw 发一句话") }, placeholder = { Text("给 $sessionTitle 发一句话") },
maxLines = 4, maxLines = 4,
enabled = !isSending, enabled = !isSending,
) )
@@ -194,7 +183,6 @@ fun ChatScreen(
private data class ChatTopStatus( private data class ChatTopStatus(
val text: String, val text: String,
val tone: StatusPillTone, val tone: StatusPillTone,
val actionLabel: String,
) )
private fun buildChatTopStatus( private fun buildChatTopStatus(
@@ -209,149 +197,100 @@ private fun buildChatTopStatus(
errorMessage != null -> ChatTopStatus( errorMessage != null -> ChatTopStatus(
text = errorMessage, text = errorMessage,
tone = StatusPillTone.Error, tone = StatusPillTone.Error,
actionLabel = "重试",
) )
pendingQueueStatus != null -> ChatTopStatus( pendingQueueStatus != null -> ChatTopStatus(
text = pendingQueueStatus, text = pendingQueueStatus,
tone = StatusPillTone.Warning, tone = StatusPillTone.Warning,
actionLabel = if (streamStatus == "failed") "重连" else "刷新",
) )
cacheNotice != null -> ChatTopStatus( cacheNotice != null -> ChatTopStatus(
text = cacheNotice, text = cacheNotice,
tone = StatusPillTone.Warning, tone = StatusPillTone.Warning,
actionLabel = if (streamStatus == "failed") "重连" else "刷新",
) )
isSending -> ChatTopStatus( isSending -> ChatTopStatus(
text = "正在等待实时回复…", text = "正在等待实时回复…",
tone = StatusPillTone.Info, tone = StatusPillTone.Info,
actionLabel = "刷新",
) )
isLoading -> ChatTopStatus( isLoading -> ChatTopStatus(
text = "正在同步消息…", text = "正在同步消息…",
tone = StatusPillTone.Info, tone = StatusPillTone.Info,
actionLabel = "刷新",
) )
streamStatus == "recovering" -> ChatTopStatus( streamStatus == "recovering" -> ChatTopStatus(
text = "上游恢复中,消息会继续同步。", text = "上游恢复中,消息会继续同步。",
tone = StatusPillTone.Warning, tone = StatusPillTone.Warning,
actionLabel = "刷新",
) )
streamStatus == "reconnecting" -> ChatTopStatus( streamStatus == "reconnecting" -> ChatTopStatus(
text = "正在重连实时流。", text = "正在重连实时流。",
tone = StatusPillTone.Warning, tone = StatusPillTone.Warning,
actionLabel = "重连",
) )
streamStatus == "failed" -> ChatTopStatus( streamStatus == "failed" -> ChatTopStatus(
text = "实时流已断开,请重试连接。", text = "实时流已断开,请重试连接。",
tone = StatusPillTone.Error, tone = StatusPillTone.Error,
actionLabel = "重连",
) )
streamStatus == "connecting" -> ChatTopStatus( streamStatus == "connecting" -> ChatTopStatus(
text = "正在连接实时流。", text = "正在连接实时流。",
tone = StatusPillTone.Info, tone = StatusPillTone.Info,
actionLabel = "刷新",
) )
else -> ChatTopStatus( else -> ChatTopStatus(
text = "在线,可继续浏览和发送消息。", text = "在线,可继续浏览和发送消息。",
tone = StatusPillTone.Success, tone = StatusPillTone.Success,
actionLabel = "刷新",
) )
} }
} }
@Composable @Composable
private fun ChatHeader( private fun ChatStatusBanner(
sessionTitle: String,
topStatus: ChatTopStatus, topStatus: ChatTopStatus,
onBack: () -> Unit,
onRetry: () -> Unit,
onSendAttachmentStub: () -> Unit,
) { ) {
Card( Card(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
colors = CardDefaults.cardColors( colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainerLow, containerColor = when (topStatus.tone) {
StatusPillTone.Error -> MaterialTheme.colorScheme.errorContainer
StatusPillTone.Warning -> MaterialTheme.colorScheme.tertiaryContainer.copy(alpha = 0.55f)
StatusPillTone.Success -> MaterialTheme.colorScheme.secondaryContainer.copy(alpha = 0.55f)
StatusPillTone.Info -> MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.5f)
StatusPillTone.Neutral -> MaterialTheme.colorScheme.surfaceContainerHigh
},
), ),
) { ) {
Column( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(12.dp), .padding(horizontal = 12.dp, vertical = 10.dp),
verticalArrangement = Arrangement.spacedBy(10.dp), horizontalArrangement = Arrangement.spacedBy(10.dp),
verticalAlignment = Alignment.CenterVertically,
) { ) {
Row( StatusPill(
modifier = Modifier.fillMaxWidth(), text = when (topStatus.tone) {
horizontalArrangement = Arrangement.spacedBy(12.dp), StatusPillTone.Error -> "需处理"
verticalAlignment = Alignment.CenterVertically, StatusPillTone.Warning -> "处理中"
) { StatusPillTone.Success -> "在线"
TextButton(onClick = onBack) { Text("返回") } StatusPillTone.Info -> "同步中"
Text( StatusPillTone.Neutral -> "提示"
text = sessionTitle, },
modifier = Modifier.weight(1f), tone = topStatus.tone,
style = MaterialTheme.typography.titleMedium, )
maxLines = 1, Text(
overflow = TextOverflow.Ellipsis, text = topStatus.text,
) style = MaterialTheme.typography.bodySmall,
TextButton(onClick = onSendAttachmentStub) { color = when (topStatus.tone) {
Text("附件") StatusPillTone.Error -> MaterialTheme.colorScheme.onErrorContainer
} StatusPillTone.Warning -> MaterialTheme.colorScheme.onTertiaryContainer
TextButton(onClick = onRetry) { StatusPillTone.Success -> MaterialTheme.colorScheme.onSecondaryContainer
Text(topStatus.actionLabel) StatusPillTone.Info -> MaterialTheme.colorScheme.onPrimaryContainer
} StatusPillTone.Neutral -> MaterialTheme.colorScheme.onSurfaceVariant
} },
modifier = Modifier.weight(1f),
Card( )
modifier = Modifier.fillMaxWidth(),
colors = CardDefaults.cardColors(
containerColor = when (topStatus.tone) {
StatusPillTone.Error -> MaterialTheme.colorScheme.errorContainer
StatusPillTone.Warning -> MaterialTheme.colorScheme.tertiaryContainer.copy(alpha = 0.55f)
StatusPillTone.Success -> MaterialTheme.colorScheme.secondaryContainer.copy(alpha = 0.55f)
StatusPillTone.Info -> MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.5f)
StatusPillTone.Neutral -> MaterialTheme.colorScheme.surfaceContainerHigh
},
),
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 12.dp, vertical = 10.dp),
horizontalArrangement = Arrangement.spacedBy(10.dp),
verticalAlignment = Alignment.CenterVertically,
) {
StatusPill(
text = when (topStatus.tone) {
StatusPillTone.Error -> "需处理"
StatusPillTone.Warning -> "处理中"
StatusPillTone.Success -> "在线"
StatusPillTone.Info -> "同步中"
StatusPillTone.Neutral -> "提示"
},
tone = topStatus.tone,
)
Text(
text = topStatus.text,
style = MaterialTheme.typography.bodySmall,
color = when (topStatus.tone) {
StatusPillTone.Error -> MaterialTheme.colorScheme.onErrorContainer
StatusPillTone.Warning -> MaterialTheme.colorScheme.onTertiaryContainer
StatusPillTone.Success -> MaterialTheme.colorScheme.onSecondaryContainer
StatusPillTone.Info -> MaterialTheme.colorScheme.onPrimaryContainer
StatusPillTone.Neutral -> MaterialTheme.colorScheme.onSurfaceVariant
},
modifier = Modifier.weight(1f),
)
}
}
} }
} }
} }
+2
View File
@@ -439,3 +439,5 @@ Android/iOS App
- 2026-03-07:设置页重做为分组式连接中心:移除 HeroCard 式说明块,改成“连接与账号 / 默认 Agent / 外观 / 诊断信息”四组,减少说明书感,重点回到用户真正能查看和切换的配置项。 - 2026-03-07:设置页重做为分组式连接中心:移除 HeroCard 式说明块,改成“连接与账号 / 默认 Agent / 外观 / 诊断信息”四组,减少说明书感,重点回到用户真正能查看和切换的配置项。
- 2026-03-07:顺手把状态页头部也收轻:去掉大 HeroCard,改为直接标题 + 指标卡 + 详情卡,避免多个页面同时维持两套厚重的页头语言。 - 2026-03-07:顺手把状态页头部也收轻:去掉大 HeroCard,改为直接标题 + 指标卡 + 详情卡,避免多个页面同时维持两套厚重的页头语言。
- 2026-03-07:补了一轮真正的详情页导航语义:聊天详情页重新加回明确的顶部导航头(返回 / 标题 / 附件 / 刷新),不再只是内容区里塞一个“返回”按钮;同时抽了一个轻量 `PlatformBackHandler`,先在 Android 接上系统返回,让详情页能正常退回首页/列表。 - 2026-03-07:补了一轮真正的详情页导航语义:聊天详情页重新加回明确的顶部导航头(返回 / 标题 / 附件 / 刷新),不再只是内容区里塞一个“返回”按钮;同时抽了一个轻量 `PlatformBackHandler`,先在 Android 接上系统返回,让详情页能正常退回首页/列表。
- 2026-03-07:进一步把页面切换从“状态变量拼页面”收成显式 route:`OpenClawAppState` 现在用 `AppRoute`(Sessions / Status / Settings / Chat(sessionId))管理当前页面,详情页与首页切换不再依赖 `selectedTab + activeSessionId` 的隐式组合,后续继续加真正导航能力会顺很多。
- 2026-03-07:把详情页顶部导航头正式迁回 `Scaffold.topBar`:聊天页内部不再自己伪造导航栏,而是由 app 壳层根据 route 决定顶栏标题、返回、附件、刷新动作;这样详情页终于有了正经的二级页面导航结构。