feat: bulk dictionary import via paste or file upload#461
feat: bulk dictionary import via paste or file upload#461NathanSkene wants to merge 2 commits intoOpenWhispr:mainfrom
Conversation
JiwaniZakir
left a comment
There was a problem hiding this comment.
The handleFileUpload callback has no file size guard before calling reader.readAsText(file) — a user dropping a multi-megabyte .txt or .csv file will synchronously block the main thread while it's parsed into the textarea. A simple early return when file.size exceeds a reasonable limit (e.g. 1 MB) would prevent that.
The parsedImportWords, existingSet, newImportWords, and duplicateCount computations run on every render of DictionaryView regardless of whether the import dialog is open. For users with large custom dictionaries, rebuilding the Set and filtering on every keystroke in the main word input is unnecessary work — wrapping these in useMemo (gated on importText and customDictionary) would scope that cost to when it actually matters.
In handleFileUpload, the JSON branch only handles the case where the parsed value is a top-level array. A common export format is { "words": [...] } or similar; right now that silently falls through to dumping the raw JSON string into the textarea, which will confuse users. A comment or a slightly broader check (e.g. looking for a words/dictionary key) would make the failure mode less opaque.
Adds an "Import" button to the Custom Dictionary view that opens a dialog where users can paste words (one per line, comma, or tab separated) or upload a .txt/.csv/.json file. Shows a live preview of new vs duplicate word counts before confirming. Useful for domain-specific vocabularies (scientific terms, medical jargon, etc.) where adding words one at a time is impractical. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add 1MB file size guard before readAsText
- Wrap import preview computations in useMemo
- Handle { "words": [...] } JSON format
|
Rebased onto current main and addressed review feedback:
|
8b7790c to
600de59
Compare
|
Manual validation status note: This PR remains in the keep/merge set. During the broader validation pass I did not uncover a blocker or regression here, and the branch is already rebased with the earlier review feedback addressed. Current upstream-facing status from my side:
I have not done the same intensive end-to-end packaged-app validation on this one that I did for the recording/audio branches, so this comment is mainly to clarify merge status rather than claim new feature-specific test coverage. |
Summary
Closes #460
Test plan
🤖 Generated with Claude Code