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:
@@ -773,6 +773,11 @@ class ChatViewModel(
|
|||||||
fun refreshCurrentSession() {
|
fun refreshCurrentSession() {
|
||||||
val sessionId = _uiState.value.currentSessionId ?: return
|
val sessionId = _uiState.value.currentSessionId ?: return
|
||||||
loadCachedMessages(sessionId)
|
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)
|
loadSessionMessages(sessionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user