fix(#148): prevent chatTitle being overwritten by response handlers (#161)

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
M57andM57 authored and GitHub committed 2026-06-20 14:04:59 +03:00
1 parent 0ec70beb84
commit 87392f5e57
1 file changed
+6 -5
@@ -475,8 +475,11 @@ class ChatViewModel(
)
}
_uiState.update { state ->
val title = sessions.find { s -> s.id == state.currentSessionId }?.title ?: "Hermes"
state.copy(sessions = sessions, chatTitle = title)
val newTitle = sessions.find { s -> s.id == state.currentSessionId }?.title
state.copy(
sessions = sessions,
chatTitle = newTitle ?: state.chatTitle,
)
}
}
@@ -492,11 +495,9 @@ class ChatViewModel(
// overwrite any message the user sent between switchSession() and
// the server ack, making the chat appear to go blank.
_uiState.update {
val title = it.sessions.find { s -> s.id == sessionId }?.title ?: "Hermes"
it.copy(
isLoading = false,
currentSessionId = sessionId,
chatTitle = title,
)
}
addSystemMessage("Session resumed")
@@ -766,7 +767,7 @@ class ChatViewModel(
streamingMessageId = null
_uiState.update {
val title = it.sessions.find { s -> s.id == sessionId }?.title ?: "Hermes"
val title = it.sessions.find { s -> s.id == sessionId }?.title ?: it.chatTitle
it.copy(
isLoading = true,
messages = emptyList(),