Skip to content

Fix Manifest V3 context menu persistence - #4

Open
Fernancelot wants to merge 5 commits into
genetrader:mainfrom
Fernancelot:fix-context-menu-mv3
Open

Fix Manifest V3 context menu persistence#4
Fernancelot wants to merge 5 commits into
genetrader:mainfrom
Fernancelot:fix-context-menu-mv3

Conversation

@Fernancelot

Copy link
Copy Markdown

This fixes the right-click Pushbullet menu disappearing or failing to rebuild under Manifest V3 service-worker lifecycle behavior.

Changes

  • Reworks context-menu-v3.js so menu IDs encode their device/chat target instead of relying on an in-memory Map that is lost when the service worker stops.
  • Rebuilds the menu from persisted device/chat state on service-worker startup and relevant lifecycle/state changes.
  • Builds the complete desired menu before replacing the browser-owned menu, avoiding the startup race where removeAll() ran before device data was ready.
  • Keeps the Pushbullet context menu enabled as core extension behavior and removes the additional context-menu enable/disable setting.
  • Makes normal HTTP/HTTPS host access non-optional so right-click image pushes do not silently fail on sites where the image bytes require host permission.
  • Removes the now-obsolete context-menu and host-permission controls from Options.

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, and options.html.

Copilot AI lite review requested due to automatic review settings August 24, 2026 05:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 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 thread context-menu-v3.js
Comment on lines +245 to +249
if (menuId == CONTEXT_MENU_SNOOZE) {
pb.snooze()
pb.updateContextMenu()
return
}
Comment thread context-menu-v3.js
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 thread manifest.json
Comment on lines +32 to 35
"http://localhost:20807/*",
"https://*/*",
"http://*/*"
],
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.

2 participants