Add Sanitize UI (#4123)

# Description of Changes

Implementation of Sanitize UI for V2.

Also removes parameter validation from standard tool hooks because the
logic would have to be duplicated between parameter handling and
operation hooks, and the nicer workflow is for the tools to reject using
the Go button if the validation fails, rather than the operation hook
checking it, since that can't appear in the UI.

Co-authored-by: James <[email protected]>
Co-authored-by: Anthony Stirling <[email protected]>
Co-authored-by: ConnorYoh <[email protected]>
This commit is contained in:
James Brunton
2025-08-12 16:05:59 +01:00
committed by GitHub
co-authored by James Anthony Stirling ConnorYoh
parent adf6feea27
commit 8eeb4c148c
17 changed files with 688 additions and 56 deletions
@@ -9,11 +9,6 @@ import { extractErrorMessage } from '../../../utils/toolErrorHandler';
import { createOperation } from '../../../utils/toolOperationTracker';
import { ResponseHandler } from '../../../utils/toolResponseProcessor';
export interface ValidationResult {
valid: boolean;
errors?: string[];
}
// Re-export for backwards compatibility
export type { ProcessingProgress, ResponseHandler };
@@ -64,9 +59,6 @@ export interface ToolOperationConfig<TParams = void> {
*/
customProcessor?: (params: TParams, files: File[]) => Promise<File[]>;
/** Validate parameters before execution. Return validation errors if invalid. */
validateParams?: (params: TParams) => ValidationResult;
/** Extract user-friendly error messages from API errors */
getErrorMessage?: (error: any) => string;
}
@@ -129,14 +121,6 @@ export const useToolOperation = <TParams = void>(
return;
}
if (config.validateParams) {
const validation = config.validateParams(params);
if (!validation.valid) {
actions.setError(validation.errors?.join(', ') || 'Invalid parameters');
return;
}
}
const validFiles = selectedFiles.filter(file => file.size > 0);
if (validFiles.length === 0) {
actions.setError(t('noValidFiles', 'No valid files to process'));
@@ -186,7 +170,7 @@ export const useToolOperation = <TParams = void>(
// Individual file processing - separate API call per file
const apiCallsConfig: ApiCallsConfig<TParams> = {
endpoint: config.endpoint,
buildFormData: (file: File, params: TParams) => (config.buildFormData as any /* FIX ME */)(file, params),
buildFormData: (file: File, params: TParams) => (config.buildFormData as (params: TParams, file: File) => FormData /* FIX ME */)(params, file),
filePrefix: config.filePrefix,
responseHandler: config.responseHandler
};