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