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 <hy4ri@users.noreply.github.com>
This commit is contained in:
M57andM57 authored and GitHub committed 2026-06-27 21:26:49 +03:00
1 parent 03866a611b
commit 2d8d3ac57a
1 file changed
+5
@@ -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)
}