@principal-ai/subsystems-react 0.56.34 → 0.56.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/subsystem/SubsystemComponentGraph.d.ts +62 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +175 -32
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/TrailStepsNav.d.ts +3 -1
- package/dist/subsystem/TrailStepsNav.d.ts.map +1 -1
- package/dist/subsystem/TrailStepsNav.js +13 -4
- package/dist/subsystem/TrailStepsNav.js.map +1 -1
- package/dist/subsystem/TrailsPanel.d.ts +18 -2
- package/dist/subsystem/TrailsPanel.d.ts.map +1 -1
- package/dist/subsystem/TrailsPanel.js +57 -15
- package/dist/subsystem/TrailsPanel.js.map +1 -1
- package/dist/subsystem/model.d.ts +6 -0
- package/dist/subsystem/model.d.ts.map +1 -1
- package/dist/subsystem/model.js.map +1 -1
- package/dist/subsystem/nodes.d.ts.map +1 -1
- package/dist/subsystem/nodes.js +101 -19
- package/dist/subsystem/nodes.js.map +1 -1
- package/package.json +1 -1
- package/src/stories/Canvases/Subsystem/AgentDrivenWalkthrough.stories.tsx +2007 -0
- package/src/stories/Canvases/Subsystem/NodeIconography.stories.tsx +190 -0
- package/src/subsystem/SubsystemComponentGraph.tsx +273 -31
- package/src/subsystem/TrailStepsNav.tsx +15 -3
- package/src/subsystem/TrailsPanel.tsx +137 -9
- package/src/subsystem/model.ts +6 -0
- package/src/subsystem/nodes.tsx +143 -18
|
@@ -21,7 +21,9 @@ import {
|
|
|
21
21
|
ReactFlow,
|
|
22
22
|
ReactFlowProvider,
|
|
23
23
|
useReactFlow,
|
|
24
|
+
useStore,
|
|
24
25
|
useViewport,
|
|
26
|
+
getViewportForBounds,
|
|
25
27
|
type NodeTypes,
|
|
26
28
|
type EdgeTypes,
|
|
27
29
|
type Node,
|
|
@@ -103,7 +105,12 @@ import { ShareButton } from './ShareButton';
|
|
|
103
105
|
import { DescriptionOverlay } from './DescriptionOverlay';
|
|
104
106
|
import { DescriptionPreview } from './DescriptionPreview';
|
|
105
107
|
import type { GraphSidebarTab } from './GraphSidebar';
|
|
106
|
-
import {
|
|
108
|
+
import {
|
|
109
|
+
TrailsPanel,
|
|
110
|
+
TRAIL_PLAY_PAUSE_MS,
|
|
111
|
+
TRAIL_HOVER_PREVIEW_MS,
|
|
112
|
+
type TrailsStepChange,
|
|
113
|
+
} from './TrailsPanel';
|
|
107
114
|
import type { StepEmphasisMap } from './stepEmphasis';
|
|
108
115
|
import {
|
|
109
116
|
EDGE_LABEL_WIDTH,
|
|
@@ -335,6 +342,56 @@ export interface SubsystemComponentGraphProps {
|
|
|
335
342
|
* trail.
|
|
336
343
|
*/
|
|
337
344
|
onTrailSelect?: (ref: { trailId: string; stepIndices?: number[] } | null) => void;
|
|
345
|
+
/**
|
|
346
|
+
* PROTOTYPE: host-controlled trail focus. Changing this expands the trail
|
|
347
|
+
* and drives the camera. With a `stepIndex`, it focuses that step's edge;
|
|
348
|
+
* without one, it frames the whole trail. `showFile` controls whether the
|
|
349
|
+
* step's file/trail drawer opens — omit it for whole-trail focus, or set it
|
|
350
|
+
* to `false` to select a step without showing its file.
|
|
351
|
+
*
|
|
352
|
+
* `undefined` leaves in-graph focus untouched; `null` clears host control.
|
|
353
|
+
*/
|
|
354
|
+
focusedTrailStep?: {
|
|
355
|
+
trailId: string;
|
|
356
|
+
stepIndex?: number;
|
|
357
|
+
showFile?: boolean;
|
|
358
|
+
} | null;
|
|
359
|
+
/**
|
|
360
|
+
* PROTOTYPE: host-local ids of trails awaiting confirmation. Their Trails
|
|
361
|
+
* panel icon uses the proposal color instead of labelling the title.
|
|
362
|
+
*/
|
|
363
|
+
proposedTrailIds?: Set<string>;
|
|
364
|
+
/**
|
|
365
|
+
* PROTOTYPE: host-local ids of steps awaiting confirmation, keyed by
|
|
366
|
+
* `emphasisKey(trailId, step)`. Their Trails panel text uses proposal color.
|
|
367
|
+
*/
|
|
368
|
+
proposedStepKeys?: Set<string>;
|
|
369
|
+
/**
|
|
370
|
+
* PROTOTYPE: host-local before/after view for an accepted step replacement.
|
|
371
|
+
* The previous step stays out of the trails array; the panel renders it as a
|
|
372
|
+
* ghost beneath the committed step.
|
|
373
|
+
*/
|
|
374
|
+
stepChange?: TrailsStepChange | null;
|
|
375
|
+
/** Whether the previous-state ghost is visible. @default true */
|
|
376
|
+
showPreviousStep?: boolean;
|
|
377
|
+
/** Dismiss or restore just the previous-state ghost. */
|
|
378
|
+
onTogglePreviousStep?: () => void;
|
|
379
|
+
/**
|
|
380
|
+
* PROTOTYPE: host-local component aliases awaiting confirmation. Their boxes
|
|
381
|
+
* use the proposal border, name colour and `PROPOSED` badge.
|
|
382
|
+
*/
|
|
383
|
+
proposedComponentAliases?: Set<string>;
|
|
384
|
+
/**
|
|
385
|
+
* PROTOTYPE: host-local component aliases the agent is currently working on.
|
|
386
|
+
* Their boxes get a static ring and a sparkling WandSparkles icon.
|
|
387
|
+
*/
|
|
388
|
+
workingComponentAliases?: Set<string>;
|
|
389
|
+
/**
|
|
390
|
+
* PROTOTYPE: host-local component aliases removed from the model. Their
|
|
391
|
+
* nodes stay in the layout, dimmed and `REMOVED`-badged, so the change is
|
|
392
|
+
* legible instead of silently disappearing.
|
|
393
|
+
*/
|
|
394
|
+
removedComponentAliases?: Set<string>;
|
|
338
395
|
/**
|
|
339
396
|
* Reports which trail step is currently hovered in the Trails panel —
|
|
340
397
|
* the transient preview mirror of `onTrailSelect`. `null` when nothing is
|
|
@@ -404,6 +461,11 @@ export interface SubsystemComponentGraphProps {
|
|
|
404
461
|
* subsystem name visible as an overlay on the canvas.
|
|
405
462
|
*/
|
|
406
463
|
hideSidebar?: boolean;
|
|
464
|
+
/**
|
|
465
|
+
* Suppress only the standard full-width header (title + sidebar-view switch)
|
|
466
|
+
* while keeping the sidebar and canvas. Hosts can render their own header.
|
|
467
|
+
*/
|
|
468
|
+
hideHeader?: boolean;
|
|
407
469
|
/**
|
|
408
470
|
* How trail step highlighting behaves on the canvas.
|
|
409
471
|
* - `focus` (default): zoom to the step, hide non-participants, open drawer
|
|
@@ -435,6 +497,12 @@ export interface SubsystemComponentGraphProps {
|
|
|
435
497
|
* @default 300
|
|
436
498
|
*/
|
|
437
499
|
trailFocusDurationMs?: number;
|
|
500
|
+
/**
|
|
501
|
+
* Downward screen-pixel offset applied when the camera frames the graph or
|
|
502
|
+
* a focused trail step. Useful for hosts with chrome over the canvas top.
|
|
503
|
+
* @default 0
|
|
504
|
+
*/
|
|
505
|
+
focusVerticalBiasPx?: number;
|
|
438
506
|
/**
|
|
439
507
|
* Subsystem title rendered as a non-interactive overlay chip on the graph
|
|
440
508
|
* canvas (top-center). Does not trigger the sidebar — for graph-only
|
|
@@ -749,9 +817,13 @@ interface InnerProps extends SubsystemComponentGraphProps {
|
|
|
749
817
|
onSidebarTrailChange: (trailId: string | null) => void;
|
|
750
818
|
}
|
|
751
819
|
|
|
752
|
-
function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirection: layoutDirectionProp, defaultLayoutDirection = 'horizontal', onLayoutDirectionChange, hideLayoutToggle = false, refocusOnLayoutFlip = true, initialTrailId, onTrailSelect, onTrailStepHover, onReorderTrails, stepEmphasis, onRemoveStepEmphasis, onSelect, onEdgeSelect, measured: _measured, maxNodeWidth, showEdgeLabels, showSingletonFrames = true, moduleNesting, edgeView, hideSidebar, trailStepMode = 'focus', autoPlayTrails = false, trailAutoPlayIntervalMs = TRAIL_PLAY_PAUSE_MS, onAutoPlayStep, zoomOnTrailFocus = true, trailFocusDurationMs = 300, graphTitle, showTrailTitle = false, description, notes, canvasOverlay, interactive = true, canvasBackground = 'theme', onLayoutReady, onNodeRects, sidebarExtra, sidebarAfterDescription, issues, showIssues, filesActive, sidebarScope, onSidebarTrailChange, focusIssueCategory, laneStatus, onSelectIssue, onApplyIssueFix, onHoverIssue, renderFileViewer, renderTrailViewer, onFileSelect, componentVerification, onInspectSymbol, boundaryColors, codeProcessKeys, regionDetails, defaultFramesCollapsed, containersActive, hideDrawer = false, persistKey, liveEvents, agentsPanel }: InnerProps) {
|
|
820
|
+
function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirection: layoutDirectionProp, defaultLayoutDirection = 'horizontal', onLayoutDirectionChange, hideLayoutToggle = false, refocusOnLayoutFlip = true, initialTrailId, onTrailSelect, focusedTrailStep, proposedTrailIds, proposedStepKeys, stepChange, showPreviousStep, onTogglePreviousStep, proposedComponentAliases, workingComponentAliases, removedComponentAliases, onTrailStepHover, onReorderTrails, stepEmphasis, onRemoveStepEmphasis, onSelect, onEdgeSelect, measured: _measured, maxNodeWidth, showEdgeLabels, showSingletonFrames = true, moduleNesting, edgeView, hideSidebar, trailStepMode = 'focus', autoPlayTrails = false, trailAutoPlayIntervalMs = TRAIL_PLAY_PAUSE_MS, onAutoPlayStep, zoomOnTrailFocus = true, trailFocusDurationMs = 300, focusVerticalBiasPx = 0, graphTitle, showTrailTitle = false, description, notes, canvasOverlay, interactive = true, canvasBackground = 'theme', onLayoutReady, onNodeRects, sidebarExtra, sidebarAfterDescription, issues, showIssues, filesActive, sidebarScope, onSidebarTrailChange, focusIssueCategory, laneStatus, onSelectIssue, onApplyIssueFix, onHoverIssue, renderFileViewer, renderTrailViewer, onFileSelect, componentVerification, onInspectSymbol, boundaryColors, codeProcessKeys, regionDetails, defaultFramesCollapsed, containersActive, hideDrawer = false, persistKey, liveEvents, agentsPanel }: InnerProps) {
|
|
753
821
|
const { theme } = useTheme();
|
|
754
|
-
const { fitView, fitBounds } = useReactFlow();
|
|
822
|
+
const { fitView, fitBounds, setViewport } = useReactFlow();
|
|
823
|
+
const flowWidth = useStore((state) => state.width);
|
|
824
|
+
const flowHeight = useStore((state) => state.height);
|
|
825
|
+
const minZoom = useStore((state) => state.minZoom);
|
|
826
|
+
const maxZoom = useStore((state) => state.maxZoom);
|
|
755
827
|
const [descriptionOpen, setDescriptionOpen] = useState(false);
|
|
756
828
|
const rawDescription = description?.trim();
|
|
757
829
|
// The host caps the authored description; trim defensively for other hosts.
|
|
@@ -781,6 +853,47 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
781
853
|
edges: [],
|
|
782
854
|
absoluteRects: new Map(),
|
|
783
855
|
});
|
|
856
|
+
|
|
857
|
+
// React Flow's `fitBounds` always centres the bounds. A host may need the
|
|
858
|
+
// diagram deliberately lower (e.g. to leave room for status chrome over the
|
|
859
|
+
// canvas), so recompute the same viewport and shift only its screen-space y.
|
|
860
|
+
const fitBoundsWithBias = useCallback(
|
|
861
|
+
(
|
|
862
|
+
bounds: { x: number; y: number; width: number; height: number },
|
|
863
|
+
options: { padding: number; duration?: number },
|
|
864
|
+
) => {
|
|
865
|
+
if (
|
|
866
|
+
!focusVerticalBiasPx ||
|
|
867
|
+
flowWidth <= 0 ||
|
|
868
|
+
flowHeight <= 0
|
|
869
|
+
) {
|
|
870
|
+
void fitBounds(bounds, options);
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
const viewport = getViewportForBounds(
|
|
874
|
+
bounds,
|
|
875
|
+
flowWidth,
|
|
876
|
+
flowHeight,
|
|
877
|
+
minZoom,
|
|
878
|
+
maxZoom,
|
|
879
|
+
options.padding,
|
|
880
|
+
);
|
|
881
|
+
void setViewport(
|
|
882
|
+
{ ...viewport, y: viewport.y + focusVerticalBiasPx },
|
|
883
|
+
{ duration: options.duration },
|
|
884
|
+
);
|
|
885
|
+
},
|
|
886
|
+
[
|
|
887
|
+
fitBounds,
|
|
888
|
+
setViewport,
|
|
889
|
+
flowWidth,
|
|
890
|
+
flowHeight,
|
|
891
|
+
minZoom,
|
|
892
|
+
maxZoom,
|
|
893
|
+
focusVerticalBiasPx,
|
|
894
|
+
],
|
|
895
|
+
);
|
|
896
|
+
|
|
784
897
|
const fitGraphContents = useCallback(
|
|
785
898
|
(duration = 300) => {
|
|
786
899
|
const edges = built.edges.map((edge) => {
|
|
@@ -814,9 +927,9 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
814
927
|
});
|
|
815
928
|
return;
|
|
816
929
|
}
|
|
817
|
-
|
|
930
|
+
fitBoundsWithBias(bounds, { padding: 0.1, duration });
|
|
818
931
|
},
|
|
819
|
-
[built.absoluteRects, built.edges,
|
|
932
|
+
[built.absoluteRects, built.edges, fitBoundsWithBias, fitView],
|
|
820
933
|
);
|
|
821
934
|
const [layoutReady, setLayoutReady] = useState(false);
|
|
822
935
|
const transparentCanvas = canvasBackground === 'transparent';
|
|
@@ -869,6 +982,12 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
869
982
|
const flipFadeTimerRef = useRef<number | null>(null);
|
|
870
983
|
/** Set when a layout flip starts; the camera refits once layout lands. */
|
|
871
984
|
const refitAfterLayoutRef = useRef(false);
|
|
985
|
+
/** A host-driven step focus owns the camera across frame-layout flips. */
|
|
986
|
+
const stepFocusActiveRef = useRef(false);
|
|
987
|
+
const focusEdgeIdsRef = useRef<ReadonlySet<string> | null>(null);
|
|
988
|
+
const fitFocusBoundsRef = useRef<(ids: ReadonlySet<string>) => void>(
|
|
989
|
+
() => {},
|
|
990
|
+
);
|
|
872
991
|
|
|
873
992
|
/** Solo layout: only this trail's components and edges are laid out. */
|
|
874
993
|
const [layoutTrailId, setLayoutTrailId] = useState<string | null>(null);
|
|
@@ -1048,7 +1167,14 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1048
1167
|
if (!layoutReady || !refitAfterLayoutRef.current) return;
|
|
1049
1168
|
refitAfterLayoutRef.current = false;
|
|
1050
1169
|
requestAnimationFrame(() => {
|
|
1051
|
-
|
|
1170
|
+
// Focused trail/step edges (e.g. an agent walkthrough step that just
|
|
1171
|
+
// opened a different trail's frames) must not be replaced by a
|
|
1172
|
+
// whole-graph fit — that would zoom back out to the entire model.
|
|
1173
|
+
if (focusEdgeIdsRef.current) {
|
|
1174
|
+
fitFocusBoundsRef.current(focusEdgeIdsRef.current);
|
|
1175
|
+
} else {
|
|
1176
|
+
fitGraphContents(LAYOUT_FLIP_NODE_MS);
|
|
1177
|
+
}
|
|
1052
1178
|
});
|
|
1053
1179
|
}, [built, layoutReady, fitGraphContents]);
|
|
1054
1180
|
|
|
@@ -1319,7 +1445,10 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1319
1445
|
if (!committedTrailId) return { components, trails };
|
|
1320
1446
|
const trail = (trails ?? []).find((t) => t.id === committedTrailId);
|
|
1321
1447
|
if (!trail) return { components, trails };
|
|
1322
|
-
|
|
1448
|
+
// Host-local removal ghosts stay in the layout even when their steps are
|
|
1449
|
+
// gone; otherwise accepting a removal would make the node vanish from a
|
|
1450
|
+
// solo-focused flow instead of leaving the dim record the user asked for.
|
|
1451
|
+
const aliases = new Set<string>(removedComponentAliases);
|
|
1323
1452
|
for (const step of trail.steps) {
|
|
1324
1453
|
aliases.add(step.from);
|
|
1325
1454
|
aliases.add(step.to);
|
|
@@ -1328,7 +1457,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1328
1457
|
components: components.filter((c) => aliases.has(c.alias)),
|
|
1329
1458
|
trails: [trail],
|
|
1330
1459
|
};
|
|
1331
|
-
}, [components, trails, committedTrailId]);
|
|
1460
|
+
}, [components, trails, committedTrailId, removedComponentAliases]);
|
|
1332
1461
|
const layoutRelations = committedTrailId ? undefined : graphifyRelations;
|
|
1333
1462
|
|
|
1334
1463
|
const layoutKey = useMemo(
|
|
@@ -1824,7 +1953,8 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1824
1953
|
|
|
1825
1954
|
// Edge ids in trail focus (an active flow's edge set, or a single
|
|
1826
1955
|
// step's edge). Used to frame the camera. `null` = no trail focus.
|
|
1827
|
-
const focusEdgeIds = useMemo(() => {
|
|
1956
|
+
const focusEdgeIds = useMemo(() => {
|
|
1957
|
+
if (autoPlayFocus) {
|
|
1828
1958
|
const tl = trails?.find((t) => t.id === autoPlayFocus.trailId);
|
|
1829
1959
|
const step = tl?.steps[autoPlayFocus.stepIndex];
|
|
1830
1960
|
return step ? new Set([trailStepGraphEdgeId(step)]) : null;
|
|
@@ -1839,6 +1969,13 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1839
1969
|
return new Set(tl.steps.map((s) => trailStepGraphEdgeId(s)));
|
|
1840
1970
|
}, [trails, focusedTrailId, focusedStepIndex, autoPlayFocus]);
|
|
1841
1971
|
|
|
1972
|
+
// Keep these refs current during render, not in a later effect: the
|
|
1973
|
+
// post-layout refit effect is declared above and must see the focus that
|
|
1974
|
+
// triggered this layout swap, or it falls back to a whole-graph fit.
|
|
1975
|
+
stepFocusActiveRef.current =
|
|
1976
|
+
autoPlayFocus == null && focusedTrailId != null && focusedStepIndex != null;
|
|
1977
|
+
focusEdgeIdsRef.current = focusEdgeIds;
|
|
1978
|
+
|
|
1842
1979
|
// 1-based step numbers per edge of the active flow (focused or
|
|
1843
1980
|
// hover/autoplay-highlighted). An edge can appear in more than one step.
|
|
1844
1981
|
const selectedFlowStepNos = useMemo(() => {
|
|
@@ -2019,6 +2156,15 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2019
2156
|
};
|
|
2020
2157
|
}
|
|
2021
2158
|
const comp = (n.data as { component?: SubsystemComponent } | undefined)?.component;
|
|
2159
|
+
const proposed =
|
|
2160
|
+
comp?.alias != null &&
|
|
2161
|
+
proposedComponentAliases?.has(comp.alias) === true;
|
|
2162
|
+
const working =
|
|
2163
|
+
comp?.alias != null &&
|
|
2164
|
+
workingComponentAliases?.has(comp.alias) === true;
|
|
2165
|
+
const removed =
|
|
2166
|
+
comp?.alias != null &&
|
|
2167
|
+
removedComponentAliases?.has(comp.alias) === true;
|
|
2022
2168
|
const fileMatch = fileMatchForNode(comp?.file, openFile, focusNodeIds?.has(n.id) === true);
|
|
2023
2169
|
// Bases selection on the focused step, not the hover preview, so
|
|
2024
2170
|
// hovering doesn't strip the frame's `isSelected`.
|
|
@@ -2026,7 +2172,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2026
2172
|
// `brightNodeIds` (the focused step's endpoints) is a spotlight member as
|
|
2027
2173
|
// well as a bright set — see the group branch above.
|
|
2028
2174
|
const dimSource = previewNodeIds ?? brightNodeIds ?? issueFocusNodeIds;
|
|
2029
|
-
const
|
|
2175
|
+
const flowVisibility = flowNodeVisibility({
|
|
2030
2176
|
inOpened: openedNodeIds?.has(n.id) === true,
|
|
2031
2177
|
inSelected: brightNodeIds?.has(n.id) === true,
|
|
2032
2178
|
inSpotlight: dimSource?.has(n.id) === true || (hoverTrailAliases?.has(n.id) === true),
|
|
@@ -2034,13 +2180,25 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2034
2180
|
anySelected: brightNodeIds != null,
|
|
2035
2181
|
anySpotlight: dimSource != null || hoverTrailAliases != null,
|
|
2036
2182
|
});
|
|
2183
|
+
// A removed ghost is never hidden by flow focus — the whole point is to
|
|
2184
|
+
// keep it visible as a dim record of what the agent took out.
|
|
2185
|
+
const hidden = removed ? false : flowVisibility.hidden;
|
|
2186
|
+
const dimmed = removed ? true : flowVisibility.dimmed;
|
|
2037
2187
|
// Component findings key by alias, boundary findings by region node id.
|
|
2038
2188
|
// The two id spaces are disjoint (`module:` / `process:` are prefixed), so
|
|
2039
2189
|
// one lookup covers both node kinds.
|
|
2040
2190
|
const issueBadge =
|
|
2041
2191
|
issueBadgeByAlias.get(n.id) ?? regionIssueByNodeId.get(n.id);
|
|
2042
|
-
if (
|
|
2043
|
-
|
|
2192
|
+
if (
|
|
2193
|
+
fileMatch === undefined &&
|
|
2194
|
+
!isSelected &&
|
|
2195
|
+
!dimmed &&
|
|
2196
|
+
!issueBadge &&
|
|
2197
|
+
!proposed &&
|
|
2198
|
+
!working &&
|
|
2199
|
+
!removed
|
|
2200
|
+
) {
|
|
2201
|
+
const { fileMatch: _f, isSelected: _s, dimmed: _d, proposed: _p, working: _w, removed: _r, ...rest } = n.data as Record<string, unknown>;
|
|
2044
2202
|
return { ...n, hidden, data: rest };
|
|
2045
2203
|
}
|
|
2046
2204
|
return {
|
|
@@ -2051,11 +2209,14 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2051
2209
|
...(fileMatch !== undefined && { fileMatch }),
|
|
2052
2210
|
...(isSelected && { isSelected }),
|
|
2053
2211
|
...(dimmed && { dimmed: true }),
|
|
2212
|
+
...(proposed && { proposed: true }),
|
|
2213
|
+
...(working && { working: true }),
|
|
2214
|
+
...(removed && { removed: true }),
|
|
2054
2215
|
...(issueBadge && { issue: issueBadge }),
|
|
2055
2216
|
},
|
|
2056
2217
|
};
|
|
2057
2218
|
});
|
|
2058
|
-
}, [xyflowNodesBase, openFile, selected, focusNodeIds, openedNodeIds, brightNodeIds, previewNodeIds, hoverTrailAliases, aliasToComponent, issueFocusNodeIds, issueBadgeByAlias, regionIssueByNodeId, boundaryColors, toggleCollapsed]);
|
|
2219
|
+
}, [xyflowNodesBase, openFile, selected, focusNodeIds, openedNodeIds, brightNodeIds, previewNodeIds, hoverTrailAliases, aliasToComponent, issueFocusNodeIds, issueBadgeByAlias, regionIssueByNodeId, boundaryColors, proposedComponentAliases, workingComponentAliases, removedComponentAliases, toggleCollapsed]);
|
|
2059
2220
|
|
|
2060
2221
|
const baseNodesKey = useMemo(() => nodes.map((n) => n.id).sort().join(','), [nodes]);
|
|
2061
2222
|
const baseEdgesKey = useMemo(
|
|
@@ -2150,8 +2311,9 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2150
2311
|
|
|
2151
2312
|
useEffect(() => {
|
|
2152
2313
|
// A layout flip runs its own camera refit when the new layout lands. This
|
|
2153
|
-
// mount/edit fit would otherwise fire mid-flip and fight it.
|
|
2154
|
-
|
|
2314
|
+
// mount/edit fit would otherwise fire mid-flip and fight it. A focused
|
|
2315
|
+
// step also owns the camera — a frame flip must not restore whole-graph fit.
|
|
2316
|
+
if (layoutFlipping || stepFocusActiveRef.current) return;
|
|
2155
2317
|
const t = setTimeout(() => {
|
|
2156
2318
|
fitGraphContents(200);
|
|
2157
2319
|
}, 200);
|
|
@@ -2390,7 +2552,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2390
2552
|
width: Math.max(1, maxX - minX),
|
|
2391
2553
|
height: Math.max(1, maxY - minY),
|
|
2392
2554
|
};
|
|
2393
|
-
|
|
2555
|
+
fitBoundsWithBias(bounds, {
|
|
2394
2556
|
padding: 0.15,
|
|
2395
2557
|
duration: trailFocusDurationMs,
|
|
2396
2558
|
});
|
|
@@ -2398,12 +2560,16 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2398
2560
|
[
|
|
2399
2561
|
baseEdges,
|
|
2400
2562
|
built.absoluteRects,
|
|
2401
|
-
|
|
2563
|
+
fitBoundsWithBias,
|
|
2402
2564
|
zoomOnTrailFocus,
|
|
2403
2565
|
trailFocusDurationMs,
|
|
2404
2566
|
],
|
|
2405
2567
|
);
|
|
2406
2568
|
|
|
2569
|
+
useEffect(() => {
|
|
2570
|
+
fitFocusBoundsRef.current = fitFocusBounds;
|
|
2571
|
+
}, [fitFocusBounds]);
|
|
2572
|
+
|
|
2407
2573
|
// A node's laid-out rect in absolute flow coords. `absoluteRects` is the
|
|
2408
2574
|
// authority; the fallback covers an unparented group node, whose `position` is
|
|
2409
2575
|
// already absolute. Nested groups are parent-relative, so they are skipped
|
|
@@ -2451,7 +2617,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2451
2617
|
maxY = Math.max(maxY, r.y + r.height);
|
|
2452
2618
|
}
|
|
2453
2619
|
if (!Number.isFinite(minX) || !Number.isFinite(minY)) return;
|
|
2454
|
-
|
|
2620
|
+
fitBoundsWithBias(
|
|
2455
2621
|
{
|
|
2456
2622
|
x: minX,
|
|
2457
2623
|
y: minY,
|
|
@@ -2461,7 +2627,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2461
2627
|
{ padding, duration: trailFocusDurationMs },
|
|
2462
2628
|
);
|
|
2463
2629
|
},
|
|
2464
|
-
[rectForNode,
|
|
2630
|
+
[rectForNode, fitBoundsWithBias, trailFocusDurationMs],
|
|
2465
2631
|
);
|
|
2466
2632
|
|
|
2467
2633
|
// The Containers list: every card frame in the laid-out graph, parents before
|
|
@@ -2538,11 +2704,12 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2538
2704
|
// frame the flow on the canvas. Selection state is cleared — the graph now
|
|
2539
2705
|
// reads as the narrative. No drawer: the code view only opens on a step
|
|
2540
2706
|
// click. A stale trail drawer (from a previously focused flow's step)
|
|
2541
|
-
// closes; an explicitly opened file drawer stays
|
|
2707
|
+
// closes; an explicitly opened file drawer stays unless a host asks for
|
|
2708
|
+
// file-free focus (e.g. a walkthrough step that only selects the trail).
|
|
2542
2709
|
// In `dim` mode: clear step highlight and leave the full graph visible
|
|
2543
2710
|
// (no zoom / hide) — matching "step away from a hovered step".
|
|
2544
2711
|
const focusTrailEdges = useCallback(
|
|
2545
|
-
(tl: SubsystemTrail) => {
|
|
2712
|
+
(tl: SubsystemTrail, closeFile = false) => {
|
|
2546
2713
|
setSelected(null);
|
|
2547
2714
|
setSelectedEdgeId(null);
|
|
2548
2715
|
setHoveredTrailStep(null);
|
|
@@ -2559,10 +2726,34 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2559
2726
|
setFocusedStepIndex(null);
|
|
2560
2727
|
setFocusedTrailId(tl.id);
|
|
2561
2728
|
onTrailSelect?.({ trailId: tl.id });
|
|
2562
|
-
|
|
2563
|
-
|
|
2729
|
+
const edgeIds = new Set(tl.steps.map((s) => trailStepGraphEdgeId(s)));
|
|
2730
|
+
const drawerWillClose =
|
|
2731
|
+
drawerOpenRef.current && (closeFile || drawerTarget?.kind === 'trail');
|
|
2732
|
+
setDrawerTarget((prev) =>
|
|
2733
|
+
closeFile || prev?.kind === 'trail' ? null : prev,
|
|
2734
|
+
);
|
|
2735
|
+
if (pendingFocusFitRef.current != null) {
|
|
2736
|
+
window.clearTimeout(pendingFocusFitRef.current);
|
|
2737
|
+
pendingFocusFitRef.current = null;
|
|
2738
|
+
}
|
|
2739
|
+
if (drawerWillClose) {
|
|
2740
|
+
// Wait for the canvas to reclaim the drawer's height, or the fit uses
|
|
2741
|
+
// the temporarily shortened viewport and settles too far off-centre.
|
|
2742
|
+
pendingFocusFitRef.current = window.setTimeout(() => {
|
|
2743
|
+
pendingFocusFitRef.current = null;
|
|
2744
|
+
requestAnimationFrame(() => fitFocusBounds(edgeIds));
|
|
2745
|
+
}, FILE_DRAWER_HEIGHT_MS + 20);
|
|
2746
|
+
} else {
|
|
2747
|
+
fitFocusBounds(edgeIds);
|
|
2748
|
+
}
|
|
2564
2749
|
},
|
|
2565
|
-
[
|
|
2750
|
+
[
|
|
2751
|
+
fitFocusBounds,
|
|
2752
|
+
trailStepMode,
|
|
2753
|
+
onTrailSelect,
|
|
2754
|
+
onSidebarTrailChange,
|
|
2755
|
+
drawerTarget,
|
|
2756
|
+
],
|
|
2566
2757
|
);
|
|
2567
2758
|
|
|
2568
2759
|
const clearTrailFocus = useCallback(() => {
|
|
@@ -2614,7 +2805,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2614
2805
|
// In `dim` mode: only dim non-participants (same as hovering a step) —
|
|
2615
2806
|
// no camera move, no drawer, no hide.
|
|
2616
2807
|
const focusTrailStep = useCallback(
|
|
2617
|
-
(tl: SubsystemTrail, stepIndex: number) => {
|
|
2808
|
+
(tl: SubsystemTrail, stepIndex: number, showFile = true) => {
|
|
2618
2809
|
const step = tl.steps[stepIndex];
|
|
2619
2810
|
if (!step) return;
|
|
2620
2811
|
setSelected(null);
|
|
@@ -2627,6 +2818,11 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2627
2818
|
onTrailSelect?.(null);
|
|
2628
2819
|
return;
|
|
2629
2820
|
}
|
|
2821
|
+
// Opening the focused step's containing frames is what makes an
|
|
2822
|
+
// intra-process edge (e.g. api → store) renderable at all. Without this,
|
|
2823
|
+
// host-driven step focus can only frame cross-boundary hops.
|
|
2824
|
+
setExpandedTrails(new Set([tl.id]));
|
|
2825
|
+
setLayoutTrailId(tl.id);
|
|
2630
2826
|
// Toggle: clicking the selected step unselects it (back to whole flow).
|
|
2631
2827
|
onSidebarTrailChange(tl.id);
|
|
2632
2828
|
if (focusedTrailId === tl.id && focusedStepIndex === stepIndex) {
|
|
@@ -2634,7 +2830,9 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2634
2830
|
// Pointer is still over the row — keep hover preview so dimming doesn't
|
|
2635
2831
|
// flash off until mouseleave.
|
|
2636
2832
|
setHoveredTrailStep({ trailId: tl.id, stepIndex });
|
|
2637
|
-
setDrawerTarget((prev) =>
|
|
2833
|
+
setDrawerTarget((prev) =>
|
|
2834
|
+
!showFile ? null : prev?.kind === 'trail' ? null : prev,
|
|
2835
|
+
);
|
|
2638
2836
|
if (pendingFocusFitRef.current != null) {
|
|
2639
2837
|
window.clearTimeout(pendingFocusFitRef.current);
|
|
2640
2838
|
pendingFocusFitRef.current = null;
|
|
@@ -2646,10 +2844,12 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2646
2844
|
setFocusedTrailId(tl.id);
|
|
2647
2845
|
setHoveredTrailStep(null);
|
|
2648
2846
|
onTrailSelect?.({ trailId: tl.id, stepIndices: [stepIndex] });
|
|
2649
|
-
//
|
|
2650
|
-
// transition
|
|
2847
|
+
// The drawer changes the usable canvas height, so wait for its height
|
|
2848
|
+
// transition whenever we open or close it — not just when opening.
|
|
2651
2849
|
const drawerWasOpen = drawerOpenRef.current;
|
|
2652
|
-
if (
|
|
2850
|
+
if (!showFile) {
|
|
2851
|
+
setDrawerTarget(null);
|
|
2852
|
+
} else if (renderTrailViewer) {
|
|
2653
2853
|
setDrawerTarget({
|
|
2654
2854
|
kind: 'trail',
|
|
2655
2855
|
trailId: tl.id,
|
|
@@ -2668,7 +2868,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2668
2868
|
window.clearTimeout(pendingFocusFitRef.current);
|
|
2669
2869
|
pendingFocusFitRef.current = null;
|
|
2670
2870
|
}
|
|
2671
|
-
if (drawerWasOpen) {
|
|
2871
|
+
if (drawerWasOpen === showFile) {
|
|
2672
2872
|
fitFocusBounds(edgeIds);
|
|
2673
2873
|
} else {
|
|
2674
2874
|
pendingFocusFitRef.current = window.setTimeout(() => {
|
|
@@ -2688,6 +2888,43 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2688
2888
|
],
|
|
2689
2889
|
);
|
|
2690
2890
|
|
|
2891
|
+
// Host-controlled trail focus for agent-driven walkthroughs. Unlike
|
|
2892
|
+
// `initialTrailId`, this is repeatable. A `stepIndex` focuses one step;
|
|
2893
|
+
// omitting it frames the whole trail. `showFile: false` selects without
|
|
2894
|
+
// opening the file/trail drawer. `undefined` leaves graph-owned focus alone;
|
|
2895
|
+
// `null` hands control back to the graph.
|
|
2896
|
+
const appliedFocusedTrailStepRef = useRef<string | null>(null);
|
|
2897
|
+
useEffect(() => {
|
|
2898
|
+
if (focusedTrailStep === undefined) return;
|
|
2899
|
+
if (focusedTrailStep === null) {
|
|
2900
|
+
if (appliedFocusedTrailStepRef.current == null) return;
|
|
2901
|
+
appliedFocusedTrailStepRef.current = null;
|
|
2902
|
+
clearTrailFocus();
|
|
2903
|
+
return;
|
|
2904
|
+
}
|
|
2905
|
+
const { trailId, stepIndex } = focusedTrailStep;
|
|
2906
|
+
const showFile = focusedTrailStep.showFile ?? stepIndex != null;
|
|
2907
|
+
const key = `${trailId}:${stepIndex ?? 'trail'}:${showFile ? 'file' : 'nofile'}`;
|
|
2908
|
+
if (appliedFocusedTrailStepRef.current === key) return;
|
|
2909
|
+
if (!layoutReady || !trails?.length) return;
|
|
2910
|
+
const tl = trails.find((t) => t.id === trailId);
|
|
2911
|
+
if (!tl) return;
|
|
2912
|
+
if (stepIndex != null && !tl.steps[stepIndex]) return;
|
|
2913
|
+
appliedFocusedTrailStepRef.current = key;
|
|
2914
|
+
if (stepIndex == null) {
|
|
2915
|
+
focusTrailEdges(tl, !showFile);
|
|
2916
|
+
} else {
|
|
2917
|
+
focusTrailStep(tl, stepIndex, showFile);
|
|
2918
|
+
}
|
|
2919
|
+
}, [
|
|
2920
|
+
focusedTrailStep,
|
|
2921
|
+
layoutReady,
|
|
2922
|
+
trails,
|
|
2923
|
+
focusTrailEdges,
|
|
2924
|
+
focusTrailStep,
|
|
2925
|
+
clearTrailFocus,
|
|
2926
|
+
]);
|
|
2927
|
+
|
|
2691
2928
|
useEffect(() => {
|
|
2692
2929
|
return () => {
|
|
2693
2930
|
if (pendingFocusFitRef.current != null) {
|
|
@@ -3217,6 +3454,11 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
3217
3454
|
expandedTrails={expandedTrails}
|
|
3218
3455
|
focusedTrailId={sidebarTrail?.id ?? focusedTrailId}
|
|
3219
3456
|
focusedStepIndex={!sidebarTrail || focusedTrailId === sidebarTrail.id ? focusedStepIndex : null}
|
|
3457
|
+
proposedTrailIds={proposedTrailIds}
|
|
3458
|
+
proposedStepKeys={proposedStepKeys}
|
|
3459
|
+
stepChange={stepChange}
|
|
3460
|
+
showPreviousStep={showPreviousStep}
|
|
3461
|
+
onTogglePreviousStep={onTogglePreviousStep}
|
|
3220
3462
|
detailContent={sidebarPanel}
|
|
3221
3463
|
hoveredTrailStep={hoveredTrailStep}
|
|
3222
3464
|
onToggleCollapsed={toggleTrailCollapsed}
|
|
@@ -3996,7 +4238,7 @@ export function SubsystemComponentGraph(props: SubsystemComponentGraphProps) {
|
|
|
3996
4238
|
flexDirection: 'column',
|
|
3997
4239
|
}}
|
|
3998
4240
|
>
|
|
3999
|
-
{!constructsOnly && !props.hideSidebar && (
|
|
4241
|
+
{!constructsOnly && !props.hideSidebar && !props.hideHeader && (
|
|
4000
4242
|
<header
|
|
4001
4243
|
style={{
|
|
4002
4244
|
flexShrink: 0,
|
|
@@ -56,6 +56,8 @@ export interface TrailStepsNavProps {
|
|
|
56
56
|
renderSteps?: (trail: SubsystemTrail) => ReactNode;
|
|
57
57
|
/** Replace the step body without replacing the selected trail's header. */
|
|
58
58
|
detailContent?: ReactNode;
|
|
59
|
+
/** Host-local trails awaiting confirmation; their header icon uses proposal color. */
|
|
60
|
+
proposedTrailIds?: Set<string>;
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
const PANE: CSSProperties = {
|
|
@@ -83,6 +85,7 @@ export function TrailStepsNav({
|
|
|
83
85
|
listContent,
|
|
84
86
|
renderSteps,
|
|
85
87
|
detailContent,
|
|
88
|
+
proposedTrailIds,
|
|
86
89
|
}: TrailStepsNavProps) {
|
|
87
90
|
const { theme } = useTheme();
|
|
88
91
|
const muted = theme.colors.textMuted ?? theme.colors.textSecondary;
|
|
@@ -113,6 +116,9 @@ export function TrailStepsNav({
|
|
|
113
116
|
const timer = setTimeout(() => setDisplayedTrail(null), transitionMs);
|
|
114
117
|
return () => clearTimeout(timer);
|
|
115
118
|
}, [focused, transitionMs]);
|
|
119
|
+
const proposed = displayedTrail
|
|
120
|
+
? (proposedTrailIds?.has(displayedTrail.id) ?? false)
|
|
121
|
+
: false;
|
|
116
122
|
|
|
117
123
|
// A focused trail (from the graph side) always lands on the step pane.
|
|
118
124
|
const leaveList = useCallback(() => {
|
|
@@ -234,9 +240,15 @@ export function TrailStepsNav({
|
|
|
234
240
|
size={14}
|
|
235
241
|
strokeWidth={2}
|
|
236
242
|
aria-hidden
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
style={{
|
|
243
|
+
// A proposed trail keeps the proposal colour here too, matching
|
|
244
|
+
// its row icon in the list it came from.
|
|
245
|
+
style={{
|
|
246
|
+
flexShrink: 0,
|
|
247
|
+
marginTop: 3,
|
|
248
|
+
color: proposed
|
|
249
|
+
? (theme.colors.warning ?? '#d4a017')
|
|
250
|
+
: theme.colors.primary,
|
|
251
|
+
}}
|
|
240
252
|
/>
|
|
241
253
|
{/* The title is the back affordance too: clicking it goes back to
|
|
242
254
|
the list, like the trailing close. */}
|