feat: add execution overlay types and extend ProcessDiagram with diagramLayout prop
Define the execution overlay type system (NodeExecutionState, IterationInfo, DetailTab) and extend ProcessDiagramProps with optional overlay props. Add diagramLayout prop so ExecutionDiagram can pass a pre-fetched layout by content hash, bypassing the internal route-based fetch in useDiagramData. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useDiagramByRoute } from '../../api/queries/diagrams';
|
||||
import type { DiagramNode, DiagramEdge } from '../../api/queries/diagrams';
|
||||
import type { DiagramNode, DiagramEdge, DiagramLayout } from '../../api/queries/diagrams';
|
||||
import type { DiagramSection } from './types';
|
||||
import { isErrorCompoundType, isCompletionCompoundType } from './node-colors';
|
||||
|
||||
@@ -10,8 +10,14 @@ export function useDiagramData(
|
||||
application: string,
|
||||
routeId: string,
|
||||
direction: 'LR' | 'TB' = 'LR',
|
||||
preloadedLayout?: DiagramLayout,
|
||||
) {
|
||||
const { data: layout, isLoading, error } = useDiagramByRoute(application, routeId, direction);
|
||||
// When a preloaded layout is provided, disable the internal fetch
|
||||
const fetchApp = preloadedLayout ? undefined : application;
|
||||
const fetchRoute = preloadedLayout ? undefined : routeId;
|
||||
const { data: fetchedLayout, isLoading, error } = useDiagramByRoute(fetchApp, fetchRoute, direction);
|
||||
|
||||
const layout = preloadedLayout ?? fetchedLayout;
|
||||
|
||||
const result = useMemo(() => {
|
||||
if (!layout?.nodes) {
|
||||
@@ -106,7 +112,11 @@ export function useDiagramData(
|
||||
return { sections, totalWidth, totalHeight };
|
||||
}, [layout]);
|
||||
|
||||
return { ...result, isLoading, error };
|
||||
return {
|
||||
...result,
|
||||
isLoading: preloadedLayout ? false : isLoading,
|
||||
error: preloadedLayout ? null : error,
|
||||
};
|
||||
}
|
||||
|
||||
/** Shift all node coordinates by subtracting an offset, recursively. */
|
||||
|
||||
Reference in New Issue
Block a user