@@ -307,16 +307,28 @@ class SessionListViewModel(private val container: AppContainer) : ViewModel() {
307307 _switchingId.value = null
308308 result.onSuccess { refresh() }
309309 .onFailure { error ->
310− // connect() already closed the old connection; if we just disconnect()
311− // the user is left with nothing. Try to restore the previous profile so
312− // the session list survives. If there was none, show the error state.
310+ // connect() already closed the old connection; try to restore the
311+ // previous profile so the session list survives. If there was none,
312+ // show the error state.
313313 container.disconnect()
314314 if (previousProfile != null) {
315− runCatchingCancellable { container.connect(previousProfile) }
315+ val restored = runCatchingCancellable { container.connect(previousProfile) }
316316 // connect() clears unread state; restore what we saved so the
317317 // user doesn't lose unread badges on a failed server switch.
318318 savedUnread.forEach { container.restoreUnread(it) }
319− _state.update { it.copy(loading = false, error = container.friendlyError(error)) }
319+ if (restored.isSuccess) {
320+ _state.update { it.copy(loading = false, error = container.friendlyError(error)) }
321+ } else {
322+ // Restore also failed — the user is now disconnected from
323+ // both servers. Surface both failures so the user understands
324+ // why they're looking at an empty list.
325+ val restoreMsg = container.friendlyError(restored.exceptionOrNull() ?: error)
326+ _state.value = SessionListState(
327+ loading = false,
328+ error = container.string(R.string.error_switch_and_restore_failed,
329+ container.friendlyError(error), restoreMsg),
330+ )
331+ }
320332 } else {
321333 _state.value = SessionListState(loading = false, error = container.friendlyError(error))
322334 }