feat: Jump to Error centers the failed node in the viewport
Added centerOnNodeId prop to ProcessDiagram. When set, the diagram pans to center the specified node in the viewport. Jump to Error now selects the failed processor AND centers the viewport on it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -80,8 +80,9 @@ export function ExecutionDiagram({
|
||||
// 4. Compute overlay
|
||||
const overlay = useExecutionOverlay(detail?.processors, iterationState);
|
||||
|
||||
// 5. Manage selection
|
||||
// 5. Manage selection + center-on-node
|
||||
const [selectedProcessorId, setSelectedProcessorId] = useState<string>('');
|
||||
const [centerOnNodeId, setCenterOnNodeId] = useState<string>('');
|
||||
|
||||
// 6. Resizable splitter state
|
||||
const [splitPercent, setSplitPercent] = useState(60);
|
||||
@@ -105,12 +106,15 @@ export function ExecutionDiagram({
|
||||
document.addEventListener('pointerup', onUp);
|
||||
}, []);
|
||||
|
||||
// Jump to error: find first FAILED processor and select it
|
||||
// Jump to error: find first FAILED processor, select it, and center the viewport
|
||||
const handleJumpToError = useCallback(() => {
|
||||
if (!detail?.processors) return;
|
||||
const failed = findFailedProcessor(detail.processors);
|
||||
if (failed?.processorId) {
|
||||
setSelectedProcessorId(failed.processorId);
|
||||
// Use a unique value to re-trigger centering even if the same node
|
||||
setCenterOnNodeId('');
|
||||
requestAnimationFrame(() => setCenterOnNodeId(failed.processorId));
|
||||
}
|
||||
}, [detail?.processors]);
|
||||
|
||||
@@ -187,6 +191,7 @@ export function ExecutionDiagram({
|
||||
executionOverlay={overlay}
|
||||
iterationState={iterationState}
|
||||
onIterationChange={setIteration}
|
||||
centerOnNodeId={centerOnNodeId}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user