Feature/Browser Notifications#151
Open
Rotto84 wants to merge 1 commit into
Open
Conversation
Rotto84
marked this pull request as draft
July 24, 2026 02:12
Rotto84
marked this pull request as ready for review
July 24, 2026 19:52
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.
Add browser notifications for download completion/failure
Summary
Implements the
EnableNotificationsoption that already existed in the store/options UI but was previously non-functional (the checkbox was commented out with the note "Currently does nothing, so let's not show it"). Users can now opt in to a browser notification whenever a queued download finishes successfully or fails.What changed
Completion detection (
src/Client.ts)addCompletionListener/removeCompletionListenersubscribers.History API implementation (
src/downloader/SABnzbd.ts,src/downloader/NZBGet.ts)getHistory()methods were previously stubs returning[]. Implemented real calls: SABnzbd'smode=history, NZBGet'shistoryJSON-RPC method.'Completed'/'Failed'string.messagefield toNZBQueueItem(src/downloader/index.ts) to carry the failure reason:fail_messagefield directly.FAILURE/PAR,WARNING/DAMAGED) to readable text via a small lookup table, with a generic fallback for unmapped codes.Notification UI (
src/entrypoints/background.ts)EnableNotificationssetting, and callsbrowser.notifications.create()with the extension's existing green/red icons.contextMessage(the dimmer second line).Options UI (
src/entrypoints/options/Options.tsx)Testing
Added 15 unit tests, none requiring a live SABnzbd/NZBGet server:
src/__tests__/Client.test.ts(8 tests) — queue-diffing/completion-detection logic, listener add/remove, multi-item completions, failure reason pass-through.src/downloader/__tests__/SABnzbd.history.test.ts(3 tests) —getHistory()parsing incl.fail_message.src/downloader/__tests__/NZBGet.history.test.ts(4 tests) —getHistory()parsing incl. status-code-to-reason mapping.All 15 pass.
tsc --noEmitandwxt buildare clean. Manually tested end-to-end in Chrome with a live downloader — success and failure notifications both fire correctly and show the expected icon/title/reason.Known limitations / follow-ups
getHistory()field mappings are based on SABnzbd's and NZBGet's documented API shapes; if either project changes field names in a future version, this may need adjustment.NZBGET_STATUS_REASONS) covers the most common codes (par, unpack, disk space, password, etc.) but not the full list NZBGet can emit — unmapped codes fall back to a readable but generic label rather than being dropped.setInterval(pre-existing, not introduced by this PR) rather thanchrome.alarms. Under Manifest V3, service workers can be evicted after ~30s idle, which can interrupt polling and reset in-memory completion tracking. There's an existing// TODO: Switch to alarmscomment inClient.ts— worth addressing in a follow-up PR since it affects notification reliability, not just this feature.