Hi Chrome Extensions Team,
I am developing a productivity extension (WaVault) and I'm trying to implement a keyboard shortcut to toggle the side panel using the chrome.commands and chrome.sidePanel APIs.
The Problem: > There is currently no native sidePanel.toggle() method. To implement a toggle manually, I must first check the current state (using chrome.runtime.getContexts). However, because getContexts is asynchronous, the "User Gesture" from the keyboard command often expires before I can call sidePanel.open(). This results in the error: "sidePanel.open() may only be called in response to a user gesture."
Even a single await for chrome.windows.getCurrent() or chrome.tabs.query() can consume the gesture.
My Questions:
Is there a "recommended" way to toggle the panel that preserves the user gesture across the necessary async state checks?
Are there plans to add _execute_side_panel as a standard command ID in manifest.json that supports toggling (similar to how _execute_action works)?
Is the sidePanel.toggle() method (referenced in Chromium Issue 482108261) currently on the roadmap for a stable release?
Currently, the only workaround is to never use await, which limits logic, or to use a global variable to track state—which is unreliable due to Service Worker termination.