How to restore a recently-closed tab group via WebExtensions API

I’m working on updating my Firefox extension, Panic Button, to handle tab groups. Currently, if a user invoked the Panic Button action to close all browser windows, when Panic Button restores them afterwards, any tab groups in the browser window are lost, although the tabs themselves are intact.

But I notice that the previous tab groups are still accessible from the List All Tabs menu (on the right-hand side of the browser tab bar). The recent tab groups are listed there, and the user could click on them to bring them back.

Is there a way to bring back recently-closed tab groups using the WebExtensions API? I’m reading the documentation on MDN and experimenting in the extension console, and so far I’ve discovered that browser.tabGroups.get() won’t recognize the ID of a recently-closed tab group and will throw an exception.

I suppose that one solution would be for my extension to recreate the tab groups when restoring the browser windows, using the available APIs. But that would create duplicate entries in the list of recently-closed tab groups – one for the tab group that was closed, and the other for the one created by my extension via API.

3 Likes

Have you tried restoring the closed windows with sessions.restore()? I hope that would take care of the closed tab groups in the List All Tabs menu, please do report back your findings.

Ahh, what a timely thread bump, @lionelw. In today’s WECG meeting we discussed a request to have more of the functionality of tab groups (besides the concept as it exists it is exposed in the tab strip) exposed in web extensions APIs. Firefox and Chrome representatives indicated that they don’t have any immediate plans to work on this. Firefox (and maybe Chrome?) also indicated they were open to community contributions here.

If anyone is interested, this request is being tracked in issue 861 on the group’s repository. Next steps here are for someone to create a proposal that defines the functionality and API surface that should be exposed to web extensions.

3 Likes