Context & Impact
In csv-processing.ts, the file size is validated at 1MB max, but the file.text() call that reads the file content has no timeout. For files approaching the 1MB limit with thousands of rows, parsing can take several seconds. During this time, the user sees no progress indicator, no loading state, and no way to cancel. If the file is malformed, the parser may hang or take excessively long.
Why this matters: Users uploading CSV files for bulk token distribution expect immediate feedback. A file with 10,000 recipients is a legitimate use case, but the current implementation provides no indication that processing is happening. Users may think the upload failed and try again, or navigate away before processing completes.
Scope
- Add a loading state to the CSV upload flow with a progress indicator
- Add a timeout for the
file.text() call (10 seconds max)
- Show row count feedback as the CSV is parsed ("Processing 5,000 recipients...")
- Add a cancel button to abort long-running CSV processing
- Validate CSV structure (headers, column count) before processing all rows
- Show specific error messages for common CSV issues (wrong delimiter, missing columns)
Implementation Guidelines
- Wrap
file.text() with Promise.race() against a timeout promise
- Add a
processingState to the upload component: 'idle' | 'reading' | 'parsing' | 'validating' | 'complete' | 'error'
- Show a progress bar or spinner during the
reading and parsing phases
- Parse the CSV header row first and validate column names before processing data rows
- For very large files, consider using a streaming parser or Web Worker to avoid blocking the main thread
- Use the existing
FileUploadArea.tsx component for the UI updates
Acceptance Criteria
Getting Started
- Read
src/utils/csv-processing.ts — understand the current parsing flow
- Read
src/components/molecules/FileUploadArea.tsx — understand the upload UI
- Add timeout wrapper:
Promise.race([file.text(), timeoutPromise(10000)])
- Add
processingState to the upload component
- Add header validation before processing data rows
- Add progress feedback UI (spinner + row count)
- Test with: empty file, 10-row file, 1000-row file, malformed CSV, wrong delimiter
PR Submission Guide
This section applies to every PR for this issue. Follow it exactly.
Before You Start
While Working
Before Submitting the PR
PR Requirements
PRs without a screen recording or without a linked issue will not be reviewed. Failure to meet PR requirements may lead to PR rejection.
Context & Impact
In
csv-processing.ts, the file size is validated at 1MB max, but thefile.text()call that reads the file content has no timeout. For files approaching the 1MB limit with thousands of rows, parsing can take several seconds. During this time, the user sees no progress indicator, no loading state, and no way to cancel. If the file is malformed, the parser may hang or take excessively long.Why this matters: Users uploading CSV files for bulk token distribution expect immediate feedback. A file with 10,000 recipients is a legitimate use case, but the current implementation provides no indication that processing is happening. Users may think the upload failed and try again, or navigate away before processing completes.
Scope
file.text()call (10 seconds max)Implementation Guidelines
file.text()withPromise.race()against a timeout promiseprocessingStateto the upload component:'idle' | 'reading' | 'parsing' | 'validating' | 'complete' | 'error'readingandparsingphasesFileUploadArea.tsxcomponent for the UI updatesAcceptance Criteria
Getting Started
src/utils/csv-processing.ts— understand the current parsing flowsrc/components/molecules/FileUploadArea.tsx— understand the upload UIPromise.race([file.text(), timeoutPromise(10000)])processingStateto the upload componentPR Submission Guide
Before You Start
mainbranch:git checkout main && git pull origin mainmain:git checkout -b feat/<issue-number>-csv-processing-feedbackWhile Working
feat(scope): description,fix(scope): descriptiongit pull origin main --rebaseregularlyBefore Submitting the PR
mainand rebase:git checkout main && git pull origin main && git checkout <your-branch> && git rebase mainpnpm buildpnpm lintPR Requirements
Closes #<issue-number>PRs without a screen recording or without a linked issue will not be reviewed. Failure to meet PR requirements may lead to PR rejection.