pi-dashboard
pi-dashboard copied to clipboard
bug: iOS CancellationError surfacing on navigation
Description
When navigating between chats or backgrounding the app, Swift's structured concurrency cancels in-flight Tasks. ChatViewModel.loadHistory() catches CancellationError and URLError.cancelled, but other async paths don't, causing error banners to flash briefly.
Steps to reproduce
- Open a chat in the iOS app
- While it's loading or streaming, quickly tap back to the chat list
- An error banner may flash briefly before disappearing
Expected behavior
Navigation cancellations are silently swallowed — they're not real errors.
Actual behavior
Error text like CancellationError or URLError Code=-999 briefly appears.
Likely uncaught paths
WebSocketManager.receiveLoop()—ws.receive()throws on task cancel, reconnect logic may trigger unnecessarilySlotListViewModelpolling — refresh in-flight when swapping chats- Image loading tasks in assistant messages
Suggested fix
Add a global helper and use it consistently:
func isCancellation(_ error: Error) -> Bool {
error is CancellationError || (error as? URLError)?.code == .cancelled
}
Audit every do/catch in async viewmodels and networking:
} catch where isCancellation(error) {
return // not a real error
}
Files to audit
ViewModels/ChatViewModel.swift(partially fixed)ViewModels/SlotListViewModel.swiftNetworking/WebSocketManager.swiftNetworking/APIClient.swift
Fixed in e2ed28f — added isCancellation() helper and guarded all async catch paths in ChatViewModel + ChatView .task chain.