Skip to content

[BUG] Download speed and estimated time remaining never render in Downloads Manager #3477

Description

@Pcmhacker-piro

Search before asking

  • I had searched in the issues and found no similar issues.

Operating System

  • macOS
  • Windows
  • Linux

Operating System Version

macOS 14+ / Windows 11 / Ubuntu 22.04

It happens on the web browser too?

No, it just happens on the Desktop app

Rocket.Chat Desktop App Version

4.x / develop (main)

Rocket.Chat Server Version

6.x+

Describe the bug

In src/ui/components/DownloadsManagerView/DownloadItem.tsx, the Download Item component contains useMemo hooks for calculating download speed (progressSpeed) and estimated time left (estimatedTimeLeft) to display in the Downloads Manager UI during active downloads.

However, both useMemo hooks require !endTime to be false (i.e. endTime must be defined):

// Lines 48-63 in src/ui/components/DownloadsManagerView/DownloadItem.tsx
const progressSpeed = useMemo(() => {
  if (
    !receivedBytes ||
    !totalBytes ||
    !startTime ||
    !endTime ||              // ❌ Blocks calculation while progressing
    state !== 'progressing'
  ) {
    return undefined;
  }

  return i18n.format(
    (receivedBytes / (endTime - startTime)) * 1000,
    'byteSpeed'
  );
}, [endTime, i18n, receivedBytes, startTime, state, totalBytes]);

Why this creates a permanent UI blocker:

  1. While a download is actively in progress (state === 'progressing'):
    • In Electron's download lifecycle (src/downloads/main.ts), endTime is explicitly undefined until the download finishes.
    • Because !endTime is true, progressSpeed and estimatedTimeLeft evaluate to undefined.
  2. When the download completes (state === 'completed'):
    • endTime is finally set (Date.now()), but state !== 'progressing' is now true, which also returns undefined.
  3. When paused or cancelled:
    • state !== 'progressing' is true, returning undefined.

As a consequence, progressSpeed and estimatedTimeLeft can never evaluate to a value, and the download speed and time remaining indicators never appear in the Downloads Manager UI under any condition.

How to Reproduce

  1. Open the Rocket.Chat Desktop App and go to the Downloads Manager (DownloadsManagerView).
  2. Start downloading any large file or attachment.
  3. Inspect the progress row for the progressing item.
  4. Observe that only the received/total byte size is rendered; download speed and estimated time remaining are completely missing from the UI.

Describe your Expected behavior

While a file is in the progressing state, the component should calculate elapsed time using (endTime ?? Date.now()) - startTime so that current download speed and estimated remaining time are rendered live next to the file size progress.

Anything else

Proposed Solution

Calculate elapsed time dynamically using current time if endTime is not yet set:

--- a/src/ui/components/DownloadsManagerView/DownloadItem.tsx
+++ b/src/ui/components/DownloadsManagerView/DownloadItem.tsx
@@ -52,3 +52,2 @@ const DownloadItem = ({
       !startTime ||
-      !endTime ||
       state !== 'progressing'
@@ -58,3 +57,3 @@ const DownloadItem = ({
     return i18n.format(
-      (receivedBytes / (endTime - startTime)) * 1000,
+      (receivedBytes / ((endTime ?? Date.now()) - startTime)) * 1000,
       'byteSpeed'
@@ -69,3 +68,2 @@ const DownloadItem = ({
       !startTime ||
-      !endTime ||
       state !== 'progressing'
@@ -76,3 +74,3 @@ const DownloadItem = ({
     const remainingBytes = totalBytes - receivedBytes;
-    const speed = receivedBytes / (endTime - startTime);
+    const speed = receivedBytes / ((endTime ?? Date.now()) - startTime);
     return i18n.format(remainingBytes / speed, 'duration');

Are you willing to submit a code contribution?

  • Yes, I am willing to submit a Pull Request!

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions