Fix Manifest V3 context menu persistence - #4
Open
Fernancelot wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
It expands host permissions to all sites and changes service-worker/lifecycle behavior in a core UX surface area, which warrants manual validation and policy review.
Pull request overview
This PR updates the MV3 service-worker context menu implementation so Pushbullet’s right-click menu remains functional across service-worker termination/restarts, and simplifies Options/permissions so the menu and required host access are always available.
Changes:
- Reworks MV3 context menu IDs to encode their device/chat target and rebuilds menus from persisted state across lifecycle events.
- Removes the context-menu enable/disable option and related Options UI.
- Makes broad HTTP/HTTPS host access non-optional by moving it into required
host_permissions, and removes the related Options control.
File summaries
| File | Description |
|---|---|
| context-menu-v3.js | Rebuilds MV3 context menus from persisted state; encodes targets into menu IDs; adds lifecycle/state rebuild triggers. |
| manifest.json | Moves broad http/https patterns into required host_permissions; formatting cleanup for web_accessible_resources. |
| settings.js | Makes showContextMenu always enabled and stops reading it from storage. |
| options.js | Removes Options wiring for context-menu and host-permission toggles. |
| options.html | Removes the corresponding UI controls from the Options page. |
Review details
Suppressed comments (1)
context-menu-v3.js:255
- The onClicked handler calls pb.updateContextMenu() immediately after pb.unsnooze(), but pb.unsnooze() already calls pb.loadSettings(), which triggers pb.updateContextMenu(). This doubles the amount of work for a single action-menu click.
if (menuId == CONTEXT_MENU_UNSNOOZE) {
pb.unsnooze()
pb.updateContextMenu()
return
}
- Files reviewed: 5/5 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+245
to
+249
| if (menuId == CONTEXT_MENU_SNOOZE) { | ||
| pb.snooze() | ||
| pb.updateContextMenu() | ||
| return | ||
| } |
Comment on lines
+296
to
+304
| chrome.storage.onChanged.addListener(function(changes, areaName) { | ||
| if (areaName != 'local') { | ||
| return | ||
| } | ||
|
|
||
| if (changes.devices || changes.chats || changes.snoozedUntil) { | ||
| pb.updateContextMenu() | ||
| } | ||
| }) |
Comment on lines
+32
to
35
| "http://localhost:20807/*", | ||
| "https://*/*", | ||
| "http://*/*" | ||
| ], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the right-click Pushbullet menu disappearing or failing to rebuild under Manifest V3 service-worker lifecycle behavior.
Changes
context-menu-v3.jsso menu IDs encode their device/chat target instead of relying on an in-memoryMapthat is lost when the service worker stops.removeAll()ran before device data was ready.Testing
Tested in Chromium, including explicitly terminating the MV3 service worker and then using the already-registered context menu to verify that Chromium wakes the worker and routes the click correctly. Also confirmed working in Microsoft Edge with the full fixed v382 build.
The branch changes only the five files involved in this fix:
context-menu-v3.js,manifest.json,settings.js,options.js, andoptions.html.