From 2d8d3ac57acb590a89a2b2401886a592f4a6d013 Mon Sep 17 00:00:00 2001 From: M57 <41645758+Hy4ri@users.noreply.github.com> Date: Sat, 27 Jun 2026 21:26:49 +0300 Subject: [PATCH] fix(#366): skip redundant REST call on tab switch-back (#411) Prevents the 404 error banner that briefly flashes when switching back to the Chat tab. The WebSocket keeps the UI current, so the REST call is only needed on initial session load. Co-authored-by: M57 --- .../main/java/com/m57/hermescontrol/ui/chat/ChatViewModel.kt | 5 +++++ 1 file changed, 5 insertions(+) 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 1d85939e..e99c5ee0 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 @@ -773,6 +773,11 @@ class ChatViewModel( fun refreshCurrentSession() { val sessionId = _uiState.value.currentSessionId ?: return loadCachedMessages(sessionId) + // Skip the REST call if we already have messages — the WebSocket keeps + // the UI current. The REST endpoint can 404 on tab switch-back when the + // WS session ID doesn't round-trip through the resolver (issue #366), + // showing a misleading error banner while the connection is fine. + if (_uiState.value.messages.isNotEmpty()) return loadSessionMessages(sessionId) }