aboutsummaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorTianren Dong <tianrendong.dtr@gmail.com>2026-09-28 19:45:18 -0400
committerTianren Dong <tianrendong.dtr@gmail.com>2026-09-28 19:45:18 -0400
commitb33d18552599664901356ae27db0270df3cc3129 (patch)
tree362a08c4721e65f084390cf6976292ccda375253 /extensions
parent9e4514f020ecab9af0a8b8d36f01fc802ff5123e (diff)
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.
Diffstat (limited to 'extensions')
-rw-r--r--extensions/chrome-profile-bridge/browser-extension/service_worker.js8
1 files changed, 6 insertions, 2 deletions
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);