Add drag-reorder, validation, and flow-to-tool sync
List View:
- Enable drag-drop reordering of steps
- Show broken dependency warnings when reordering
- Steps with missing variable refs shown in red with tooltip
Validation:
- Parse {variable} references from prompts and code
- Track available variables at each step position
- Warn when steps reference undefined variables
Flow View Sync:
- Deleting nodes in flow view updates the tool model
- steps_deleted signal propagates changes to builder
- Both views stay in sync
Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
@@ -122,6 +122,9 @@ class FlowGraphWidget(QWidget):
|
||||
# Emitted when the flow structure changes
|
||||
flow_changed = Signal()
|
||||
|
||||
# Emitted when steps are deleted from flow view (list of step indices)
|
||||
steps_deleted = Signal(list)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self._tool: Optional[Tool] = None
|
||||
@@ -149,6 +152,7 @@ class FlowGraphWidget(QWidget):
|
||||
|
||||
# Connect signals
|
||||
self._graph.node_double_clicked.connect(self._on_node_double_clicked)
|
||||
self._graph.nodes_deleted.connect(self._on_nodes_deleted)
|
||||
|
||||
# Add graph widget
|
||||
layout.addWidget(self._graph.widget, 1)
|
||||
@@ -409,6 +413,20 @@ class FlowGraphWidget(QWidget):
|
||||
step_type = 'prompt' if isinstance(node, PromptNode) else 'code'
|
||||
self.node_double_clicked.emit(node._step_index, step_type)
|
||||
|
||||
def _on_nodes_deleted(self, nodes):
|
||||
"""Handle node deletion from the graph."""
|
||||
# Collect step indices of deleted step nodes (not Input/Output nodes)
|
||||
deleted_indices = []
|
||||
for node in nodes:
|
||||
if hasattr(node, '_step_index') and node._step_index >= 0:
|
||||
deleted_indices.append(node._step_index)
|
||||
|
||||
if deleted_indices:
|
||||
# Sort in reverse order so we delete from end first
|
||||
deleted_indices.sort(reverse=True)
|
||||
self.steps_deleted.emit(deleted_indices)
|
||||
self.flow_changed.emit()
|
||||
|
||||
def refresh(self):
|
||||
"""Refresh the graph from current tool data."""
|
||||
self._rebuild_graph()
|
||||
|
||||
Reference in New Issue
Block a user