If I want to count the total number of Tab Groups, when someone use the save & close a Tab Group, I think it’s not currently possible to count those ones and how many tabs are inside, right?
Hi, and thanks for reaching out!
You are right. The tabGroups API only covers tab groups that have visible tabs in a window. Once a group is saved and closed, extensions can’t see it, so there’s no way to count saved groups or the tabs inside them. The sessions API doesn’t fill that gap either, since it isn’t aware of tab groups today.
This gap is tracked here, and input on what the API should look like is welcome: 2076798 - sessions.getRecentlyClosed does not expose tab group membership of closed tab groups. The cross-browser request for exactly this (tab counts for closed groups) is here: Enhancement request - Expand the Tab Groups API to include some info about Closed Tab Groups · Issue #861 · w3c/webextensions · GitHub. Your use case would be a helpful addition to either.
Thank you!
-Christos
As far as I know, that’s right: the tabGroups API only exposes groups that are currently open in a window. Saved-and-closed groups aren’t queryable from extensions yet. A workaround is to track groups yourself: listen for tabGroups.onRemoved (and tab events) and store the group title and tab count in storage.local before it closes. It’s worth filing a request on Bugzilla under WebExtensions: General for read access to saved groups.