From 4715c85185695e5bf4685f51cf0cfbf652b53ea8 Mon Sep 17 00:00:00 2001 From: M57 <41645758+Hy4ri@users.noreply.github.com> Date: Sun, 21 Jun 2026 19:45:08 +0300 Subject: [PATCH] fix(#204): dynamically reset and reload chat title when creating or switching sessions (#247) * fix(#204): dynamically reset and reload chat title when creating or switching sessions * fix(#204): refresh session list on message completion to catch auto-generated titles --- .../java/com/m57/hermescontrol/ui/chat/ChatViewModel.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 293e247f..6fca505a 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 @@ -359,6 +359,8 @@ class ChatViewModel( dao.upsert(msgToPersist.toEntity(sid)) } } + // Refresh session list to catch newly generated titles + loadSessions() } private fun handleMessageDone(event: WsEvent.MessageDone) { @@ -500,6 +502,7 @@ class ChatViewModel( isLoading = false, messages = emptyList(), streamingMessage = null, + chatTitle = "Hermes", ) } addSystemMessage("Session created", persist = true) @@ -783,6 +786,7 @@ class ChatViewModel( isLoading = true, messages = emptyList(), streamingMessage = null, + chatTitle = "Hermes", ) } streamingMessageId = null @@ -816,7 +820,7 @@ class ChatViewModel( streamingMessageId = null _uiState.update { - val title = it.sessions.find { s -> s.id == sessionId }?.title ?: it.chatTitle + val title = it.sessions.find { s -> s.id == sessionId }?.title ?: "Hermes" it.copy( isLoading = true, messages = emptyList(), @@ -841,6 +845,8 @@ class ChatViewModel( } // Step 3: Load fresh messages from REST and merge loadSessionMessages(sessionId) + // Step 4: Refresh session list to get latest titles + loadSessions() } private fun loadCachedMessages(sessionId: String) {