From 87392f5e574ad6a227e55efa35f46f298bce5c69 Mon Sep 17 00:00:00 2001 From: M57 <41645758+Hy4ri@users.noreply.github.com> Date: Sat, 20 Jun 2026 14:04:59 +0300 Subject: [PATCH] fix(#148): prevent chatTitle being overwritten by response handlers (#161) Co-authored-by: M57 --- .../com/m57/hermescontrol/ui/chat/ChatViewModel.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatViewModel.kt b/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatViewModel.kt index aaecaf56..6de6010c 100644 --- a/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatViewModel.kt +++ b/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatViewModel.kt @@ -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(),