Fix: upload input v3 file size - #304
Conversation
📝 WalkthroughWalkthroughThe upload input now omits size text when a completed file has no ChangesUpload status update
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@src/components/inputs/upload-input-v3/index.js`:
- Line 478: Update the file-size display in the upload completion rendering near
formatFileSize so zero-byte files retain and show “0 KB ·”. Replace the
truthiness check on file.size with a missing-metadata check that only omits the
size when file or its size is unavailable, and add a test covering a zero-byte
file.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7869b93b-3624-4e49-a97e-cc57960ed706
📒 Files selected for processing (3)
package.jsonsrc/components/inputs/upload-input-v3/__tests__/upload-input-v3.test.jssrc/components/inputs/upload-input-v3/index.js
| </Typography> | ||
| <Typography variant="caption" color="text.secondary"> | ||
| {fileSize} · {T.translate("upload_input_v3.complete")} | ||
| {file?.size ? `${fileSize} ·` : ''} {T.translate("upload_input_v3.complete")} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Preserve the size for zero-byte files.
formatFileSize returns 0 KB when file.size is 0, but this truthiness check hides it. A valid empty file will display only Complete. Check for missing metadata instead and add a zero-byte test.
Proposed fix
- {file?.size ? `${fileSize} ·` : ''} {T.translate("upload_input_v3.complete")}
+ {file?.size != null ? `${fileSize} ·` : ''} {T.translate("upload_input_v3.complete")}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| {file?.size ? `${fileSize} ·` : ''} {T.translate("upload_input_v3.complete")} | |
| {file?.size != null ? `${fileSize} ·` : ''} {T.translate("upload_input_v3.complete")} |
🧰 Tools
🪛 ast-grep (0.45.0)
[warning] 476-478: A list component should have a key to prevent re-rendering
Context:
{file?.size ? ${fileSize} · : ''} {T.translate("upload_input_v3.complete")}
Note: [CWE-710] Improper Adherence to Coding Standards. Security best practice.
(list-component-needs-key)
🤖 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/components/inputs/upload-input-v3/index.js` at line 478, Update the
file-size display in the upload completion rendering near formatFileSize so
zero-byte files retain and show “0 KB ·”. Replace the truthiness check on
file.size with a missing-metadata check that only omits the size when file or
its size is unavailable, and add a test covering a zero-byte file.
https://app.clickup.com/t/9014802374/86bb61cdw
Summary by CodeRabbit
Bug Fixes
0 KBvalue.Tests