Skip to content

feat(uploads-manager): add upload progress and time left to uploads manager#4716

Closed
pierre-pigeon wants to merge 10 commits into
box:masterfrom
pierre-pigeon:pgolebiowski-WEBAPP-65289-add-counters-to-uploading-file
Closed

feat(uploads-manager): add upload progress and time left to uploads manager#4716
pierre-pigeon wants to merge 10 commits into
box:masterfrom
pierre-pigeon:pgolebiowski-WEBAPP-65289-add-counters-to-uploading-file

Conversation

@pierre-pigeon

@pierre-pigeon pierre-pigeon commented Jul 22, 2026

Copy link
Copy Markdown

This PR enriches the modernized uploads manager with per-item byte progress and a smoothed time-remaining (ETA) estimate.

ContentUploader now tracks bytesUploaded/totalBytes from upload progress events and computes an EMA-smoothed ETA.

Summary by CodeRabbit

  • New Features

    • Added optional upload byte tracking and estimated time remaining.
    • Added an opt-in setting to display enhanced upload progress details.
    • Added a Storybook example showcasing uploads in progress with enhanced tracking.
  • Bug Fixes

    • Reset upload items now clear progress and time-remaining information.
    • ETA estimates are smoothed, throttled, and hidden when insufficient data is available.
  • Chores

    • Updated the uploads manager integration to version 2.4.0.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


pgolebiowski seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds opt-in upload ETA tracking with smoothed progress estimates, extends upload item metadata, wires the data into the modernized uploads manager, upgrades its dependency, and adds tests and Storybook coverage.

Changes

Upload ETA tracking

Layer / File(s) Summary
ETA estimation utilities
src/elements/content-uploader/utils/uploadEta.ts, src/elements/content-uploader/utils/__tests__/uploadEta.test.ts
Adds sampled, smoothed ETA calculation with grace-period, throttling, sliding-window, and zero-speed handling.
Modernized upload item mapping
src/common/types/upload.js, src/elements/content-uploader/utils/mapToModernizedUploadItem.ts, src/elements/content-uploader/utils/__tests__/mapToModernizedUploadItem.test.ts
Adds optional byte and ETA fields and conditionally maps, clamps, defaults, or omits them based on the feature flag and upload status.
ContentUploader integration and validation
package.json, src/elements/content-uploader/ContentUploader.tsx, src/elements/content-uploader/__tests__/ContentUploader.test.js, src/elements/content-uploader/stories/ContentUploader.stories.js
Adds opt-in ETA state handling, reset behavior, modernized-manager wiring, dependency version updates, progress tests, and an in-progress Storybook story.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant UploadsManager
  participant ContentUploader
  participant ETAUtilities
  participant ItemMapper
  UploadsManager->>ContentUploader: report upload progress
  ContentUploader->>ETAUtilities: update loaded bytes and timestamp
  ETAUtilities-->>ContentUploader: return smoothed remainingMs
  ContentUploader->>ItemMapper: map items with ETA enabled
  ItemMapper-->>UploadsManager: return byte progress and ETA metadata
Loading

Possibly related PRs

Suggested labels: ready-to-merge

Suggested reviewers: dealwith, olehrybak

Poem

I’m a rabbit with bytes in my burrow tonight,
Smoothing each estimate, hopping just right.
Progress goes forward, the minutes grow clear,
Modern uploads know when the finish is near.
Hop, hop—ETA is here! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: upload progress and ETA support in uploads manager.
Description check ✅ Passed The description summarizes the change and includes the template's merge-queue guidance block.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@pierre-pigeon pierre-pigeon changed the title Pgolebiowski webapp 65289 add counters to uploading file feat(uploads-manager): add upload progress and time left to uploads manager (WEBAPP-65289) Jul 22, 2026
@pierre-pigeon
pierre-pigeon force-pushed the pgolebiowski-WEBAPP-65289-add-counters-to-uploading-file branch from 45e3968 to e9a462a Compare July 23, 2026 10:13
@socket-security

socket-security Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​box/​uploads-manager@​1.17.2 ⏵ 2.4.07710010099 +150

View full report

@pierre-pigeon
pierre-pigeon marked this pull request as ready for review July 23, 2026 11:20
@pierre-pigeon
pierre-pigeon requested review from a team as code owners July 23, 2026 11:20

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/elements/content-uploader/ContentUploader.tsx (1)

1265-1287: 🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

Gate ETA tracking behind isUploadEtaEnabled.

handleUploadProgress unconditionally runs updateEta and updates etaByItem/bytesUploaded/totalBytes/remainingMs on every progress tick, even when isUploadEtaEnabled is false (the default). Only mapToModernizedUploadItem honors the flag by stripping these fields before render, so the UI is correct, but the EMA computation and WeakMap bookkeeping run on every progress event for free — wasted work for the common (flag-off) case, and it also means ContentUploader.test.js's handleUploadProgress() tests pass without ever setting isUploadEtaEnabled: true, masking that the "kill switch" isn't applied at the source.

⚡ Proposed guard
         item.progress = Math.min(Math.round((event.loaded / event.total) * 100), 100);
         item.status = item.progress === 100 ? STATUS_STAGED : STATUS_IN_PROGRESS;

-        // Track byte-level progress and a smoothed ETA for the modernized manager.
-        const nextEta = updateEta(this.etaByItem.get(item), event.loaded, event.total, Date.now());
-        this.etaByItem.set(item, nextEta);
-        item.bytesUploaded = event.loaded;
-        item.totalBytes = event.total;
-        item.remainingMs = getRemainingMs(nextEta);
+        // Track byte-level progress and a smoothed ETA for the modernized manager.
+        if (this.props.isUploadEtaEnabled) {
+            const nextEta = updateEta(this.etaByItem.get(item), event.loaded, event.total, Date.now());
+            this.etaByItem.set(item, nextEta);
+            item.bytesUploaded = event.loaded;
+            item.totalBytes = event.total;
+            item.remainingMs = getRemainingMs(nextEta);
+        }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/elements/content-uploader/ContentUploader.tsx` around lines 1265 - 1287,
Gate the ETA-specific work in handleUploadProgress behind the isUploadEtaEnabled
prop or configuration flag. Only call updateEta, write etaByItem, and assign
bytesUploaded, totalBytes, and remainingMs when the flag is enabled; preserve
the existing progress, status, callback, and collection updates for all uploads.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/elements/content-uploader/ContentUploader.tsx`:
- Around line 1265-1287: Gate the ETA-specific work in handleUploadProgress
behind the isUploadEtaEnabled prop or configuration flag. Only call updateEta,
write etaByItem, and assign bytesUploaded, totalBytes, and remainingMs when the
flag is enabled; preserve the existing progress, status, callback, and
collection updates for all uploads.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ef802a16-d441-4cfd-98d2-b454765cdda3

📥 Commits

Reviewing files that changed from the base of the PR and between e8139fd and 821a657.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (9)
  • package.json
  • src/common/types/upload.js
  • src/elements/content-uploader/ContentUploader.tsx
  • src/elements/content-uploader/__tests__/ContentUploader.test.js
  • src/elements/content-uploader/stories/ContentUploader.stories.js
  • src/elements/content-uploader/utils/__tests__/mapToModernizedUploadItem.test.ts
  • src/elements/content-uploader/utils/__tests__/uploadEta.test.ts
  • src/elements/content-uploader/utils/mapToModernizedUploadItem.ts
  • src/elements/content-uploader/utils/uploadEta.ts

@pierre-pigeon pierre-pigeon changed the title feat(uploads-manager): add upload progress and time left to uploads manager (WEBAPP-65289) feat(uploads-manager): add upload progress and time left to uploads manager Jul 23, 2026
@pierre-pigeon
pierre-pigeon deleted the pgolebiowski-WEBAPP-65289-add-counters-to-uploading-file branch July 23, 2026 13:39
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.

2 participants