fix: type guard for compiler

This commit is contained in:
Dustin Healy 2025-09-07 01:15:27 -07:00
parent 0a61e3cb39
commit 5b38ce8fd9

View file

@ -10,20 +10,20 @@ interface PromptFilesPreviewProps {
const PromptFilesPreview: React.FC<PromptFilesPreviewProps> = ({ toolResources }) => {
const localize = useLocalize();
const { data: allFiles = [] } = useGetFiles();
const { data: allFiles } = useGetFiles();
// Create a fileMap for quick lookup
const fileMap = useMemo(() => {
const map: Record<string, any> = {};
allFiles.forEach((file) => {
if (file.file_id) {
map[file.file_id] = file;
}
});
if (Array.isArray(allFiles)) {
allFiles.forEach((file) => {
if (file.file_id) {
map[file.file_id] = file;
}
});
}
return map;
}, [allFiles]);
// Extract all file IDs from tool resources
const attachedFiles = useMemo(() => {
const files: Array<{ file: any; toolResource: string }> = [];