Search before asking
Operating System
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:
- 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.
- When the download completes (
state === 'completed'):
endTime is finally set (Date.now()), but state !== 'progressing' is now true, which also returns undefined.
- 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
- Open the Rocket.Chat Desktop App and go to the Downloads Manager (
DownloadsManagerView).
- Start downloading any large file or attachment.
- Inspect the progress row for the progressing item.
- 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?
Search before asking
Operating System
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 containsuseMemohooks for calculating download speed (progressSpeed) and estimated time left (estimatedTimeLeft) to display in the Downloads Manager UI during active downloads.However, both
useMemohooks require!endTimeto be false (i.e.endTimemust be defined):Why this creates a permanent UI blocker:
state === 'progressing'):src/downloads/main.ts),endTimeis explicitlyundefineduntil the download finishes.!endTimeistrue,progressSpeedandestimatedTimeLeftevaluate toundefined.state === 'completed'):endTimeis finally set (Date.now()), butstate !== 'progressing'is nowtrue, which also returnsundefined.state !== 'progressing'istrue, returningundefined.As a consequence,
progressSpeedandestimatedTimeLeftcan 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
DownloadsManagerView).Describe your Expected behavior
While a file is in the
progressingstate, the component should calculate elapsed time using(endTime ?? Date.now()) - startTimeso 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
endTimeis not yet set:Are you willing to submit a code contribution?