Skip to content

fix(firefox): add browser-level keyboard shortcuts via commands API - #2727

Merged
webbrain-one merged 4 commits into
webbrain-one:mainfrom
EvanLind:fix/firefox-keyboard-shortcuts
Aug 10, 2026
Merged

fix(firefox): add browser-level keyboard shortcuts via commands API#2727
webbrain-one merged 4 commits into
webbrain-one:mainfrom
EvanLind:fix/firefox-keyboard-shortcuts

Conversation

@EvanLind

Copy link
Copy Markdown
Contributor

Problem

Firefox users cannot use keyboard shortcuts to open the WebBrain panel or switch modes. The about:addons → "Manage Extension Shortcuts" page lists WebBrain under "extensions without shortcuts."

Root Cause

The Firefox manifest.json has no commands field. The Chrome manifest already defines _execute_action (Alt+Shift+W), but the Firefox build was never updated to include the equivalent Firefox commands API.

The existing shortcuts (Ctrl+/, Ctrl+Shift+A/X/D, Escape) are JavaScript keydown listeners in sidepanel.js that only work when the side panel has keyboard focus — which Firefox's sidebar_action does not reliably grant.

Changes

src/firefox/manifest.json

  • Add commands field with _execute_sidebar_action (Firefox MV2 equivalent of Chrome's _execute_action) and four custom commands for mode switching and input focus

src/firefox/src/background.js

  • Add browser.commands.onCommand listener that forwards custom commands to the side panel via runtime.sendMessage

src/firefox/src/ui/sidepanel.js

  • Add runtime.onMessage listener that handles forwarded commands by calling the existing setMode(), ensureActMode(), ensureDevMode(), and inputEl.focus() functions

Shortcuts

Shortcut Command Description
Alt+Shift+W _execute_sidebar_action Open/close the panel
Ctrl+Shift+A switch-to-ask Switch to Ask mode
Ctrl+Shift+X switch-to-act Switch to Act mode
Ctrl+Shift+D switch-to-dev Switch to Dev mode
Ctrl+/ focus-input Focus the chat input

All shortcuts are user-configurable in about:addons → Manage Extension Shortcuts.

Firefox manifest.json had no 'commands' field, which meant browser-level
keyboard shortcuts were not registered at all. The sidepanel.js
keydown listeners only work when the panel has focus, which Firefox's
sidebar_action does not reliably grant.

This adds the same commands already present in the Chrome manifest
(_execute_action → _execute_sidebar_action for Firefox MV2), plus
custom commands for mode switching (Ctrl+Shift+A/X/D) and input focus
(Ctrl+/) that the background script forwards to the side panel.

Closes the parity gap where Firefox users could not use keyboard
shortcuts to open the panel or switch modes.
@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

@EvanLind is attempting to deploy a commit to the esokullu's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Firefox browser-level shortcuts for opening the sidebar, switching modes, and focusing input.

Changes:

  • Registers Firefox commands shortcuts.
  • Forwards commands from the background script.
  • Dispatches commands within the side panel.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/firefox/manifest.json Defines shortcut commands.
src/firefox/src/background.js Forwards custom commands.
src/firefox/src/ui/sidepanel.js Handles mode and focus commands.
Suppressed comments (2)

src/firefox/manifest.json:134

  • Ctrl+Shift+D is Firefox's built-in “Bookmark All Tabs” shortcut, so Firefox gives the browser action precedence and this command will not fire with the proposed default. Use a non-conflicting suggested key for Dev mode.
        "default": "Ctrl+Shift+D"

src/firefox/manifest.json:140

  • Slash is not a valid Firefox WebExtensions command key token, so Ctrl+Slash cannot register through commands.suggested_key and the browser-level focus shortcut will remain unavailable. Replace it with a supported key combination.
        "default": "Ctrl+Slash"

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/firefox/manifest.json
},
"switch-to-ask": {
"suggested_key": {
"default": "Ctrl+Shift+A"
Comment thread src/firefox/src/background.js Outdated
Comment on lines +2898 to +2902
browser.commands.onCommand.addListener((command) => {
// _execute_sidebar_action is handled natively by Firefox — no need to forward
if (command === '_execute_sidebar_action') return;

browser.runtime.sendMessage({ type: 'command', command }).catch(() => {
Firefox's commands API does not accept 'Slash' as a valid key name.
Valid keys are A-Z, 0-9, Comma, Period, Home, End, PageUp, PageDown,
Space, Insert, Delete, Up, Down, Left, Right, and F1-F12.
…ndMessage

runtime.sendMessage from background to sidepanel can be unreliable in
Firefox when the sidepanel isn't fully loaded. Switch to storage.local
set + storage.onChanged, which is guaranteed to fire in all extension
pages regardless of load state.

Also:
- Keep the Ctrl+Period shortcut for focus-input
- Add console.error logging on dispatch failure
- Rebuild XPI
@EvanLind
EvanLind force-pushed the fix/firefox-keyboard-shortcuts branch from fb248a9 to ba9c886 Compare August 10, 2026 14:43
Firefox won't allow inputEl.focus() to take effect if the sidebar panel
doesn't currently have focus. window.focus() acquires sidebar focus first
so the subsequent inputEl.focus() actually works.
@webbrain-one
webbrain-one merged commit 2e1dc07 into webbrain-one:main Aug 10, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants