feat: Phase 5 - Visual Workflow Editor (Option B)
Backend (Mini-Backend 1-2h): - Migration 016: ai_prompts.graph_data JSONB column - workflow_executor: graph_data parameter support (backward-compatible) - prompt_executor: execute_workflow_prompt uses graph_data Frontend (Main effort 25-35h): - WorkflowCanvas: React Flow wrapper component - 5 Custom Nodes: Start, End, Analysis, Logic, Join - 4 Config Panels: QuestionAugmentation, LogicExpression, Fallback, Join - workflowValidation: Structural + logical validation - workflowSerializer: Canvas ↔ JSONB conversion - WorkflowEditorPage: Main orchestration (420 LOC) - Route: /workflow-editor/:id - CSS: workflowEditor.css (300 LOC) Architecture: - Option B: ai_prompts.type='workflow' (not separate table) - panels/ subdirectory for clean separation - WorkflowCanvas reusable component - User GUI identical (Workflows = Prompts) - Backward-compatible (type='pipeline' unchanged) Version: v0.9m → v0.9n (Phase 5 complete) Module: workflow 0.5.0 → 0.6.0 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
a7058c30be
commit
dc59596f01
23 files changed
+3010
-48
No files matched your search
@@ -0,0 +1,51 @@
|
||||
import { Handle, Position } from 'reactflow'
|
||||
|
||||
/**
|
||||
* AnalysisNode - KI-Prompt Knoten
|
||||
*
|
||||
* Properties:
|
||||
* - data.label: Node-Label
|
||||
* - data.prompt_id: ID des referenzierten Basis-Prompts
|
||||
* - data.prompt_name: Name des Prompts (optional, für Display)
|
||||
* - data.questions: Array von Question Augmentations
|
||||
* - selected: Boolean
|
||||
*/
|
||||
export function AnalysisNode({ data, selected }) {
|
||||
const hasQuestions = data.questions?.length > 0
|
||||
const promptName = data.prompt_name || (data.prompt_id ? `Prompt #${data.prompt_id}` : 'Kein Prompt')
|
||||
const questionCount = data.questions?.length || 0
|
||||
|
||||
return (
|
||||
<div className={`workflow-node analysis-node ${selected ? 'selected' : ''}`}>
|
||||
<div className="node-header">
|
||||
<div className="node-icon">🤖</div>
|
||||
<div className="node-label">{data.label || 'Analyse'}</div>
|
||||
</div>
|
||||
|
||||
<div className="node-body">
|
||||
<div className="prompt-name" title={promptName}>
|
||||
{promptName}
|
||||
</div>
|
||||
|
||||
{hasQuestions && (
|
||||
<div className="questions-indicator">
|
||||
📋 {questionCount} {questionCount === 1 ? 'Frage' : 'Fragen'}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Handle
|
||||
type="target"
|
||||
position={Position.Top}
|
||||
id="in"
|
||||
style={{ background: 'var(--accent)' }}
|
||||
/>
|
||||
<Handle
|
||||
type="source"
|
||||
position={Position.Bottom}
|
||||
id="out"
|
||||
style={{ background: 'var(--accent)' }}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Handle, Position } from 'reactflow'
|
||||
|
||||
/**
|
||||
* EndNode - Workflow Austritt
|
||||
*
|
||||
* Properties:
|
||||
* - data.label: Node-Label (default: "Ende")
|
||||
* - selected: Boolean (Node ist ausgewählt)
|
||||
*/
|
||||
export function EndNode({ data, selected }) {
|
||||
return (
|
||||
<div className={`workflow-node end-node ${selected ? 'selected' : ''}`}>
|
||||
<div className="node-icon">🏁</div>
|
||||
<div className="node-label">{data.label || 'Ende'}</div>
|
||||
|
||||
{/* Nur Target Handle (kein Source, da Endpunkt) */}
|
||||
<Handle
|
||||
type="target"
|
||||
position={Position.Top}
|
||||
id="in"
|
||||
style={{ background: 'var(--danger)' }}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import { Handle, Position } from 'reactflow'
|
||||
|
||||
/**
|
||||
* JoinNode - Pfad-Konsolidierung
|
||||
*
|
||||
* Properties:
|
||||
* - data.label: Node-Label
|
||||
* - data.join_strategy: 'wait_all' | 'wait_any' | 'best_effort'
|
||||
* - data.skip_handling: 'ignore_skipped' | 'use_placeholder' | 'require_minimum'
|
||||
* - selected: Boolean
|
||||
*/
|
||||
export function JoinNode({ data, selected }) {
|
||||
const strategy = data.join_strategy || 'wait_all'
|
||||
const skipHandling = data.skip_handling || 'ignore_skipped'
|
||||
|
||||
// Strategy Display Names
|
||||
const strategyLabels = {
|
||||
'wait_all': 'Alle warten',
|
||||
'wait_any': 'Beliebig',
|
||||
'best_effort': 'Best Effort'
|
||||
}
|
||||
|
||||
const skipLabels = {
|
||||
'ignore_skipped': 'Ignorieren',
|
||||
'use_placeholder': 'Platzhalter',
|
||||
'require_minimum': 'Minimum'
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`workflow-node join-node ${selected ? 'selected' : ''}`}>
|
||||
<div className="node-header">
|
||||
<div className="node-icon">🔀</div>
|
||||
<div className="node-label">{data.label || 'Join'}</div>
|
||||
</div>
|
||||
|
||||
<div className="node-body">
|
||||
<div className="strategy">
|
||||
<strong>Strategie:</strong> {strategyLabels[strategy] || strategy}
|
||||
</div>
|
||||
<div className="skip-handling">
|
||||
<strong>Skip:</strong> {skipLabels[skipHandling] || skipHandling}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Mehrere Target Handles für eingehende Pfade */}
|
||||
<Handle
|
||||
type="target"
|
||||
position={Position.Top}
|
||||
id="path_1"
|
||||
style={{ left: '25%', background: '#17A2B8' }}
|
||||
/>
|
||||
<Handle
|
||||
type="target"
|
||||
position={Position.Top}
|
||||
id="path_2"
|
||||
style={{ left: '50%', background: '#17A2B8' }}
|
||||
/>
|
||||
<Handle
|
||||
type="target"
|
||||
position={Position.Top}
|
||||
id="path_3"
|
||||
style={{ left: '75%', background: '#17A2B8' }}
|
||||
/>
|
||||
|
||||
{/* Ein Source Handle für konsolidierten Ausgang */}
|
||||
<Handle
|
||||
type="source"
|
||||
position={Position.Bottom}
|
||||
id="out"
|
||||
style={{ background: '#17A2B8' }}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { Handle, Position } from 'reactflow'
|
||||
|
||||
/**
|
||||
* LogicNode - Bedingungs-Knoten (If-Then-Else)
|
||||
*
|
||||
* Properties:
|
||||
* - data.label: Node-Label
|
||||
* - data.condition: Logic Expression Object
|
||||
* - selected: Boolean
|
||||
*/
|
||||
export function LogicNode({ data, selected }) {
|
||||
const hasCondition = !!data.condition && !!data.condition.operator
|
||||
|
||||
// Condition Summary (vereinfacht für Display)
|
||||
const getConditionSummary = () => {
|
||||
if (!hasCondition) return 'Keine Bedingung'
|
||||
|
||||
const op = data.condition.operator?.toUpperCase()
|
||||
const operandCount = data.condition.operands?.length || 0
|
||||
|
||||
if (op === 'AND' || op === 'OR' || op === 'NOT') {
|
||||
return `${op} (${operandCount} Bedingungen)`
|
||||
}
|
||||
|
||||
// Simple condition (ref, operator, value)
|
||||
if (data.condition.ref) {
|
||||
return `${data.condition.ref} ${data.condition.operator} ...`
|
||||
}
|
||||
|
||||
return 'Bedingung definiert'
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`workflow-node logic-node ${selected ? 'selected' : ''}`}>
|
||||
<div className="node-header">
|
||||
<div className="node-icon">⚡</div>
|
||||
<div className="node-label">{data.label || 'Logik'}</div>
|
||||
</div>
|
||||
|
||||
<div className="node-body">
|
||||
<div className={`condition-summary ${hasCondition ? 'has-condition' : 'no-condition'}`}>
|
||||
{getConditionSummary()}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Handle
|
||||
type="target"
|
||||
position={Position.Top}
|
||||
id="in"
|
||||
style={{ background: '#FFC107' }}
|
||||
/>
|
||||
|
||||
{/* Zwei Source Handles für True/False Pfade */}
|
||||
<Handle
|
||||
type="source"
|
||||
position={Position.Bottom}
|
||||
id="true"
|
||||
style={{ left: '33%', background: '#4CAF50' }}
|
||||
/>
|
||||
<Handle
|
||||
type="source"
|
||||
position={Position.Bottom}
|
||||
id="false"
|
||||
style={{ left: '66%', background: '#F44336' }}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Handle, Position } from 'reactflow'
|
||||
|
||||
/**
|
||||
* StartNode - Workflow Einstiegspunkt
|
||||
*
|
||||
* Properties:
|
||||
* - data.label: Node-Label (default: "Start")
|
||||
* - selected: Boolean (Node ist ausgewählt)
|
||||
*/
|
||||
export function StartNode({ data, selected }) {
|
||||
return (
|
||||
<div className={`workflow-node start-node ${selected ? 'selected' : ''}`}>
|
||||
<div className="node-icon">🚀</div>
|
||||
<div className="node-label">{data.label || 'Start'}</div>
|
||||
|
||||
{/* Nur Source Handle (kein Target, da Einstiegspunkt) */}
|
||||
<Handle
|
||||
type="source"
|
||||
position={Position.Bottom}
|
||||
id="out"
|
||||
style={{ background: 'var(--accent)' }}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user