validate and filter in one place + fix copy

This commit is contained in:
phact 2025-11-24 09:58:14 -05:00
parent aa0be423fa
commit 9cee47071e
2 changed files with 32 additions and 30 deletions

View file

@ -43,6 +43,33 @@ import {
} from "@/lib/upload-utils";
import { cn } from "@/lib/utils";
// Supported file extensions - single source of truth
const SUPPORTED_EXTENSIONS = [
".pdf",
".doc",
".docx",
".pptx",
".ppt",
".xlsx",
".xls",
".csv",
".txt",
".md",
".html",
".htm",
".rtf",
".odt",
".asciidoc",
".adoc",
".png",
".jpg",
".jpeg",
".gif",
".bmp",
".tiff",
".webp",
];
export function KnowledgeDropdown() {
const { addTask } = useTask();
const { refetch: refetchTasks } = useGetTasksQuery();
@ -247,43 +274,18 @@ export function KnowledgeDropdown() {
try {
const fileList = Array.from(files);
const supportedExtensions = [
".pdf",
".doc",
".docx",
".pptx",
".ppt",
".xlsx",
".xls",
".csv",
".txt",
".md",
".html",
".htm",
".rtf",
".odt",
".asciidoc",
".adoc",
".png",
".jpg",
".jpeg",
".gif",
".bmp",
".tiff",
".webp",
];
const filteredFiles = fileList.filter((file) => {
const ext = file.name
.substring(file.name.lastIndexOf("."))
.toLowerCase();
return supportedExtensions.includes(ext);
return SUPPORTED_EXTENSIONS.includes(ext);
});
if (filteredFiles.length === 0) {
toast.error("No supported files found", {
description:
"Please select a folder containing PDF, DOC, DOCX, TXT, MD, RTF, or ODT files.",
"Please select a folder containing supported document files (PDF, DOCX, PPTX, XLSX, CSV, HTML, images, etc.).",
});
return;
}
@ -543,7 +545,7 @@ export function KnowledgeDropdown() {
type="file"
onChange={handleFileChange}
className="hidden"
accept=".pdf,.doc,.docx,.txt,.md,.rtf,.odt"
accept={SUPPORTED_EXTENSIONS.join(",")}
/>
<input

4
uv.lock generated
View file

@ -1,5 +1,5 @@
version = 1
revision = 2
revision = 3
requires-python = ">=3.13"
resolution-markers = [
"platform_machine == 'x86_64' and sys_platform == 'linux'",
@ -2352,7 +2352,7 @@ wheels = [
[[package]]
name = "openrag"
version = "0.1.35"
version = "0.1.37"
source = { editable = "." }
dependencies = [
{ name = "agentd" },