fix: show debug info on errors + prompt export function
- Frontend: debug viewer now shows even when test fails - Frontend: export button to download complete prompt config as JSON - Backend: attach debug info to JSON validation errors - Backend: include raw output and length in error details Users can now debug failed prompts and export configs for analysis. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
7f2ba4fbad
commit
84dad07e15
2 files changed
+74
-7
No files matched your search
@@ -236,6 +236,33 @@ export default function UnifiedPromptModal({ prompt, onSave, onClose }) {
|
||||
}
|
||||
}
|
||||
|
||||
const handleExport = () => {
|
||||
// Export complete prompt configuration as JSON
|
||||
const exportData = {
|
||||
name,
|
||||
slug,
|
||||
display_name: displayName,
|
||||
description,
|
||||
type,
|
||||
category,
|
||||
active,
|
||||
sort_order: sortOrder,
|
||||
output_format: outputFormat,
|
||||
template: type === 'base' ? template : null,
|
||||
stages: type === 'pipeline' ? stages : null
|
||||
}
|
||||
|
||||
const blob = new Blob([JSON.stringify(exportData, null, 2)], { type: 'application/json' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = `prompt-${slug || 'new'}-${new Date().toISOString().split('T')[0]}.json`
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
const handleTest = async () => {
|
||||
// Can only test existing prompts (need slug in database)
|
||||
if (!prompt?.slug) {
|
||||
@@ -252,7 +279,30 @@ export default function UnifiedPromptModal({ prompt, onSave, onClose }) {
|
||||
setTestResult(result)
|
||||
setShowDebug(true)
|
||||
} catch (e) {
|
||||
setError('Test-Fehler: ' + e.message)
|
||||
// Show error AND try to extract debug info from error
|
||||
const errorMsg = e.message
|
||||
let debugData = null
|
||||
|
||||
// Try to parse error message for embedded debug info
|
||||
try {
|
||||
const parsed = JSON.parse(errorMsg)
|
||||
if (parsed.detail) {
|
||||
setError('Test-Fehler: ' + parsed.detail)
|
||||
debugData = parsed
|
||||
} else {
|
||||
setError('Test-Fehler: ' + errorMsg)
|
||||
}
|
||||
} catch {
|
||||
setError('Test-Fehler: ' + errorMsg)
|
||||
}
|
||||
|
||||
// Set result with error info so debug viewer shows it
|
||||
setTestResult({
|
||||
error: true,
|
||||
error_message: errorMsg,
|
||||
debug: debugData || { error: errorMsg }
|
||||
})
|
||||
setShowDebug(true) // ALWAYS show debug on test, even on error
|
||||
} finally {
|
||||
setTesting(false)
|
||||
}
|
||||
@@ -640,7 +690,7 @@ export default function UnifiedPromptModal({ prompt, onSave, onClose }) {
|
||||
display: 'flex', gap: 12, justifyContent: 'space-between',
|
||||
paddingTop: 16, borderTop: '1px solid var(--border)'
|
||||
}}>
|
||||
<div>
|
||||
<div style={{ display: 'flex', gap: 8 }}>
|
||||
{prompt?.slug && (
|
||||
<button
|
||||
className="btn"
|
||||
@@ -654,6 +704,14 @@ export default function UnifiedPromptModal({ prompt, onSave, onClose }) {
|
||||
{testing ? '🔬 Teste...' : '🔬 Test ausführen'}
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className="btn"
|
||||
onClick={handleExport}
|
||||
disabled={loading}
|
||||
title="Exportiere Prompt-Konfiguration als JSON"
|
||||
>
|
||||
📥 Export
|
||||
</button>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 12 }}>
|
||||
<button className="btn" onClick={onClose}>
|
||||
|
||||
Reference in new issue
Block a user