feat: export all placeholders from debug viewer (Issue #28 Debug A)
Added "📋 Platzhalter exportieren" button in debug viewer:
- Exports all resolved placeholders with values
- Includes all available_variables
- For pipelines: exports per-stage placeholder data
- JSON format with timestamp and prompt metadata
- Filename: placeholders-{slug}-{date}.json
Use case: Development aid - see exactly what data is available
for prompt templates without null values.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
97e57481f9
commit
8b287ca6c9
|
|
@ -308,6 +308,58 @@ export default function UnifiedPromptModal({ prompt, onSave, onClose }) {
|
|||
}
|
||||
}
|
||||
|
||||
const handleExportPlaceholders = () => {
|
||||
if (!testResult) return
|
||||
|
||||
// Extract all placeholder data from test result
|
||||
const debug = testResult.debug || testResult
|
||||
const exportData = {
|
||||
export_date: new Date().toISOString(),
|
||||
prompt_slug: prompt?.slug || 'unknown',
|
||||
prompt_name: name || 'Unnamed Prompt',
|
||||
placeholders: {}
|
||||
}
|
||||
|
||||
// For pipeline prompts, collect from all stages
|
||||
if (debug.stages && Array.isArray(debug.stages)) {
|
||||
debug.stages.forEach(stage => {
|
||||
exportData.placeholders[`stage_${stage.stage}`] = {
|
||||
available_variables: stage.available_variables || [],
|
||||
prompts: stage.prompts?.map(p => ({
|
||||
source: p.source,
|
||||
resolved: p.resolved_placeholders || p.ref_debug?.resolved_placeholders || {},
|
||||
unresolved: p.unresolved_placeholders || p.ref_debug?.unresolved_placeholders || []
|
||||
})) || []
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// For base prompts or direct execution
|
||||
if (debug.resolved_placeholders) {
|
||||
exportData.placeholders.resolved = debug.resolved_placeholders
|
||||
}
|
||||
if (debug.unresolved_placeholders) {
|
||||
exportData.placeholders.unresolved = debug.unresolved_placeholders
|
||||
}
|
||||
if (debug.available_variables) {
|
||||
exportData.available_variables = debug.available_variables
|
||||
}
|
||||
if (debug.initial_variables) {
|
||||
exportData.initial_variables = debug.initial_variables
|
||||
}
|
||||
|
||||
// Download as JSON
|
||||
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 = `placeholders-${prompt?.slug || 'test'}-${new Date().toISOString().split('T')[0]}.json`
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.5)',
|
||||
|
|
@ -662,6 +714,20 @@ export default function UnifiedPromptModal({ prompt, onSave, onClose }) {
|
|||
<h3 style={{ margin: 0, fontSize: 14, fontWeight: 600 }}>
|
||||
🔬 Debug-Info
|
||||
</h3>
|
||||
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
||||
<button
|
||||
className="btn"
|
||||
onClick={handleExportPlaceholders}
|
||||
style={{
|
||||
padding: '4px 8px',
|
||||
fontSize: 11,
|
||||
background: 'var(--accent)',
|
||||
color: 'white'
|
||||
}}
|
||||
title="Exportiere alle Platzhalter mit Werten als JSON"
|
||||
>
|
||||
📋 Platzhalter exportieren
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setShowDebug(false)}
|
||||
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: 4 }}
|
||||
|
|
@ -669,6 +735,7 @@ export default function UnifiedPromptModal({ prompt, onSave, onClose }) {
|
|||
<X size={16} color="var(--text3)" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<pre style={{
|
||||
fontSize: 11,
|
||||
fontFamily: 'monospace',
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user