From 78734bf1e888b61dee2149b590ba32856520aab2 Mon Sep 17 00:00:00 2001 From: "Tommy D. Rossi" Date: Fri, 6 Feb 2026 15:39:35 +0100 Subject: [PATCH] fix: prevent tab group add/remove infinite loop when dragging tabs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a user drags a tab into the playwriter group, connectTab() sets its state to 'connecting'. syncTabGroup() previously only kept 'connected' tabs in the group, so it would immediately ungroup the 'connecting' tab. This ungroup fired chrome.tabs.onUpdated, which called disconnectTab(). When the original connectTab() resolved, it re-added the tab, triggering onUpdated again — creating an infinite add/remove/add/remove loop. Fix: include 'connecting' tabs in syncTabGroup's group membership filter. This way syncTabGroup won't fight the user's intent by removing tabs that are still being set up. Error-state tabs are still correctly excluded from the group. --- extension/src/background.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extension/src/background.ts b/extension/src/background.ts index 7a0ce6e..b869aaf 100644 --- a/extension/src/background.ts +++ b/extension/src/background.ts @@ -683,10 +683,11 @@ export function sendMessage(message: any): void { async function syncTabGroup(): Promise { try { - // Only tabs with state 'connected' are in the group. - // Tabs in 'connecting' or 'error' state are removed from the group. + // Tabs in 'connected' or 'connecting' state belong in the group. + // Including 'connecting' prevents a loop where syncTabGroup removes a tab the user + // just dragged in (still connecting), which triggers onUpdated → disconnect → reconnect. const connectedTabIds = Array.from(store.getState().tabs.entries()) - .filter(([_, info]) => info.state === 'connected') + .filter(([_, info]) => info.state === 'connected' || info.state === 'connecting') .map(([tabId]) => tabId) // Always query by title - no cached ID that can go stale