This commit is contained in:
overcuriousity
2025-07-26 22:27:29 +02:00
parent 3eb1b9d8d7
commit 69aa19642c
3 changed files with 46 additions and 78 deletions

View File

@@ -66,7 +66,7 @@ const domainAgnosticSoftware = data['domain-agnostic-software'] || [];
</div>
<div id="suggested-questions" class="suggested-questions" style="display: none;">
<p style="margin: 0 0 0.75rem 0; font-size: 0.875rem; color: var(--color-text-secondary); line-height: 1.5;">
Zur besseren Analyse Ihres Szenarios könnten diese Informationen hilfreich sein:
Zur besseren Analyse könnten diese Zusatzinformationen hilfreich sein:
</p>
<div id="questions-list"></div>
<div style="margin-top: 1rem; text-align: right;">
@@ -200,7 +200,6 @@ document.addEventListener('DOMContentLoaded', () => {
// Smart prompting state
let enhancementTimeout;
let enhancementAbortController;
let suggestionsVisible = false;
if (!aiInput || !aiSubmitBtn || !aiLoading || !aiError || !aiResults) {
console.error('AI interface elements not found');
@@ -259,7 +258,7 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
// Smart Prompting Functions
// Smart Prompting Functions - Simplified
function showPromptingStatus(state) {
if (!smartPromptingContainer || !promptingStatus || !promptingSpinner) return;
@@ -269,33 +268,26 @@ document.addEventListener('DOMContentLoaded', () => {
promptingStatus.textContent = '💡 KI analysiert Ihre Eingabe...';
promptingSpinner.style.display = 'inline-block';
suggestedQuestions.style.display = 'none';
suggestionsVisible = false;
break;
case 'suggestions':
promptingStatus.textContent = '✅ Verbesserungsvorschläge verfügbar';
promptingSpinner.style.display = 'none';
suggestedQuestions.style.display = 'block';
suggestionsVisible = true;
break;
case 'rate-limited':
promptingStatus.textContent = '⏸️ Verbesserungen verfügbar nach Hauptabfrage';
promptingStatus.textContent = '⏸️ Verbesserungen nach Hauptabfrage verfügbar';
promptingSpinner.style.display = 'none';
suggestedQuestions.style.display = 'none';
suggestionsVisible = false;
break;
case 'error':
promptingStatus.textContent = '⚠️ Verbesserungen temporär nicht verfügbar';
promptingSpinner.style.display = 'none';
suggestedQuestions.style.display = 'none';
suggestionsVisible = false;
smartPromptingContainer.style.display = 'none'; // Just hide on error
break;
case 'hidden':
smartPromptingContainer.style.display = 'none';
suggestionsVisible = false;
break;
}
}
function displaySuggestions(suggestions) {
if (!questionsList || !suggestions || suggestions.length === 0) return;
@@ -306,37 +298,17 @@ document.addEventListener('DOMContentLoaded', () => {
questionElement.className = 'suggestion-item';
questionElement.innerHTML = `
<div style="display: flex; align-items: start; gap: 0.5rem;">
<span class="suggestion-number">${index + 1}.</span>
<span class="suggestion-text">${question}</span>
<svg class="suggestion-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="12" y1="5" x2="12" y2="19"/>
<line x1="5" y1="12" x2="19" y2="12"/>
</svg>
</div>
<span class="suggestion-number">${index + 1}.</span>
${question}
`;
questionElement.addEventListener('click', () => {
const currentText = aiInput.value.trim();
const newText = currentText ? `${currentText}\n\n${question}` : question;
aiInput.value = newText;
aiInput.focus();
// Trigger input event to update character counter
aiInput.dispatchEvent(new Event('input', { bubbles: true }));
// Hide suggestions after adding
showPromptingStatus('hidden');
});
questionsList.appendChild(questionElement);
});
showPromptingStatus('suggestions');
}
async function triggerSmartPrompting() {
console.log('[DEBUG] triggerSmartPrompting function defined');
const inputText = aiInput.value.trim();
if (inputText.length < 50) {
@@ -367,7 +339,6 @@ document.addEventListener('DOMContentLoaded', () => {
});
const data = await response.json();
console.log('[DEBUG AIQuery]Enhancement response:', data);
if (!response.ok) {
if (response.status === 429) {
@@ -391,13 +362,6 @@ document.addEventListener('DOMContentLoaded', () => {
console.warn('Smart prompting failed:', error);
showPromptingStatus('error');
// Auto-hide error after 3 seconds
setTimeout(() => {
if (promptingStatus && promptingStatus.textContent.includes('nicht verfügbar')) {
showPromptingStatus('hidden');
}
}, 3000);
}
}