From 6fb1547882c34063627344e45cf84f109fa3c8eb Mon Sep 17 00:00:00 2001 From: Vasish Baungally Date: Thu, 30 Jul 2026 21:33:53 -0500 Subject: [PATCH] feat: add tab groups to json response --- experiments/smartwindow/api.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/experiments/smartwindow/api.js b/experiments/smartwindow/api.js index 0518f63..532e40f 100644 --- a/experiments/smartwindow/api.js +++ b/experiments/smartwindow/api.js @@ -1910,6 +1910,7 @@ async function collectSmartWindowData({ notes = "", bugzillaUrls = [], tags = [] title: tab.label ?? null, isActiveTab: tab.selected, lastAccessed: tab.lastAccessed, + groupId: tab.group?.id ?? null, })); // Gather all stored SmartWindow memories @@ -2063,6 +2064,7 @@ async function collectSmartWindowData({ notes = "", bugzillaUrls = [], tags = [] // Context for the browser like tabs, SmartWindow memories, and browsing history if the user specified at least a startDate browserContext: { tabs, + tabGroups: getTabGroups(), memories, browsingHistory: { datetimeRange: { start: startDate, end: endDate }, @@ -2647,6 +2649,22 @@ function getOpenTabs() { })); } +// Snapshot of the active window's tab group definitions. Tab -> group +// membership lives on browserContext.tabs[].groupId (null = ungrouped, so don't +// collapse those into one cluster when evaluating). Unnamed groups have title "". +function getTabGroups() { + const win = windowMediator.getMostRecentWindow("navigator:browser"); + if (!win?.gBrowser) { + return []; + } + return Array.from(win.gBrowser.tabGroups).map(group => ({ + id: group.id, + title: group.label ?? "", + color: group.color, + collapsed: group.collapsed, + })); +} + /** * Get the compacted SmartWindow conversation messages with auto-injected * system/user messages (system prompt, real-time-context, relevant-memories)