fix: OCR-aware supported file types#2055
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughA shared supported-file-types module and hook now provide OCR-aware MIME types and extensions. Chat, knowledge, and onboarding upload components use the shared values instead of local constants. ChangesSupported file types centralization
Estimated code review effort: 2 (Simple) | ~12 minutes Suggested labels: 🚥 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 |
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
frontend/hooks/use-supported-file-types.ts (1)
16-19: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueOptional: derive
supportedExtensionsfrom memoizedsupportedFileTypes.
getSupportedExtensionsinternally callsgetSupportedFileTypesagain, creating a second object that's immediately discarded. Since both are memoized with the same dependency, you could reuse the already-computedsupportedFileTypesto avoid the redundant allocation.♻️ Optional refactor
const supportedFileTypes = useMemo( () => getSupportedFileTypes(ocrEnabled), [ocrEnabled], ); const supportedExtensions = useMemo( - () => getSupportedExtensions(ocrEnabled), - [ocrEnabled], + () => Object.values(supportedFileTypes).flat(), + [supportedFileTypes], );🤖 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 `@frontend/hooks/use-supported-file-types.ts` around lines 16 - 19, Reuse the already memoized supportedFileTypes in useSupportedFileTypes instead of calling getSupportedExtensions(ocrEnabled) directly, since that helper recomputes getSupportedFileTypes and creates a redundant object. Update the supportedExtensions derivation to come from supportedFileTypes with the same ocrEnabled dependency so both values stay in sync while avoiding the extra allocation.
🤖 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.
Nitpick comments:
In `@frontend/hooks/use-supported-file-types.ts`:
- Around line 16-19: Reuse the already memoized supportedFileTypes in
useSupportedFileTypes instead of calling getSupportedExtensions(ocrEnabled)
directly, since that helper recomputes getSupportedFileTypes and creates a
redundant object. Update the supportedExtensions derivation to come from
supportedFileTypes with the same ocrEnabled dependency so both values stay in
sync while avoiding the extra allocation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f2f3da4e-d46d-48a2-9e9c-c3a702df4dc8
📒 Files selected for processing (5)
frontend/app/chat/_components/chat-input.tsxfrontend/app/onboarding/_components/onboarding-upload.tsxfrontend/components/knowledge-dropdown.tsxfrontend/hooks/use-supported-file-types.tsfrontend/lib/supported-file-types.ts
Resolve chat-input conflict by keeping main's ref API refactor and reapplying OCR-aware useSupportedFileTypes. Co-authored-by: Cursor <cursoragent@cursor.com>
* add image type as valid types files if o r on * address react doctor fb --------- Co-authored-by: Olfa Maslah <olfamaslah@Olfas-MacBook-Pro.local> Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Include OCR image types (.bmp, .jpeg, .jpg, .png, .tiff, .webp) in supported upload lists when settings.knowledge.ocr is enabled, matching backend _OCR_REQUIRED_EXTENSIONS.
Move supported file type constants out of knowledge-dropdown.tsx into lib/supported-file-types.ts and expose them via a shared useSupportedFileTypes hook to satisfy React Doctor's only-export-components rule.
Wire OCR-aware file types into Knowledge upload (single file + folder filter) and Chat file attach/dropzone; onboarding keeps the static OCR-off list.
OCR disabled
OCR enabled → upload .png/.jpg via Knowledge File picker
OCR enabled → folder with mixed docs + images
OCR enabled → attach image in Chat (picker or drag-drop)
Test plan
With OCR disabled in Settings → Knowledge Base, verify file pickers accept documents only (PDF, DOCX, TXT, etc.) and reject images
Enable OCR in Settings → Knowledge Base, reload, and verify .png/.jpg appear in the Knowledge File picker and upload successfully
With OCR enabled, upload a folder containing mixed documents + images; confirm images are included and unsupported files are skipped
With OCR enabled, attach an image via Chat file picker and drag-and-drop
Toggle OCR off → on in settings without reload; confirm accepted file types update after settings refresh
Summary by CodeRabbit
New Features
Bug Fixes