-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix: feature flag sidepanel context menu cp-13.10.3 #38220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Builds ready [d5bdc68]
UI Startup Metrics (1195 ± 106 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
97662ec to
04eb620
Compare
| } else { | ||
| removeMenu(); | ||
| } | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Missing state comparison causes duplicate context menu operations
The RemoteFeatureFlagController:stateChange subscription doesn't compare previous and current values of extensionUxSidepanel. Unlike other parts of the codebase that use previousValueComparator, this code calls createMenu() or removeMenu() on every state change event without checking if the flag actually changed. If the menu already exists (created initially at line 33-35) and any state change occurs while still enabled, browser.contextMenus.create will fail with "Cannot create item with duplicate id" error. Similarly, calling removeMenu() when the menu doesn't exist will also fail.
Additional Locations (1)
Builds ready [04eb620]
UI Startup Metrics (1130 ± 98 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
| } else { | ||
| removeMenu(); | ||
| } | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Context menu state changes cause duplicate creation errors
The state change subscription calls createMenu() or removeMenu() on every RemoteFeatureFlagController:stateChange event without tracking whether the menu already exists or comparing with the previous flag value. Since the state change event fires when ANY remote feature flag changes (not just extensionUxSidepanel), this will repeatedly try to create an already-existing menu item (causing "Cannot create item with duplicate id" error) or remove a non-existent menu. The codebase has an established previousValueComparator utility for this exact scenario that compares previous and current state before acting.
Additional Locations (1)
| if (info.menuItemId === MENU_ITEM_ID && tab?.windowId) { | ||
| browserWithSidePanel.sidePanel?.open({ windowId: tab.windowId }); | ||
| } | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Context menu click handler only registered on install
The browser.contextMenus.onClicked listener is now registered inside initSidePanelContextMenu, which only runs when lazyListener.once('runtime', 'onInstalled') resolves. The onInstalled event only fires on fresh install, extension update, or browser update—not on regular browser restart or service worker wake-up. In the old code, the click listener was registered at module load time, ensuring it worked whenever the service worker started. Now, after a normal browser restart, the click handler won't be registered and clicking the context menu item will do nothing.
Additional Locations (1)
Builds ready [bc69ea7]
UI Startup Metrics (1257 ± 110 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
|
||
| const isEnabled = (state?: { | ||
| remoteFeatureFlags?: { extensionUxSidepanel?: boolean }; | ||
| }) => state?.remoteFeatureFlags?.extensionUxSidepanel !== false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
| }) => state?.remoteFeatureFlags?.extensionUxSidepanel !== false; | |
| }) => state?.remoteFeatureFlags?.extensionUxSidepanel === true; |
Description
fixes #38222
Wraps the sidepanel context menu configuration with the remote feature flag
Changelog
CHANGELOG entry: fix: feature flag sidepanel context menu
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Gates the sidepanel context menu behind a remote feature flag and refactors its setup into a dedicated module initialized after background startup.
app/scripts/lib/sidepanel-context-menu.tswithinitSidePanelContextMenu(controller).openSidePanelmenu based onIS_SIDEPANELandremoteFeatureFlags.extensionUxSidepanel; opens side panel on click.RemoteFeatureFlagController:stateChangeto toggle menu dynamically.app/scripts/background.js, register sidepanel context menu vialazyListener.once('runtime','onInstalled'), callinghandleSidePanelContextMenu()afterhandleOnInstalled.handleSidePanelContextMenuwaits forisInitializedthen invokesinitSidePanelContextMenu(controller).Written by Cursor Bugbot for commit bc69ea7. This will update automatically on new commits. Configure here.