@principal-ai/subsystems-react 0.56.21 → 0.56.23
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/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/stories/Canvases/Aggregate/aggregateViewLargeFixture.d.ts +12 -0
- package/dist/stories/Canvases/Aggregate/aggregateViewLargeFixture.d.ts.map +1 -0
- package/dist/stories/Canvases/Aggregate/aggregateViewLargeFixture.js +4 -0
- package/dist/stories/Canvases/Aggregate/aggregateViewLargeFixture.js.map +1 -0
- package/dist/subsystem/C4Graph.d.ts +2 -69
- package/dist/subsystem/C4Graph.d.ts.map +1 -1
- package/dist/subsystem/C4Graph.js +8 -154
- package/dist/subsystem/C4Graph.js.map +1 -1
- package/dist/subsystem/C4NodeCard.d.ts +1 -47
- package/dist/subsystem/C4NodeCard.d.ts.map +1 -1
- package/dist/subsystem/C4NodeCard.js +6 -141
- package/dist/subsystem/C4NodeCard.js.map +1 -1
- package/dist/subsystem/ContainersPanel.d.ts +33 -0
- package/dist/subsystem/ContainersPanel.d.ts.map +1 -0
- package/dist/subsystem/ContainersPanel.js +116 -0
- package/dist/subsystem/ContainersPanel.js.map +1 -0
- package/dist/subsystem/SubsystemAggregateGraph.d.ts +14 -0
- package/dist/subsystem/SubsystemAggregateGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemAggregateGraph.js +116 -69
- package/dist/subsystem/SubsystemAggregateGraph.js.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts +18 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +143 -21
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/containerCard.d.ts +132 -0
- package/dist/subsystem/containerCard.d.ts.map +1 -0
- package/dist/subsystem/containerCard.js +167 -0
- package/dist/subsystem/containerCard.js.map +1 -0
- package/dist/subsystem/graphChrome.d.ts +11 -8
- package/dist/subsystem/graphChrome.d.ts.map +1 -1
- package/dist/subsystem/graphChrome.js +11 -9
- package/dist/subsystem/graphChrome.js.map +1 -1
- package/dist/subsystem/graphMorph.d.ts +142 -0
- package/dist/subsystem/graphMorph.d.ts.map +1 -0
- package/dist/subsystem/graphMorph.js +177 -0
- package/dist/subsystem/graphMorph.js.map +1 -0
- package/dist/subsystem/model.d.ts +89 -0
- package/dist/subsystem/model.d.ts.map +1 -1
- package/dist/subsystem/model.js +224 -15
- package/dist/subsystem/model.js.map +1 -1
- package/dist/subsystem/nodes.d.ts +9 -3
- package/dist/subsystem/nodes.d.ts.map +1 -1
- package/dist/subsystem/nodes.js +134 -82
- package/dist/subsystem/nodes.js.map +1 -1
- package/dist/utils/elkLayout.d.ts +11 -0
- package/dist/utils/elkLayout.d.ts.map +1 -1
- package/dist/utils/elkLayout.js +4 -3
- package/dist/utils/elkLayout.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +6 -0
- package/src/stories/Canvases/Aggregate/AggregateFrameGraph.stories.tsx +140 -2
- package/src/stories/Canvases/Aggregate/aggregateViewLargeFixture.ts +14 -0
- package/src/stories/Canvases/Subsystem/ContainerFrames.stories.tsx +132 -0
- package/src/subsystem/C4Graph.tsx +20 -180
- package/src/subsystem/C4NodeCard.tsx +34 -202
- package/src/subsystem/ContainersPanel.tsx +239 -0
- package/src/subsystem/SubsystemAggregateGraph.tsx +146 -78
- package/src/subsystem/SubsystemComponentGraph.tsx +222 -25
- package/src/subsystem/containerCard.tsx +264 -0
- package/src/subsystem/graphChrome.tsx +11 -9
- package/src/subsystem/graphMorph.tsx +212 -0
- package/src/subsystem/model.collapse.test.ts +128 -0
- package/src/subsystem/model.ts +306 -16
- package/src/subsystem/nodes.group.test.tsx +125 -16
- package/src/subsystem/nodes.tsx +201 -91
- package/src/utils/elkLayout.ts +16 -2
|
@@ -32,12 +32,15 @@ import {
|
|
|
32
32
|
applyNodeChanges,
|
|
33
33
|
} from '@xyflow/react';
|
|
34
34
|
import { useTheme } from '@principal-ade/industry-theme';
|
|
35
|
-
import { ArrowDown, ArrowRight, Files, Route, Unlink, X } from 'lucide-react';
|
|
35
|
+
import { ArrowDown, ArrowRight, Boxes, Files, Route, Unlink, X } from 'lucide-react';
|
|
36
36
|
import { IndustryMarkdownSlide } from 'themed-markdown';
|
|
37
37
|
import {
|
|
38
38
|
buildSubsystemGraph,
|
|
39
39
|
deriveGraphEdges,
|
|
40
|
+
buildBoundaryLayoutGroups,
|
|
41
|
+
isCardFrame,
|
|
40
42
|
isConstructsOnlyModel,
|
|
43
|
+
packageColor,
|
|
41
44
|
moduleGroupNodeId,
|
|
42
45
|
processGroupNodeId,
|
|
43
46
|
isTrailMechanism,
|
|
@@ -52,11 +55,16 @@ import {
|
|
|
52
55
|
type SubsystemEdgeView,
|
|
53
56
|
type SubsystemLayoutDirection,
|
|
54
57
|
type SubsystemGraphifyRelation,
|
|
58
|
+
type SubsystemGroupNodeData,
|
|
55
59
|
type SubsystemNodeIssue,
|
|
60
|
+
type SubsystemProcessRegion,
|
|
61
|
+
type SubsystemRegionDetails,
|
|
56
62
|
type SubsystemRegionIssue,
|
|
57
63
|
type SubsystemTrail,
|
|
58
64
|
} from './model';
|
|
59
65
|
import { ConstructsCatalog } from './ConstructsCatalog';
|
|
66
|
+
import { ContainersPanel, type ContainerListItem } from './ContainersPanel';
|
|
67
|
+
import { technologyBrand } from './techIcons';
|
|
60
68
|
import type { SubsystemOpenFileOptions } from './sourceSpan';
|
|
61
69
|
import {
|
|
62
70
|
SubsystemAgentsPanel,
|
|
@@ -161,6 +169,9 @@ interface PersistedViewState {
|
|
|
161
169
|
diagnosticsTab?: 'issues' | 'agents';
|
|
162
170
|
/** Flow direction chosen with the canvas toggle, restored on the next visit. */
|
|
163
171
|
layoutDirection?: SubsystemLayoutDirection;
|
|
172
|
+
/** Whether card frames default to closed, and the frames toggled away from that default. */
|
|
173
|
+
framesCollapsed?: boolean;
|
|
174
|
+
toggledFrames?: string[];
|
|
164
175
|
}
|
|
165
176
|
|
|
166
177
|
const VIEW_STATE_PREFIX = 'principal.subsystems.viewState.';
|
|
@@ -192,6 +203,16 @@ function writeViewState(
|
|
|
192
203
|
}
|
|
193
204
|
}
|
|
194
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Whether an edge is one of `set`. A line a collapsed frame rolled up stands in
|
|
208
|
+
* for each edge it absorbed, so it matches when any of those ids is in the set.
|
|
209
|
+
*/
|
|
210
|
+
function edgeMatches(set: ReadonlySet<string>, e: Edge): boolean {
|
|
211
|
+
if (set.has(e.id)) return true;
|
|
212
|
+
const ids = (e.data as { rolledUpIds?: string[] } | undefined)?.rolledUpIds;
|
|
213
|
+
return ids?.some((id) => set.has(id)) === true;
|
|
214
|
+
}
|
|
215
|
+
|
|
195
216
|
/** Screen-space rectangle of a component node, relative to the graph canvas box. */
|
|
196
217
|
export interface SubsystemNodeRect {
|
|
197
218
|
alias: string;
|
|
@@ -546,6 +567,23 @@ export interface SubsystemComponentGraphProps {
|
|
|
546
567
|
* membership are unchanged. See `BoundaryFrameOptions.codeProcessKeys`.
|
|
547
568
|
*/
|
|
548
569
|
codeProcessKeys?: ReadonlySet<string>;
|
|
570
|
+
/**
|
|
571
|
+
* C4 facts for boundary regions, keyed by region key (the `process` value
|
|
572
|
+
* or the package purl key): technology, description, container sort. A
|
|
573
|
+
* process or package frame draws them in its header the way a C4 container
|
|
574
|
+
* card does — hosts pass what their accepted C4 container states. Regions
|
|
575
|
+
* not named here derive a technology from their members' `framework`.
|
|
576
|
+
* See `BoundaryFrameOptions.regionDetails`.
|
|
577
|
+
*/
|
|
578
|
+
regionDetails?: Readonly<Record<string, SubsystemRegionDetails>>;
|
|
579
|
+
/**
|
|
580
|
+
* Whether process / package frames start closed: drawn as a container card
|
|
581
|
+
* with its members folded away and their lines rolled up onto it, the way a
|
|
582
|
+
* C4 container view reads. The user opens frames from the card, by
|
|
583
|
+
* double-click, or from the Containers list; a `persistKey` remembers the
|
|
584
|
+
* result. Default true; pass `false` to start with every frame laid out.
|
|
585
|
+
*/
|
|
586
|
+
defaultFramesCollapsed?: boolean;
|
|
549
587
|
}
|
|
550
588
|
|
|
551
589
|
const nodeTypes: NodeTypes = {
|
|
@@ -655,11 +693,12 @@ const TrailDrawerContent = memo(function TrailDrawerContent({
|
|
|
655
693
|
interface InnerProps extends SubsystemComponentGraphProps {
|
|
656
694
|
measured: { w: number; h: number } | null;
|
|
657
695
|
filesActive: boolean;
|
|
696
|
+
containersActive: boolean;
|
|
658
697
|
sidebarScope: TrailSidebarScope;
|
|
659
698
|
onSidebarTrailChange: (trailId: string | null) => void;
|
|
660
699
|
}
|
|
661
700
|
|
|
662
|
-
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, 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, hideDrawer = false, persistKey, liveEvents, agentsPanel }: InnerProps) {
|
|
701
|
+
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, 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 = true, containersActive, hideDrawer = false, persistKey, liveEvents, agentsPanel }: InnerProps) {
|
|
663
702
|
const { theme } = useTheme();
|
|
664
703
|
const { fitView, fitBounds } = useReactFlow();
|
|
665
704
|
const [descriptionOpen, setDescriptionOpen] = useState(false);
|
|
@@ -736,6 +775,38 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
736
775
|
const [layoutTrailId, setLayoutTrailId] = useState<string | null>(null);
|
|
737
776
|
const [committedTrailId, setCommittedTrailId] = useState<string | null>(null);
|
|
738
777
|
|
|
778
|
+
// Closed container cards. A frame folds its members away and rolls their
|
|
779
|
+
// lines up onto the card; opening it again lays the members back out. Each
|
|
780
|
+
// toggle is a layout flip like a direction change: ELK re-runs behind the
|
|
781
|
+
// edge fade while the frames slide to their new slots.
|
|
782
|
+
// Stored as a default plus exceptions so "close all" needs no knowledge of
|
|
783
|
+
// which frames the layout will produce: `framesCollapsed` is the default
|
|
784
|
+
// every card frame takes, `toggledGroupIds` the frames flipped away from it.
|
|
785
|
+
const [framesCollapsed, setFramesCollapsed] = useState<boolean>(
|
|
786
|
+
() => persisted.framesCollapsed ?? defaultFramesCollapsed,
|
|
787
|
+
);
|
|
788
|
+
const [toggledGroupIds, setToggledGroupIds] = useState<ReadonlySet<string>>(
|
|
789
|
+
() => new Set(persisted.toggledFrames ?? []),
|
|
790
|
+
);
|
|
791
|
+
const [committedCollapsed, setCommittedCollapsed] = useState<{
|
|
792
|
+
framesCollapsed: boolean;
|
|
793
|
+
toggled: ReadonlySet<string>;
|
|
794
|
+
}>({ framesCollapsed, toggled: toggledGroupIds });
|
|
795
|
+
const toggleCollapsed = useCallback((groupId: string) => {
|
|
796
|
+
setToggledGroupIds((prev) => {
|
|
797
|
+
const next = new Set(prev);
|
|
798
|
+
if (next.has(groupId)) next.delete(groupId);
|
|
799
|
+
else next.add(groupId);
|
|
800
|
+
return next;
|
|
801
|
+
});
|
|
802
|
+
}, []);
|
|
803
|
+
const setAllFramesCollapsed = useCallback((collapsed: boolean) => {
|
|
804
|
+
setFramesCollapsed(collapsed);
|
|
805
|
+
setToggledGroupIds(new Set());
|
|
806
|
+
}, []);
|
|
807
|
+
const collapsedKey = `${framesCollapsed ? 'closed' : 'open'}:${Array.from(toggledGroupIds).sort().join(',')}`;
|
|
808
|
+
const committedCollapsedKey = `${committedCollapsed.framesCollapsed ? 'closed' : 'open'}:${Array.from(committedCollapsed.toggled).sort().join(',')}`;
|
|
809
|
+
|
|
739
810
|
const changeLayoutDirection = useCallback(
|
|
740
811
|
(next: SubsystemLayoutDirection) => {
|
|
741
812
|
if (next === requestedDirection) return;
|
|
@@ -753,8 +824,8 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
753
824
|
}
|
|
754
825
|
}, [trails, layoutTrailId]);
|
|
755
826
|
|
|
756
|
-
const requestedLayoutKey = `${requestedDirection}|${layoutTrailId ?? ''}`;
|
|
757
|
-
const committedLayoutKey = `${committedDirection}|${committedTrailId ?? ''}`;
|
|
827
|
+
const requestedLayoutKey = `${requestedDirection}|${layoutTrailId ?? ''}|${collapsedKey}`;
|
|
828
|
+
const committedLayoutKey = `${committedDirection}|${committedTrailId ?? ''}|${committedCollapsedKey}`;
|
|
758
829
|
|
|
759
830
|
// Beat 1: request → fade the edges out, then commit the direction / focus
|
|
760
831
|
// (which re-runs ELK). Reduced-motion users get the new layout immediately.
|
|
@@ -781,6 +852,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
781
852
|
if (reduceMotion) {
|
|
782
853
|
setCommittedDirection(requestedDirection);
|
|
783
854
|
setCommittedTrailId(layoutTrailId);
|
|
855
|
+
setCommittedCollapsed({ framesCollapsed, toggled: toggledGroupIds });
|
|
784
856
|
return;
|
|
785
857
|
}
|
|
786
858
|
flipSawPendingLayoutRef.current = false;
|
|
@@ -789,6 +861,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
789
861
|
flipFadeTimerRef.current = null;
|
|
790
862
|
setCommittedDirection(requestedDirection);
|
|
791
863
|
setCommittedTrailId(layoutTrailId);
|
|
864
|
+
setCommittedCollapsed({ framesCollapsed, toggled: toggledGroupIds });
|
|
792
865
|
}, LAYOUT_FLIP_EDGE_MS);
|
|
793
866
|
return () => {
|
|
794
867
|
if (flipFadeTimerRef.current != null) {
|
|
@@ -802,6 +875,8 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
802
875
|
refocusOnLayoutFlip,
|
|
803
876
|
requestedDirection,
|
|
804
877
|
layoutTrailId,
|
|
878
|
+
framesCollapsed,
|
|
879
|
+
toggledGroupIds,
|
|
805
880
|
]);
|
|
806
881
|
|
|
807
882
|
// Beat 3: the committed layout has settled → the node slide is over, fade
|
|
@@ -843,6 +918,10 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
843
918
|
if (!persistKey) return;
|
|
844
919
|
writeViewState(persistKey, { layoutDirection: requestedDirection });
|
|
845
920
|
}, [persistKey, requestedDirection]);
|
|
921
|
+
useEffect(() => {
|
|
922
|
+
if (!persistKey) return;
|
|
923
|
+
writeViewState(persistKey, { framesCollapsed, toggledFrames: Array.from(toggledGroupIds) });
|
|
924
|
+
}, [persistKey, framesCollapsed, toggledGroupIds]);
|
|
846
925
|
|
|
847
926
|
// Safety net: never leave the canvas edge-less if a layout pass stalls
|
|
848
927
|
// (measurement never lands, ELK hangs). The edges come back; the layout
|
|
@@ -1119,13 +1198,15 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1119
1198
|
components: layoutDoc.components,
|
|
1120
1199
|
trails: layoutDoc.trails,
|
|
1121
1200
|
graphifyRelations: layoutRelations,
|
|
1122
|
-
})
|
|
1123
|
-
[layoutDoc, layoutRelations],
|
|
1201
|
+
}) + `|collapsed:${committedCollapsedKey}`,
|
|
1202
|
+
[layoutDoc, layoutRelations, committedCollapsedKey],
|
|
1124
1203
|
);
|
|
1125
1204
|
const layoutDocRef = useRef(layoutDoc);
|
|
1126
1205
|
const layoutRelationsRef = useRef(layoutRelations);
|
|
1206
|
+
const committedCollapsedRef = useRef(committedCollapsed);
|
|
1127
1207
|
layoutDocRef.current = layoutDoc;
|
|
1128
1208
|
layoutRelationsRef.current = layoutRelations;
|
|
1209
|
+
committedCollapsedRef.current = committedCollapsed;
|
|
1129
1210
|
|
|
1130
1211
|
// Track measured dimensions from React Flow's dimension changes.
|
|
1131
1212
|
// These arrive as { type: 'dimensions', id, dimensions } in onNodesChange.
|
|
@@ -1152,6 +1233,9 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1152
1233
|
orderByLine,
|
|
1153
1234
|
layoutDirection: committedDirection,
|
|
1154
1235
|
codeProcessKeys,
|
|
1236
|
+
regionDetails,
|
|
1237
|
+
collapsedGroupIds: committedCollapsedRef.current.toggled,
|
|
1238
|
+
cardFramesCollapsed: committedCollapsedRef.current.framesCollapsed,
|
|
1155
1239
|
})
|
|
1156
1240
|
.then(({ nodes, edges: e, absoluteRects }) => {
|
|
1157
1241
|
if (!alive) return;
|
|
@@ -1201,7 +1285,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1201
1285
|
const gen = ++pass2GenRef.current;
|
|
1202
1286
|
void buildSubsystemGraph(
|
|
1203
1287
|
layoutDoc,
|
|
1204
|
-
{ maxNodeWidth, showEdgeLabels, measuredWidths, measuredHeights, showSingletonFrames, moduleNesting, graphifyRelations: layoutRelations, orderByLine, layoutDirection: committedDirection, codeProcessKeys },
|
|
1288
|
+
{ maxNodeWidth, showEdgeLabels, measuredWidths, measuredHeights, showSingletonFrames, moduleNesting, graphifyRelations: layoutRelations, orderByLine, layoutDirection: committedDirection, codeProcessKeys, regionDetails, collapsedGroupIds: committedCollapsed.toggled, cardFramesCollapsed: committedCollapsed.framesCollapsed },
|
|
1205
1289
|
)
|
|
1206
1290
|
.then(({ nodes, edges: e, absoluteRects }) => {
|
|
1207
1291
|
if (gen !== pass2GenRef.current) return;
|
|
@@ -1214,7 +1298,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1214
1298
|
// Reveal Pass 1 layout rather than leaving the cover up forever.
|
|
1215
1299
|
setLayoutReady(true);
|
|
1216
1300
|
});
|
|
1217
|
-
}, [built.nodes, layoutDoc, layoutRelations, orderByLine, maxNodeWidth, showEdgeLabels, moduleNesting, committedDirection]);
|
|
1301
|
+
}, [built.nodes, layoutDoc, layoutRelations, orderByLine, maxNodeWidth, showEdgeLabels, moduleNesting, committedDirection, committedCollapsed]);
|
|
1218
1302
|
|
|
1219
1303
|
// After Pass 1 commits, try Pass 2 immediately with retained measurements.
|
|
1220
1304
|
// Same-id live updates often get no new React Flow `dimensions` events, so
|
|
@@ -1647,7 +1731,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1647
1731
|
if (!edgeIds) return null;
|
|
1648
1732
|
const ids = new Set<string>();
|
|
1649
1733
|
for (const e of baseEdges) {
|
|
1650
|
-
if (!edgeIds
|
|
1734
|
+
if (!edgeMatches(edgeIds, e)) continue;
|
|
1651
1735
|
ids.add(e.source);
|
|
1652
1736
|
ids.add(e.target);
|
|
1653
1737
|
}
|
|
@@ -1725,8 +1809,10 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1725
1809
|
// Boundary frames follow their members: hidden when no member is
|
|
1726
1810
|
// visible, dimmed when members are dimmed. Never selectable.
|
|
1727
1811
|
if (n.type === 'subsystem-group') {
|
|
1728
|
-
const region = (n.data as { region?:
|
|
1729
|
-
|
|
1812
|
+
const region = (n.data as { region?: SubsystemProcessRegion } | undefined)?.region;
|
|
1813
|
+
// A collapsed card is an edge endpoint in its own right, so its own id
|
|
1814
|
+
// joins its members' when deciding whether the frame is on an open flow.
|
|
1815
|
+
const memberAliases = [n.id, ...(region?.memberAliases ?? [])];
|
|
1730
1816
|
// `brightNodeIds` is the focused step's endpoints. It has to be a
|
|
1731
1817
|
// spotlight member as well as a bright set: without an expanded flow
|
|
1732
1818
|
// there is no opened set, so dimming has to be driven from the
|
|
@@ -1755,6 +1841,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1755
1841
|
...(color != null && { color }),
|
|
1756
1842
|
...(dimmed && { dimmed: true }),
|
|
1757
1843
|
...(regionIssue && { issue: regionIssue }),
|
|
1844
|
+
...(region && isCardFrame(region) && { onToggleCollapse: () => toggleCollapsed(n.id) }),
|
|
1758
1845
|
},
|
|
1759
1846
|
};
|
|
1760
1847
|
}
|
|
@@ -1795,7 +1882,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1795
1882
|
},
|
|
1796
1883
|
};
|
|
1797
1884
|
});
|
|
1798
|
-
}, [xyflowNodesBase, openFile, selected, focusNodeIds, openedNodeIds, brightNodeIds, previewNodeIds, issueFocusNodeIds, issueBadgeByAlias, regionIssueByNodeId, boundaryColors]);
|
|
1885
|
+
}, [xyflowNodesBase, openFile, selected, focusNodeIds, openedNodeIds, brightNodeIds, previewNodeIds, issueFocusNodeIds, issueBadgeByAlias, regionIssueByNodeId, boundaryColors, toggleCollapsed]);
|
|
1799
1886
|
|
|
1800
1887
|
const baseNodesKey = useMemo(() => nodes.map((n) => n.id).sort().join(','), [nodes]);
|
|
1801
1888
|
const baseEdgesKey = useMemo(
|
|
@@ -1829,16 +1916,18 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1829
1916
|
}
|
|
1830
1917
|
return isTrailMechanism(mechanism);
|
|
1831
1918
|
};
|
|
1919
|
+
const inSet = (set: ReadonlySet<string> | null | undefined, e: Edge): boolean =>
|
|
1920
|
+
set != null && edgeMatches(set, e);
|
|
1832
1921
|
if (openedEdgeIds || focusEdgeIds || previewEdgeIds || issueFocusEdgeIds) {
|
|
1833
1922
|
return baseEdges.map((e) => {
|
|
1834
1923
|
const vis = flowElementVisibility({
|
|
1835
|
-
inOpened: openedEdgeIds
|
|
1836
|
-
inSelected: focusEdgeIds
|
|
1924
|
+
inOpened: inSet(openedEdgeIds, e),
|
|
1925
|
+
inSelected: inSet(focusEdgeIds, e),
|
|
1837
1926
|
anyOpened: openedEdgeIds != null,
|
|
1838
1927
|
anySelected: focusEdgeIds != null,
|
|
1839
1928
|
});
|
|
1840
1929
|
const dimSource = previewEdgeIds ?? issueFocusEdgeIds;
|
|
1841
|
-
const dimmed = dimSource ? vis.hidden || !dimSource
|
|
1930
|
+
const dimmed = dimSource ? vis.hidden || !inSet(dimSource, e) : vis.dimmed;
|
|
1842
1931
|
const hidden = vis.hidden || !edgeInView(e);
|
|
1843
1932
|
return { ...paint(e, dimmed), hidden };
|
|
1844
1933
|
});
|
|
@@ -1988,8 +2077,14 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
1988
2077
|
// Boundary frame → frame its members on the canvas; double-click again to
|
|
1989
2078
|
// zoom back out. User-initiated, so it ignores the trail zoom gate.
|
|
1990
2079
|
if (node.type === 'subsystem-group') {
|
|
1991
|
-
const
|
|
1992
|
-
|
|
2080
|
+
const region = (node.data as { region?: SubsystemProcessRegion } | undefined)?.region;
|
|
2081
|
+
// Card frames (process / package) grow and shrink on double-click, the
|
|
2082
|
+
// way a C4 container does; module frames keep the zoom-to-frame.
|
|
2083
|
+
if (region && isCardFrame(region)) {
|
|
2084
|
+
toggleCollapsed(node.id);
|
|
2085
|
+
return;
|
|
2086
|
+
}
|
|
2087
|
+
const key = region?.key;
|
|
1993
2088
|
if (!key) return;
|
|
1994
2089
|
if (focusedBoundaryKey === key) {
|
|
1995
2090
|
setFocusedBoundaryKey(null);
|
|
@@ -2083,7 +2178,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2083
2178
|
const nodeIds = new Set<string>();
|
|
2084
2179
|
const points: { x: number; y: number }[] = [];
|
|
2085
2180
|
for (const e of baseEdges) {
|
|
2086
|
-
if (!ids
|
|
2181
|
+
if (!edgeMatches(ids, e)) continue;
|
|
2087
2182
|
nodeIds.add(e.source);
|
|
2088
2183
|
nodeIds.add(e.target);
|
|
2089
2184
|
const pts = (e.data as { elkPathPoints?: { x: number; y: number }[] } | undefined)
|
|
@@ -2196,6 +2291,67 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2196
2291
|
[rectForNode, fitBounds, trailFocusDurationMs],
|
|
2197
2292
|
);
|
|
2198
2293
|
|
|
2294
|
+
// The Containers list: every card frame in the laid-out graph, parents before
|
|
2295
|
+
// their children, with the colour the canvas draws it in. Rows keep the
|
|
2296
|
+
// grouping's declaration order — the layout moves closed cards after open
|
|
2297
|
+
// frames, and a row must not jump when its frame is toggled.
|
|
2298
|
+
const containerOrder = useMemo(() => {
|
|
2299
|
+
const ids = buildBoundaryLayoutGroups(
|
|
2300
|
+
{ components },
|
|
2301
|
+
{ showSingletonFrames, moduleNesting, codeProcessKeys },
|
|
2302
|
+
).map((g) => g.id);
|
|
2303
|
+
return new Map(ids.map((id, i) => [id, i]));
|
|
2304
|
+
}, [components, showSingletonFrames, moduleNesting, codeProcessKeys]);
|
|
2305
|
+
const containerItems = useMemo((): ContainerListItem[] => {
|
|
2306
|
+
const frames = built.nodes
|
|
2307
|
+
.filter(
|
|
2308
|
+
(n): n is typeof n & { data: SubsystemGroupNodeData } =>
|
|
2309
|
+
n.type === 'subsystem-group' &&
|
|
2310
|
+
isCardFrame((n.data as SubsystemGroupNodeData).region),
|
|
2311
|
+
)
|
|
2312
|
+
.sort(
|
|
2313
|
+
(a, b) =>
|
|
2314
|
+
(containerOrder.get(a.id) ?? Number.MAX_SAFE_INTEGER) -
|
|
2315
|
+
(containerOrder.get(b.id) ?? Number.MAX_SAFE_INTEGER),
|
|
2316
|
+
);
|
|
2317
|
+
const byId = new Map(frames.map((n) => [n.id, n]));
|
|
2318
|
+
const children = new Map<string | undefined, typeof frames>();
|
|
2319
|
+
for (const n of frames) {
|
|
2320
|
+
const parent = n.parentId && byId.has(n.parentId) ? n.parentId : undefined;
|
|
2321
|
+
const list = children.get(parent) ?? [];
|
|
2322
|
+
list.push(n);
|
|
2323
|
+
children.set(parent, list);
|
|
2324
|
+
}
|
|
2325
|
+
const out: ContainerListItem[] = [];
|
|
2326
|
+
const walk = (parent: string | undefined, depth: number) => {
|
|
2327
|
+
for (const n of children.get(parent) ?? []) {
|
|
2328
|
+
const region = n.data.region;
|
|
2329
|
+
out.push({
|
|
2330
|
+
id: n.id,
|
|
2331
|
+
region,
|
|
2332
|
+
collapsed: n.data.collapsed === true,
|
|
2333
|
+
depth,
|
|
2334
|
+
color:
|
|
2335
|
+
boundaryColors?.[region.key] ??
|
|
2336
|
+
technologyBrand(region.technology)?.color ??
|
|
2337
|
+
packageColor(region.key),
|
|
2338
|
+
});
|
|
2339
|
+
walk(n.id, depth + 1);
|
|
2340
|
+
}
|
|
2341
|
+
};
|
|
2342
|
+
walk(undefined, 0);
|
|
2343
|
+
return out;
|
|
2344
|
+
}, [built.nodes, boundaryColors, containerOrder]);
|
|
2345
|
+
const focusContainer = useCallback(
|
|
2346
|
+
(id: string) => {
|
|
2347
|
+
const item = containerItems.find((c) => c.id === id);
|
|
2348
|
+
if (!item) return;
|
|
2349
|
+
setFocusedBoundaryKey(item.region.key);
|
|
2350
|
+
requestAnimationFrame(() => fitNodeRects(new Set([id]), 0.25));
|
|
2351
|
+
},
|
|
2352
|
+
[containerItems, fitNodeRects],
|
|
2353
|
+
);
|
|
2354
|
+
|
|
2199
2355
|
// Zoom back out to the full diagram after the last expanded trail
|
|
2200
2356
|
// closes (visibility restores non-flow nodes that were hidden).
|
|
2201
2357
|
const fitOverview = useCallback(() => {
|
|
@@ -2780,7 +2936,12 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2780
2936
|
midX: d?.labelX ?? 0,
|
|
2781
2937
|
midY: d?.labelY ?? 0,
|
|
2782
2938
|
pathLength: d?.pathLength ?? 0,
|
|
2783
|
-
|
|
2939
|
+
// A rolled-up line numbers every step it absorbed.
|
|
2940
|
+
stepNos: selectedFlowStepNos
|
|
2941
|
+
? [e.id, ...((d as { rolledUpIds?: string[] } | undefined)?.rolledUpIds ?? [])]
|
|
2942
|
+
.flatMap((id) => selectedFlowStepNos.get(id) ?? [])
|
|
2943
|
+
.sort((a, b) => a - b)
|
|
2944
|
+
: undefined,
|
|
2784
2945
|
stepIssue,
|
|
2785
2946
|
};
|
|
2786
2947
|
});
|
|
@@ -2814,9 +2975,9 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2814
2975
|
// the same facts the sidebar renders.
|
|
2815
2976
|
const sidebarVisible =
|
|
2816
2977
|
!hideSidebar &&
|
|
2817
|
-
(description || filesActive || issuesActive || sidebarExtra || sidebarAfterDescription ||
|
|
2978
|
+
(description || filesActive || containersActive || issuesActive || sidebarExtra || sidebarAfterDescription ||
|
|
2818
2979
|
hasTrails);
|
|
2819
|
-
const sidebarBodyVisible = hasTrails || filesActive || issuesActive;
|
|
2980
|
+
const sidebarBodyVisible = hasTrails || filesActive || containersActive || issuesActive;
|
|
2820
2981
|
const sidebarTabs: GraphSidebarTab[] | undefined = issuesActive && !sidebarTrail
|
|
2821
2982
|
? agentsPanel
|
|
2822
2983
|
? [
|
|
@@ -2891,6 +3052,15 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2891
3052
|
onExpandedCategoriesChange={handleExpandedCategoriesChange}
|
|
2892
3053
|
/>
|
|
2893
3054
|
)
|
|
3055
|
+
) : containersActive ? (
|
|
3056
|
+
<ContainersPanel
|
|
3057
|
+
containers={containerItems}
|
|
3058
|
+
activeId={containerItems.find((c) => c.region.key === focusedBoundaryKey)?.id ?? null}
|
|
3059
|
+
onFocus={focusContainer}
|
|
3060
|
+
onToggle={toggleCollapsed}
|
|
3061
|
+
onOpenAll={() => setAllFramesCollapsed(false)}
|
|
3062
|
+
onCloseAll={() => setAllFramesCollapsed(true)}
|
|
3063
|
+
/>
|
|
2894
3064
|
) : filesActive ? treePaths.entries.length === 0 ? (
|
|
2895
3065
|
<div style={{ padding: 16, color: theme.colors.textSecondary }}>No files for this trail.</div>
|
|
2896
3066
|
) : (
|
|
@@ -3553,6 +3723,17 @@ export function SubsystemComponentGraph(props: SubsystemComponentGraphProps) {
|
|
|
3553
3723
|
[props.components, props.trails, props.issues, sidebarTrailId],
|
|
3554
3724
|
);
|
|
3555
3725
|
const fileCount = sidebarScope.treePaths.entries.length;
|
|
3726
|
+
// Card frames the layout will draw — the same grouping `buildSubsystemGraph`
|
|
3727
|
+
// runs, so the count matches the canvas.
|
|
3728
|
+
const containerCount = useMemo(
|
|
3729
|
+
() =>
|
|
3730
|
+
buildBoundaryLayoutGroups(
|
|
3731
|
+
{ components: props.components },
|
|
3732
|
+
{ showSingletonFrames: props.showSingletonFrames ?? true, moduleNesting: props.moduleNesting, codeProcessKeys: props.codeProcessKeys },
|
|
3733
|
+
).filter((g) => isCardFrame(g.region)).length,
|
|
3734
|
+
[props.components, props.showSingletonFrames, props.moduleNesting, props.codeProcessKeys],
|
|
3735
|
+
);
|
|
3736
|
+
const [containersOpen, setContainersOpen] = useState(false);
|
|
3556
3737
|
const trailViewLabel = sidebarScope.trail ? 'Trail' : 'Trails';
|
|
3557
3738
|
const trailCount = props.trails?.length ?? 0;
|
|
3558
3739
|
const hasFiles = fileCount > 0 || sidebarScope.trail != null;
|
|
@@ -3576,9 +3757,11 @@ export function SubsystemComponentGraph(props: SubsystemComponentGraphProps) {
|
|
|
3576
3757
|
const issuesRequested = props.showIssues ?? diagnosticsOpen;
|
|
3577
3758
|
const issuesActive = hasIssues && issuesRequested;
|
|
3578
3759
|
const filesActive = filesOpen && hasFiles && !issuesActive;
|
|
3579
|
-
const
|
|
3760
|
+
const containersActive = containersOpen && containerCount > 0 && !issuesActive && !filesActive;
|
|
3761
|
+
const selectSidebarView = (view: 'trails' | 'files' | 'containers' | 'issues') => {
|
|
3580
3762
|
const nextIssuesActive = view === 'issues';
|
|
3581
3763
|
setFilesOpen(view === 'files');
|
|
3764
|
+
setContainersOpen(view === 'containers');
|
|
3582
3765
|
if (nextIssuesActive !== issuesRequested) {
|
|
3583
3766
|
if (props.showIssues === undefined) setDiagnosticsOpen(nextIssuesActive);
|
|
3584
3767
|
props.diagnostic?.onToggle?.();
|
|
@@ -3679,12 +3862,26 @@ export function SubsystemComponentGraph(props: SubsystemComponentGraphProps) {
|
|
|
3679
3862
|
borderRadius: 6,
|
|
3680
3863
|
}}
|
|
3681
3864
|
>
|
|
3865
|
+
{containerCount > 0 && (
|
|
3866
|
+
<button
|
|
3867
|
+
type="button"
|
|
3868
|
+
aria-label={`Containers (${containerCount} ${containerCount === 1 ? 'container' : 'containers'})`}
|
|
3869
|
+
title="Show containers"
|
|
3870
|
+
aria-pressed={containersActive}
|
|
3871
|
+
onClick={() => selectSidebarView('containers')}
|
|
3872
|
+
style={viewButtonStyle(containersActive)}
|
|
3873
|
+
>
|
|
3874
|
+
<Boxes size={14} aria-hidden />
|
|
3875
|
+
<span>Containers</span>
|
|
3876
|
+
<span style={{ fontWeight: 600, marginLeft: 4 }}>{containerCount}</span>
|
|
3877
|
+
</button>
|
|
3878
|
+
)}
|
|
3682
3879
|
<button
|
|
3683
3880
|
type="button"
|
|
3684
3881
|
aria-label={sidebarScope.trail ? 'Trail' : `Trails (${trailCount} ${trailCount === 1 ? 'trail' : 'trails'})`}
|
|
3685
|
-
aria-pressed={!filesActive && !issuesActive}
|
|
3882
|
+
aria-pressed={!filesActive && !containersActive && !issuesActive}
|
|
3686
3883
|
onClick={() => selectSidebarView('trails')}
|
|
3687
|
-
style={viewButtonStyle(!filesActive && !issuesActive)}
|
|
3884
|
+
style={viewButtonStyle(!filesActive && !containersActive && !issuesActive)}
|
|
3688
3885
|
>
|
|
3689
3886
|
<Route size={14} aria-hidden />
|
|
3690
3887
|
<span>{trailViewLabel}</span>
|
|
@@ -3737,7 +3934,7 @@ export function SubsystemComponentGraph(props: SubsystemComponentGraphProps) {
|
|
|
3737
3934
|
/>
|
|
3738
3935
|
) : (
|
|
3739
3936
|
<ReactFlowProvider>
|
|
3740
|
-
<Inner {...props} showIssues={issuesActive} filesActive={filesActive} measured={size}
|
|
3937
|
+
<Inner {...props} showIssues={issuesActive} filesActive={filesActive} containersActive={containersActive} measured={size}
|
|
3741
3938
|
sidebarScope={sidebarScope} onSidebarTrailChange={setSidebarTrailId} />
|
|
3742
3939
|
</ReactFlowProvider>
|
|
3743
3940
|
)}
|