fix: unstick isConnected when first connect follows a disconnect
markConnected skipped onReconnect on the very first successful connect (hasConnected=false branch), but an earlier failed attempt could have already fired onDisconnect -> isConnected=false. Consumer state stayed stuck at false forever. Fire onReconnect in that case too. Repro: launch app while opencode sidecar is still warming up so the first WS attempt fails. Second attempt succeeds but isConnected stays false; user sees "Connection lost" toast on every send.
This commit is contained in:
@@ -245,12 +245,19 @@ export function createEventPipeline(input: EventPipelineInput) {
|
||||
let heartbeat: ReturnType<typeof setTimeout> | undefined
|
||||
|
||||
const markConnected = () => {
|
||||
const wasDisconnected = disconnected
|
||||
disconnected = false
|
||||
if (hasConnected) {
|
||||
onReconnect?.()
|
||||
return
|
||||
}
|
||||
hasConnected = true
|
||||
// First successful connect, but an earlier attempt already fired onDisconnect
|
||||
// (e.g. sidecar was not ready at launch). Consumer state is stuck at
|
||||
// isConnected=false — fire onReconnect to unstick it.
|
||||
if (wasDisconnected) {
|
||||
onReconnect?.()
|
||||
}
|
||||
}
|
||||
|
||||
const enqueueEvent = (directory: string, payload: Event) => {
|
||||
|
||||
Reference in New Issue
Block a user