Skip to content

fix/consistent-browser-api-usage#545

Open
PhilixTheExplorer wants to merge 1 commit intofossasia:mainfrom
PhilixTheExplorer:fix/consistent-browser-api-usage
Open

fix/consistent-browser-api-usage#545
PhilixTheExplorer wants to merge 1 commit intofossasia:mainfrom
PhilixTheExplorer:fix/consistent-browser-api-usage

Conversation

@PhilixTheExplorer
Copy link
Copy Markdown

@PhilixTheExplorer PhilixTheExplorer commented Apr 14, 2026

📌 Fixes

Fixes #542


📝 Summary of Changes

  • Replaced 3 instances of chrome.* with browser.* in scrumHelper.js:
    • Line 18-19: chrome.i18nbrowser.i18n (in renderErrorMessage())
    • Line 173: chrome.storage.local.set()browser.storage.local.set() (onlyIssues/onlyPRs mutual exclusivity fix)
    • Line 194: chrome.storage.local.set()browser.storage.local.set() (onlyMergedPRs corrections)
  • Replaced 2 instances of chrome.* with browser.* in popup.js:
    • Line 30: chrome.i18n guard → browser.i18n (in showShortcutNotification())
    • Line 39: chrome.i18n.getMessage()browser.i18n.getMessage()
      The project uses browser-polyfill.min.js for cross-browser support. The entire codebase
      consistently uses browser.* APIs — except these 5 places that used chrome.* directly.
      While this works in Chrome (where chrome.* is native), in Firefox chrome.storage.local.set()
      uses callbacks instead of Promises, which can cause silent failures.

How to verify

grep -rn "chrome\." src/scripts/ --include="*.js" | grep -v "browser-polyfill"

✅ Checklist

  • I’ve tested my changes locally
  • I’ve added tests (if applicable)
  • I’ve updated documentation (if applicable)
  • My code follows the project’s code style guidelines

👀 Reviewer Notes

Add any special notes for the reviewer here

Summary by Sourcery

Ensure consistent use of WebExtension browser APIs for cross-browser compatibility.

Bug Fixes:

  • Replace remaining chrome.i18n usages with browser.i18n to align with the browser polyfill and prevent localization issues in non-Chrome browsers.
  • Replace remaining chrome.storage.local.set usages with browser.storage.local.set to avoid callback/Promise mismatches that can cause silent failures in Firefox.

Enhancements:

  • Align popup and scrum helper scripts with the project-wide convention of using browser.* APIs exclusively.

Copilot AI review requested due to automatic review settings April 14, 2026 10:46
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Apr 14, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR standardizes extension code to use the Promise-based browser.* WebExtension API everywhere, replacing remaining chrome.* usages in the scrum helper logic and popup UI so behavior is consistent across browsers (especially Firefox).

Sequence diagram for updated shortcut notification in popup

sequenceDiagram
  actor User
  participant PopupScript
  participant BrowserAPI

  User->>PopupScript: triggerShortcutNotification
  PopupScript->>PopupScript: showShortcutNotification(messageKey)
  PopupScript->>BrowserAPI: check browser_i18n
  alt browser_i18n_unavailable
    PopupScript-->>User: no_notification
  else browser_i18n_available
    PopupScript->>BrowserAPI: i18n_getMessage(messageKey)
    BrowserAPI-->>PopupScript: localizedMessage
    PopupScript->>PopupScript: createOrUpdateNotification(localizedMessage)
    PopupScript-->>User: notificationDisplayed
  end
Loading

Flow diagram for storage normalization in allIncluded

flowchart TD
  Start[Start allIncluded]
  Load[Load_settings_from_browser_storage]
  CheckBoth[onlyIssues && onlyPRs?]
  NormalizeOnlyPRs[Set onlyPRs = false]
  PersistOnlyPRs[browser_storage_local_set onlyPRs_false]
  CheckMerged[onlyMergedPRs_enabled?]
  BuildCorrections[Build_corrections_for_onlyRevPRs_onlyIssues_onlyPRs]
  PersistCorrections[browser_storage_local_set corrections]
  Continue[Continue_allIncluded_processing]

  Start --> Load --> CheckBoth
  CheckBoth -- Yes --> NormalizeOnlyPRs --> PersistOnlyPRs --> CheckMerged
  CheckBoth -- No --> CheckMerged
  CheckMerged -- Yes --> BuildCorrections --> PersistCorrections --> Continue
  CheckMerged -- No --> Continue
Loading

File-Level Changes

Change Details Files
Use browser.i18n consistently for localized messages in the scrum helper and popup UIs.
  • Update the renderErrorMessage helper to guard against and use browser.i18n instead of chrome.i18n when resolving localized messages.
  • Update the popup shortcut notification flow to check for browser.i18n availability and retrieve localized messages via browser.i18n.getMessage.
src/scripts/scrumHelper.js
src/scripts/popup.js
Use Promise-compatible browser.storage.local.set instead of callback-based chrome.storage.local.set in scrum configuration normalization.
  • Change the normalization path that disables onlyPRs when both onlyIssues and onlyPRs are enabled to call browser.storage.local.set.
  • Change the corrections path that enforces onlyMergedPRs overriding other flags to persist the corrections object via browser.storage.local.set.
src/scripts/scrumHelper.js

Assessment against linked issues

Issue Objective Addressed Explanation
#542 Replace all remaining direct uses of chrome.* in scrumHelper.js with browser.* to align with the browser polyfill and ensure Firefox compatibility.
#542 Replace all remaining direct uses of chrome.* in popup.js with browser.* to align with the browser polyfill and ensure Firefox compatibility.
#542 Ensure that storage operations for filter mutual exclusivity (onlyIssues, onlyPRs, onlyMergedPRs) use the Promise-based browser.storage API so they work correctly in Firefox.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions bot added javascript Pull requests that update javascript code core labels Apr 14, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR resolves Firefox compatibility and codebase consistency issues by replacing remaining direct chrome.* extension API usages with browser.*, aligning with the repo’s use of browser-polyfill.min.js.

Changes:

  • Updated scrumHelper.js to use browser.i18n.getMessage and browser.storage.local.set instead of chrome.*.
  • Updated popup.js to use browser.i18n for shortcut notification rendering and guarding.

Reviewed changes

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

File Description
src/scripts/scrumHelper.js Switches remaining chrome.* i18n/storage calls to browser.* for promise-based, cross-browser behavior.
src/scripts/popup.js Updates shortcut notification i18n guard + message retrieval to use browser.*.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Inconsistent chrome.* vs browser.* API usage in scrumHelper.js and popup.js

2 participants