import React, { useState } from "react"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { Label } from "@/components/ui/label"; import { Input } from "@/components/ui/input"; import { Checkbox } from "@/components/ui/checkbox"; import { Separator } from "@/components/ui/separator"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Settings, Zap, RotateCcw } from "lucide-react"; interface PreprocessingOptions { max_char: number | null; topk: number; raw: boolean; hierarchy: boolean; replace: boolean; truncate_enabled: boolean; } interface PreprocessingMethodModalProps { open: boolean; onOpenChange: (open: boolean) => void; onConfirm: (options: PreprocessingOptions) => void; onCancel: () => void; isLoading?: boolean; } export function PreprocessingMethodModal({ open, onOpenChange, onConfirm, onCancel, isLoading = false, }: PreprocessingMethodModalProps) { const [options, setOptions] = useState({ max_char: 1000, topk: 10, raw: false, hierarchy: true, replace: true, truncate_enabled: false, }); const handleConfirm = () => { // Set max_char to null if truncate is disabled const processedOptions = { ...options, max_char: options.truncate_enabled ? options.max_char : null }; onConfirm(processedOptions); }; const handleReset = () => { setOptions({ max_char: 1000, topk: 10, raw: false, hierarchy: true, replace: true, truncate_enabled: false, }); }; const updateOption = ( key: K, value: PreprocessingOptions[K] ) => { setOptions(prev => ({ ...prev, [key]: value })); }; return ( Preprocessing Configuration Configure how traces will be processed before import. Adjust these settings to optimize trace analysis and storage.
Preprocessing Configuration Configure how traces will be processed before import
{/* Keep Raw Data Toggle - Top right */}
updateOption('raw', checked)} disabled={isLoading} />
{options.raw && (
!
⚠️ Raw Data Mode Warning
  • Large file sizes: No compression or truncation applied
  • Unnecessary noise: Metadata and debug info will reduce analysis quality
  • Agent Graph degradation: Unfiltered data may harm knowledge extraction
  • Higher processing costs: Larger files require more resources
Recommended: Use filtering options for better analysis results
)} {/* Show processing options only when raw is false */} {!options.raw && ( <> {/* Compression Options */}

Compression Options

{/* Hierarchical Structure */}
updateOption('hierarchy', checked)} disabled={isLoading} />

Organize runs in parent-child hierarchy instead of flat list

{/* Extract Repeated Variables */}
updateOption('replace', checked)} disabled={isLoading} />

Replace repeated strings with variables to reduce file size

{/* Repeated Variables Count - only when compression is enabled */} {options.replace && (
updateOption('topk', parseInt(e.target.value) || 10)} disabled={isLoading} />

Number of repeated strings to extract as variables for compression (1-50)

)} {/* Enable String Truncation */}
updateOption('truncate_enabled', checked)} disabled={isLoading} />

Limit the length of strings to manage file size and processing costs

{/* Maximum Characters - only when truncation is enabled */} {options.truncate_enabled && (
updateOption('max_char', parseInt(e.target.value) || 1000)} disabled={isLoading} />

Longer text will be truncated to this length to manage processing costs (1000-10000 characters)

)}
)}
); }