@@ -76,6 +76,7 @@ struct AlertsView: View {
7676
7777 private func loadAlerts(stream: String) async {
7878 guard let client = appState.client else { return }
79+ let connID = appState.activeConnection?.id
7980 isLoading = true
8081 errorMessage = nil
8182 alertConfig = nil
@@ -84,13 +85,17 @@ struct AlertsView: View {
8485 let config = try await client.getAlerts(stream: stream)
8586 // The manual Refresh/Retry buttons spawn detached Tasks not tied to
8687 // `.task(id: stream)` cancellation, so a slow refresh for the old stream
87− // can resolve after a switch. Drop stale results.
88+ // can resolve after a switch. Drop stale results. Check the connection
89+ // id too: two servers can expose a same-named stream, so a name-only
90+ // guard could write the previous server's alerts after a server switch.
8891 // Still clear isLoading on the stale path: this task set the spinner,
8992 // so leaving it true wedges the ProgressView and disables Refresh.
90− guard stream == appState.selectedStream else { isLoading = false; return }
93+ guard stream == appState.selectedStream,
94+ connID == appState.activeConnection?.id else { isLoading = false; return }
9195 alertConfig = config
9296 } catch {
93− guard stream == appState.selectedStream else { isLoading = false; return }
97+ guard stream == appState.selectedStream,
98+ connID == appState.activeConnection?.id else { isLoading = false; return }
9499 errorMessage = ParseableError.userFriendlyMessage(for: error)
95100 }
96101