diff --git a/surfsense_web/components/assistant-ui/document-upload-popup.tsx b/surfsense_web/components/assistant-ui/document-upload-popup.tsx index 4f06588c1..59d73e651 100644 --- a/surfsense_web/components/assistant-ui/document-upload-popup.tsx +++ b/surfsense_web/components/assistant-ui/document-upload-popup.tsx @@ -125,7 +125,7 @@ const DocumentUploadPopupContent: FC<{ onPointerDownOutside={(e) => e.preventDefault()} onInteractOutside={(e) => e.preventDefault()} onEscapeKeyDown={(e) => e.preventDefault()} - className="select-none max-w-2xl w-[95vw] sm:w-[640px] h-[min(460px,75dvh)] sm:h-[min(520px,80vh)] flex flex-col p-0 gap-0 overflow-hidden border border-border ring-0 bg-muted dark:bg-muted text-foreground [&>button]:right-3 sm:[&>button]:right-6 [&>button]:top-3 sm:[&>button]:top-5 [&>button]:opacity-80 hover:[&>button]:opacity-100 [&>button]:z-[100] [&>button_svg]:size-4 sm:[&>button_svg]:size-5" + className="select-none max-w-2xl w-[95vw] sm:w-[640px] h-[min(440px,75dvh)] sm:h-[min(500px,80vh)] flex flex-col p-0 gap-0 overflow-hidden border border-border ring-0 bg-muted dark:bg-muted text-foreground [&>button]:right-3 sm:[&>button]:right-6 [&>button]:top-3 sm:[&>button]:top-5 [&>button]:opacity-80 hover:[&>button]:opacity-100 [&>button]:z-[100] [&>button_svg]:size-4 sm:[&>button_svg]:size-5" > Upload Document diff --git a/surfsense_web/components/sources/DocumentUploadTab.tsx b/surfsense_web/components/sources/DocumentUploadTab.tsx index 940d1560a..dcafe62ba 100644 --- a/surfsense_web/components/sources/DocumentUploadTab.tsx +++ b/surfsense_web/components/sources/DocumentUploadTab.tsx @@ -121,10 +121,6 @@ interface FileWithId { file: File; } -const MAX_FILES = 50; -const MAX_TOTAL_SIZE_MB = 200; -const MAX_TOTAL_SIZE_BYTES = MAX_TOTAL_SIZE_MB * 1024 * 1024; - const MAX_FILE_SIZE_MB = 500; const MAX_FILE_SIZE_BYTES = MAX_FILE_SIZE_MB * 1024 * 1024; @@ -204,7 +200,6 @@ export function DocumentUploadTab({ accept: acceptedFileTypes, maxSize: MAX_FILE_SIZE_BYTES, noClick: isElectron, - disabled: files.length >= MAX_FILES, }); const handleFileInputClick = useCallback((e: React.MouseEvent) => { @@ -224,24 +219,8 @@ export function DocumentUploadTab({ id: crypto.randomUUID?.() ?? `file-${Date.now()}-${Math.random().toString(36)}`, file: new File([fd.data], fd.name, { type: fd.mimeType }), })); - setFiles((prev) => { - const merged = [...prev, ...newFiles]; - if (merged.length > MAX_FILES) { - toast.error(t("max_files_exceeded"), { - description: t("max_files_exceeded_desc", { max: MAX_FILES }), - }); - return prev; - } - const totalSize = merged.reduce((sum, e) => sum + e.file.size, 0); - if (totalSize > MAX_TOTAL_SIZE_BYTES) { - toast.error(t("max_size_exceeded"), { - description: t("max_size_exceeded_desc", { max: MAX_TOTAL_SIZE_MB }), - }); - return prev; - } - return merged; - }); - }, [t]); + setFiles((prev) => [...prev, ...newFiles]); + }, []); const handleBrowseFolder = useCallback(async () => { const api = window.electronAPI; @@ -288,14 +267,6 @@ export function DocumentUploadTab({ const totalFileSize = files.reduce((total, entry) => total + entry.file.size, 0); - const isFileCountLimitReached = files.length >= MAX_FILES; - const isSizeLimitReached = totalFileSize >= MAX_TOTAL_SIZE_BYTES; - const remainingFiles = MAX_FILES - files.length; - const remainingSizeMB = Math.max( - 0, - (MAX_TOTAL_SIZE_BYTES - totalFileSize) / (1024 * 1024) - ).toFixed(1); - const hasContent = files.length > 0 || selectedFolder !== null; const handleAccordionChange = useCallback( @@ -392,8 +363,6 @@ export function DocumentUploadTab({ const renderBrowseButton = (options?: { compact?: boolean; fullWidth?: boolean }) => { const { compact, fullWidth } = options ?? {}; - if (isFileCountLimitReached) return null; - const sizeClass = compact ? "h-7" : "h-8"; const widthClass = fullWidth ? "w-full" : ""; @@ -478,7 +447,6 @@ export function DocumentUploadTab({
{hasContent ? ( !selectedFolder && - !isFileCountLimitReached && (isElectron ? (
{renderBrowseButton({ compact: true, fullWidth: true })}
) : ( @@ -502,12 +470,8 @@ export function DocumentUploadTab({

{isElectron ? "Select files or folder" : "Tap to select files or folder"}

-

- {t("file_size_limit")} - - - {t("upload_limits", { maxFiles: MAX_FILES, maxSizeMB: MAX_TOTAL_SIZE_MB })} - +

+ {t("file_size_limit")}

e.stopPropagation()}> @@ -520,11 +484,7 @@ export function DocumentUploadTab({ {/* DESKTOP DROP ZONE */}
{hasContent ? (
@@ -532,20 +492,10 @@ export function DocumentUploadTab({ {isDragActive ? t("drop_files") - : isFileCountLimitReached - ? t("file_limit_reached") - : t("remaining_capacity", { files: remainingFiles, sizeMB: remainingSizeMB })} + : t("drag_drop_more")} {renderBrowseButton({ compact: true })}
- ) : isFileCountLimitReached ? ( -
- -

{t("file_limit_reached")}

-

- {t("file_limit_reached_desc", { max: MAX_FILES })} -

-
) : isDragActive ? (
@@ -555,12 +505,8 @@ export function DocumentUploadTab({

{t("drag_drop")}

-

- {t("file_size_limit")} - - - {t("upload_limits", { maxFiles: MAX_FILES, maxSizeMB: MAX_TOTAL_SIZE_MB })} - +

+ {t("file_size_limit")}

{renderBrowseButton()}
@@ -632,8 +578,7 @@ export function DocumentUploadTab({

- {t("selected_files", { count: files.length })} ·{" "} - {formatFileSize(totalFileSize)} + {t("selected_files", { count: files.length })}{formatFileSize(totalFileSize)}