@principal-ai/subsystems-react 0.56.33 → 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 +65 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +190 -33
- 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 +292 -33
- 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
|
@@ -24,6 +24,7 @@ import { type SubsystemDiagnostic } from './DiagnosticToggle';
|
|
|
24
24
|
import { type SubsystemIssueListProps, type SubsystemIssue, type SubsystemIssueCategory } from './IssueList';
|
|
25
25
|
import type { ComponentVerificationState } from './ComponentDeclaration';
|
|
26
26
|
import type { DeclarationSymbolRef, SymbolInspection } from './symbolRefs';
|
|
27
|
+
import { type TrailsStepChange } from './TrailsPanel';
|
|
27
28
|
import type { StepEmphasisMap } from './stepEmphasis';
|
|
28
29
|
/** Context passed to `renderTrailViewer` when a flow/step is focused. */
|
|
29
30
|
export interface TrailViewerContext {
|
|
@@ -135,6 +136,56 @@ export interface SubsystemComponentGraphProps {
|
|
|
135
136
|
trailId: string;
|
|
136
137
|
stepIndices?: number[];
|
|
137
138
|
} | null) => void;
|
|
139
|
+
/**
|
|
140
|
+
* PROTOTYPE: host-controlled trail focus. Changing this expands the trail
|
|
141
|
+
* and drives the camera. With a `stepIndex`, it focuses that step's edge;
|
|
142
|
+
* without one, it frames the whole trail. `showFile` controls whether the
|
|
143
|
+
* step's file/trail drawer opens — omit it for whole-trail focus, or set it
|
|
144
|
+
* to `false` to select a step without showing its file.
|
|
145
|
+
*
|
|
146
|
+
* `undefined` leaves in-graph focus untouched; `null` clears host control.
|
|
147
|
+
*/
|
|
148
|
+
focusedTrailStep?: {
|
|
149
|
+
trailId: string;
|
|
150
|
+
stepIndex?: number;
|
|
151
|
+
showFile?: boolean;
|
|
152
|
+
} | null;
|
|
153
|
+
/**
|
|
154
|
+
* PROTOTYPE: host-local ids of trails awaiting confirmation. Their Trails
|
|
155
|
+
* panel icon uses the proposal color instead of labelling the title.
|
|
156
|
+
*/
|
|
157
|
+
proposedTrailIds?: Set<string>;
|
|
158
|
+
/**
|
|
159
|
+
* PROTOTYPE: host-local ids of steps awaiting confirmation, keyed by
|
|
160
|
+
* `emphasisKey(trailId, step)`. Their Trails panel text uses proposal color.
|
|
161
|
+
*/
|
|
162
|
+
proposedStepKeys?: Set<string>;
|
|
163
|
+
/**
|
|
164
|
+
* PROTOTYPE: host-local before/after view for an accepted step replacement.
|
|
165
|
+
* The previous step stays out of the trails array; the panel renders it as a
|
|
166
|
+
* ghost beneath the committed step.
|
|
167
|
+
*/
|
|
168
|
+
stepChange?: TrailsStepChange | null;
|
|
169
|
+
/** Whether the previous-state ghost is visible. @default true */
|
|
170
|
+
showPreviousStep?: boolean;
|
|
171
|
+
/** Dismiss or restore just the previous-state ghost. */
|
|
172
|
+
onTogglePreviousStep?: () => void;
|
|
173
|
+
/**
|
|
174
|
+
* PROTOTYPE: host-local component aliases awaiting confirmation. Their boxes
|
|
175
|
+
* use the proposal border, name colour and `PROPOSED` badge.
|
|
176
|
+
*/
|
|
177
|
+
proposedComponentAliases?: Set<string>;
|
|
178
|
+
/**
|
|
179
|
+
* PROTOTYPE: host-local component aliases the agent is currently working on.
|
|
180
|
+
* Their boxes get a static ring and a sparkling WandSparkles icon.
|
|
181
|
+
*/
|
|
182
|
+
workingComponentAliases?: Set<string>;
|
|
183
|
+
/**
|
|
184
|
+
* PROTOTYPE: host-local component aliases removed from the model. Their
|
|
185
|
+
* nodes stay in the layout, dimmed and `REMOVED`-badged, so the change is
|
|
186
|
+
* legible instead of silently disappearing.
|
|
187
|
+
*/
|
|
188
|
+
removedComponentAliases?: Set<string>;
|
|
138
189
|
/**
|
|
139
190
|
* Reports which trail step is currently hovered in the Trails panel —
|
|
140
191
|
* the transient preview mirror of `onTrailSelect`. `null` when nothing is
|
|
@@ -207,6 +258,11 @@ export interface SubsystemComponentGraphProps {
|
|
|
207
258
|
* subsystem name visible as an overlay on the canvas.
|
|
208
259
|
*/
|
|
209
260
|
hideSidebar?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* Suppress only the standard full-width header (title + sidebar-view switch)
|
|
263
|
+
* while keeping the sidebar and canvas. Hosts can render their own header.
|
|
264
|
+
*/
|
|
265
|
+
hideHeader?: boolean;
|
|
210
266
|
/**
|
|
211
267
|
* How trail step highlighting behaves on the canvas.
|
|
212
268
|
* - `focus` (default): zoom to the step, hide non-participants, open drawer
|
|
@@ -241,6 +297,12 @@ export interface SubsystemComponentGraphProps {
|
|
|
241
297
|
* @default 300
|
|
242
298
|
*/
|
|
243
299
|
trailFocusDurationMs?: number;
|
|
300
|
+
/**
|
|
301
|
+
* Downward screen-pixel offset applied when the camera frames the graph or
|
|
302
|
+
* a focused trail step. Useful for hosts with chrome over the canvas top.
|
|
303
|
+
* @default 0
|
|
304
|
+
*/
|
|
305
|
+
focusVerticalBiasPx?: number;
|
|
244
306
|
/**
|
|
245
307
|
* Subsystem title rendered as a non-interactive overlay chip on the graph
|
|
246
308
|
* canvas (top-center). Does not trigger the sidebar — for graph-only
|
|
@@ -436,7 +498,9 @@ export interface SubsystemComponentGraphProps {
|
|
|
436
498
|
* with its members folded away and their lines rolled up onto it, the way a
|
|
437
499
|
* C4 container view reads. The user opens frames from the card, by
|
|
438
500
|
* double-click, or from the Containers list; a `persistKey` remembers the
|
|
439
|
-
* result. Default true
|
|
501
|
+
* result. Default true, except a model with a single container frame starts
|
|
502
|
+
* open (there is nothing to compare collapsed cards against); pass `false`
|
|
503
|
+
* to start with every frame laid out, `true` to force even a lone frame shut.
|
|
440
504
|
*/
|
|
441
505
|
defaultFramesCollapsed?: boolean;
|
|
442
506
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubsystemComponentGraph.d.ts","sourceRoot":"","sources":["../../src/subsystem/SubsystemComponentGraph.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAiC,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SubsystemComponentGraph.d.ts","sourceRoot":"","sources":["../../src/subsystem/SubsystemComponentGraph.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAiC,SAAS,EAAE,MAAM,OAAO,CAAC;AAoBtE,OAAO,EAiBL,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EAEvB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAI9B,KAAK,sBAAsB,EAE3B,KAAK,cAAc,EACpB,MAAM,SAAS,CAAC;AAIjB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAEL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EAAE,0BAA0B,GAAG,IAAI,CAAC;IAC1D;;;;;OAKG;IACH,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE;QACtB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,oBAAoB,CAAC;KAC3B,KAAK,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,gBAAgB,GAAG,IAAI,CAAC;IACjE;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAAC;IACjE;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAg3GD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,+BAqN1E"}
|
|
@@ -16,7 +16,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
16
16
|
* injection, onNodeClick) adapted to the subsystem model — read-only.
|
|
17
17
|
*/
|
|
18
18
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
19
|
-
import { ReactFlow, ReactFlowProvider, useReactFlow, useViewport, applyNodeChanges, } from '@xyflow/react';
|
|
19
|
+
import { ReactFlow, ReactFlowProvider, useReactFlow, useStore, useViewport, getViewportForBounds, applyNodeChanges, } from '@xyflow/react';
|
|
20
20
|
import { useTheme } from '@principal-ade/industry-theme';
|
|
21
21
|
import { SUBSYSTEM_MODEL_DESCRIPTION_MAX } from '@principal-ai/subsystems-core';
|
|
22
22
|
import { ArrowDown, ArrowRight, Boxes, Files, Route, Unlink, X } from 'lucide-react';
|
|
@@ -39,7 +39,7 @@ import { GraphWithSidebar } from './GraphWithSidebar';
|
|
|
39
39
|
import { ShareButton } from './ShareButton';
|
|
40
40
|
import { DescriptionOverlay } from './DescriptionOverlay';
|
|
41
41
|
import { DescriptionPreview } from './DescriptionPreview';
|
|
42
|
-
import { TrailsPanel, TRAIL_PLAY_PAUSE_MS, TRAIL_HOVER_PREVIEW_MS } from './TrailsPanel';
|
|
42
|
+
import { TrailsPanel, TRAIL_PLAY_PAUSE_MS, TRAIL_HOVER_PREVIEW_MS, } from './TrailsPanel';
|
|
43
43
|
import { EDGE_LABEL_WIDTH, EDGE_LABEL_HEIGHT, EDGE_LABEL_FONT_SIZE, EDGE_LABEL_CLOUD_PATH, EDGE_LABEL_CLOUD_EXTRA_TOP, } from '../utils/edgeLabel';
|
|
44
44
|
import { graphGeometryBounds } from '../utils/elkLayout';
|
|
45
45
|
/** Identifiers a token could match to name this component as a construct. */
|
|
@@ -179,9 +179,13 @@ const TrailDrawerContent = memo(function TrailDrawerContent({ render, trail, ste
|
|
|
179
179
|
onVisibleStepChange,
|
|
180
180
|
}) }));
|
|
181
181
|
});
|
|
182
|
-
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
|
|
182
|
+
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 }) {
|
|
183
183
|
const { theme } = useTheme();
|
|
184
|
-
const { fitView, fitBounds } = useReactFlow();
|
|
184
|
+
const { fitView, fitBounds, setViewport } = useReactFlow();
|
|
185
|
+
const flowWidth = useStore((state) => state.width);
|
|
186
|
+
const flowHeight = useStore((state) => state.height);
|
|
187
|
+
const minZoom = useStore((state) => state.minZoom);
|
|
188
|
+
const maxZoom = useStore((state) => state.maxZoom);
|
|
185
189
|
const [descriptionOpen, setDescriptionOpen] = useState(false);
|
|
186
190
|
const rawDescription = description?.trim();
|
|
187
191
|
// The host caps the authored description; trim defensively for other hosts.
|
|
@@ -203,6 +207,27 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
203
207
|
edges: [],
|
|
204
208
|
absoluteRects: new Map(),
|
|
205
209
|
});
|
|
210
|
+
// React Flow's `fitBounds` always centres the bounds. A host may need the
|
|
211
|
+
// diagram deliberately lower (e.g. to leave room for status chrome over the
|
|
212
|
+
// canvas), so recompute the same viewport and shift only its screen-space y.
|
|
213
|
+
const fitBoundsWithBias = useCallback((bounds, options) => {
|
|
214
|
+
if (!focusVerticalBiasPx ||
|
|
215
|
+
flowWidth <= 0 ||
|
|
216
|
+
flowHeight <= 0) {
|
|
217
|
+
void fitBounds(bounds, options);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const viewport = getViewportForBounds(bounds, flowWidth, flowHeight, minZoom, maxZoom, options.padding);
|
|
221
|
+
void setViewport({ ...viewport, y: viewport.y + focusVerticalBiasPx }, { duration: options.duration });
|
|
222
|
+
}, [
|
|
223
|
+
fitBounds,
|
|
224
|
+
setViewport,
|
|
225
|
+
flowWidth,
|
|
226
|
+
flowHeight,
|
|
227
|
+
minZoom,
|
|
228
|
+
maxZoom,
|
|
229
|
+
focusVerticalBiasPx,
|
|
230
|
+
]);
|
|
206
231
|
const fitGraphContents = useCallback((duration = 300) => {
|
|
207
232
|
const edges = built.edges.map((edge) => {
|
|
208
233
|
const data = edge.data;
|
|
@@ -224,8 +249,8 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
224
249
|
});
|
|
225
250
|
return;
|
|
226
251
|
}
|
|
227
|
-
|
|
228
|
-
}, [built.absoluteRects, built.edges,
|
|
252
|
+
fitBoundsWithBias(bounds, { padding: 0.1, duration });
|
|
253
|
+
}, [built.absoluteRects, built.edges, fitBoundsWithBias, fitView]);
|
|
229
254
|
const [layoutReady, setLayoutReady] = useState(false);
|
|
230
255
|
const transparentCanvas = canvasBackground === 'transparent';
|
|
231
256
|
// Host notifications. Refs keep the callbacks out of effect deps so an
|
|
@@ -276,6 +301,10 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
276
301
|
const flipFadeTimerRef = useRef(null);
|
|
277
302
|
/** Set when a layout flip starts; the camera refits once layout lands. */
|
|
278
303
|
const refitAfterLayoutRef = useRef(false);
|
|
304
|
+
/** A host-driven step focus owns the camera across frame-layout flips. */
|
|
305
|
+
const stepFocusActiveRef = useRef(false);
|
|
306
|
+
const focusEdgeIdsRef = useRef(null);
|
|
307
|
+
const fitFocusBoundsRef = useRef(() => { });
|
|
279
308
|
/** Solo layout: only this trail's components and edges are laid out. */
|
|
280
309
|
const [layoutTrailId, setLayoutTrailId] = useState(null);
|
|
281
310
|
const [committedTrailId, setCommittedTrailId] = useState(null);
|
|
@@ -286,7 +315,21 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
286
315
|
// Stored as a default plus exceptions so "close all" needs no knowledge of
|
|
287
316
|
// which frames the layout will produce: `framesCollapsed` is the default
|
|
288
317
|
// every card frame takes, `toggledGroupIds` the frames flipped away from it.
|
|
289
|
-
|
|
318
|
+
// A lone container starts open — a single collapsed card hides the whole
|
|
319
|
+
// model behind one box with nothing to compare it against. An explicit
|
|
320
|
+
// `defaultFramesCollapsed` still wins; so does a persisted choice.
|
|
321
|
+
const resolvedDefaultFramesCollapsed = useMemo(() => {
|
|
322
|
+
if (defaultFramesCollapsed !== undefined)
|
|
323
|
+
return defaultFramesCollapsed;
|
|
324
|
+
try {
|
|
325
|
+
const count = buildBoundaryLayoutGroups({ components }, { showSingletonFrames, moduleNesting, codeProcessKeys }).filter((g) => isCardFrame(g.region)).length;
|
|
326
|
+
return count <= 1 ? false : true;
|
|
327
|
+
}
|
|
328
|
+
catch {
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
}, [components, showSingletonFrames, moduleNesting, codeProcessKeys, defaultFramesCollapsed]);
|
|
332
|
+
const [framesCollapsed, setFramesCollapsed] = useState(() => persisted.framesCollapsed ?? resolvedDefaultFramesCollapsed);
|
|
290
333
|
const [toggledGroupIds, setToggledGroupIds] = useState(() => new Set(persisted.toggledFrames ?? []));
|
|
291
334
|
// Picking a trail opens the container cards that hold its cast, so the flow
|
|
292
335
|
// reads as its components instead of a row of folded boxes. Derived rather
|
|
@@ -429,7 +472,15 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
429
472
|
return;
|
|
430
473
|
refitAfterLayoutRef.current = false;
|
|
431
474
|
requestAnimationFrame(() => {
|
|
432
|
-
|
|
475
|
+
// Focused trail/step edges (e.g. an agent walkthrough step that just
|
|
476
|
+
// opened a different trail's frames) must not be replaced by a
|
|
477
|
+
// whole-graph fit — that would zoom back out to the entire model.
|
|
478
|
+
if (focusEdgeIdsRef.current) {
|
|
479
|
+
fitFocusBoundsRef.current(focusEdgeIdsRef.current);
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
fitGraphContents(LAYOUT_FLIP_NODE_MS);
|
|
483
|
+
}
|
|
433
484
|
});
|
|
434
485
|
}, [built, layoutReady, fitGraphContents]);
|
|
435
486
|
// Persist the choice so a model reopens the way it was left.
|
|
@@ -687,7 +738,10 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
687
738
|
const trail = (trails ?? []).find((t) => t.id === committedTrailId);
|
|
688
739
|
if (!trail)
|
|
689
740
|
return { components, trails };
|
|
690
|
-
|
|
741
|
+
// Host-local removal ghosts stay in the layout even when their steps are
|
|
742
|
+
// gone; otherwise accepting a removal would make the node vanish from a
|
|
743
|
+
// solo-focused flow instead of leaving the dim record the user asked for.
|
|
744
|
+
const aliases = new Set(removedComponentAliases);
|
|
691
745
|
for (const step of trail.steps) {
|
|
692
746
|
aliases.add(step.from);
|
|
693
747
|
aliases.add(step.to);
|
|
@@ -696,7 +750,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
696
750
|
components: components.filter((c) => aliases.has(c.alias)),
|
|
697
751
|
trails: [trail],
|
|
698
752
|
};
|
|
699
|
-
}, [components, trails, committedTrailId]);
|
|
753
|
+
}, [components, trails, committedTrailId, removedComponentAliases]);
|
|
700
754
|
const layoutRelations = committedTrailId ? undefined : graphifyRelations;
|
|
701
755
|
const layoutKey = useMemo(() => subsystemGraphLayoutKey({
|
|
702
756
|
components: layoutDoc.components,
|
|
@@ -1169,6 +1223,12 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1169
1223
|
}
|
|
1170
1224
|
return new Set(tl.steps.map((s) => trailStepGraphEdgeId(s)));
|
|
1171
1225
|
}, [trails, focusedTrailId, focusedStepIndex, autoPlayFocus]);
|
|
1226
|
+
// Keep these refs current during render, not in a later effect: the
|
|
1227
|
+
// post-layout refit effect is declared above and must see the focus that
|
|
1228
|
+
// triggered this layout swap, or it falls back to a whole-graph fit.
|
|
1229
|
+
stepFocusActiveRef.current =
|
|
1230
|
+
autoPlayFocus == null && focusedTrailId != null && focusedStepIndex != null;
|
|
1231
|
+
focusEdgeIdsRef.current = focusEdgeIds;
|
|
1172
1232
|
// 1-based step numbers per edge of the active flow (focused or
|
|
1173
1233
|
// hover/autoplay-highlighted). An edge can appear in more than one step.
|
|
1174
1234
|
const selectedFlowStepNos = useMemo(() => {
|
|
@@ -1354,6 +1414,12 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1354
1414
|
};
|
|
1355
1415
|
}
|
|
1356
1416
|
const comp = n.data?.component;
|
|
1417
|
+
const proposed = comp?.alias != null &&
|
|
1418
|
+
proposedComponentAliases?.has(comp.alias) === true;
|
|
1419
|
+
const working = comp?.alias != null &&
|
|
1420
|
+
workingComponentAliases?.has(comp.alias) === true;
|
|
1421
|
+
const removed = comp?.alias != null &&
|
|
1422
|
+
removedComponentAliases?.has(comp.alias) === true;
|
|
1357
1423
|
const fileMatch = fileMatchForNode(comp?.file, openFile, focusNodeIds?.has(n.id) === true);
|
|
1358
1424
|
// Bases selection on the focused step, not the hover preview, so
|
|
1359
1425
|
// hovering doesn't strip the frame's `isSelected`.
|
|
@@ -1361,7 +1427,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1361
1427
|
// `brightNodeIds` (the focused step's endpoints) is a spotlight member as
|
|
1362
1428
|
// well as a bright set — see the group branch above.
|
|
1363
1429
|
const dimSource = previewNodeIds ?? brightNodeIds ?? issueFocusNodeIds;
|
|
1364
|
-
const
|
|
1430
|
+
const flowVisibility = flowNodeVisibility({
|
|
1365
1431
|
inOpened: openedNodeIds?.has(n.id) === true,
|
|
1366
1432
|
inSelected: brightNodeIds?.has(n.id) === true,
|
|
1367
1433
|
inSpotlight: dimSource?.has(n.id) === true || (hoverTrailAliases?.has(n.id) === true),
|
|
@@ -1369,12 +1435,22 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1369
1435
|
anySelected: brightNodeIds != null,
|
|
1370
1436
|
anySpotlight: dimSource != null || hoverTrailAliases != null,
|
|
1371
1437
|
});
|
|
1438
|
+
// A removed ghost is never hidden by flow focus — the whole point is to
|
|
1439
|
+
// keep it visible as a dim record of what the agent took out.
|
|
1440
|
+
const hidden = removed ? false : flowVisibility.hidden;
|
|
1441
|
+
const dimmed = removed ? true : flowVisibility.dimmed;
|
|
1372
1442
|
// Component findings key by alias, boundary findings by region node id.
|
|
1373
1443
|
// The two id spaces are disjoint (`module:` / `process:` are prefixed), so
|
|
1374
1444
|
// one lookup covers both node kinds.
|
|
1375
1445
|
const issueBadge = issueBadgeByAlias.get(n.id) ?? regionIssueByNodeId.get(n.id);
|
|
1376
|
-
if (fileMatch === undefined &&
|
|
1377
|
-
|
|
1446
|
+
if (fileMatch === undefined &&
|
|
1447
|
+
!isSelected &&
|
|
1448
|
+
!dimmed &&
|
|
1449
|
+
!issueBadge &&
|
|
1450
|
+
!proposed &&
|
|
1451
|
+
!working &&
|
|
1452
|
+
!removed) {
|
|
1453
|
+
const { fileMatch: _f, isSelected: _s, dimmed: _d, proposed: _p, working: _w, removed: _r, ...rest } = n.data;
|
|
1378
1454
|
return { ...n, hidden, data: rest };
|
|
1379
1455
|
}
|
|
1380
1456
|
return {
|
|
@@ -1385,11 +1461,14 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1385
1461
|
...(fileMatch !== undefined && { fileMatch }),
|
|
1386
1462
|
...(isSelected && { isSelected }),
|
|
1387
1463
|
...(dimmed && { dimmed: true }),
|
|
1464
|
+
...(proposed && { proposed: true }),
|
|
1465
|
+
...(working && { working: true }),
|
|
1466
|
+
...(removed && { removed: true }),
|
|
1388
1467
|
...(issueBadge && { issue: issueBadge }),
|
|
1389
1468
|
},
|
|
1390
1469
|
};
|
|
1391
1470
|
});
|
|
1392
|
-
}, [xyflowNodesBase, openFile, selected, focusNodeIds, openedNodeIds, brightNodeIds, previewNodeIds, hoverTrailAliases, aliasToComponent, issueFocusNodeIds, issueBadgeByAlias, regionIssueByNodeId, boundaryColors, toggleCollapsed]);
|
|
1471
|
+
}, [xyflowNodesBase, openFile, selected, focusNodeIds, openedNodeIds, brightNodeIds, previewNodeIds, hoverTrailAliases, aliasToComponent, issueFocusNodeIds, issueBadgeByAlias, regionIssueByNodeId, boundaryColors, proposedComponentAliases, workingComponentAliases, removedComponentAliases, toggleCollapsed]);
|
|
1393
1472
|
const baseNodesKey = useMemo(() => nodes.map((n) => n.id).sort().join(','), [nodes]);
|
|
1394
1473
|
const baseEdgesKey = useMemo(() => convertedEdges.map((e) => e.id).sort().join(','), [convertedEdges]);
|
|
1395
1474
|
const dispEdges = useMemo(() => {
|
|
@@ -1461,8 +1540,9 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1461
1540
|
const onEdgesChange = useCallback((_changes) => dispEdges, [dispEdges]);
|
|
1462
1541
|
useEffect(() => {
|
|
1463
1542
|
// A layout flip runs its own camera refit when the new layout lands. This
|
|
1464
|
-
// mount/edit fit would otherwise fire mid-flip and fight it.
|
|
1465
|
-
|
|
1543
|
+
// mount/edit fit would otherwise fire mid-flip and fight it. A focused
|
|
1544
|
+
// step also owns the camera — a frame flip must not restore whole-graph fit.
|
|
1545
|
+
if (layoutFlipping || stepFocusActiveRef.current)
|
|
1466
1546
|
return;
|
|
1467
1547
|
const t = setTimeout(() => {
|
|
1468
1548
|
fitGraphContents(200);
|
|
@@ -1674,17 +1754,20 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1674
1754
|
width: Math.max(1, maxX - minX),
|
|
1675
1755
|
height: Math.max(1, maxY - minY),
|
|
1676
1756
|
};
|
|
1677
|
-
|
|
1757
|
+
fitBoundsWithBias(bounds, {
|
|
1678
1758
|
padding: 0.15,
|
|
1679
1759
|
duration: trailFocusDurationMs,
|
|
1680
1760
|
});
|
|
1681
1761
|
}, [
|
|
1682
1762
|
baseEdges,
|
|
1683
1763
|
built.absoluteRects,
|
|
1684
|
-
|
|
1764
|
+
fitBoundsWithBias,
|
|
1685
1765
|
zoomOnTrailFocus,
|
|
1686
1766
|
trailFocusDurationMs,
|
|
1687
1767
|
]);
|
|
1768
|
+
useEffect(() => {
|
|
1769
|
+
fitFocusBoundsRef.current = fitFocusBounds;
|
|
1770
|
+
}, [fitFocusBounds]);
|
|
1688
1771
|
// A node's laid-out rect in absolute flow coords. `absoluteRects` is the
|
|
1689
1772
|
// authority; the fallback covers an unparented group node, whose `position` is
|
|
1690
1773
|
// already absolute. Nested groups are parent-relative, so they are skipped
|
|
@@ -1724,13 +1807,13 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1724
1807
|
}
|
|
1725
1808
|
if (!Number.isFinite(minX) || !Number.isFinite(minY))
|
|
1726
1809
|
return;
|
|
1727
|
-
|
|
1810
|
+
fitBoundsWithBias({
|
|
1728
1811
|
x: minX,
|
|
1729
1812
|
y: minY,
|
|
1730
1813
|
width: Math.max(1, maxX - minX),
|
|
1731
1814
|
height: Math.max(1, maxY - minY),
|
|
1732
1815
|
}, { padding, duration: trailFocusDurationMs });
|
|
1733
|
-
}, [rectForNode,
|
|
1816
|
+
}, [rectForNode, fitBoundsWithBias, trailFocusDurationMs]);
|
|
1734
1817
|
// The Containers list: every card frame in the laid-out graph, parents before
|
|
1735
1818
|
// their children, with the colour the canvas draws it in. Rows keep the
|
|
1736
1819
|
// grouping's declaration order — the layout moves closed cards after open
|
|
@@ -1792,10 +1875,11 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1792
1875
|
// frame the flow on the canvas. Selection state is cleared — the graph now
|
|
1793
1876
|
// reads as the narrative. No drawer: the code view only opens on a step
|
|
1794
1877
|
// click. A stale trail drawer (from a previously focused flow's step)
|
|
1795
|
-
// closes; an explicitly opened file drawer stays
|
|
1878
|
+
// closes; an explicitly opened file drawer stays unless a host asks for
|
|
1879
|
+
// file-free focus (e.g. a walkthrough step that only selects the trail).
|
|
1796
1880
|
// In `dim` mode: clear step highlight and leave the full graph visible
|
|
1797
1881
|
// (no zoom / hide) — matching "step away from a hovered step".
|
|
1798
|
-
const focusTrailEdges = useCallback((tl) => {
|
|
1882
|
+
const focusTrailEdges = useCallback((tl, closeFile = false) => {
|
|
1799
1883
|
setSelected(null);
|
|
1800
1884
|
setSelectedEdgeId(null);
|
|
1801
1885
|
setHoveredTrailStep(null);
|
|
@@ -1812,9 +1896,31 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1812
1896
|
setFocusedStepIndex(null);
|
|
1813
1897
|
setFocusedTrailId(tl.id);
|
|
1814
1898
|
onTrailSelect?.({ trailId: tl.id });
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1899
|
+
const edgeIds = new Set(tl.steps.map((s) => trailStepGraphEdgeId(s)));
|
|
1900
|
+
const drawerWillClose = drawerOpenRef.current && (closeFile || drawerTarget?.kind === 'trail');
|
|
1901
|
+
setDrawerTarget((prev) => closeFile || prev?.kind === 'trail' ? null : prev);
|
|
1902
|
+
if (pendingFocusFitRef.current != null) {
|
|
1903
|
+
window.clearTimeout(pendingFocusFitRef.current);
|
|
1904
|
+
pendingFocusFitRef.current = null;
|
|
1905
|
+
}
|
|
1906
|
+
if (drawerWillClose) {
|
|
1907
|
+
// Wait for the canvas to reclaim the drawer's height, or the fit uses
|
|
1908
|
+
// the temporarily shortened viewport and settles too far off-centre.
|
|
1909
|
+
pendingFocusFitRef.current = window.setTimeout(() => {
|
|
1910
|
+
pendingFocusFitRef.current = null;
|
|
1911
|
+
requestAnimationFrame(() => fitFocusBounds(edgeIds));
|
|
1912
|
+
}, FILE_DRAWER_HEIGHT_MS + 20);
|
|
1913
|
+
}
|
|
1914
|
+
else {
|
|
1915
|
+
fitFocusBounds(edgeIds);
|
|
1916
|
+
}
|
|
1917
|
+
}, [
|
|
1918
|
+
fitFocusBounds,
|
|
1919
|
+
trailStepMode,
|
|
1920
|
+
onTrailSelect,
|
|
1921
|
+
onSidebarTrailChange,
|
|
1922
|
+
drawerTarget,
|
|
1923
|
+
]);
|
|
1818
1924
|
const clearTrailFocus = useCallback(() => {
|
|
1819
1925
|
if (pendingFocusFitRef.current != null) {
|
|
1820
1926
|
window.clearTimeout(pendingFocusFitRef.current);
|
|
@@ -1866,7 +1972,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1866
1972
|
// step focus and returns to whole-flow (high-level) framing.
|
|
1867
1973
|
// In `dim` mode: only dim non-participants (same as hovering a step) —
|
|
1868
1974
|
// no camera move, no drawer, no hide.
|
|
1869
|
-
const focusTrailStep = useCallback((tl, stepIndex) => {
|
|
1975
|
+
const focusTrailStep = useCallback((tl, stepIndex, showFile = true) => {
|
|
1870
1976
|
const step = tl.steps[stepIndex];
|
|
1871
1977
|
if (!step)
|
|
1872
1978
|
return;
|
|
@@ -1880,6 +1986,11 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1880
1986
|
onTrailSelect?.(null);
|
|
1881
1987
|
return;
|
|
1882
1988
|
}
|
|
1989
|
+
// Opening the focused step's containing frames is what makes an
|
|
1990
|
+
// intra-process edge (e.g. api → store) renderable at all. Without this,
|
|
1991
|
+
// host-driven step focus can only frame cross-boundary hops.
|
|
1992
|
+
setExpandedTrails(new Set([tl.id]));
|
|
1993
|
+
setLayoutTrailId(tl.id);
|
|
1883
1994
|
// Toggle: clicking the selected step unselects it (back to whole flow).
|
|
1884
1995
|
onSidebarTrailChange(tl.id);
|
|
1885
1996
|
if (focusedTrailId === tl.id && focusedStepIndex === stepIndex) {
|
|
@@ -1887,7 +1998,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1887
1998
|
// Pointer is still over the row — keep hover preview so dimming doesn't
|
|
1888
1999
|
// flash off until mouseleave.
|
|
1889
2000
|
setHoveredTrailStep({ trailId: tl.id, stepIndex });
|
|
1890
|
-
setDrawerTarget((prev) =>
|
|
2001
|
+
setDrawerTarget((prev) => !showFile ? null : prev?.kind === 'trail' ? null : prev);
|
|
1891
2002
|
if (pendingFocusFitRef.current != null) {
|
|
1892
2003
|
window.clearTimeout(pendingFocusFitRef.current);
|
|
1893
2004
|
pendingFocusFitRef.current = null;
|
|
@@ -1899,10 +2010,13 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1899
2010
|
setFocusedTrailId(tl.id);
|
|
1900
2011
|
setHoveredTrailStep(null);
|
|
1901
2012
|
onTrailSelect?.({ trailId: tl.id, stepIndices: [stepIndex] });
|
|
1902
|
-
//
|
|
1903
|
-
// transition
|
|
2013
|
+
// The drawer changes the usable canvas height, so wait for its height
|
|
2014
|
+
// transition whenever we open or close it — not just when opening.
|
|
1904
2015
|
const drawerWasOpen = drawerOpenRef.current;
|
|
1905
|
-
if (
|
|
2016
|
+
if (!showFile) {
|
|
2017
|
+
setDrawerTarget(null);
|
|
2018
|
+
}
|
|
2019
|
+
else if (renderTrailViewer) {
|
|
1906
2020
|
setDrawerTarget({
|
|
1907
2021
|
kind: 'trail',
|
|
1908
2022
|
trailId: tl.id,
|
|
@@ -1922,7 +2036,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1922
2036
|
window.clearTimeout(pendingFocusFitRef.current);
|
|
1923
2037
|
pendingFocusFitRef.current = null;
|
|
1924
2038
|
}
|
|
1925
|
-
if (drawerWasOpen) {
|
|
2039
|
+
if (drawerWasOpen === showFile) {
|
|
1926
2040
|
fitFocusBounds(edgeIds);
|
|
1927
2041
|
}
|
|
1928
2042
|
else {
|
|
@@ -1940,6 +2054,49 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1940
2054
|
onTrailSelect,
|
|
1941
2055
|
onSidebarTrailChange,
|
|
1942
2056
|
]);
|
|
2057
|
+
// Host-controlled trail focus for agent-driven walkthroughs. Unlike
|
|
2058
|
+
// `initialTrailId`, this is repeatable. A `stepIndex` focuses one step;
|
|
2059
|
+
// omitting it frames the whole trail. `showFile: false` selects without
|
|
2060
|
+
// opening the file/trail drawer. `undefined` leaves graph-owned focus alone;
|
|
2061
|
+
// `null` hands control back to the graph.
|
|
2062
|
+
const appliedFocusedTrailStepRef = useRef(null);
|
|
2063
|
+
useEffect(() => {
|
|
2064
|
+
if (focusedTrailStep === undefined)
|
|
2065
|
+
return;
|
|
2066
|
+
if (focusedTrailStep === null) {
|
|
2067
|
+
if (appliedFocusedTrailStepRef.current == null)
|
|
2068
|
+
return;
|
|
2069
|
+
appliedFocusedTrailStepRef.current = null;
|
|
2070
|
+
clearTrailFocus();
|
|
2071
|
+
return;
|
|
2072
|
+
}
|
|
2073
|
+
const { trailId, stepIndex } = focusedTrailStep;
|
|
2074
|
+
const showFile = focusedTrailStep.showFile ?? stepIndex != null;
|
|
2075
|
+
const key = `${trailId}:${stepIndex ?? 'trail'}:${showFile ? 'file' : 'nofile'}`;
|
|
2076
|
+
if (appliedFocusedTrailStepRef.current === key)
|
|
2077
|
+
return;
|
|
2078
|
+
if (!layoutReady || !trails?.length)
|
|
2079
|
+
return;
|
|
2080
|
+
const tl = trails.find((t) => t.id === trailId);
|
|
2081
|
+
if (!tl)
|
|
2082
|
+
return;
|
|
2083
|
+
if (stepIndex != null && !tl.steps[stepIndex])
|
|
2084
|
+
return;
|
|
2085
|
+
appliedFocusedTrailStepRef.current = key;
|
|
2086
|
+
if (stepIndex == null) {
|
|
2087
|
+
focusTrailEdges(tl, !showFile);
|
|
2088
|
+
}
|
|
2089
|
+
else {
|
|
2090
|
+
focusTrailStep(tl, stepIndex, showFile);
|
|
2091
|
+
}
|
|
2092
|
+
}, [
|
|
2093
|
+
focusedTrailStep,
|
|
2094
|
+
layoutReady,
|
|
2095
|
+
trails,
|
|
2096
|
+
focusTrailEdges,
|
|
2097
|
+
focusTrailStep,
|
|
2098
|
+
clearTrailFocus,
|
|
2099
|
+
]);
|
|
1943
2100
|
useEffect(() => {
|
|
1944
2101
|
return () => {
|
|
1945
2102
|
if (pendingFocusFitRef.current != null) {
|
|
@@ -2366,7 +2523,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2366
2523
|
if (file)
|
|
2367
2524
|
onOpenDeclarationFile(file);
|
|
2368
2525
|
} })) : null;
|
|
2369
|
-
const trailNavigation = trails && trails.length > 0 ? (_jsx(TrailsPanel, { drilldown: trailStepMode !== 'dim', trails: trails, expandedTrails: expandedTrails, focusedTrailId: sidebarTrail?.id ?? focusedTrailId, focusedStepIndex: !sidebarTrail || focusedTrailId === sidebarTrail.id ? focusedStepIndex : null, detailContent: sidebarPanel, hoveredTrailStep: hoveredTrailStep, onToggleCollapsed: toggleTrailCollapsed, onFocusFlow: focusTrailEdges, onClearFocus: clearTrailFocus, onFocusStep: focusTrailStep, onHoverStep: (tl, i) => {
|
|
2526
|
+
const trailNavigation = trails && trails.length > 0 ? (_jsx(TrailsPanel, { drilldown: trailStepMode !== 'dim', trails: trails, expandedTrails: expandedTrails, focusedTrailId: sidebarTrail?.id ?? focusedTrailId, focusedStepIndex: !sidebarTrail || focusedTrailId === sidebarTrail.id ? focusedStepIndex : null, proposedTrailIds: proposedTrailIds, proposedStepKeys: proposedStepKeys, stepChange: stepChange, showPreviousStep: showPreviousStep, onTogglePreviousStep: onTogglePreviousStep, detailContent: sidebarPanel, hoveredTrailStep: hoveredTrailStep, onToggleCollapsed: toggleTrailCollapsed, onFocusFlow: focusTrailEdges, onClearFocus: clearTrailFocus, onFocusStep: focusTrailStep, onHoverStep: (tl, i) => {
|
|
2370
2527
|
cancelPendingHoverLeave();
|
|
2371
2528
|
setHoveredTrailStep({ trailId: tl.id, stepIndex: i });
|
|
2372
2529
|
onTrailStepHover?.({ trailId: tl.id, stepIndex: i });
|
|
@@ -2792,7 +2949,7 @@ export function SubsystemComponentGraph(props) {
|
|
|
2792
2949
|
minHeight: 0,
|
|
2793
2950
|
display: 'flex',
|
|
2794
2951
|
flexDirection: 'column',
|
|
2795
|
-
}, children: [!constructsOnly && !props.hideSidebar && (_jsxs("header", { style: {
|
|
2952
|
+
}, children: [!constructsOnly && !props.hideSidebar && !props.hideHeader && (_jsxs("header", { style: {
|
|
2796
2953
|
flexShrink: 0,
|
|
2797
2954
|
display: 'flex',
|
|
2798
2955
|
alignItems: 'center',
|