-
Notifications
You must be signed in to change notification settings - Fork 11
Description
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()withPromise.race()against a timeout promise - Add a
processingStateto the upload component:'idle' | 'reading' | 'parsing' | 'validating' | 'complete' | 'error' - Show a progress bar or spinner during the
readingandparsingphases - 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.tsxcomponent for the UI updates
Acceptance Criteria
- A loading spinner/progress indicator shows during CSV processing
- Files approaching 1MB show "Processing X recipients..." feedback
- A 10-second timeout prevents indefinite hangs on malformed files
- Users can cancel CSV processing mid-way
- CSV header validation catches wrong column names before processing rows
- Specific error messages for: wrong delimiter, missing required columns, empty file
- Successfully processed CSV shows "X recipients loaded" confirmation
- The upload area is disabled during processing (no duplicate uploads)
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
processingStateto 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
- Fork the repository first if you haven't already — all contributions must come from a fork
- Pull the latest
mainbranch:git checkout main && git pull origin main - Create your feature branch from
main:git checkout -b feat/<issue-number>-csv-processing-feedback
While Working
- Make atomic commits — one concern per commit, each commit must build
- Use Conventional Commits:
feat(scope): description,fix(scope): description - Keep your branch up to date:
git pull origin main --rebaseregularly
Before Submitting the PR
- Pull latest
mainand rebase:git checkout main && git pull origin main && git checkout <your-branch> && git rebase main - Ensure the build passes:
pnpm build - Ensure linting passes:
pnpm lint - Record a screen recording of your implementation showing the feature/fix working in the browser. Attach it to the PR.
PR Requirements
- Link this issue in your PR description using
Closes #<issue-number> - Fill out the full PR template — Summary, What Was Implemented, Implementation Details, How to Test
- Attach your screen recording demonstrating the implementation
- Request a review from a maintainer
PRs without a screen recording or without a linked issue will not be reviewed. Failure to meet PR requirements may lead to PR rejection.