diff --git a/src/components/AIQueryInterface.astro b/src/components/AIQueryInterface.astro index 2b60021..97b3835 100644 --- a/src/components/AIQueryInterface.astro +++ b/src/components/AIQueryInterface.astro @@ -451,7 +451,6 @@ class AIQueryInterface { this.elements.dismissSuggestions?.addEventListener('click', () => this.hideSmartPrompting()); - // CRITICAL: Setup upload for previous analysis (always available) this.setupPreviousAnalysisUpload(); console.log('[AI Interface] Event listeners setup complete'); @@ -951,7 +950,6 @@ class AIQueryInterface { console.log('[AI Interface] Rendering comprehensive audit trail with', rawAuditTrail.length, 'entries'); try { - // Calculate audit statistics const stats = this.calculateAuditStats(rawAuditTrail); container.innerHTML = ` @@ -1060,7 +1058,6 @@ class AIQueryInterface { } setupUnifiedUploadSystem() { - // Setup the always-available upload (previous analysis) const previousUploadInput = document.getElementById('upload-previous-analysis'); if (previousUploadInput) { previousUploadInput.addEventListener('change', (event) => { @@ -1069,12 +1066,11 @@ class AIQueryInterface { if (file) { this.handlePreviousAnalysisUpload(file); } - event.target.value = ''; // Reset for reuse + event.target.value = ''; }); console.log('[AI Interface] Previous analysis upload setup complete'); } - // Setup download buttons automatically when they appear const setupDownloadBtn = () => { const downloadBtn = document.getElementById('download-results-btn'); if (downloadBtn && !downloadBtn.hasAttribute('data-setup')) { @@ -1084,10 +1080,8 @@ class AIQueryInterface { } }; - // Try to setup immediately (if already present) setupDownloadBtn(); - // Watch for dynamically added download buttons const observer = new MutationObserver(() => { setupDownloadBtn(); }); @@ -1097,7 +1091,6 @@ class AIQueryInterface { subtree: true }); - // Store observer for cleanup this.uploadObserver = observer; console.log('[AI Interface] Unified upload system setup complete'); @@ -1148,7 +1141,6 @@ class AIQueryInterface { } renderPhaseGroups(auditTrail, stats) { - // Group audit entries by phase const phaseGroups = new Map(); auditTrail.forEach(entry => { @@ -1156,7 +1148,6 @@ class AIQueryInterface { if (!phaseGroups.has(phase)) { phaseGroups.set(phase, []); } - // FIXED: Remove non-null assertion, use proper null checking const phaseEntries = phaseGroups.get(phase); if (phaseEntries) { phaseEntries.push(entry); @@ -1221,12 +1212,10 @@ class AIQueryInterface { renderEntryDetails(entry) { const details = []; - // AI-specific details if (entry.action === 'ai-decision' && entry.metadata?.reasoning) { details.push(`
Begründung: ${truncateText(entry.metadata.reasoning, 200)}
`); } - // Tool selection details if (entry.action === 'selection-decision') { if (entry.metadata?.selectedToolsCount && entry.metadata?.availableToolsCount) { details.push(`
Auswahl: ${entry.metadata.selectedToolsCount} von ${entry.metadata.availableToolsCount} Tools
`); @@ -1236,12 +1225,10 @@ class AIQueryInterface { } } - // Embeddings details if (entry.metadata?.embeddingsUsed && entry.metadata?.totalMatches) { details.push(`
Semantische Treffer: ${entry.metadata.totalMatches}
`); } - // Confidence factors if (entry.metadata?.confidenceFactors?.length > 0) { const factors = entry.metadata.confidenceFactors.slice(0, 2).join(', '); details.push(`
Faktoren: ${factors}
`); @@ -1332,12 +1319,10 @@ class AIQueryInterface { const inputValue = this.elements.input ? this.elements.input.value : ''; - // Extract real data from the current recommendation and stored response const processingStats = this.currentRecommendation.processingStats || {}; const aiModel = processingStats.aiModel || 'unknown'; const toolsDataHash = processingStats.toolsDataHash || 'unknown'; - // Get real AI parameters from the processing stats const aiParameters = { maxTokens: processingStats.maxTokensUsed || 0, temperature: processingStats.temperature || 0.3, @@ -1347,7 +1332,6 @@ class AIQueryInterface { embeddingsUsed: processingStats.embeddingsUsed || false }; - // Extract real context data from the recommendation const rawContext = { selectedTools: this.currentRecommendation.recommended_tools?.map(tool => ({ name: tool.name, @@ -1423,23 +1407,18 @@ class AIQueryInterface { try { console.log('[AI Interface] Displaying uploaded results'); - // Show upload banner this.showUploadedBanner(data.metadata); - // Restore interface state this.currentRecommendation = data.recommendation; - // Display the uploaded analysis this.showResults(); - // Update the recommendation display based on mode if (data.metadata.mode === 'workflow') { this.displayWorkflowResults(data.recommendation, data.metadata.userQuery); } else { this.displayToolResults(data.recommendation, data.metadata.userQuery); } - // Render the uploaded audit trail setTimeout(() => { try { this.renderAuditTrail(data.auditTrail); @@ -1487,7 +1466,6 @@ class AIQueryInterface { if (file) { this.handlePreviousAnalysisUpload(file); } - // Reset the input so the same file can be uploaded again event.target.value = ''; }); @@ -1501,7 +1479,6 @@ class AIQueryInterface { console.log('[AI Interface] Handling previous analysis upload:', file.name); try { - // Security validation if (file.size > 10 * 1024 * 1024) { throw new Error('Datei zu groß (max 10MB)'); } @@ -1525,20 +1502,16 @@ class AIQueryInterface { console.log('[AI Interface] Valid previous analysis file uploaded'); - // Hide any existing results or errors this.hideResults(); this.hideError(); this.hideLoading(); - // Display the uploaded analysis this.displayUploadedResults(data); - // Update mode if different if (data.metadata.mode && data.metadata.mode !== this.currentMode) { this.setMode(data.metadata.mode); } - // Optionally restore the query in the input field if (data.metadata.userQuery && this.elements.input) { this.elements.input.value = data.metadata.userQuery; this.updateCharacterCount();