diconnect tabs on close of ws
This commit is contained in:
@@ -252,10 +252,26 @@ class ConnectionManager {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to connect silently in background - don't show 'connecting' badge
|
// Ensure tabs are in 'connecting' state when WS is not connected
|
||||||
// Individual tab states will show 'connecting' when user explicitly clicks
|
// This handles edge cases where handleClose wasn't called or state got out of sync
|
||||||
try {
|
const currentTabs = store.getState().tabs
|
||||||
await this.ensureConnection()
|
const hasConnectedTabs = Array.from(currentTabs.values()).some((t) => t.state === 'connected')
|
||||||
|
if (hasConnectedTabs) {
|
||||||
|
store.setState((state) => {
|
||||||
|
const newTabs = new Map(state.tabs)
|
||||||
|
for (const [tabId, tab] of newTabs) {
|
||||||
|
if (tab.state === 'connected') {
|
||||||
|
newTabs.set(tabId, { ...tab, state: 'connecting' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { tabs: newTabs }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to connect silently in background - don't show 'connecting' badge
|
||||||
|
// Individual tab states will show 'connecting' when user explicitly clicks
|
||||||
|
try {
|
||||||
|
await this.ensureConnection()
|
||||||
store.setState({ connectionState: 'connected' })
|
store.setState({ connectionState: 'connected' })
|
||||||
|
|
||||||
// Re-attach any tabs that were in 'connecting' state (from a previous disconnect)
|
// Re-attach any tabs that were in 'connecting' state (from a previous disconnect)
|
||||||
|
|||||||
Reference in New Issue
Block a user