fix: enforce file type filtering using tool's acceptedInputs

When registryEntry.accept is undefined, fall back to tool.acceptedInputs
to derive the file filter. This ensures image tools reject audio/video
files in the file picker, and vice versa.
This commit is contained in:
SnapOtter
2026-06-14 23:42:20 +08:00
parent 826f1efc08
commit adfa53246a
+2 -2
View File
@@ -361,13 +361,13 @@ export function ToolPage() {
setMobileSettingsOpen(false);
}, [toolId]);
const toolAccept = registryEntry?.accept;
const toolAccept = registryEntry?.accept ?? tool?.acceptedInputs?.join(",");
const toolAcceptExts = useMemo(
() => toolAccept?.split(",").map((e) => e.trim().replace(/^\./, "").toLowerCase()),
[toolAccept],
);
const toolFileFilter = useMemo(() => {
if (!toolAcceptExts) return undefined;
if (!toolAcceptExts || toolAcceptExts.length === 0) return undefined;
return (file: File) => {
const ext = file.name.split(".").pop()?.toLowerCase() ?? "";
return toolAcceptExts.includes(ext);