From b33d18552599664901356ae27db0270df3cc3129 Mon Sep 17 00:00:00 2001 From: Tianren Dong Date: Mon, 28 Sep 2026 19:45:18 -0400 Subject: Create session tab groups in the tab's own window chrome.tabs.group without createProperties.windowId creates the group in the current (user's) window and moves the tab there, so a session's automation tab left its dedicated window and became a hidden inactive tab. Make the unit mock match Chrome's behavior. --- .../chrome-profile-bridge/browser-extension/service_worker.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'extensions') diff --git a/extensions/chrome-profile-bridge/browser-extension/service_worker.js b/extensions/chrome-profile-bridge/browser-extension/service_worker.js index bcc795b..68fe8c9 100644 --- a/extensions/chrome-profile-bridge/browser-extension/service_worker.js +++ b/extensions/chrome-profile-bridge/browser-extension/service_worker.js @@ -1711,10 +1711,14 @@ async function groupTab(tab, title, color) { const groupTitle = cleanGroupTitle(title); let groupId = tab.groupId; if (typeof groupId !== "number" || groupId < 0) { - const existing = await findGroupByTitle(tab.windowId, groupTitle); + // Some browsers omit windowId on freshly created tabs; read it back instead of guessing. + const windowId = typeof tab.windowId === "number" ? tab.windowId : (await chrome.tabs.get(tab.id).catch(() => null))?.windowId; + const existing = await findGroupByTitle(windowId, groupTitle); + // Without createProperties.windowId Chrome creates the group in the *current* (user's) window + // and moves the tab there, pulling Pi's automation tab out of its own window as a hidden tab. groupId = existing !== null ? await chrome.tabs.group({ groupId: existing, tabIds: [tab.id] }) - : await chrome.tabs.group({ tabIds: [tab.id] }); + : await chrome.tabs.group(typeof windowId === "number" ? { tabIds: [tab.id], createProperties: { windowId } } : { tabIds: [tab.id] }); } await chrome.tabGroups.update(groupId, { title: groupTitle, color: cleanGroupColor(color), collapsed: false }); const grouped = await chrome.tabs.get(tab.id); -- cgit v1.2.3