@principal-ai/subsystems-react 0.56.25 → 0.56.27

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.
Files changed (45) hide show
  1. package/dist/subsystem/C4ProjectionView.d.ts +12 -2
  2. package/dist/subsystem/C4ProjectionView.d.ts.map +1 -1
  3. package/dist/subsystem/C4ProjectionView.js +22 -9
  4. package/dist/subsystem/C4ProjectionView.js.map +1 -1
  5. package/dist/subsystem/ConstructsCatalog.d.ts +18 -11
  6. package/dist/subsystem/ConstructsCatalog.d.ts.map +1 -1
  7. package/dist/subsystem/ConstructsCatalog.js +25 -27
  8. package/dist/subsystem/ConstructsCatalog.js.map +1 -1
  9. package/dist/subsystem/SubsystemComponentGraph.d.ts +13 -3
  10. package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
  11. package/dist/subsystem/SubsystemComponentGraph.js +81 -27
  12. package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
  13. package/dist/subsystem/__fixtures__/c4SketchGallery.d.ts +2 -0
  14. package/dist/subsystem/__fixtures__/c4SketchGallery.d.ts.map +1 -1
  15. package/dist/subsystem/__fixtures__/c4SketchGallery.js +8 -0
  16. package/dist/subsystem/__fixtures__/c4SketchGallery.js.map +1 -1
  17. package/dist/subsystem/__fixtures__/c4Sketches/maintenance-bridge.json +2 -1
  18. package/dist/subsystem/__fixtures__/c4Sketches/openbot.json +2 -1
  19. package/dist/subsystem/model.d.ts +7 -0
  20. package/dist/subsystem/model.d.ts.map +1 -1
  21. package/dist/subsystem/model.js +27 -0
  22. package/dist/subsystem/model.js.map +1 -1
  23. package/package.json +1 -1
  24. package/src/stories/Canvases/C4/C4Sketch.stories.tsx +6 -0
  25. package/src/stories/Canvases/Subsystem/ContainerFrames.stories.tsx +6 -3
  26. package/src/stories/Canvases/Subsystem/CustomEntities.stories.tsx +2 -1
  27. package/src/stories/Canvases/Subsystem/EdgeViews.stories.tsx +2 -1
  28. package/src/stories/Canvases/Subsystem/Issues.stories.tsx +2 -1
  29. package/src/stories/Canvases/Subsystem/ModuleBadges.stories.tsx +3 -2
  30. package/src/stories/Canvases/Subsystem/Processes.stories.tsx +2 -1
  31. package/src/stories/Canvases/Subsystem/Reorder.stories.tsx +2 -1
  32. package/src/stories/Canvases/Subsystem/Scenarios.stories.tsx +6 -3
  33. package/src/stories/Canvases/Subsystem/TrailAutoplay.stories.tsx +2 -1
  34. package/src/stories/Canvases/Subsystem/Trails.stories.tsx +4 -2
  35. package/src/stories/Components/ConstructsCatalog.stories.tsx +2 -1
  36. package/src/subsystem/C4ProjectionView.tsx +44 -16
  37. package/src/subsystem/ConstructsCatalog.tsx +59 -58
  38. package/src/subsystem/DescriptionOverlay.test.tsx +16 -8
  39. package/src/subsystem/SubsystemComponentGraph.sidebar.test.tsx +27 -7
  40. package/src/subsystem/SubsystemComponentGraph.tsx +140 -54
  41. package/src/subsystem/__fixtures__/c4SketchGallery.ts +10 -0
  42. package/src/subsystem/__fixtures__/c4Sketches/maintenance-bridge.json +2 -1
  43. package/src/subsystem/__fixtures__/c4Sketches/openbot.json +2 -1
  44. package/src/subsystem/model.collapse.test.ts +35 -1
  45. package/src/subsystem/model.ts +28 -0
@@ -16,7 +16,7 @@
16
16
  */
17
17
 
18
18
  import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
19
- import type { CSSProperties, MouseEvent as ReactMouseEvent, ReactNode } from 'react';
19
+ import type { MouseEvent as ReactMouseEvent, ReactNode } from 'react';
20
20
  import {
21
21
  ReactFlow,
22
22
  ReactFlowProvider,
@@ -32,11 +32,13 @@ import {
32
32
  applyNodeChanges,
33
33
  } from '@xyflow/react';
34
34
  import { useTheme } from '@principal-ade/industry-theme';
35
+ import { SUBSYSTEM_MODEL_DESCRIPTION_MAX } from '@principal-ai/subsystems-core';
35
36
  import { ArrowDown, ArrowRight, Boxes, Files, Route, Unlink, X } from 'lucide-react';
36
37
  import {
37
38
  buildSubsystemGraph,
38
39
  deriveGraphEdges,
39
40
  buildBoundaryLayoutGroups,
41
+ cardFramesForAliases,
40
42
  isCardFrame,
41
43
  isConstructsOnlyModel,
42
44
  packageColor,
@@ -408,11 +410,21 @@ export interface SubsystemComponentGraphProps {
408
410
  * Uses the focused or hover-highlighted trail.
409
411
  */
410
412
  showTrailTitle?: boolean;
411
- /** Markdown description rendered in the sidebar. */
413
+ /**
414
+ * Short description rendered at the top of the sidebar. At most 200
415
+ * characters; extended detail belongs in `notes`.
416
+ */
412
417
  description?: string;
413
418
  /**
414
- * Controlled open state for the constructs catalog's description overlay.
415
- * When provided, the host owns it (e.g. a button in its own header).
419
+ * Extended Markdown notes about the model. When set, the description's
420
+ * `Show more` link opens the full document in an Overview overlay. Omit
421
+ * `description` and the sidebar falls back to a clamped preview of these
422
+ * notes.
423
+ */
424
+ notes?: string;
425
+ /**
426
+ * Controlled open state for the notes overlay. When provided, the host owns
427
+ * it (e.g. a button in its own header).
416
428
  */
417
429
  descriptionOpen?: boolean;
418
430
  onDescriptionOpenChange?: (open: boolean) => void;
@@ -698,10 +710,21 @@ interface InnerProps extends SubsystemComponentGraphProps {
698
710
  onSidebarTrailChange: (trailId: string | null) => void;
699
711
  }
700
712
 
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) {
713
+ 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 = true, containersActive, hideDrawer = false, persistKey, liveEvents, agentsPanel }: InnerProps) {
702
714
  const { theme } = useTheme();
703
715
  const { fitView, fitBounds } = useReactFlow();
704
716
  const [descriptionOpen, setDescriptionOpen] = useState(false);
717
+ const rawDescription = description?.trim();
718
+ // The host caps the authored description; trim defensively for other hosts.
719
+ const shortDescription =
720
+ rawDescription && rawDescription.length > SUBSYSTEM_MODEL_DESCRIPTION_MAX
721
+ ? `${rawDescription.slice(0, SUBSYSTEM_MODEL_DESCRIPTION_MAX - 1)}…`
722
+ : rawDescription;
723
+ const extendedNotes = notes?.trim();
724
+ // The short description owns the top-left slot; a legacy model with only
725
+ // notes falls back to a clamped preview of them.
726
+ const descriptionPreview = shortDescription || extendedNotes;
727
+ const hasNotes = Boolean(extendedNotes);
705
728
  const viewport = useViewport();
706
729
  // Restored once per mount from `localStorage` (see `readViewState`). Each
707
730
  // graph is its own tab/mount, so `persistKey` is stable for a mount.
@@ -788,10 +811,41 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
788
811
  const [toggledGroupIds, setToggledGroupIds] = useState<ReadonlySet<string>>(
789
812
  () => new Set(persisted.toggledFrames ?? []),
790
813
  );
814
+ // Picking a trail opens the container cards that hold its cast, so the flow
815
+ // reads as its components instead of a row of folded boxes. Derived rather
816
+ // than written into the user's frame state: clearing the trail — or moving to
817
+ // another — restores exactly the frames they had open before.
818
+ const trailFrameIds = useMemo<ReadonlySet<string>>(() => {
819
+ if (!layoutTrailId) return new Set();
820
+ const trail = (trails ?? []).find((t) => t.id === layoutTrailId);
821
+ if (!trail) return new Set();
822
+ const aliases = new Set<string>();
823
+ for (const step of trail.steps) {
824
+ aliases.add(step.from);
825
+ aliases.add(step.to);
826
+ }
827
+ return cardFramesForAliases(
828
+ { components },
829
+ aliases,
830
+ { showSingletonFrames, moduleNesting, codeProcessKeys },
831
+ );
832
+ }, [layoutTrailId, trails, components, showSingletonFrames, moduleNesting, codeProcessKeys]);
833
+ // `framesCollapsed` is the default every card takes; a toggled id is the
834
+ // exception. Opening a trail's frames therefore means adding them to the
835
+ // default-collapsed set (or removing them from the default-open one).
836
+ const effectiveToggledGroupIds = useMemo<ReadonlySet<string>>(() => {
837
+ if (trailFrameIds.size === 0) return toggledGroupIds;
838
+ const next = new Set(toggledGroupIds);
839
+ for (const id of trailFrameIds) {
840
+ if (framesCollapsed) next.add(id);
841
+ else next.delete(id);
842
+ }
843
+ return next;
844
+ }, [toggledGroupIds, trailFrameIds, framesCollapsed]);
791
845
  const [committedCollapsed, setCommittedCollapsed] = useState<{
792
846
  framesCollapsed: boolean;
793
847
  toggled: ReadonlySet<string>;
794
- }>({ framesCollapsed, toggled: toggledGroupIds });
848
+ }>({ framesCollapsed, toggled: effectiveToggledGroupIds });
795
849
  const toggleCollapsed = useCallback((groupId: string) => {
796
850
  setToggledGroupIds((prev) => {
797
851
  const next = new Set(prev);
@@ -804,7 +858,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
804
858
  setFramesCollapsed(collapsed);
805
859
  setToggledGroupIds(new Set());
806
860
  }, []);
807
- const collapsedKey = `${framesCollapsed ? 'closed' : 'open'}:${Array.from(toggledGroupIds).sort().join(',')}`;
861
+ const collapsedKey = `${framesCollapsed ? 'closed' : 'open'}:${Array.from(effectiveToggledGroupIds).sort().join(',')}`;
808
862
  const committedCollapsedKey = `${committedCollapsed.framesCollapsed ? 'closed' : 'open'}:${Array.from(committedCollapsed.toggled).sort().join(',')}`;
809
863
 
810
864
  const changeLayoutDirection = useCallback(
@@ -852,7 +906,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
852
906
  if (reduceMotion) {
853
907
  setCommittedDirection(requestedDirection);
854
908
  setCommittedTrailId(layoutTrailId);
855
- setCommittedCollapsed({ framesCollapsed, toggled: toggledGroupIds });
909
+ setCommittedCollapsed({ framesCollapsed, toggled: effectiveToggledGroupIds });
856
910
  return;
857
911
  }
858
912
  flipSawPendingLayoutRef.current = false;
@@ -861,7 +915,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
861
915
  flipFadeTimerRef.current = null;
862
916
  setCommittedDirection(requestedDirection);
863
917
  setCommittedTrailId(layoutTrailId);
864
- setCommittedCollapsed({ framesCollapsed, toggled: toggledGroupIds });
918
+ setCommittedCollapsed({ framesCollapsed, toggled: effectiveToggledGroupIds });
865
919
  }, LAYOUT_FLIP_EDGE_MS);
866
920
  return () => {
867
921
  if (flipFadeTimerRef.current != null) {
@@ -876,7 +930,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
876
930
  requestedDirection,
877
931
  layoutTrailId,
878
932
  framesCollapsed,
879
- toggledGroupIds,
933
+ effectiveToggledGroupIds,
880
934
  ]);
881
935
 
882
936
  // Beat 3: the committed layout has settled → the node slide is over, fade
@@ -2975,7 +3029,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
2975
3029
  // the same facts the sidebar renders.
2976
3030
  const sidebarVisible =
2977
3031
  !hideSidebar &&
2978
- (description || filesActive || containersActive || issuesActive || sidebarExtra || sidebarAfterDescription ||
3032
+ (descriptionPreview || filesActive || containersActive || issuesActive || sidebarExtra || sidebarAfterDescription ||
2979
3033
  hasTrails);
2980
3034
  const sidebarBodyVisible = hasTrails || filesActive || containersActive || issuesActive;
2981
3035
  const sidebarTabs: GraphSidebarTab[] | undefined = issuesActive && !sidebarTrail
@@ -2986,16 +3040,17 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
2986
3040
  ]
2987
3041
  : undefined
2988
3042
  : undefined;
2989
- // Header block: extras, then the description.
3043
+ // Header block: extras, then the short description.
2990
3044
  const sidebarHeader = (
2991
3045
  <>
2992
3046
  {sidebarExtra}
2993
- {description && (
3047
+ {descriptionPreview && (
2994
3048
  <DescriptionPreview
2995
- content={description}
2996
- open={descriptionOpen}
2997
- onOpen={() => setDescriptionOpen(true)}
2998
- onClose={() => setDescriptionOpen(false)}
3049
+ content={descriptionPreview}
3050
+ clamp={!shortDescription}
3051
+ open={hasNotes && descriptionOpen}
3052
+ onOpen={hasNotes ? () => setDescriptionOpen(true) : undefined}
3053
+ onClose={hasNotes ? () => setDescriptionOpen(false) : undefined}
2999
3054
  slideIdPrefix="subsystem-desc"
3000
3055
  />
3001
3056
  )}
@@ -3143,10 +3198,10 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
3143
3198
  persistKey={persistKey}
3144
3199
  onResizeEnd={() => requestAnimationFrame(() => fitView())}
3145
3200
  >
3146
- {!hideSidebar && description && descriptionOpen && (
3201
+ {!hideSidebar && hasNotes && descriptionOpen && (
3147
3202
  <DescriptionOverlay
3148
- description={description}
3149
- ariaLabel="Subsystem description"
3203
+ description={extendedNotes ?? ''}
3204
+ ariaLabel="Subsystem notes"
3150
3205
  slideIdPrefix="subsystem-desc-overlay"
3151
3206
  onClose={() => setDescriptionOpen(false)}
3152
3207
  />
@@ -3679,6 +3734,58 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
3679
3734
  );
3680
3735
  }
3681
3736
 
3737
+ /**
3738
+ * One option in the header's segmented sidebar-view switch. Owns the hover
3739
+ * state so every segment reacts the same way — the Issues segment is a
3740
+ * `SubsystemDiagnosticToggle` and already hovers; keeping the plain options
3741
+ * here means the switch has one hover affordance, not two.
3742
+ */
3743
+ function SidebarViewOption({
3744
+ active,
3745
+ ariaLabel,
3746
+ title,
3747
+ onClick,
3748
+ children,
3749
+ }: {
3750
+ active: boolean;
3751
+ ariaLabel: string;
3752
+ title?: string;
3753
+ onClick: () => void;
3754
+ children: ReactNode;
3755
+ }) {
3756
+ const { theme } = useTheme();
3757
+ const [hover, setHover] = useState(false);
3758
+ return (
3759
+ <button
3760
+ type="button"
3761
+ aria-label={ariaLabel}
3762
+ title={title}
3763
+ aria-pressed={active}
3764
+ onClick={onClick}
3765
+ onMouseEnter={() => setHover(true)}
3766
+ onMouseLeave={() => setHover(false)}
3767
+ style={{
3768
+ display: 'inline-flex',
3769
+ alignItems: 'center',
3770
+ justifyContent: 'center',
3771
+ gap: 4,
3772
+ height: 28,
3773
+ padding: '4px 16px',
3774
+ fontFamily: theme.fonts.monospace,
3775
+ fontSize: theme.fontSizes[0],
3776
+ border: 'none',
3777
+ borderRadius: 4,
3778
+ background: active || hover ? theme.colors.border : 'transparent',
3779
+ color: active ? theme.colors.text : (theme.colors.textMuted ?? theme.colors.textSecondary),
3780
+ cursor: 'pointer',
3781
+ transition: 'background 120ms ease',
3782
+ }}
3783
+ >
3784
+ {children}
3785
+ </button>
3786
+ );
3787
+ }
3788
+
3682
3789
  export function SubsystemComponentGraph(props: SubsystemComponentGraphProps) {
3683
3790
  const { theme } = useTheme();
3684
3791
  const wrapRef = useRef<HTMLDivElement>(null);
@@ -3738,22 +3845,6 @@ export function SubsystemComponentGraph(props: SubsystemComponentGraphProps) {
3738
3845
  props.diagnostic?.onToggle?.();
3739
3846
  }
3740
3847
  };
3741
- const viewButtonStyle = (active: boolean): CSSProperties => ({
3742
- display: 'inline-flex',
3743
- alignItems: 'center',
3744
- justifyContent: 'center',
3745
- gap: 4,
3746
- height: 28,
3747
- padding: '4px 16px',
3748
- fontFamily: theme.fonts.monospace,
3749
- fontSize: theme.fontSizes[0],
3750
- border: 'none',
3751
- borderRadius: 4,
3752
- background: active ? theme.colors.border : 'transparent',
3753
- color: active ? theme.colors.text : (theme.colors.textMuted ?? theme.colors.textSecondary),
3754
- cursor: 'pointer',
3755
- });
3756
-
3757
3848
  useEffect(() => {
3758
3849
  if (props.initialTrailId) setFilesOpen(false);
3759
3850
  }, [props.initialTrailId]);
@@ -3834,43 +3925,37 @@ export function SubsystemComponentGraph(props: SubsystemComponentGraphProps) {
3834
3925
  }}
3835
3926
  >
3836
3927
  {containerCount > 0 && (
3837
- <button
3838
- type="button"
3839
- aria-label={`Containers (${containerCount} ${containerCount === 1 ? 'container' : 'containers'})`}
3928
+ <SidebarViewOption
3929
+ ariaLabel={`Containers (${containerCount} ${containerCount === 1 ? 'container' : 'containers'})`}
3840
3930
  title="Show containers"
3841
- aria-pressed={containersActive}
3931
+ active={containersActive}
3842
3932
  onClick={() => selectSidebarView('containers')}
3843
- style={viewButtonStyle(containersActive)}
3844
3933
  >
3845
3934
  <Boxes size={14} aria-hidden />
3846
3935
  <span>Containers</span>
3847
3936
  <span style={{ fontWeight: 600, marginLeft: 4 }}>{containerCount}</span>
3848
- </button>
3937
+ </SidebarViewOption>
3849
3938
  )}
3850
- <button
3851
- type="button"
3852
- aria-label={sidebarScope.trail ? 'Trail' : `Trails (${trailCount} ${trailCount === 1 ? 'trail' : 'trails'})`}
3853
- aria-pressed={!filesActive && !containersActive && !issuesActive}
3939
+ <SidebarViewOption
3940
+ ariaLabel={sidebarScope.trail ? 'Trail' : `Trails (${trailCount} ${trailCount === 1 ? 'trail' : 'trails'})`}
3941
+ active={!filesActive && !containersActive && !issuesActive}
3854
3942
  onClick={() => selectSidebarView('trails')}
3855
- style={viewButtonStyle(!filesActive && !containersActive && !issuesActive)}
3856
3943
  >
3857
3944
  <Route size={14} aria-hidden />
3858
3945
  <span>{trailViewLabel}</span>
3859
3946
  {!sidebarScope.trail && <span style={{ fontWeight: 600, marginLeft: 4 }}>{trailCount}</span>}
3860
- </button>
3947
+ </SidebarViewOption>
3861
3948
  {hasFiles && (
3862
- <button
3863
- type="button"
3864
- aria-label={`Files (${fileCount} files)`}
3949
+ <SidebarViewOption
3950
+ ariaLabel={`Files (${fileCount} files)`}
3865
3951
  title="Show files"
3866
- aria-pressed={filesActive}
3952
+ active={filesActive}
3867
3953
  onClick={() => selectSidebarView('files')}
3868
- style={viewButtonStyle(filesActive)}
3869
3954
  >
3870
3955
  <Files size={14} aria-hidden />
3871
3956
  <span>Files</span>
3872
3957
  <span style={{ fontWeight: 600, marginLeft: 4 }}>{fileCount}</span>
3873
- </button>
3958
+ </SidebarViewOption>
3874
3959
  )}
3875
3960
  {hasIssues && (
3876
3961
  <SubsystemDiagnosticToggle
@@ -3893,6 +3978,7 @@ export function SubsystemComponentGraph(props: SubsystemComponentGraphProps) {
3893
3978
  title={props.title}
3894
3979
  hideSidebar={props.hideSidebar}
3895
3980
  description={props.description}
3981
+ notes={props.notes}
3896
3982
  descriptionOpen={props.descriptionOpen}
3897
3983
  onDescriptionOpenChange={props.onDescriptionOpenChange}
3898
3984
  diagnostic={props.diagnostic}
@@ -349,3 +349,13 @@ export const OPENBOT_SKETCH = openbot as unknown as C4Sketch;
349
349
 
350
350
  /** The real Studio → OpenBot maintenance bridge sketch (6 containers). */
351
351
  export const MAINTENANCE_BRIDGE_SKETCH = maintenanceBridge as unknown as C4Sketch;
352
+
353
+ /** Legacy shape: notes only, no short description (tests the fallback preview). */
354
+ export const NOTES_ONLY_SKETCH: C4Sketch = {
355
+ ...STUDIO_SKETCH,
356
+ id: 'c4s-gallery-notes-only',
357
+ title: 'Notes only — no description',
358
+ description: undefined,
359
+ notes:
360
+ '## About this sketch\n\nThis sketch has no short description. The sidebar falls back to a clamped preview of these notes, and **Show more** opens the full Markdown in the Overview overlay.\n\n- Use this story to check the legacy shape.\n- Existing sketches with only `notes` keep working.',
361
+ };
@@ -773,5 +773,6 @@
773
773
  "author": "opencode",
774
774
  "notes": "Top-down C4 sketch for topic topic-1792962278647-rghcszfxe: Studio → OpenBot maintenance progress card and signed completion delivery. The linked model is the existing reuse-first bridge proposal, not live integration evidence.",
775
775
  "createdAt": "2026-10-25T21:10:30.873Z",
776
- "updatedAt": "2026-10-25T21:10:30.873Z"
776
+ "updatedAt": "2026-10-25T21:10:30.873Z",
777
+ "description": "A Studio → OpenBot bridge hypothesis: maintenance progress cards in the renderer, signed completion delivery from the host, and both sides’ stores and services."
777
778
  }
@@ -882,5 +882,6 @@
882
882
  "author": "opencode",
883
883
  "notes": "Top-down C4 sketch authored from the OpenBot README, docs/architecture.md, package layout, and docker-compose services.",
884
884
  "createdAt": "2026-10-25T20:17:44.365Z",
885
- "updatedAt": "2026-10-25T20:17:44.365Z"
885
+ "updatedAt": "2026-10-25T20:17:44.365Z",
886
+ "description": "Top-down architecture for OpenBot: browser and server containers, routines and computer workers, agent bots, PostgreSQL + pgvector, and the desktop and mobile clients."
886
887
  }
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, test } from 'bun:test';
2
- import { buildSubsystemGraph, collapseBoundaryGroups, type BoundaryLayoutGroup, type SubsystemGraphEdge, type SubsystemGraphNode, type SubsystemProcessRegion } from './model';
2
+ import { buildSubsystemGraph, cardFramesForAliases, collapseBoundaryGroups, packageGroupNodeId, type BoundaryLayoutGroup, type SubsystemGraphEdge, type SubsystemGraphNode, type SubsystemProcessRegion } from './model';
3
3
  import { NODE_H, NODE_W } from './containerCard';
4
4
 
5
5
  function region(kind: SubsystemProcessRegion['kind'], key: string, members: string[]): SubsystemProcessRegion {
@@ -126,3 +126,37 @@ describe('buildSubsystemGraph collapsed frames', () => {
126
126
  expect(groupIds(built.nodes).sort()).toEqual([['process:A', true], ['process:B', false]]);
127
127
  });
128
128
  });
129
+
130
+ describe('cardFramesForAliases', () => {
131
+ const flatDoc = {
132
+ components: [
133
+ { alias: 'a1', name: 'a1', construct: 'function', file: 'a1.ts', purl: 'pkg:github/acme/app', process: 'A' },
134
+ { alias: 'a2', name: 'a2', construct: 'function', file: 'a2.ts', purl: 'pkg:github/acme/app', process: 'A' },
135
+ { alias: 'b1', name: 'b1', construct: 'function', file: 'b1.ts', purl: 'pkg:github/acme/app', process: 'B' },
136
+ { alias: 'b2', name: 'b2', construct: 'function', file: 'b2.ts', purl: 'pkg:github/acme/app', process: 'B' },
137
+ { alias: 'c1', name: 'c1', construct: 'function', file: 'c1.ts', purl: 'pkg:github/acme/app', process: 'C' },
138
+ ],
139
+ } as unknown as Parameters<typeof cardFramesForAliases>[0];
140
+
141
+ test('names the process card that holds a trail member', () => {
142
+ expect([...cardFramesForAliases(flatDoc, new Set(['a1']))]).toEqual(['process:A']);
143
+ });
144
+
145
+ test('opens every card ancestor of a nested module', () => {
146
+ const nestedDoc = {
147
+ components: [
148
+ { alias: 'a1', name: 'a1', construct: 'function', file: 'a1.ts', purl: 'pkg:github/acme/one', process: 'A', module: 'src/a.ts' },
149
+ { alias: 'a2', name: 'a2', construct: 'function', file: 'a2.ts', purl: 'pkg:github/acme/one', process: 'A', module: 'src/a.ts' },
150
+ { alias: 'b1', name: 'b1', construct: 'function', file: 'b1.ts', purl: 'pkg:github/acme/two', process: 'B', module: 'src/b.ts' },
151
+ { alias: 'b2', name: 'b2', construct: 'function', file: 'b2.ts', purl: 'pkg:github/acme/two', process: 'B', module: 'src/b.ts' },
152
+ ],
153
+ } as unknown as Parameters<typeof cardFramesForAliases>[0];
154
+ expect([...cardFramesForAliases(nestedDoc, new Set(['a1']))].sort()).toEqual(
155
+ ['process:A', packageGroupNodeId('pkg:github/acme/one')].sort(),
156
+ );
157
+ });
158
+
159
+ test('ignores aliases with no card frame and a singleton process', () => {
160
+ expect([...cardFramesForAliases(flatDoc, new Set(['c1', 'missing']))]).toEqual([]);
161
+ });
162
+ });
@@ -923,6 +923,34 @@ export function buildBoundaryLayoutGroups(
923
923
  return [...moduleGroups, ...processGroups, ...packageGroups];
924
924
  }
925
925
 
926
+ /**
927
+ * The card frames (process / package) that hold any of `aliases`, plus every
928
+ * card ancestor a nested module needs opened to become visible. This is the
929
+ * set a trail focus opens, so a picked flow reads as its components rather
930
+ * than a row of folded boxes.
931
+ */
932
+ export function cardFramesForAliases(
933
+ doc: Pick<SubsystemModelDocument, 'components'>,
934
+ aliases: ReadonlySet<string>,
935
+ opts: BoundaryFrameOptions = {},
936
+ ): Set<string> {
937
+ const groups = buildBoundaryLayoutGroups(doc, opts);
938
+ const byId = new Map(groups.map((g) => [g.id, g]));
939
+ const open = new Set<string>();
940
+ for (const group of groups) {
941
+ if (!group.memberAliases.some((alias) => aliases.has(alias))) continue;
942
+ if (isCardFrame(group.region)) open.add(group.id);
943
+ let parentId = group.parentId;
944
+ while (parentId) {
945
+ const parent = byId.get(parentId);
946
+ if (!parent) break;
947
+ if (isCardFrame(parent.region)) open.add(parent.id);
948
+ parentId = parent.parentId;
949
+ }
950
+ }
951
+ return open;
952
+ }
953
+
926
954
  /**
927
955
  * Path-nesting variant of {@link buildBoundaryLayoutGroups}.
928
956
  *