Skip to content

fix: Showing notifications when downloads were cancelled - #3145

Merged
jeanfbrito merged 2 commits into
masterfrom
fix-cancelled-download-notifications
Nov 26, 2025
Merged

jeanfbrito merged 2 commits into
masterfrom
fix-cancelled-download-notifications

Conversation

@jeanfbrito

@jeanfbrito jeanfbrito commented Nov 26, 2025 •

Copy link
Copy Markdown
Member

Remove Download Cancellation Notifications and Improve Downloads Interaction

Summary

This change removes the system notification that was displayed when downloads were cancelled, providing a cleaner user experience. Downloads that complete successfully still show a notification via the onCompleted callback, but cancelled downloads no longer trigger an automatic notification.

The change also improves how the Downloads button in the sidebar integrates with the notification system, ensuring that clicking on any Downloads-related notification dispatches the SIDE_BAR_DOWNLOADS_BUTTON_CLICKED action for consistent interaction patterns.

Context/Background

Previously, the application displayed system notifications for both completed and cancelled downloads in the done event handler. Completed downloads also trigger a separate notification via the onCompleted callback in electronDl, resulting in duplicate notifications for successful downloads.

By removing the notification from the done event handler, cancelled downloads no longer show an automatic notification, while completed downloads still receive user feedback through the onCompleted notification. This provides a more intentional experience—users are alerted when files successfully complete but are not interrupted by notifications for user-cancelled downloads.

Changes Made

Remove Download Cancellation Notification

  • Removed the createNotification call from the download done event handler in src/downloads/main.ts
  • This eliminates the duplicate notification for completed downloads (which already show via onCompleted in electronDl)
  • Eliminates the notification for cancelled downloads, since user-initiated cancellations don't require a notification
  • The download state update action (DOWNLOAD_UPDATED) continues to be dispatched, keeping the downloads list in the UI current

Enhance Download Access Through Sidebar Button

  • Updated src/notifications/preload.ts to dispatch the SIDE_BAR_DOWNLOADS_BUTTON_CLICKED action when a notification with the title "Downloads" is clicked
  • Modified the notification click handler to distinguish between Downloads notifications and regular server notifications
  • Downloads interaction now goes through the existing Downloads sidebar button action, ensuring consistent behavior

State Management Improvements

  • For Download-related notifications, the system dispatches SIDE_BAR_DOWNLOADS_BUTTON_CLICKED which navigates to the Downloads view
  • For all other notifications, the existing WEBVIEW_FOCUS_REQUESTED behavior is maintained, preserving compatibility with server notifications
  • The notification system continues to track downloads activity while removing the automatic display of completion alerts

Testing

Verify Completed Downloads Still Show Notifications

  1. Start a file download from any server in Rocket.Chat
  2. Wait for the download to complete
  3. Verify that a system notification appears when the download finishes
  4. Click the notification and verify it opens the Downloads view via the sidebar button action

Verify Cancelled Downloads No Longer Show Notifications

  1. Start a file download from any server in Rocket.Chat
  2. Cancel the download before it completes
  3. Verify that no system notification appears when you cancel
  4. Confirm the Downloads list still shows the cancelled download with updated status

Verify Downloads List Remains Updated

  1. Start multiple downloads
  2. Complete at least one download and cancel another
  3. Click the Downloads button in the sidebar
  4. Verify the Downloads view shows all downloads with correct status (completed, in progress, cancelled)
  5. Verify download metadata (filename, progress, completion state) are accurate

Verify Sidebar Downloads Button Interaction

  1. Click the Downloads notification that appears when a download completes
  2. Verify the Downloads view opens correctly
  3. Click the Downloads button in the sidebar directly
  4. Verify both interactions navigate to the Downloads view
  5. Test on all supported platforms (macOS, Windows, Linux)

Verify Other Notifications Still Work

  1. Receive regular Rocket.Chat notifications (messages, mentions, etc.)
  2. Verify clicking these notifications still opens the webview with correct focus behavior
  3. Confirm only Downloads notifications dispatch the sidebar action, while other notifications maintain existing behavior

References

  • Related download feature: src/ui/components/SideBar/index.tsx
  • Download state management: src/downloads/actions.ts
  • Sidebar action definitions: src/ui/actions.ts
  • Notifications preload: src/notifications/preload.ts

https://rocketchat.atlassian.net/browse/SUP-923

Summary by CodeRabbit

  • Bug Fixes
    • Download completion notifications no longer appear when a download finishes, reducing redundant alerts.
    • Notification click behavior refined: clicking a "Downloads" notification opens the downloads sidebar; other notification clicks now focus the server view for the associated URL.

✏️ Tip: You can customize this high-level summary in your review settings.

…nhance notification handling

- Removed the notification creation logic from the `done` event handler in the download process to streamline user experience.
- Updated the notification handling in `preload.ts` to dispatch a new action for sidebar downloads when the 'Downloads' title is clicked, improving user interaction and feedback.
@coderabbitai

coderabbitai Bot commented Nov 26, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Removed automatic creation of a user notification on download completion and changed notification click routing: clicks on "Downloads" notifications dispatch SIDE_BAR_DOWNLOADS_BUTTON_CLICKED; other clicks dispatch WEBVIEW_FOCUS_REQUESTED with the server URL and 'server' view.

Changes

Cohort / File(s) Change Summary
Downloads + notification routing
src/downloads/main.ts, src/notifications/preload.ts
Removed creation of a user notification from the downloads 'done' handler; the handler now dispatches DOWNLOAD_UPDATED using item.getState(). Updated notification click handling to dispatch SIDE_BAR_DOWNLOADS_BUTTON_CLICKED when title is "Downloads", otherwise dispatch WEBVIEW_FOCUS_REQUESTED with server URL and fixed 'server' view.

Sequence Diagram(s)

sequenceDiagram
    participant Downloader as Downloads Handler
    participant Store as Redux Store
    participant Notifier as Notification System
    rect rgb(240,240,255)
    Note over Downloader,Notifier: Previous download completion (before)
    Downloader->>Notifier: create notification(title="Downloads", body=filename, subtitle=...)
    Notifier->>User: show notification
    Downloader->>Store: dispatch DOWNLOAD_UPDATED (state, payload)
    end

    rect rgb(240,255,240)
    Note over Downloader,Store: New download completion (now)
    Downloader->>Store: dispatch DOWNLOAD_UPDATED (item.getState(), timing/bytes/url fields)
    %% no notification created
    end
Loading
sequenceDiagram
    participant User
    participant Notifier as Notification Preload
    participant Store as Redux Store

    rect rgb(255,245,240)
    Note over User,Notifier: Notification click handling (new)
    User->>Notifier: click notification(title)
    alt title == "Downloads"
        Notifier->>Store: dispatch SIDE_BAR_DOWNLOADS_BUTTON_CLICKED
    else
        Notifier->>Store: dispatch WEBVIEW_FOCUS_REQUESTED(serverUrl, view='server')
    end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect src/downloads/main.ts to ensure removal of notification creation didn't omit necessary side effects (metrics, analytics, cleanup).
  • Verify src/notifications/preload.ts conditional branches and imported action constants match store expectations and telemetry.
  • Run manual test: download completion and click behavior for "Downloads" and non-"Downloads" notifications.

Possibly related PRs

Poem

🐰 I watched the bytes fall soft and neat,
No trumpet blared when downloads complete.
If you click "Downloads", I hop to the side,
Else I guide you to the server ride. 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: removing duplicate notifications for cancelled downloads while preserving those for completed downloads.
Linked Issues check ✅ Passed The PR addresses SUP-923 by removing duplicate notifications from cancelled/completed downloads and updating notification click handling to dispatch proper sidebar actions.
Out of Scope Changes check ✅ Passed All changes are focused on fixing download notification behavior: removing redundant notifications and improving notification click routing, both directly addressing the linked issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-cancelled-download-notifications

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a2f6506 and 0e367c3.

📒 Files selected for processing (1)
  • src/downloads/main.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Follow existing TypeScript patterns with strict mode enabled
All new code must pass ESLint and TypeScript checks
Avoid unnecessary comments; only add comments for complex logic or non-obvious decisions

Files:

  • src/downloads/main.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: check (windows-latest)
  • GitHub Check: check (macos-latest)
  • GitHub Check: check (ubuntu-latest)
🔇 Additional comments (1)
src/downloads/main.ts (1)

78-100: Notification handling via electronDl's onCompleted callback is properly configured.

The removal of notification creation from the done handler is correct and aligns with PR objectives. Verification confirms electronDl is configured with an onCompleted callback in src/downloads/main/setup.ts (lines 97–113) that:

  • Creates notifications for all completed downloads
  • Stores the download directory for persistence
  • Handles errors gracefully

The logic changes in the code are sound:

  • Derives state from item.getState() (equivalent to the _state parameter)
  • Maps cancelled state to CANCELLED status
  • Dispatches DOWNLOAD_UPDATED to keep the UI current
  • Cleans up the items map

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- Changed the parameter names in the 'done' event handler from `state` to `_state` to indicate that the parameter is unused, improving code readability and consistency.
@jeanfbrito
jeanfbrito merged commit 06c7765 into master Nov 26, 2025
@jeanfbrito
jeanfbrito deleted the fix-cancelled-download-notifications branch November 26, 2025 19:15
sreeja2007 pushed a commit to sreeja2007/Rocket.Chat.Electron that referenced this pull request Mar 2, 2026
…3145)

* refactor(downloads): Remove notification on download completion and enhance notification handling

- Removed the notification creation logic from the `done` event handler in the download process to streamline user experience.
- Updated the notification handling in `preload.ts` to dispatch a new action for sidebar downloads when the 'Downloads' title is clicked, improving user interaction and feedback.

* fix(downloads): Update event handler parameters for clarity

- Changed the parameter names in the 'done' event handler from `state` to `_state` to indicate that the parameter is unused, improving code readability and consistency.
Ram-sah19 pushed a commit to Ram-sah19/Rocket.Chat.Electron that referenced this pull request Mar 10, 2026
…3145)

* refactor(downloads): Remove notification on download completion and enhance notification handling

- Removed the notification creation logic from the `done` event handler in the download process to streamline user experience.
- Updated the notification handling in `preload.ts` to dispatch a new action for sidebar downloads when the 'Downloads' title is clicked, improving user interaction and feedback.

* fix(downloads): Update event handler parameters for clarity

- Changed the parameter names in the 'done' event handler from `state` to `_state` to indicate that the parameter is unused, improving code readability and consistency.
Ram-sah19 pushed a commit to Ram-sah19/Rocket.Chat.Electron that referenced this pull request Mar 10, 2026
…3145)

* refactor(downloads): Remove notification on download completion and enhance notification handling

- Removed the notification creation logic from the `done` event handler in the download process to streamline user experience.
- Updated the notification handling in `preload.ts` to dispatch a new action for sidebar downloads when the 'Downloads' title is clicked, improving user interaction and feedback.

* fix(downloads): Update event handler parameters for clarity

- Changed the parameter names in the 'done' event handler from `state` to `_state` to indicate that the parameter is unused, improving code readability and consistency.
Ram-sah19 pushed a commit to Ram-sah19/Rocket.Chat.Electron that referenced this pull request Mar 10, 2026
…3145)

* refactor(downloads): Remove notification on download completion and enhance notification handling

- Removed the notification creation logic from the `done` event handler in the download process to streamline user experience.
- Updated the notification handling in `preload.ts` to dispatch a new action for sidebar downloads when the 'Downloads' title is clicked, improving user interaction and feedback.

* fix(downloads): Update event handler parameters for clarity

- Changed the parameter names in the 'done' event handler from `state` to `_state` to indicate that the parameter is unused, improving code readability and consistency.
Ram-sah19 pushed a commit to Ram-sah19/Rocket.Chat.Electron that referenced this pull request Mar 10, 2026
…3145)

* refactor(downloads): Remove notification on download completion and enhance notification handling

- Removed the notification creation logic from the `done` event handler in the download process to streamline user experience.
- Updated the notification handling in `preload.ts` to dispatch a new action for sidebar downloads when the 'Downloads' title is clicked, improving user interaction and feedback.

* fix(downloads): Update event handler parameters for clarity

- Changed the parameter names in the 'done' event handler from `state` to `_state` to indicate that the parameter is unused, improving code readability and consistency.
Ram-sah19 pushed a commit to Ram-sah19/Rocket.Chat.Electron that referenced this pull request Mar 10, 2026
…3145)

* refactor(downloads): Remove notification on download completion and enhance notification handling

- Removed the notification creation logic from the `done` event handler in the download process to streamline user experience.
- Updated the notification handling in `preload.ts` to dispatch a new action for sidebar downloads when the 'Downloads' title is clicked, improving user interaction and feedback.

* fix(downloads): Update event handler parameters for clarity

- Changed the parameter names in the 'done' event handler from `state` to `_state` to indicate that the parameter is unused, improving code readability and consistency.
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.

1 participant