@principal-ai/subsystems-react 0.56.35 → 0.56.36
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 +50 -8
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +291 -50
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/TrailStepsNav.d.ts +1 -1
- package/dist/subsystem/TrailStepsNav.d.ts.map +1 -1
- package/dist/subsystem/TrailStepsNav.js +2 -1
- package/dist/subsystem/TrailStepsNav.js.map +1 -1
- package/dist/subsystem/TrailsPanel.d.ts +5 -5
- package/dist/subsystem/TrailsPanel.d.ts.map +1 -1
- package/dist/subsystem/TrailsPanel.js +23 -43
- package/dist/subsystem/TrailsPanel.js.map +1 -1
- package/dist/subsystem/model.d.ts +21 -6
- package/dist/subsystem/model.d.ts.map +1 -1
- package/dist/subsystem/model.js +48 -45
- package/dist/subsystem/model.js.map +1 -1
- package/dist/subsystem/nodeIconography.d.ts +25 -0
- package/dist/subsystem/nodeIconography.d.ts.map +1 -0
- package/dist/subsystem/nodeIconography.js +55 -0
- package/dist/subsystem/nodeIconography.js.map +1 -0
- package/dist/subsystem/nodes.d.ts +4 -3
- package/dist/subsystem/nodes.d.ts.map +1 -1
- package/dist/subsystem/nodes.js +125 -211
- package/dist/subsystem/nodes.js.map +1 -1
- package/dist/subsystem/stepEmphasis.d.ts +5 -0
- package/dist/subsystem/stepEmphasis.d.ts.map +1 -1
- package/dist/subsystem/stepEmphasis.js +7 -0
- package/dist/subsystem/stepEmphasis.js.map +1 -1
- package/package.json +1 -1
- package/src/stories/Canvases/Subsystem/AgentDrivenWalkthrough.stories.tsx +229 -157
- package/src/stories/Canvases/Subsystem/Deprecated.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/NodeAnatomy.stories.tsx +17 -21
- package/src/stories/Canvases/Subsystem/NodeIconography.stories.tsx +791 -21
- package/src/stories/Canvases/Subsystem/Spotlights.stories.tsx +1 -1
- package/src/subsystem/SubsystemComponentGraph.tsx +359 -62
- package/src/subsystem/TrailStepsNav.tsx +2 -2
- package/src/subsystem/TrailsPanel.tsx +35 -89
- package/src/subsystem/model.test.ts +17 -13
- package/src/subsystem/model.ts +60 -48
- package/src/subsystem/nodeIconography.ts +88 -0
- package/src/subsystem/nodes.component.test.tsx +177 -0
- package/src/subsystem/nodes.tsx +225 -268
- package/src/subsystem/stepEmphasis.ts +8 -0
|
@@ -20,7 +20,7 @@ import { ReactFlow, ReactFlowProvider, useReactFlow, useStore, useViewport, getV
|
|
|
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';
|
|
23
|
-
import { buildSubsystemGraph, componentPackageKey, deriveGraphEdges, buildBoundaryLayoutGroups, cardFramesForAliases, isCardFrame, isConstructsOnlyModel, packageColor, moduleGroupNodeId, processGroupNodeId, isTrailMechanism, edgeColor, MECHANISM_DESCRIPTIONS, subsystemGraphLayoutKey, trailStepGraphEdgeId, unroutedEdgeIds, } from './model';
|
|
23
|
+
import { buildSubsystemGraph, componentPackageKey, deriveGraphEdges, buildBoundaryLayoutGroups, cardFramesForAliases, isCardFrame, isConstructsOnlyModel, packageColor, moduleGroupNodeId, processGroupNodeId, isTrailMechanism, edgeColor, HOST_PROPOSAL_COLOR, MECHANISM_DESCRIPTIONS, subsystemGraphLayoutKey, trailStepGraphEdgeId, unroutedEdgeIds, } from './model';
|
|
24
24
|
import { ConstructsCatalog } from './ConstructsCatalog';
|
|
25
25
|
import { ContainersPanel } from './ContainersPanel';
|
|
26
26
|
import { technologyBrand } from './techIcons';
|
|
@@ -40,6 +40,7 @@ import { ShareButton } from './ShareButton';
|
|
|
40
40
|
import { DescriptionOverlay } from './DescriptionOverlay';
|
|
41
41
|
import { DescriptionPreview } from './DescriptionPreview';
|
|
42
42
|
import { TrailsPanel, TRAIL_PLAY_PAUSE_MS, TRAIL_HOVER_PREVIEW_MS, } from './TrailsPanel';
|
|
43
|
+
import { emphasisKey, variationStepNumber } from './stepEmphasis';
|
|
43
44
|
import { EDGE_LABEL_WIDTH, EDGE_LABEL_HEIGHT, EDGE_LABEL_FONT_SIZE, EDGE_LABEL_CLOUD_PATH, EDGE_LABEL_CLOUD_EXTRA_TOP, } from '../utils/edgeLabel';
|
|
44
45
|
import { graphGeometryBounds } from '../utils/elkLayout';
|
|
45
46
|
/** Identifiers a token could match to name this component as a construct. */
|
|
@@ -179,7 +180,7 @@ const TrailDrawerContent = memo(function TrailDrawerContent({ render, trail, ste
|
|
|
179
180
|
onVisibleStepChange,
|
|
180
181
|
}) }));
|
|
181
182
|
});
|
|
182
|
-
function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirection: layoutDirectionProp, defaultLayoutDirection = 'horizontal', onLayoutDirectionChange, hideLayoutToggle = false, refocusOnLayoutFlip = true, initialTrailId, onTrailSelect, focusedTrailStep, proposedTrailIds, proposedStepKeys, stepChange,
|
|
183
|
+
function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirection: layoutDirectionProp, defaultLayoutDirection = 'horizontal', onLayoutDirectionChange, hideLayoutToggle = false, refocusOnLayoutFlip = true, initialTrailId, onTrailSelect, focusedTrailStep, proposedTrailIds, proposedStepKeys, stepChange, stepNumberLabels: hostStepNumberLabels, stepHistory, proposedStep, focusedVariationStepIndexes, 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
184
|
const { theme } = useTheme();
|
|
184
185
|
const { fitView, fitBounds, setViewport } = useReactFlow();
|
|
185
186
|
const flowWidth = useStore((state) => state.width);
|
|
@@ -201,7 +202,131 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
201
202
|
// Restored once per mount from `localStorage` (see `readViewState`). Each
|
|
202
203
|
// graph is its own tab/mount, so `persistKey` is stable for a mount.
|
|
203
204
|
const persisted = useMemo(() => readViewState(persistKey), [persistKey]);
|
|
204
|
-
|
|
205
|
+
// Host-local before/after links. The graph keeps the unchanged step in its
|
|
206
|
+
// layout and camera bounds, while the sidebar still renders only live steps.
|
|
207
|
+
const ghostLinksByTrail = useMemo(() => {
|
|
208
|
+
const map = new Map();
|
|
209
|
+
for (const link of stepHistory ?? []) {
|
|
210
|
+
const list = map.get(link.trailId) ?? [];
|
|
211
|
+
list.push(link);
|
|
212
|
+
map.set(link.trailId, list);
|
|
213
|
+
}
|
|
214
|
+
return map;
|
|
215
|
+
}, [stepHistory]);
|
|
216
|
+
const proposedEdgeId = proposedStep
|
|
217
|
+
? trailStepGraphEdgeId(proposedStep.step)
|
|
218
|
+
: null;
|
|
219
|
+
const proposedEdgeIds = useMemo(() => new Set(proposedEdgeId ? [proposedEdgeId] : []), [proposedEdgeId]);
|
|
220
|
+
// The staged step is a variation of the step it would replace, not the next
|
|
221
|
+
// sequential step. Share that label with the panel and the canvas edge.
|
|
222
|
+
const proposedStepLabel = proposedStep
|
|
223
|
+
? variationStepNumber(proposedStep.stepIndex + 1)
|
|
224
|
+
: null;
|
|
225
|
+
const proposedStepNumberLabels = useMemo(() => proposedStep && proposedStepLabel
|
|
226
|
+
? new Map([
|
|
227
|
+
[emphasisKey(proposedStep.trailId, proposedStep.step), proposedStepLabel],
|
|
228
|
+
])
|
|
229
|
+
: undefined, [proposedStep, proposedStepLabel]);
|
|
230
|
+
const panelStepNumberLabels = useMemo(() => {
|
|
231
|
+
if (!hostStepNumberLabels)
|
|
232
|
+
return proposedStepNumberLabels;
|
|
233
|
+
if (!proposedStepNumberLabels)
|
|
234
|
+
return hostStepNumberLabels;
|
|
235
|
+
return new Map([...proposedStepNumberLabels, ...hostStepNumberLabels]);
|
|
236
|
+
}, [hostStepNumberLabels, proposedStepNumberLabels]);
|
|
237
|
+
const ghostEdgeIds = useMemo(() => {
|
|
238
|
+
const ids = new Set();
|
|
239
|
+
for (const links of ghostLinksByTrail.values()) {
|
|
240
|
+
for (const link of links)
|
|
241
|
+
ids.add(trailStepGraphEdgeId(link.previous));
|
|
242
|
+
}
|
|
243
|
+
return ids;
|
|
244
|
+
}, [ghostLinksByTrail]);
|
|
245
|
+
// Both accepted history and a staged proposal join the layout and the camera
|
|
246
|
+
// bounds. The sidebar still renders only the live `trails` prop.
|
|
247
|
+
const linkedEdgeIdsByTrail = useMemo(() => {
|
|
248
|
+
const map = new Map();
|
|
249
|
+
const add = (trailId, id) => {
|
|
250
|
+
const ids = map.get(trailId) ?? new Set();
|
|
251
|
+
ids.add(id);
|
|
252
|
+
map.set(trailId, ids);
|
|
253
|
+
};
|
|
254
|
+
for (const [trailId, links] of ghostLinksByTrail) {
|
|
255
|
+
for (const link of links)
|
|
256
|
+
add(trailId, trailStepGraphEdgeId(link.previous));
|
|
257
|
+
}
|
|
258
|
+
if (proposedStep) {
|
|
259
|
+
if (proposedEdgeId)
|
|
260
|
+
add(proposedStep.trailId, proposedEdgeId);
|
|
261
|
+
// The step being varied stays in focus beside its staged replacement,
|
|
262
|
+
// whichever of the two the guide currently points at.
|
|
263
|
+
const sourceStep = trails
|
|
264
|
+
?.find((t) => t.id === proposedStep.trailId)
|
|
265
|
+
?.steps[proposedStep.stepIndex];
|
|
266
|
+
if (sourceStep)
|
|
267
|
+
add(proposedStep.trailId, trailStepGraphEdgeId(sourceStep));
|
|
268
|
+
}
|
|
269
|
+
return map;
|
|
270
|
+
}, [ghostLinksByTrail, proposedStep, proposedEdgeId, trails]);
|
|
271
|
+
const layoutTrails = useMemo(() => {
|
|
272
|
+
let merged = trails ?? [];
|
|
273
|
+
if (stepHistory?.length) {
|
|
274
|
+
merged = merged.map((tl) => {
|
|
275
|
+
const links = ghostLinksByTrail.get(tl.id);
|
|
276
|
+
if (!links?.length)
|
|
277
|
+
return tl;
|
|
278
|
+
const steps = [...tl.steps];
|
|
279
|
+
// Descending order keeps earlier original indices stable when several
|
|
280
|
+
// steps of one trail were changed or removed in the same proposal.
|
|
281
|
+
for (const link of [...links].sort((a, b) => b.stepIndex - a.stepIndex)) {
|
|
282
|
+
// The accepted variation can already be a live row beside its
|
|
283
|
+
// original; never duplicate the previous step in the layout.
|
|
284
|
+
const previousKey = trailStepGraphEdgeId(link.previous);
|
|
285
|
+
if (steps.some((step) => trailStepGraphEdgeId(step) === previousKey)) {
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
const at = link.kind === 'changed'
|
|
289
|
+
? Math.min(link.stepIndex + 1, steps.length)
|
|
290
|
+
: Math.min(link.stepIndex, steps.length);
|
|
291
|
+
steps.splice(at, 0, link.previous);
|
|
292
|
+
}
|
|
293
|
+
return { ...tl, steps };
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
if (proposedStep) {
|
|
297
|
+
merged = merged.map((tl) => {
|
|
298
|
+
if (tl.id !== proposedStep.trailId)
|
|
299
|
+
return tl;
|
|
300
|
+
const steps = [...tl.steps];
|
|
301
|
+
steps.splice(Math.min(proposedStep.stepIndex + 1, steps.length), 0, proposedStep.step);
|
|
302
|
+
return { ...tl, steps };
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
return merged;
|
|
306
|
+
}, [trails, stepHistory, ghostLinksByTrail, proposedStep]);
|
|
307
|
+
// Every step in a host-declared variation group stays in the focused set,
|
|
308
|
+
// even though the guide only names one of them as its active step. Indexes
|
|
309
|
+
// are resolved against `layoutTrails`, which also carries the staged step.
|
|
310
|
+
const variationEdgeIdsByTrail = useMemo(() => {
|
|
311
|
+
const map = new Map();
|
|
312
|
+
if (!focusedVariationStepIndexes)
|
|
313
|
+
return map;
|
|
314
|
+
for (const [trailId, indexes] of focusedVariationStepIndexes) {
|
|
315
|
+
const tl = layoutTrails.find((t) => t.id === trailId);
|
|
316
|
+
if (!tl)
|
|
317
|
+
continue;
|
|
318
|
+
const ids = new Set();
|
|
319
|
+
for (const index of indexes) {
|
|
320
|
+
const step = tl.steps[index];
|
|
321
|
+
if (step)
|
|
322
|
+
ids.add(trailStepGraphEdgeId(step));
|
|
323
|
+
}
|
|
324
|
+
if (ids.size > 0)
|
|
325
|
+
map.set(trailId, ids);
|
|
326
|
+
}
|
|
327
|
+
return map;
|
|
328
|
+
}, [focusedVariationStepIndexes, layoutTrails]);
|
|
329
|
+
const graphEdges = useMemo(() => deriveGraphEdges({ trails: layoutTrails }), [layoutTrails]);
|
|
205
330
|
const [built, setBuilt] = useState({
|
|
206
331
|
nodes: [],
|
|
207
332
|
edges: [],
|
|
@@ -468,14 +593,20 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
468
593
|
// Keyed on `built` as well as `layoutReady`: whichever of the two passes
|
|
469
594
|
// lands last is the one that has the final positions.
|
|
470
595
|
useEffect(() => {
|
|
471
|
-
if (!layoutReady
|
|
596
|
+
if (!layoutReady)
|
|
472
597
|
return;
|
|
598
|
+
// A staged proposal changes the graph's content without changing the
|
|
599
|
+
// layout flip keys, so the camera must re-fit whenever the new layout
|
|
600
|
+
// lands — not only for an animated direction/frame flip. While a step is
|
|
601
|
+
// focused, its edge group owns the camera; never fall back to a
|
|
602
|
+
// whole-graph fit here.
|
|
603
|
+
const shouldRefitFocus = focusEdgeIdsRef.current != null;
|
|
604
|
+
const shouldRefitGraph = refitAfterLayoutRef.current;
|
|
473
605
|
refitAfterLayoutRef.current = false;
|
|
606
|
+
if (!shouldRefitFocus && !shouldRefitGraph)
|
|
607
|
+
return;
|
|
474
608
|
requestAnimationFrame(() => {
|
|
475
|
-
|
|
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) {
|
|
609
|
+
if (shouldRefitFocus && focusEdgeIdsRef.current) {
|
|
479
610
|
fitFocusBoundsRef.current(focusEdgeIdsRef.current);
|
|
480
611
|
}
|
|
481
612
|
else {
|
|
@@ -734,8 +865,8 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
734
865
|
// edge fade like every other layout flip.
|
|
735
866
|
const layoutDoc = useMemo(() => {
|
|
736
867
|
if (!committedTrailId)
|
|
737
|
-
return { components, trails };
|
|
738
|
-
const trail = (
|
|
868
|
+
return { components, trails: layoutTrails };
|
|
869
|
+
const trail = (layoutTrails ?? []).find((t) => t.id === committedTrailId);
|
|
739
870
|
if (!trail)
|
|
740
871
|
return { components, trails };
|
|
741
872
|
// Host-local removal ghosts stay in the layout even when their steps are
|
|
@@ -750,7 +881,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
750
881
|
components: components.filter((c) => aliases.has(c.alias)),
|
|
751
882
|
trails: [trail],
|
|
752
883
|
};
|
|
753
|
-
}, [components,
|
|
884
|
+
}, [components, layoutTrails, committedTrailId, removedComponentAliases]);
|
|
754
885
|
const layoutRelations = committedTrailId ? undefined : graphifyRelations;
|
|
755
886
|
const layoutKey = useMemo(() => subsystemGraphLayoutKey({
|
|
756
887
|
components: layoutDoc.components,
|
|
@@ -1207,27 +1338,44 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1207
1338
|
// Edge ids in trail focus (an active flow's edge set, or a single
|
|
1208
1339
|
// step's edge). Used to frame the camera. `null` = no trail focus.
|
|
1209
1340
|
const focusEdgeIds = useMemo(() => {
|
|
1341
|
+
const withLinked = (trailId, ids) => {
|
|
1342
|
+
for (const id of linkedEdgeIdsByTrail.get(trailId) ?? [])
|
|
1343
|
+
ids.add(id);
|
|
1344
|
+
// All variations of the focused step are one focus group: the camera and
|
|
1345
|
+
// dimming must treat them as a single set, not just the active step.
|
|
1346
|
+
for (const id of variationEdgeIdsByTrail.get(trailId) ?? [])
|
|
1347
|
+
ids.add(id);
|
|
1348
|
+
return ids;
|
|
1349
|
+
};
|
|
1210
1350
|
if (autoPlayFocus) {
|
|
1211
1351
|
const tl = trails?.find((t) => t.id === autoPlayFocus.trailId);
|
|
1212
1352
|
const step = tl?.steps[autoPlayFocus.stepIndex];
|
|
1213
|
-
return step
|
|
1353
|
+
return step
|
|
1354
|
+
? withLinked(autoPlayFocus.trailId, new Set([trailStepGraphEdgeId(step)]))
|
|
1355
|
+
: null;
|
|
1214
1356
|
}
|
|
1215
|
-
if (focusedTrailId == null
|
|
1357
|
+
if (focusedTrailId == null)
|
|
1216
1358
|
return null;
|
|
1217
|
-
|
|
1359
|
+
// Host focus indexes can point at a staged step that exists only in the
|
|
1360
|
+
// layout trails, so resolve them there rather than in the live `trails`.
|
|
1361
|
+
const tl = layoutTrails.find((t) => t.id === focusedTrailId);
|
|
1218
1362
|
if (!tl)
|
|
1219
1363
|
return null;
|
|
1220
1364
|
if (focusedStepIndex != null) {
|
|
1221
1365
|
const step = tl.steps[focusedStepIndex];
|
|
1222
|
-
return step
|
|
1366
|
+
return step
|
|
1367
|
+
? withLinked(focusedTrailId, new Set([trailStepGraphEdgeId(step)]))
|
|
1368
|
+
: null;
|
|
1223
1369
|
}
|
|
1224
|
-
return new Set(tl.steps.map((s) => trailStepGraphEdgeId(s)));
|
|
1225
|
-
}, [trails, focusedTrailId, focusedStepIndex, autoPlayFocus]);
|
|
1370
|
+
return withLinked(focusedTrailId, new Set(tl.steps.map((s) => trailStepGraphEdgeId(s))));
|
|
1371
|
+
}, [trails, layoutTrails, focusedTrailId, focusedStepIndex, autoPlayFocus, linkedEdgeIdsByTrail, variationEdgeIdsByTrail]);
|
|
1226
1372
|
// Keep these refs current during render, not in a later effect: the
|
|
1227
1373
|
// post-layout refit effect is declared above and must see the focus that
|
|
1228
1374
|
// triggered this layout swap, or it falls back to a whole-graph fit.
|
|
1229
1375
|
stepFocusActiveRef.current =
|
|
1230
|
-
autoPlayFocus == null &&
|
|
1376
|
+
autoPlayFocus == null &&
|
|
1377
|
+
focusedTrailId != null &&
|
|
1378
|
+
focusedStepIndex != null;
|
|
1231
1379
|
focusEdgeIdsRef.current = focusEdgeIds;
|
|
1232
1380
|
// 1-based step numbers per edge of the active flow (focused or
|
|
1233
1381
|
// hover/autoplay-highlighted). An edge can appear in more than one step.
|
|
@@ -1256,9 +1404,11 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1256
1404
|
continue;
|
|
1257
1405
|
for (const s of tl.steps)
|
|
1258
1406
|
ids.add(trailStepGraphEdgeId(s));
|
|
1407
|
+
for (const id of linkedEdgeIdsByTrail.get(tl.id) ?? [])
|
|
1408
|
+
ids.add(id);
|
|
1259
1409
|
}
|
|
1260
1410
|
return ids.size > 0 ? ids : null;
|
|
1261
|
-
}, [trails, expandedTrails]);
|
|
1411
|
+
}, [trails, expandedTrails, linkedEdgeIdsByTrail]);
|
|
1262
1412
|
const endpointsOf = (edgeIds) => {
|
|
1263
1413
|
if (!edgeIds)
|
|
1264
1414
|
return null;
|
|
@@ -1278,12 +1428,18 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1278
1428
|
const tl = trails.find((t) => t.id === hoveredTrailStep.trailId);
|
|
1279
1429
|
if (!tl)
|
|
1280
1430
|
return null;
|
|
1431
|
+
const ghosts = linkedEdgeIdsByTrail.get(hoveredTrailStep.trailId) ?? [];
|
|
1281
1432
|
if (hoveredTrailStep.stepIndex == null) {
|
|
1282
|
-
return new Set(
|
|
1433
|
+
return new Set([
|
|
1434
|
+
...tl.steps.map((s) => trailStepGraphEdgeId(s)),
|
|
1435
|
+
...ghosts,
|
|
1436
|
+
]);
|
|
1283
1437
|
}
|
|
1284
1438
|
const step = tl.steps[hoveredTrailStep.stepIndex];
|
|
1285
|
-
return step
|
|
1286
|
-
|
|
1439
|
+
return step
|
|
1440
|
+
? new Set([trailStepGraphEdgeId(step), ...ghosts])
|
|
1441
|
+
: null;
|
|
1442
|
+
}, [trails, hoveredTrailStep, linkedEdgeIdsByTrail]);
|
|
1287
1443
|
// While hovering with a *step* already selected, brighten the union of
|
|
1288
1444
|
// selected + hovered participants. Whole-flow focus (or no focus) keeps
|
|
1289
1445
|
// the old hover-replace preview so a step hover still dims the rest.
|
|
@@ -1472,14 +1628,21 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1472
1628
|
const baseNodesKey = useMemo(() => nodes.map((n) => n.id).sort().join(','), [nodes]);
|
|
1473
1629
|
const baseEdgesKey = useMemo(() => convertedEdges.map((e) => e.id).sort().join(','), [convertedEdges]);
|
|
1474
1630
|
const dispEdges = useMemo(() => {
|
|
1475
|
-
const paint = (e, dimmed) => {
|
|
1631
|
+
const paint = (e, dimmed, proposed) => {
|
|
1476
1632
|
const markerEnd = e.markerEnd;
|
|
1477
|
-
const nextMarker =
|
|
1478
|
-
? {
|
|
1633
|
+
const nextMarker = markerEnd && typeof markerEnd === 'object' && typeof markerEnd.color === 'string'
|
|
1634
|
+
? {
|
|
1635
|
+
...markerEnd,
|
|
1636
|
+
color: proposed
|
|
1637
|
+
? HOST_PROPOSAL_COLOR
|
|
1638
|
+
: dimmed
|
|
1639
|
+
? hexWithAlpha(markerEnd.color, EDGE_DIM_ALPHA)
|
|
1640
|
+
: markerEnd.color,
|
|
1641
|
+
}
|
|
1479
1642
|
: markerEnd;
|
|
1480
1643
|
return {
|
|
1481
1644
|
...e,
|
|
1482
|
-
data: { ...e.data, dimmed },
|
|
1645
|
+
data: { ...e.data, dimmed, proposed },
|
|
1483
1646
|
markerEnd: nextMarker,
|
|
1484
1647
|
};
|
|
1485
1648
|
};
|
|
@@ -1497,6 +1660,8 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1497
1660
|
const inSet = (set, e) => set != null && edgeMatches(set, e);
|
|
1498
1661
|
if (openedEdgeIds || focusEdgeIds || previewEdgeIds || issueFocusEdgeIds) {
|
|
1499
1662
|
return baseEdges.map((e) => {
|
|
1663
|
+
const ghost = ghostEdgeIds.has(e.id);
|
|
1664
|
+
const proposed = !ghost && proposedEdgeIds.has(e.id);
|
|
1500
1665
|
const vis = flowElementVisibility({
|
|
1501
1666
|
inOpened: inSet(openedEdgeIds, e),
|
|
1502
1667
|
inSelected: inSet(focusEdgeIds, e),
|
|
@@ -1504,19 +1669,39 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1504
1669
|
anySelected: focusEdgeIds != null,
|
|
1505
1670
|
});
|
|
1506
1671
|
const dimSource = previewEdgeIds ?? issueFocusEdgeIds;
|
|
1507
|
-
const dimmed = dimSource
|
|
1672
|
+
const dimmed = dimSource
|
|
1673
|
+
? vis.hidden || !inSet(dimSource, e)
|
|
1674
|
+
: vis.dimmed || ghost;
|
|
1508
1675
|
const hidden = vis.hidden || !edgeInView(e);
|
|
1509
|
-
return {
|
|
1676
|
+
return {
|
|
1677
|
+
...paint(e, dimmed, proposed),
|
|
1678
|
+
data: { ...e.data, dimmed, ghost, proposed },
|
|
1679
|
+
hidden,
|
|
1680
|
+
};
|
|
1510
1681
|
});
|
|
1511
1682
|
}
|
|
1512
1683
|
if (selectedEdgeId) {
|
|
1513
|
-
return baseEdges.map((e) =>
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1684
|
+
return baseEdges.map((e) => {
|
|
1685
|
+
const ghost = ghostEdgeIds.has(e.id);
|
|
1686
|
+
const proposed = !ghost && proposedEdgeIds.has(e.id);
|
|
1687
|
+
const dimmed = e.id !== selectedEdgeId || ghost;
|
|
1688
|
+
return {
|
|
1689
|
+
...paint(e, dimmed, proposed),
|
|
1690
|
+
data: { ...e.data, dimmed, ghost, proposed },
|
|
1691
|
+
hidden: !edgeInView(e),
|
|
1692
|
+
};
|
|
1693
|
+
});
|
|
1517
1694
|
}
|
|
1518
|
-
return baseEdges.map((e) =>
|
|
1519
|
-
|
|
1695
|
+
return baseEdges.map((e) => {
|
|
1696
|
+
const ghost = ghostEdgeIds.has(e.id);
|
|
1697
|
+
const proposed = !ghost && proposedEdgeIds.has(e.id);
|
|
1698
|
+
return {
|
|
1699
|
+
...paint(e, ghost, proposed),
|
|
1700
|
+
data: { ...e.data, dimmed: ghost, ghost, proposed },
|
|
1701
|
+
hidden: !edgeInView(e),
|
|
1702
|
+
};
|
|
1703
|
+
});
|
|
1704
|
+
}, [baseEdges, selectedEdgeId, openedEdgeIds, focusEdgeIds, previewEdgeIds, issueFocusEdgeIds, resolvedEdgeView, ghostEdgeIds, proposedEdgeIds]);
|
|
1520
1705
|
// Gated on layoutReady so the pre-reveal Pass 1 swap never flashes a count.
|
|
1521
1706
|
const unroutedIds = useMemo(() => (layoutReady ? unroutedEdgeIds(dispEdges) : []), [dispEdges, layoutReady]);
|
|
1522
1707
|
const onNodesChange = useCallback((changes) => {
|
|
@@ -1896,7 +2081,10 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1896
2081
|
setFocusedStepIndex(null);
|
|
1897
2082
|
setFocusedTrailId(tl.id);
|
|
1898
2083
|
onTrailSelect?.({ trailId: tl.id });
|
|
1899
|
-
const edgeIds = new Set(
|
|
2084
|
+
const edgeIds = new Set([
|
|
2085
|
+
...tl.steps.map((s) => trailStepGraphEdgeId(s)),
|
|
2086
|
+
...(linkedEdgeIdsByTrail.get(tl.id) ?? []),
|
|
2087
|
+
]);
|
|
1900
2088
|
const drawerWillClose = drawerOpenRef.current && (closeFile || drawerTarget?.kind === 'trail');
|
|
1901
2089
|
setDrawerTarget((prev) => closeFile || prev?.kind === 'trail' ? null : prev);
|
|
1902
2090
|
if (pendingFocusFitRef.current != null) {
|
|
@@ -1920,6 +2108,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1920
2108
|
onTrailSelect,
|
|
1921
2109
|
onSidebarTrailChange,
|
|
1922
2110
|
drawerTarget,
|
|
2111
|
+
linkedEdgeIdsByTrail,
|
|
1923
2112
|
]);
|
|
1924
2113
|
const clearTrailFocus = useCallback(() => {
|
|
1925
2114
|
if (pendingFocusFitRef.current != null) {
|
|
@@ -1969,10 +2158,12 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1969
2158
|
}, [initialTrailId, layoutReady, trails, focusTrailEdges]);
|
|
1970
2159
|
// Focus a single step's edge on the canvas and open/scroll the trail
|
|
1971
2160
|
// drawer to that step's snippet. Clicking the already-focused step clears
|
|
1972
|
-
// step focus and returns to whole-flow (high-level) framing.
|
|
2161
|
+
// step focus and returns to whole-flow (high-level) framing. Host-driven
|
|
2162
|
+
// re-fits pass `allowToggle: false` so a newly linked before/after edge
|
|
2163
|
+
// cannot be mistaken for a second click on the same step.
|
|
1973
2164
|
// In `dim` mode: only dim non-participants (same as hovering a step) —
|
|
1974
2165
|
// no camera move, no drawer, no hide.
|
|
1975
|
-
const focusTrailStep = useCallback((tl, stepIndex, showFile = true) => {
|
|
2166
|
+
const focusTrailStep = useCallback((tl, stepIndex, showFile = true, options) => {
|
|
1976
2167
|
const step = tl.steps[stepIndex];
|
|
1977
2168
|
if (!step)
|
|
1978
2169
|
return;
|
|
@@ -1993,7 +2184,9 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1993
2184
|
setLayoutTrailId(tl.id);
|
|
1994
2185
|
// Toggle: clicking the selected step unselects it (back to whole flow).
|
|
1995
2186
|
onSidebarTrailChange(tl.id);
|
|
1996
|
-
if (
|
|
2187
|
+
if ((options?.allowToggle ?? true) &&
|
|
2188
|
+
focusedTrailId === tl.id &&
|
|
2189
|
+
focusedStepIndex === stepIndex) {
|
|
1997
2190
|
setFocusedStepIndex(null);
|
|
1998
2191
|
// Pointer is still over the row — keep hover preview so dimming doesn't
|
|
1999
2192
|
// flash off until mouseleave.
|
|
@@ -2003,7 +2196,11 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2003
2196
|
window.clearTimeout(pendingFocusFitRef.current);
|
|
2004
2197
|
pendingFocusFitRef.current = null;
|
|
2005
2198
|
}
|
|
2006
|
-
fitFocusBounds(new Set(
|
|
2199
|
+
fitFocusBounds(new Set([
|
|
2200
|
+
...tl.steps.map((s) => trailStepGraphEdgeId(s)),
|
|
2201
|
+
...(linkedEdgeIdsByTrail.get(tl.id) ?? []),
|
|
2202
|
+
...(variationEdgeIdsByTrail.get(tl.id) ?? []),
|
|
2203
|
+
]));
|
|
2007
2204
|
return;
|
|
2008
2205
|
}
|
|
2009
2206
|
setFocusedStepIndex(stepIndex);
|
|
@@ -2031,7 +2228,11 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2031
2228
|
endLine: step.span?.endLine,
|
|
2032
2229
|
});
|
|
2033
2230
|
}
|
|
2034
|
-
const edgeIds = new Set([
|
|
2231
|
+
const edgeIds = new Set([
|
|
2232
|
+
trailStepGraphEdgeId(step),
|
|
2233
|
+
...(linkedEdgeIdsByTrail.get(tl.id) ?? []),
|
|
2234
|
+
...(variationEdgeIdsByTrail.get(tl.id) ?? []),
|
|
2235
|
+
]);
|
|
2035
2236
|
if (pendingFocusFitRef.current != null) {
|
|
2036
2237
|
window.clearTimeout(pendingFocusFitRef.current);
|
|
2037
2238
|
pendingFocusFitRef.current = null;
|
|
@@ -2053,6 +2254,8 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2053
2254
|
trailStepMode,
|
|
2054
2255
|
onTrailSelect,
|
|
2055
2256
|
onSidebarTrailChange,
|
|
2257
|
+
linkedEdgeIdsByTrail,
|
|
2258
|
+
variationEdgeIdsByTrail,
|
|
2056
2259
|
]);
|
|
2057
2260
|
// Host-controlled trail focus for agent-driven walkthroughs. Unlike
|
|
2058
2261
|
// `initialTrailId`, this is repeatable. A `stepIndex` focuses one step;
|
|
@@ -2072,12 +2275,24 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2072
2275
|
}
|
|
2073
2276
|
const { trailId, stepIndex } = focusedTrailStep;
|
|
2074
2277
|
const showFile = focusedTrailStep.showFile ?? stepIndex != null;
|
|
2075
|
-
|
|
2278
|
+
// A step's before/after links can arrive after the step itself (an agent
|
|
2279
|
+
// proposes, then commits). Include them in the key so the same focus is
|
|
2280
|
+
// re-fit when the staged or previous state joins the layout.
|
|
2281
|
+
const linkedKey = Array.from(linkedEdgeIdsByTrail.get(trailId) ?? [])
|
|
2282
|
+
.sort()
|
|
2283
|
+
.join(',');
|
|
2284
|
+
const variationKey = Array.from(focusedVariationStepIndexes?.get(trailId) ?? [])
|
|
2285
|
+
.sort((a, b) => a - b)
|
|
2286
|
+
.join(',');
|
|
2287
|
+
const key = `${trailId}:${stepIndex ?? 'trail'}:${showFile ? 'file' : 'nofile'}:${linkedKey}:${variationKey}`;
|
|
2076
2288
|
if (appliedFocusedTrailStepRef.current === key)
|
|
2077
2289
|
return;
|
|
2078
2290
|
if (!layoutReady || !trails?.length)
|
|
2079
2291
|
return;
|
|
2080
|
-
|
|
2292
|
+
// A guide step may point at a staged variation that only exists in the
|
|
2293
|
+
// layout trails; resolve focus there so it never silently falls back to
|
|
2294
|
+
// the step it replaces.
|
|
2295
|
+
const tl = layoutTrails.find((t) => t.id === trailId);
|
|
2081
2296
|
if (!tl)
|
|
2082
2297
|
return;
|
|
2083
2298
|
if (stepIndex != null && !tl.steps[stepIndex])
|
|
@@ -2087,7 +2302,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2087
2302
|
focusTrailEdges(tl, !showFile);
|
|
2088
2303
|
}
|
|
2089
2304
|
else {
|
|
2090
|
-
focusTrailStep(tl, stepIndex, showFile);
|
|
2305
|
+
focusTrailStep(tl, stepIndex, showFile, { allowToggle: false });
|
|
2091
2306
|
}
|
|
2092
2307
|
}, [
|
|
2093
2308
|
focusedTrailStep,
|
|
@@ -2096,6 +2311,9 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2096
2311
|
focusTrailEdges,
|
|
2097
2312
|
focusTrailStep,
|
|
2098
2313
|
clearTrailFocus,
|
|
2314
|
+
linkedEdgeIdsByTrail,
|
|
2315
|
+
focusedVariationStepIndexes,
|
|
2316
|
+
layoutTrails,
|
|
2099
2317
|
]);
|
|
2100
2318
|
useEffect(() => {
|
|
2101
2319
|
return () => {
|
|
@@ -2465,7 +2683,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2465
2683
|
if (e.hidden)
|
|
2466
2684
|
return false;
|
|
2467
2685
|
const d = e?.data;
|
|
2468
|
-
return !d?.dimmed;
|
|
2686
|
+
return !d?.dimmed || d?.ghost || d?.proposed;
|
|
2469
2687
|
})
|
|
2470
2688
|
.map((e) => {
|
|
2471
2689
|
const d = e.data;
|
|
@@ -2475,6 +2693,8 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2475
2693
|
mechanism: d?.mechanism ?? 'uses',
|
|
2476
2694
|
provenance: d?.provenance,
|
|
2477
2695
|
dimmed: d?.dimmed === true,
|
|
2696
|
+
ghost: d?.ghost === true,
|
|
2697
|
+
proposed: d?.proposed === true,
|
|
2478
2698
|
midX: d?.labelX ?? 0,
|
|
2479
2699
|
midY: d?.labelY ?? 0,
|
|
2480
2700
|
pathLength: d?.pathLength ?? 0,
|
|
@@ -2523,7 +2743,22 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2523
2743
|
if (file)
|
|
2524
2744
|
onOpenDeclarationFile(file);
|
|
2525
2745
|
} })) : null;
|
|
2526
|
-
|
|
2746
|
+
// The staged variation is a graph-layout row only. In the panel it has no
|
|
2747
|
+
// row, so its index would highlight the next real step instead.
|
|
2748
|
+
const panelFocusedVariationStepIndexes = useMemo(() => {
|
|
2749
|
+
if (!focusedVariationStepIndexes || !proposedStep) {
|
|
2750
|
+
return focusedVariationStepIndexes;
|
|
2751
|
+
}
|
|
2752
|
+
const stagedIndex = proposedStep.stepIndex + 1;
|
|
2753
|
+
const map = new Map();
|
|
2754
|
+
for (const [trailId, indexes] of focusedVariationStepIndexes) {
|
|
2755
|
+
const panelIndexes = new Set([...indexes].filter((index) => trailId !== proposedStep.trailId || index !== stagedIndex));
|
|
2756
|
+
if (panelIndexes.size)
|
|
2757
|
+
map.set(trailId, panelIndexes);
|
|
2758
|
+
}
|
|
2759
|
+
return map;
|
|
2760
|
+
}, [focusedVariationStepIndexes, proposedStep]);
|
|
2761
|
+
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, focusedVariationStepIndexes: panelFocusedVariationStepIndexes, stepNumberLabels: panelStepNumberLabels, stepChange: stepChange, detailContent: sidebarPanel, hoveredTrailStep: hoveredTrailStep, onToggleCollapsed: toggleTrailCollapsed, onFocusFlow: focusTrailEdges, onClearFocus: clearTrailFocus, onFocusStep: focusTrailStep, onHoverStep: (tl, i) => {
|
|
2527
2762
|
cancelPendingHoverLeave();
|
|
2528
2763
|
setHoveredTrailStep({ trailId: tl.id, stepIndex: i });
|
|
2529
2764
|
onTrailStepHover?.({ trailId: tl.id, stepIndex: i });
|
|
@@ -2583,7 +2818,9 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2583
2818
|
}, children: edgeLabels.map((lbl) => {
|
|
2584
2819
|
const mechanism = lbl.mechanism;
|
|
2585
2820
|
const isGraphify = lbl.provenance === 'graphify';
|
|
2586
|
-
const color =
|
|
2821
|
+
const color = lbl.proposed
|
|
2822
|
+
? HOST_PROPOSAL_COLOR
|
|
2823
|
+
: edgeColor({ mechanism, provenance: lbl.provenance });
|
|
2587
2824
|
// Label chrome stays the crisp rounded box for every edge — graphify
|
|
2588
2825
|
// provenance is carried by hue (GRAPHIFY_RELATION_COLOR), the dashed
|
|
2589
2826
|
// stroke, and the tooltip, NOT by the "ambiguous" cloud silhouette
|
|
@@ -2596,9 +2833,13 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2596
2833
|
: undefined;
|
|
2597
2834
|
const screenX = lbl.midX * viewport.zoom + viewport.x;
|
|
2598
2835
|
const screenY = lbl.midY * viewport.zoom + viewport.y;
|
|
2599
|
-
const text = lbl.
|
|
2600
|
-
?
|
|
2601
|
-
: lbl.
|
|
2836
|
+
const text = lbl.ghost
|
|
2837
|
+
? `was ${lbl.mechanism}`
|
|
2838
|
+
: lbl.proposed
|
|
2839
|
+
? `${proposedStepLabel ? `${proposedStepLabel}: ` : ''}${lbl.mechanism}`
|
|
2840
|
+
: lbl.stepNos?.length
|
|
2841
|
+
? `${lbl.stepNos.map((n) => `${n}:`).join(' ')} ${lbl.mechanism}`
|
|
2842
|
+
: lbl.mechanism;
|
|
2602
2843
|
return (_jsxs("div", { "data-edge-label": lbl.id, title: labelTitle, onClick: (e) => {
|
|
2603
2844
|
e.stopPropagation();
|
|
2604
2845
|
selectEdge(lbl.id);
|
|
@@ -2620,7 +2861,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2620
2861
|
padding: '7px 8px',
|
|
2621
2862
|
cursor: 'pointer',
|
|
2622
2863
|
pointerEvents: 'auto',
|
|
2623
|
-
opacity: lbl.dimmed ? 0.15 : 1,
|
|
2864
|
+
opacity: lbl.ghost ? 0.5 : lbl.proposed ? 1 : lbl.dimmed ? 0.15 : 1,
|
|
2624
2865
|
}, children: [verifiable ? (_jsx("span", { "aria-hidden": true, style: {
|
|
2625
2866
|
position: 'absolute',
|
|
2626
2867
|
inset: 0,
|