Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/app/components/document-upload-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,11 @@ export default function DocumentUploadDialog({

const validateAndSetFile = (file: File) => {
const allowedTypes = ['application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'text/plain', 'text/csv', 'text/markdown'];
const maxSize = 10 * 1024 * 1024; // 10MB

if (!allowedTypes.includes(file.type) && !/\.md$/i.test(file.name)) {
setUploadError('Invalid file type. Supported: PDF, DOCX, TXT, CSV, MD');
return;
}

if (file.size > maxSize) {
setUploadError('File size exceeds 10MB limit');
return;
}

setUploadError('');
setUploadFiles([file]);
};
Expand Down Expand Up @@ -343,7 +336,7 @@ export default function DocumentUploadDialog({
or click to browse
</Typography>
<Typography className="text-sl-text-faint text-xs">
Supported: PDF, DOCX, TXT, CSV (Max 50MB)
Supported: PDF, DOCX, TXT, CSV
</Typography>
<input
id="file-upload-input"
Expand Down
9 changes: 1 addition & 8 deletions src/app/components/file-attacher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
disabled?: boolean;
size?: 'small' | 'medium';
showDragDrop?: boolean;
maxFileSize?: number; // in MB
clearTrigger?: number; // Increment this to trigger clear from parent
allowImages?: boolean; // Accept PNG/JPG — only when a vision model is enabled (backend OCRs them)

Expand All @@ -82,7 +81,6 @@
disabled = false,
size = 'small',
showDragDrop = false,
maxFileSize = 20,
clearTrigger = 0,
allowImages = false,
externalDrop = null,
Expand All @@ -106,7 +104,7 @@
if (externalDrop && handleFileSelectRef.current) {
handleFileSelectRef.current(externalDrop.file);
}
}, [externalDrop?.id]);

Check warning on line 107 in src/app/components/file-attacher.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'externalDrop'. Either include it or remove the dependency array

// Handle external clear trigger
useEffect(() => {
Expand All @@ -116,7 +114,7 @@
setAttachError('');
setIsUploading(false);
}
}, [clearTrigger]);

Check warning on line 117 in src/app/components/file-attacher.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'setIsUploading'. Either include it or remove the dependency array

const validateFile = (file: File): string | null => {
const allowedTypes = [
Expand All @@ -134,17 +132,12 @@
const allowedExtensions = ['.pdf', '.docx', '.txt', '.csv', '.json', '.md', ...(allowImages ? ['.png', '.jpg', '.jpeg'] : [])];
const fileExtension = file.name.toLowerCase().substring(file.name.lastIndexOf('.'));

const maxSizeBytes = maxFileSize * 1024 * 1024;

// Check by MIME type OR by file extension
const isValidType = allowedTypes.includes(file.type) || allowedExtensions.includes(fileExtension);

if (!isValidType) {
return `Invalid file type. Supported: PDF, DOCX, TXT, CSV, JSON${allowImages ? ', PNG, JPG' : ''}`;
}
if (file.size > maxSizeBytes) {
return `File size exceeds ${maxFileSize}MB limit`;
}
return null;
};

Expand Down Expand Up @@ -196,7 +189,7 @@

// Start upload immediately
await uploadFile(file);
}, [maxFileSize, onError]);
}, [onError]);

Check warning on line 192 in src/app/components/file-attacher.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useCallback has missing dependencies: 'uploadFile' and 'validateFile'. Either include them or remove the dependency array

// Keep ref in sync so external drop useEffect can call it
handleFileSelectRef.current = handleFileSelect;
Expand Down
7 changes: 0 additions & 7 deletions src/app/components/right-sidebar/use-project-documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,11 @@ export function useProjectDocuments({ projectId, folderPath }: UseProjectDocumen

const validateFile = (file: File): boolean => {
const allowedTypes = ['application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'text/plain', 'text/markdown'];
const maxSize = 50 * 1024 * 1024; // 50MB

if (!allowedTypes.includes(file.type) && !/\.md$/i.test(file.name)) {
setUploadError('Invalid file type. Supported: PDF, DOCX, TXT, MD');
return false;
}

if (file.size > maxSize) {
setUploadError('File size exceeds 50MB limit');
return false;
}

return true;
};

Expand Down
Loading