diff --git a/frontend/src/hooks/tools/shared/useBaseTool.ts b/frontend/src/hooks/tools/shared/useBaseTool.ts index 996fae712..56174a73a 100644 --- a/frontend/src/hooks/tools/shared/useBaseTool.ts +++ b/frontend/src/hooks/tools/shared/useBaseTool.ts @@ -1,4 +1,4 @@ -import { useEffect, useCallback } from 'react'; +import { useEffect, useCallback, useRef } from 'react'; import { useFileSelection } from '../../../contexts/FileContext'; import { useEndpointEnabled } from '../../useEndpointConfig'; import { BaseToolProps } from '../../../types/tool'; @@ -45,6 +45,7 @@ export function useBaseTool { + const currentFileCount = selectedFiles.length; + const prevFileCount = previousFileCount.current; + + if (prevFileCount === 0 && currentFileCount > 0) { + params.resetParameters(); + } + + previousFileCount.current = currentFileCount; + }, [selectedFiles.length]); + // Standard handlers const handleExecute = useCallback(async () => { try {