fix: Part 3 - PlaceholderPicker enhancements (4 critical fixes)
**User Feedback Issues Fixed:** 1. **Registrierte Platzhalter fehlten** ❌ → ✅ - PlaceholderPicker lädt jetzt ~120+ Platzhalter vom Backend - Endpoint: GET /api/prompts/placeholders (get_placeholder_catalog) - Kategorisiert nach: Profil, Körper, Ernährung, Training, etc. - Icons pro Kategorie (👤 💪 🍎 🏃 😴 ❤️ 🎯) 2. **Node-Namen nicht sichtbar** ❌ → ✅ - Vorher: "{{ node_2.analysis_core }}" - Jetzt: "Körper-Analyse (node_2) - Hauptausgabe" - Node-Label wird in Beschreibung angezeigt 3. **Cursor-Position ignoriert** ❌ → ✅ - Platzhalter werden jetzt an Cursor-Position eingefügt - textareaRef von WorkflowEditorPage an EndNodeConfig übergeben - textarea.selectionStart/End für exakte Position - Cursor wird nach Einfügen an korrekte Stelle gesetzt - Focus zurück auf Textarea 4. **Fragen-Kontext unklar** ⚠️ → ✅ - Signal-Platzhalter zeigen jetzt Frage-Text - Format: "Körper-Analyse - Signal: Ist Gewichtstrend positiv?" - Frage wird auf 50 Zeichen gekürzt wenn zu lang **Komponenten-Änderungen:** PlaceholderPicker.jsx: - useEffect zum Laden von Backend-Platzhaltern - Gruppierung nach Kategorien (System + Workflow) - System-Platzhalter: ~120+ aus placeholder_registrations - Workflow-Platzhalter: Node Outputs + Signals - Bessere Beschreibungen mit Node-Label - Stats-Anzeige: "X Platzhalter gefunden (Y Workflow, Z System)" - Loading State während Backend-Call EndNodeConfig.jsx: - useRef für Textarea - textareaRef Prop (optional, Fallback zu lokalem ref) - ref an Textarea gebunden WorkflowEditorPage.jsx: - useRef Hook importiert - endNodeTextareaRef erstellt - handlePlaceholderSelect umgebaut: - Liest selectionStart vom Textarea - Fügt an Cursor-Position ein (before + placeholder + after) - Setzt Cursor nach Platzhalter - Fokussiert Textarea wieder - Fallback: Am Ende einfügen wenn ref nicht verfügbar - textareaRef an EndNodeConfig übergeben **UX-Verbesserungen:** - Suchfunktion durchsucht jetzt auch Kategorie-Namen - Sticky Category Headers beim Scrollen - Example-Werte in Beschreibung (wenn vorhanden) - AutoFocus auf Suchfeld beim Öffnen - Gruppiert: Workflow-Outputs immer oben, dann System-Platzhalter **Testing Required:** - [ ] End Node öffnen → Template Mode → Platzhalter-Button klicken - [ ] Prüfen: ~120+ Platzhalter sichtbar (nicht nur 2-3 Workflow-Outputs) - [ ] Prüfen: Node-Namen in Beschreibungen ("Körper-Analyse (node_2)") - [ ] Cursor an beliebige Stelle setzen → Platzhalter einfügen - [ ] Prüfen: Einfügen an Cursor-Position (nicht am Ende) Part 3 Bugfixes - User Feedback Complete Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
228010a6d3
commit
b779c2f2a8
3 files changed
+236
-86
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useState, useCallback, useEffect } from 'react'
|
||||
import { useState, useCallback, useEffect, useRef } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { useNodesState, useEdgesState, addEdge } from 'reactflow'
|
||||
import { api } from '../utils/api'
|
||||
@@ -50,6 +50,7 @@ export default function WorkflowEditorPage() {
|
||||
const [availablePrompts, setAvailablePrompts] = useState([])
|
||||
const [executionResult, setExecutionResult] = useState(null)
|
||||
const [showPlaceholderPicker, setShowPlaceholderPicker] = useState(false)
|
||||
const endNodeTextareaRef = useRef(null)
|
||||
|
||||
// Load available basis prompts for Analysis nodes
|
||||
useEffect(() => {
|
||||
@@ -263,10 +264,29 @@ export default function WorkflowEditorPage() {
|
||||
const handlePlaceholderSelect = (placeholderString) => {
|
||||
if (!selectedNode || selectedNode.type !== 'end') return
|
||||
|
||||
const textarea = endNodeTextareaRef.current
|
||||
const currentTemplate = selectedNode.data.template || ''
|
||||
const newTemplate = currentTemplate + placeholderString
|
||||
|
||||
handleNodeUpdate(selectedNode.id, { template: newTemplate })
|
||||
// Wenn Textarea Ref verfügbar, an Cursor-Position einfügen
|
||||
if (textarea) {
|
||||
const cursorPos = textarea.selectionStart || currentTemplate.length
|
||||
const before = currentTemplate.substring(0, cursorPos)
|
||||
const after = currentTemplate.substring(cursorPos)
|
||||
const newTemplate = before + placeholderString + after
|
||||
|
||||
handleNodeUpdate(selectedNode.id, { template: newTemplate })
|
||||
|
||||
// Cursor nach eingefügtem Platzhalter positionieren
|
||||
setTimeout(() => {
|
||||
const newPos = cursorPos + placeholderString.length
|
||||
textarea.setSelectionRange(newPos, newPos)
|
||||
textarea.focus()
|
||||
}, 0)
|
||||
} else {
|
||||
// Fallback: Am Ende einfügen
|
||||
const newTemplate = currentTemplate + placeholderString
|
||||
handleNodeUpdate(selectedNode.id, { template: newTemplate })
|
||||
}
|
||||
}
|
||||
|
||||
// ── Render ────────────────────────────────────────────────────────────────
|
||||
@@ -498,6 +518,7 @@ export default function WorkflowEditorPage() {
|
||||
node={selectedNode}
|
||||
onChange={handleNodeUpdate}
|
||||
onOpenPlaceholderPicker={() => setShowPlaceholderPicker(true)}
|
||||
textareaRef={endNodeTextareaRef}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user