Co-authored-by: ronia <ronia@m57>
This commit is contained in:
1 parent
913c6fa878
commit
261ee6379a
2 files changed
+14
-3
No files matched your search
@@ -86,6 +86,7 @@ import androidx.compose.ui.platform.LocalContext
|
|||||||
import androidx.compose.ui.platform.testTag
|
import androidx.compose.ui.platform.testTag
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
@@ -212,11 +213,13 @@ fun ChatScreen(
|
|||||||
title = {
|
title = {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
Text(
|
Text(
|
||||||
text = "Hermes",
|
text = state.chatTitle,
|
||||||
style =
|
style =
|
||||||
MaterialTheme.typography.titleLarge.copy(
|
MaterialTheme.typography.titleMedium.copy(
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
),
|
),
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
)
|
)
|
||||||
// Connection status dot — red when offline, hidden when connected
|
// Connection status dot — red when offline, hidden when connected
|
||||||
if (!state.isConnected) {
|
if (!state.isConnected) {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ data class ChatUiState(
|
|||||||
val messages: List<ChatMessage> = emptyList(),
|
val messages: List<ChatMessage> = emptyList(),
|
||||||
val currentSessionId: String? = null,
|
val currentSessionId: String? = null,
|
||||||
val sessions: List<SessionUi> = emptyList(),
|
val sessions: List<SessionUi> = emptyList(),
|
||||||
|
val chatTitle: String = "Hermes",
|
||||||
val isConnected: Boolean = false,
|
val isConnected: Boolean = false,
|
||||||
val isAgentTyping: Boolean = false,
|
val isAgentTyping: Boolean = false,
|
||||||
val isThinking: Boolean = false,
|
val isThinking: Boolean = false,
|
||||||
@@ -316,7 +317,10 @@ class ChatViewModel(
|
|||||||
messageCount = (s["message_count"] as? Double)?.toInt() ?: 0,
|
messageCount = (s["message_count"] as? Double)?.toInt() ?: 0,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
_uiState.update { it.copy(sessions = sessions) }
|
_uiState.update { state ->
|
||||||
|
val title = sessions.find { s -> s.id == state.currentSessionId }?.title ?: "Hermes"
|
||||||
|
state.copy(sessions = sessions, chatTitle = title)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WsMethods.SESSION_RESUME -> {
|
WsMethods.SESSION_RESUME -> {
|
||||||
@@ -331,9 +335,11 @@ class ChatViewModel(
|
|||||||
// overwrite any message the user sent between switchSession() and
|
// overwrite any message the user sent between switchSession() and
|
||||||
// the server ack, making the chat appear to go blank.
|
// the server ack, making the chat appear to go blank.
|
||||||
_uiState.update {
|
_uiState.update {
|
||||||
|
val title = it.sessions.find { s -> s.id == sessionId }?.title ?: "Hermes"
|
||||||
it.copy(
|
it.copy(
|
||||||
isLoading = false,
|
isLoading = false,
|
||||||
currentSessionId = sessionId,
|
currentSessionId = sessionId,
|
||||||
|
chatTitle = title,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
addSystemMessage("Session resumed")
|
addSystemMessage("Session resumed")
|
||||||
@@ -574,10 +580,12 @@ class ChatViewModel(
|
|||||||
fun switchSession(sessionId: String) {
|
fun switchSession(sessionId: String) {
|
||||||
if (sessionId == _uiState.value.currentSessionId) return
|
if (sessionId == _uiState.value.currentSessionId) return
|
||||||
_uiState.update {
|
_uiState.update {
|
||||||
|
val title = it.sessions.find { s -> s.id == sessionId }?.title ?: "Hermes"
|
||||||
it.copy(
|
it.copy(
|
||||||
isLoading = true,
|
isLoading = true,
|
||||||
messages = emptyList(),
|
messages = emptyList(),
|
||||||
currentSessionId = sessionId,
|
currentSessionId = sessionId,
|
||||||
|
chatTitle = title,
|
||||||
showSessionPicker = false,
|
showSessionPicker = false,
|
||||||
isAgentTyping = false,
|
isAgentTyping = false,
|
||||||
isThinking = false,
|
isThinking = false,
|
||||||
|
|||||||
Reference in new issue
Block a user