fix: hide tab group when relay dies instead of keeping it green
syncTabGroup was including 'connecting' tabs in the group unconditionally, so when the relay WebSocket closed and all tabs transitioned to 'connecting', the group stayed green. Now 'connecting' tabs are only included when the relay is actually connected (connectionState === 'connected'). When the relay is dead, 'connecting' tabs are excluded and the group gets cleaned up. The onUpdated handler at line ~1601 already guards against the ungroup→disconnect loop for 'connecting' tabs, so this is safe.
This commit is contained in:
@@ -710,11 +710,15 @@ export function sendMessage(message: any): void {
|
|||||||
|
|
||||||
async function syncTabGroup(): Promise<void> {
|
async function syncTabGroup(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
// Tabs in 'connected' or 'connecting' state belong in the group.
|
// Include 'connecting' tabs in the group only when the relay is alive, so that
|
||||||
// Including 'connecting' prevents a loop where syncTabGroup removes a tab the user
|
// tabs the user drags into the group stay visible while attaching. When the relay
|
||||||
// just dragged in (still connecting), which triggers onUpdated → disconnect → reconnect.
|
// is dead all tabs are 'connecting' (waiting for reconnect) and the group should
|
||||||
|
// be cleaned up. The onUpdated handler (line ~1601) already guards against the
|
||||||
|
// ungroup→disconnect loop for 'connecting' tabs, so excluding them here is safe.
|
||||||
|
const { connectionState } = store.getState()
|
||||||
|
const isRelayConnected = connectionState === 'connected'
|
||||||
const connectedTabIds = Array.from(store.getState().tabs.entries())
|
const connectedTabIds = Array.from(store.getState().tabs.entries())
|
||||||
.filter(([_, info]) => info.state === 'connected' || info.state === 'connecting')
|
.filter(([_, info]) => info.state === 'connected' || (info.state === 'connecting' && isRelayConnected))
|
||||||
.map(([tabId]) => tabId)
|
.map(([tabId]) => tabId)
|
||||||
|
|
||||||
// Always query by title - no cached ID that can go stale
|
// Always query by title - no cached ID that can go stale
|
||||||
|
|||||||
Reference in New Issue
Block a user