Issue 1: Connection failures aren’t surfaced to users
When the WebSocket connect call fails, the client updates internal state with ChatState.Error, but the UI never displays this information, leaving users unaware of connection issues and without any retry path
Surface connection errors with a retry option
Issue 2: No user feedback on disconnection
ChatUiState tracks isConnected, and ChatViewModel updates it on ChatState.Disconnected, but the UI ignores this flag. Users receive no notice when the connection drops, so their inputs may fail silently
Notify users when disconnected and allow manual reconnection
Testing
After implementing the above, verify that connection failures trigger the UI alert with a working retry button.
Disconnect the server to confirm the disconnection banner appears and that reconnecting restores functionality.
Notes
The retry logic assumes the last message can safely be resent; adjust as needed for idempotency or multi-step conversations.
Issue 1: Connection failures aren’t surfaced to users
When the WebSocket connect call fails, the client updates internal state with ChatState.Error, but the UI never displays this information, leaving users unaware of connection issues and without any retry path
Surface connection errors with a retry option
ChatViewModel (
app/src/commonMain/kotlin/gemstone/framework/ui/viewmodel/ChatViewModel.kt)lastMessage: String?field to remember the most recent message.lastMessagebefore each send attempt and add aretryLastMessage()function that reuses it.ChatScreen (
app/src/commonMain/kotlin/gemstone/framework/ui/compose/screen/chat/ChatScreen.kt)uiState.error; when non‑null, display aSnackbarorAlertDialogshowing the error message.ChatViewModel.retryLastMessage()and clears the error viaChatViewModel.clearError().Issue 2: No user feedback on disconnection
ChatUiState tracks isConnected, and ChatViewModel updates it on ChatState.Disconnected, but the UI ignores this flag. Users receive no notice when the connection drops, so their inputs may fail silently
Notify users when disconnected and allow manual reconnection
ChatScreen (
app/src/commonMain/kotlin/gemstone/framework/ui/compose/screen/chat/ChatScreen.kt)uiState.isConnected; whenfalse, show a persistent banner orSnackbarstating “Disconnected from server.”ChatViewModel.retryLastMessage()or a newreconnect()method.ChatViewModel (
app/src/commonMain/kotlin/gemstone/framework/ui/viewmodel/ChatViewModel.kt)reconnect()to reinitialize the WebSocket session and resendlastMessageif present.ChatState.Connectedis observed.Testing
After implementing the above, verify that connection failures trigger the UI alert with a working retry button.
Disconnect the server to confirm the disconnection banner appears and that reconnecting restores functionality.
Notes
The retry logic assumes the last message can safely be resent; adjust as needed for idempotency or multi-step conversations.