@principal-ai/subsystems-react 0.56.24 → 0.56.26

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 (133) hide show
  1. package/dist/index.d.ts +7 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +4 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/stories/Canvases/Subsystem/issuesFixtures.d.ts +4 -0
  6. package/dist/stories/Canvases/Subsystem/issuesFixtures.d.ts.map +1 -0
  7. package/dist/stories/Canvases/Subsystem/issuesFixtures.js +189 -0
  8. package/dist/stories/Canvases/Subsystem/issuesFixtures.js.map +1 -0
  9. package/dist/stories/Canvases/Subsystem/reorderFixtures.d.ts +8 -0
  10. package/dist/stories/Canvases/Subsystem/reorderFixtures.d.ts.map +1 -0
  11. package/dist/stories/Canvases/Subsystem/reorderFixtures.js +103 -0
  12. package/dist/stories/Canvases/Subsystem/reorderFixtures.js.map +1 -0
  13. package/dist/subsystem/C4ContainersPanel.d.ts +35 -0
  14. package/dist/subsystem/C4ContainersPanel.d.ts.map +1 -0
  15. package/dist/subsystem/C4ContainersPanel.js +165 -0
  16. package/dist/subsystem/C4ContainersPanel.js.map +1 -0
  17. package/dist/subsystem/C4NodeCard.d.ts.map +1 -1
  18. package/dist/subsystem/C4NodeCard.js +10 -4
  19. package/dist/subsystem/C4NodeCard.js.map +1 -1
  20. package/dist/subsystem/C4ProjectionView.d.ts +12 -2
  21. package/dist/subsystem/C4ProjectionView.d.ts.map +1 -1
  22. package/dist/subsystem/C4ProjectionView.js +100 -33
  23. package/dist/subsystem/C4ProjectionView.js.map +1 -1
  24. package/dist/subsystem/C4SketchView.d.ts.map +1 -1
  25. package/dist/subsystem/C4SketchView.js +53 -34
  26. package/dist/subsystem/C4SketchView.js.map +1 -1
  27. package/dist/subsystem/ConstructsCatalog.d.ts +18 -11
  28. package/dist/subsystem/ConstructsCatalog.d.ts.map +1 -1
  29. package/dist/subsystem/ConstructsCatalog.js +25 -27
  30. package/dist/subsystem/ConstructsCatalog.js.map +1 -1
  31. package/dist/subsystem/DescriptionOverlay.d.ts +10 -2
  32. package/dist/subsystem/DescriptionOverlay.d.ts.map +1 -1
  33. package/dist/subsystem/DescriptionOverlay.js +4 -4
  34. package/dist/subsystem/DescriptionOverlay.js.map +1 -1
  35. package/dist/subsystem/DescriptionPreview.d.ts +31 -0
  36. package/dist/subsystem/DescriptionPreview.d.ts.map +1 -0
  37. package/dist/subsystem/DescriptionPreview.js +31 -0
  38. package/dist/subsystem/DescriptionPreview.js.map +1 -0
  39. package/dist/subsystem/SubsystemComponentGraph.d.ts +13 -3
  40. package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
  41. package/dist/subsystem/SubsystemComponentGraph.js +18 -23
  42. package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
  43. package/dist/subsystem/__fixtures__/c4Sketch.d.ts.map +1 -1
  44. package/dist/subsystem/__fixtures__/c4Sketch.js +1 -0
  45. package/dist/subsystem/__fixtures__/c4Sketch.js.map +1 -1
  46. package/dist/subsystem/__fixtures__/c4SketchGallery.d.ts +29 -0
  47. package/dist/subsystem/__fixtures__/c4SketchGallery.d.ts.map +1 -0
  48. package/dist/subsystem/__fixtures__/c4SketchGallery.js +320 -0
  49. package/dist/subsystem/__fixtures__/c4SketchGallery.js.map +1 -0
  50. package/dist/subsystem/__fixtures__/c4Sketches/maintenance-bridge.json +778 -0
  51. package/dist/subsystem/__fixtures__/c4Sketches/openbot.json +887 -0
  52. package/dist/subsystem/c4Sketch.d.ts +12 -0
  53. package/dist/subsystem/c4Sketch.d.ts.map +1 -1
  54. package/dist/subsystem/c4Sketch.js +2 -1
  55. package/dist/subsystem/c4Sketch.js.map +1 -1
  56. package/dist/subsystem/containerCard.d.ts +3 -1
  57. package/dist/subsystem/containerCard.d.ts.map +1 -1
  58. package/dist/subsystem/containerCard.js +2 -2
  59. package/dist/subsystem/containerCard.js.map +1 -1
  60. package/dist/subsystem/techIcons/index.d.ts +3 -1
  61. package/dist/subsystem/techIcons/index.d.ts.map +1 -1
  62. package/dist/subsystem/techIcons/index.js +2 -2
  63. package/dist/subsystem/techIcons/index.js.map +1 -1
  64. package/package.json +1 -1
  65. package/src/index.ts +10 -0
  66. package/src/stories/Canvases/C4/C4CardGrow.stories.tsx +1 -1
  67. package/src/stories/Canvases/C4/C4Component.stories.tsx +1 -1
  68. package/src/stories/Canvases/C4/C4Container.stories.tsx +1 -1
  69. package/src/stories/Canvases/C4/C4Draft.stories.tsx +1 -1
  70. package/src/stories/Canvases/C4/C4NodeGallery.stories.tsx +1 -1
  71. package/src/stories/Canvases/C4/C4Sketch.stories.tsx +62 -4
  72. package/src/stories/Canvases/C4/C4ToComponentDrill.stories.tsx +1 -1
  73. package/src/stories/Canvases/C4/C4Transition.stories.tsx +1 -1
  74. package/src/stories/Canvases/Subsystem/AnimatedProgression.stories.tsx +1 -1
  75. package/src/stories/Canvases/Subsystem/Appearance.stories.tsx +1 -1
  76. package/src/stories/Canvases/Subsystem/Basics.stories.tsx +1 -1
  77. package/src/stories/Canvases/Subsystem/Captures.stories.tsx +1 -1
  78. package/src/stories/Canvases/Subsystem/Constructs.stories.tsx +3 -7
  79. package/src/stories/Canvases/Subsystem/ConstructsEmbed.stories.tsx +27 -0
  80. package/src/stories/Canvases/Subsystem/ContainerFrames.stories.tsx +7 -4
  81. package/src/stories/Canvases/Subsystem/CustomEntities.stories.tsx +3 -2
  82. package/src/stories/Canvases/Subsystem/Deprecated.stories.tsx +2 -100
  83. package/src/stories/Canvases/Subsystem/DeprecatedGraph.stories.tsx +124 -0
  84. package/src/stories/Canvases/Subsystem/DetailPanel.stories.tsx +1 -1
  85. package/src/stories/Canvases/Subsystem/Diagnostics.stories.tsx +1 -43
  86. package/src/stories/Canvases/Subsystem/DiagnosticsStates.stories.tsx +63 -0
  87. package/src/stories/Canvases/Subsystem/EdgeViews.stories.tsx +3 -2
  88. package/src/stories/Canvases/Subsystem/FrameworkStereotype.stories.tsx +1 -1
  89. package/src/stories/Canvases/Subsystem/GraphTitle.stories.tsx +1 -19
  90. package/src/stories/Canvases/Subsystem/GraphTitleGraph.stories.tsx +51 -0
  91. package/src/stories/Canvases/Subsystem/Issues.stories.tsx +5 -229
  92. package/src/stories/Canvases/Subsystem/IssuesList.stories.tsx +60 -0
  93. package/src/stories/Canvases/Subsystem/LayoutDirection.stories.tsx +1 -1
  94. package/src/stories/Canvases/Subsystem/ModuleBadges.stories.tsx +6 -63
  95. package/src/stories/Canvases/Subsystem/ModuleBadgesNode.stories.tsx +81 -0
  96. package/src/stories/Canvases/Subsystem/ModulePathNesting.stories.tsx +1 -1
  97. package/src/stories/Canvases/Subsystem/Modules.stories.tsx +1 -1
  98. package/src/stories/Canvases/Subsystem/NodeAnatomy.stories.tsx +1 -1
  99. package/src/stories/Canvases/Subsystem/Packages.stories.tsx +1 -1
  100. package/src/stories/Canvases/Subsystem/Presentation.stories.tsx +1 -1
  101. package/src/stories/Canvases/Subsystem/Processes.stories.tsx +3 -2
  102. package/src/stories/Canvases/Subsystem/Reorder.stories.tsx +5 -154
  103. package/src/stories/Canvases/Subsystem/ReorderPanel.stories.tsx +75 -0
  104. package/src/stories/Canvases/Subsystem/Scenarios.stories.tsx +7 -4
  105. package/src/stories/Canvases/Subsystem/Spotlights.stories.tsx +1 -1
  106. package/src/stories/Canvases/Subsystem/StepEmphasis.stories.tsx +1 -1
  107. package/src/stories/Canvases/Subsystem/StoreValueType.stories.tsx +1 -1
  108. package/src/stories/Canvases/Subsystem/TrailAutoplay.stories.tsx +3 -2
  109. package/src/stories/Canvases/Subsystem/TrailSidebarViews.stories.tsx +1 -1
  110. package/src/stories/Canvases/Subsystem/Trails.stories.tsx +5 -3
  111. package/src/stories/Canvases/Subsystem/WorkspacePackageFrames.stories.tsx +1 -1
  112. package/src/stories/Canvases/Subsystem/issuesFixtures.ts +192 -0
  113. package/src/stories/Canvases/Subsystem/reorderFixtures.tsx +125 -0
  114. package/src/stories/Components/ConstructsCatalog.stories.tsx +2 -1
  115. package/src/subsystem/C4ContainersPanel.test.tsx +151 -0
  116. package/src/subsystem/C4ContainersPanel.tsx +315 -0
  117. package/src/subsystem/C4NodeCard.tsx +12 -4
  118. package/src/subsystem/C4ProjectionView.tsx +151 -53
  119. package/src/subsystem/C4SketchView.tsx +96 -74
  120. package/src/subsystem/ConstructsCatalog.tsx +59 -58
  121. package/src/subsystem/DescriptionOverlay.test.tsx +18 -8
  122. package/src/subsystem/DescriptionOverlay.tsx +20 -5
  123. package/src/subsystem/DescriptionPreview.tsx +96 -0
  124. package/src/subsystem/SubsystemComponentGraph.sidebar.test.tsx +28 -8
  125. package/src/subsystem/SubsystemComponentGraph.tsx +46 -51
  126. package/src/subsystem/__fixtures__/c4Sketch.ts +2 -0
  127. package/src/subsystem/__fixtures__/c4SketchGallery.test.ts +65 -0
  128. package/src/subsystem/__fixtures__/c4SketchGallery.ts +361 -0
  129. package/src/subsystem/__fixtures__/c4Sketches/maintenance-bridge.json +778 -0
  130. package/src/subsystem/__fixtures__/c4Sketches/openbot.json +887 -0
  131. package/src/subsystem/c4Sketch.ts +13 -0
  132. package/src/subsystem/containerCard.tsx +4 -1
  133. package/src/subsystem/techIcons/index.tsx +11 -2
@@ -61,19 +61,39 @@ describe('subsystem graph sidebar', () => {
61
61
  expect(content?.textContent).not.toContain('Request subsystem');
62
62
  });
63
63
 
64
- test('truncates the description without scrolling and offers the full description', () => {
64
+ test('shows the short description unclamped and without a notes link', () => {
65
65
  const body = renderGraph();
66
- const description = body.querySelector('[style*="-webkit-line-clamp:6"]') as HTMLElement;
67
- expect(description).not.toBeNull();
68
- expect(description.textContent).toContain('Always visible description.');
69
- expect(description.style.overflow).toBe('hidden');
70
- expect(description.style.maxHeight).toBe('9em');
66
+ const description = body.querySelector('[style*="-webkit-line-clamp:6"]') as HTMLElement | null;
67
+ expect(description).toBeNull();
68
+ expect(body.textContent).toContain('Always visible description.');
69
+ expect(body.querySelector('button[aria-label="Read full description"]')).toBeNull();
70
+ expect(body.querySelector('[role="dialog"]')).toBeNull();
71
+ });
72
+
73
+ test('offers the extended notes from the short description', () => {
74
+ const body = renderGraph({
75
+ notes: '## Extended\n\nLonger **context**.',
76
+ });
77
+ expect(body.textContent).toContain('Always visible description.');
78
+ expect(body.textContent).not.toContain('Longer context.');
71
79
  const more = body.querySelector('button[aria-label="Read full description"]');
72
- expect(more?.textContent).toBe('More');
80
+ expect(more?.textContent).toBe('Show more');
73
81
  expect(more?.getAttribute('aria-haspopup')).toBe('dialog');
74
82
  expect(more?.getAttribute('aria-expanded')).toBe('false');
75
83
  expect(body.querySelector('[role="dialog"]')).toBeNull();
76
- expect(body.querySelector('[style*="max-height:30%"]')).toBeNull();
84
+ });
85
+
86
+ test('falls back to a clamped notes preview when there is no description', () => {
87
+ const body = renderGraph({
88
+ description: undefined,
89
+ notes: '## Extended\n\nLonger **context**.',
90
+ });
91
+ const preview = body.querySelector('[style*="-webkit-line-clamp:6"]') as HTMLElement;
92
+ expect(preview).not.toBeNull();
93
+ expect(preview.textContent).toContain('Extended');
94
+ expect(preview.style.overflow).toBe('hidden');
95
+ expect(preview.style.maxHeight).toBe('9em');
96
+ expect(body.querySelector('button[aria-label="Read full description"]')?.textContent).toBe('Show more');
77
97
  });
78
98
 
79
99
  test('keeps the Files button in the header when no name is provided', () => {
@@ -32,8 +32,8 @@ 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
- import { IndustryMarkdownSlide } from 'themed-markdown';
37
37
  import {
38
38
  buildSubsystemGraph,
39
39
  deriveGraphEdges,
@@ -98,6 +98,7 @@ import type { DeclarationSymbolRef, SymbolInspection } from './symbolRefs';
98
98
  import { FileDrawer, FILE_DRAWER_HEIGHT_MS } from './FileDrawer';
99
99
  import { GraphWithSidebar } from './GraphWithSidebar';
100
100
  import { DescriptionOverlay } from './DescriptionOverlay';
101
+ import { DescriptionPreview } from './DescriptionPreview';
101
102
  import type { GraphSidebarTab } from './GraphSidebar';
102
103
  import { TrailsPanel, TRAIL_PLAY_PAUSE_MS, TRAIL_HOVER_PREVIEW_MS } from './TrailsPanel';
103
104
  import type { StepEmphasisMap } from './stepEmphasis';
@@ -408,11 +409,21 @@ export interface SubsystemComponentGraphProps {
408
409
  * Uses the focused or hover-highlighted trail.
409
410
  */
410
411
  showTrailTitle?: boolean;
411
- /** Markdown description rendered in the sidebar. */
412
+ /**
413
+ * Short description rendered at the top of the sidebar. At most 200
414
+ * characters; extended detail belongs in `notes`.
415
+ */
412
416
  description?: string;
413
417
  /**
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).
418
+ * Extended Markdown notes about the model. When set, the description's
419
+ * `Show more` link opens the full document in an Overview overlay. Omit
420
+ * `description` and the sidebar falls back to a clamped preview of these
421
+ * notes.
422
+ */
423
+ notes?: string;
424
+ /**
425
+ * Controlled open state for the notes overlay. When provided, the host owns
426
+ * it (e.g. a button in its own header).
416
427
  */
417
428
  descriptionOpen?: boolean;
418
429
  onDescriptionOpenChange?: (open: boolean) => void;
@@ -698,10 +709,21 @@ interface InnerProps extends SubsystemComponentGraphProps {
698
709
  onSidebarTrailChange: (trailId: string | null) => void;
699
710
  }
700
711
 
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) {
712
+ 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
713
  const { theme } = useTheme();
703
714
  const { fitView, fitBounds } = useReactFlow();
704
715
  const [descriptionOpen, setDescriptionOpen] = useState(false);
716
+ const rawDescription = description?.trim();
717
+ // The host caps the authored description; trim defensively for other hosts.
718
+ const shortDescription =
719
+ rawDescription && rawDescription.length > SUBSYSTEM_MODEL_DESCRIPTION_MAX
720
+ ? `${rawDescription.slice(0, SUBSYSTEM_MODEL_DESCRIPTION_MAX - 1)}…`
721
+ : rawDescription;
722
+ const extendedNotes = notes?.trim();
723
+ // The short description owns the top-left slot; a legacy model with only
724
+ // notes falls back to a clamped preview of them.
725
+ const descriptionPreview = shortDescription || extendedNotes;
726
+ const hasNotes = Boolean(extendedNotes);
705
727
  const viewport = useViewport();
706
728
  // Restored once per mount from `localStorage` (see `readViewState`). Each
707
729
  // graph is its own tab/mount, so `persistKey` is stable for a mount.
@@ -2975,7 +2997,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
2975
2997
  // the same facts the sidebar renders.
2976
2998
  const sidebarVisible =
2977
2999
  !hideSidebar &&
2978
- (description || filesActive || containersActive || issuesActive || sidebarExtra || sidebarAfterDescription ||
3000
+ (descriptionPreview || filesActive || containersActive || issuesActive || sidebarExtra || sidebarAfterDescription ||
2979
3001
  hasTrails);
2980
3002
  const sidebarBodyVisible = hasTrails || filesActive || containersActive || issuesActive;
2981
3003
  const sidebarTabs: GraphSidebarTab[] | undefined = issuesActive && !sidebarTrail
@@ -2986,52 +3008,19 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
2986
3008
  ]
2987
3009
  : undefined
2988
3010
  : undefined;
2989
- // Header block: extras, then the description.
3011
+ // Header block: extras, then the short description.
2990
3012
  const sidebarHeader = (
2991
3013
  <>
2992
3014
  {sidebarExtra}
2993
- {description && (
2994
- <div style={{ fontSize: theme.fontSizes[0], lineHeight: 1.5 }}>
2995
- <div style={{
2996
- display: '-webkit-box',
2997
- WebkitBoxOrient: 'vertical',
2998
- WebkitLineClamp: 6,
2999
- maxHeight: '9em',
3000
- overflow: 'hidden',
3001
- }}>
3002
- <IndustryMarkdownSlide
3003
- content={description}
3004
- slideIdPrefix="subsystem-desc"
3005
- slideIndex={0}
3006
- isVisible={true}
3007
- theme={theme}
3008
- disableScroll={true}
3009
- disableBasePadding
3010
- enableKeyboardScrolling={false}
3011
- autoFocusOnVisible={false}
3012
- />
3013
- </div>
3014
- <button
3015
- type="button"
3016
- aria-label="Read full description"
3017
- aria-haspopup="dialog"
3018
- aria-expanded={descriptionOpen}
3019
- onClick={() => setDescriptionOpen(true)}
3020
- style={{
3021
- marginTop: 6,
3022
- padding: 0,
3023
- border: 'none',
3024
- background: 'transparent',
3025
- color: theme.colors.textSecondary,
3026
- fontFamily: theme.fonts.body,
3027
- fontSize: theme.fontSizes[0],
3028
- textDecoration: 'underline',
3029
- cursor: 'pointer',
3030
- }}
3031
- >
3032
- More
3033
- </button>
3034
- </div>
3015
+ {descriptionPreview && (
3016
+ <DescriptionPreview
3017
+ content={descriptionPreview}
3018
+ clamp={!shortDescription}
3019
+ open={hasNotes && descriptionOpen}
3020
+ onOpen={hasNotes ? () => setDescriptionOpen(true) : undefined}
3021
+ onClose={hasNotes ? () => setDescriptionOpen(false) : undefined}
3022
+ slideIdPrefix="subsystem-desc"
3023
+ />
3035
3024
  )}
3036
3025
  {sidebarAfterDescription}
3037
3026
  </>
@@ -3177,8 +3166,13 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
3177
3166
  persistKey={persistKey}
3178
3167
  onResizeEnd={() => requestAnimationFrame(() => fitView())}
3179
3168
  >
3180
- {!hideSidebar && description && descriptionOpen && (
3181
- <DescriptionOverlay description={description} onClose={() => setDescriptionOpen(false)} />
3169
+ {!hideSidebar && hasNotes && descriptionOpen && (
3170
+ <DescriptionOverlay
3171
+ description={extendedNotes ?? ''}
3172
+ ariaLabel="Subsystem notes"
3173
+ slideIdPrefix="subsystem-desc-overlay"
3174
+ onClose={() => setDescriptionOpen(false)}
3175
+ />
3182
3176
  )}
3183
3177
  {/* Graph area */}
3184
3178
  <div style={{ flex: 1, position: 'relative', display: 'flex', flexDirection: committedDirection === 'vertical' ? 'row' : 'column', minHeight: 0, minWidth: 0 }}>
@@ -3922,6 +3916,7 @@ export function SubsystemComponentGraph(props: SubsystemComponentGraphProps) {
3922
3916
  title={props.title}
3923
3917
  hideSidebar={props.hideSidebar}
3924
3918
  description={props.description}
3919
+ notes={props.notes}
3925
3920
  descriptionOpen={props.descriptionOpen}
3926
3921
  onDescriptionOpenChange={props.onDescriptionOpenChange}
3927
3922
  diagnostic={props.diagnostic}
@@ -14,6 +14,8 @@ export const SKETCH_FIXTURE: C4Sketch = {
14
14
  title: 'Acme widget architecture',
15
15
  repoKeys: [PURL],
16
16
  author: 'storybook',
17
+ description:
18
+ 'An authored hypothesis for the Acme widget: a host, a worker, a store inside the host, and a GitHub integration.',
17
19
  notes:
18
20
  '## About this sketch\n\nThis is an **authored hypothesis** for the Acme widget. It describes the host and worker containers, the store inside the host, and the GitHub integration.\n\n- The worker calls the host over RPC.\n- The host calls GitHub over HTTPS.\n- Nothing here is verified or promoted.',
19
21
  createdAt: '2026-10-25T00:00:00.000Z',
@@ -0,0 +1,65 @@
1
+ import { describe, expect, test } from 'bun:test';
2
+ import type { C4Container } from '../c4';
3
+ import { C4_SKETCH_DESCRIPTION_MAX } from '../c4Sketch';
4
+ import {
5
+ CONTAINER_MATRIX_SKETCH,
6
+ DESCRIPTION_BOUNDARY_SKETCH,
7
+ MAINTENANCE_BRIDGE_SKETCH,
8
+ OPENBOT_SKETCH,
9
+ STUDIO_SKETCH,
10
+ } from './c4SketchGallery';
11
+
12
+ const containers = (sketch: { model: { nodes: Array<{ kind: string }> } }) =>
13
+ sketch.model.nodes.filter((node): node is C4Container => node.kind === 'container');
14
+
15
+ describe('C4 sketch gallery fixtures', () => {
16
+ test('the studio sketch carries the shipped system containers', () => {
17
+ const labels = containers(STUDIO_SKETCH).map((c) => c.label);
18
+ expect(labels).toEqual([
19
+ 'Studio host',
20
+ 'Studio renderer',
21
+ 'Principal CLI',
22
+ 'Site — web',
23
+ 'Model store',
24
+ ]);
25
+ const store = containers(STUDIO_SKETCH).find((c) => c.label === 'Model store');
26
+ expect(store?.containerKind).toBe('data-store');
27
+ expect(containers(STUDIO_SKETCH).every((c) => c.state === 'proposed')).toBe(true);
28
+ });
29
+
30
+ test('the real sketches keep their authored container counts', () => {
31
+ expect(containers(OPENBOT_SKETCH)).toHaveLength(12);
32
+ expect(containers(MAINTENANCE_BRIDGE_SKETCH)).toHaveLength(6);
33
+ expect(OPENBOT_SKETCH.notes?.length ?? 0).toBeGreaterThan(0);
34
+ expect(MAINTENANCE_BRIDGE_SKETCH.notes?.length ?? 0).toBeGreaterThan(0);
35
+ });
36
+
37
+ test('the matrix covers kind, state, technology, and member-count variants', () => {
38
+ const rows = containers(CONTAINER_MATRIX_SKETCH);
39
+ expect(rows.length).toBe(7);
40
+ expect(new Set(rows.map((c) => c.containerKind))).toEqual(
41
+ new Set(['application', 'data-store']),
42
+ );
43
+ expect(new Set(rows.map((c) => c.state))).toEqual(
44
+ new Set(['accepted', 'proposed']),
45
+ );
46
+ expect(rows.some((c) => c.technology === '')).toBe(true);
47
+ expect(rows.some((c) => c.label.length > 50)).toBe(true);
48
+ expect(rows.some((c) => c.label === 'Crowded container')).toBe(true);
49
+ expect(rows.some((c) => c.label === 'Empty but accepted')).toBe(true);
50
+ });
51
+
52
+ test('descriptions stay inside the 200-character contract', () => {
53
+ for (const sketch of [
54
+ STUDIO_SKETCH,
55
+ CONTAINER_MATRIX_SKETCH,
56
+ DESCRIPTION_BOUNDARY_SKETCH,
57
+ ]) {
58
+ expect((sketch.description ?? '').length).toBeLessThanOrEqual(
59
+ C4_SKETCH_DESCRIPTION_MAX,
60
+ );
61
+ }
62
+ expect(DESCRIPTION_BOUNDARY_SKETCH.description?.length).toBeGreaterThan(180);
63
+ expect(DESCRIPTION_BOUNDARY_SKETCH.notes?.length ?? 0).toBeGreaterThan(200);
64
+ });
65
+ });
@@ -0,0 +1,361 @@
1
+ /**
2
+ * Storybook fixtures for the C4 sketch gallery.
3
+ *
4
+ * The two `OPENBOT_*` / `MAINTENANCE_BRIDGE_*` sketches are the real authored
5
+ * sketches from `~/.principal/c4-sketches`, kept verbatim so the stories
6
+ * exercise the container shapes and edge counts the views actually see.
7
+ *
8
+ * `STUDIO_SKETCH` is this repo's own system drawn at the same level: host,
9
+ * renderer, CLI, site, and the on-disk model store. `CONTAINER_MATRIX_SKETCH`
10
+ * and `DESCRIPTION_BOUNDARY_SKETCH` are deliberate stress rows for the sidebar
11
+ * (kind, state, technology, member count, long labels, 200-char description).
12
+ */
13
+
14
+ import type {
15
+ C4Component,
16
+ C4Container,
17
+ C4Edge,
18
+ C4ExternalSystem,
19
+ C4Person,
20
+ } from '../c4';
21
+ import type { C4Sketch } from '../c4Sketch';
22
+ import openbot from './c4Sketches/openbot.json';
23
+ import maintenanceBridge from './c4Sketches/maintenance-bridge.json';
24
+
25
+ const PURL = 'pkg:github/principal-ai/subsystem-modeling';
26
+
27
+ function container(
28
+ over: Partial<C4Container> & Pick<C4Container, 'id' | 'label'>,
29
+ ): C4Container {
30
+ return {
31
+ kind: 'container',
32
+ containerKind: 'application',
33
+ technology: '',
34
+ state: 'proposed',
35
+ ...over,
36
+ };
37
+ }
38
+
39
+ function component(
40
+ over: Partial<C4Component> & Pick<C4Component, 'id' | 'label' | 'container'>,
41
+ ): C4Component {
42
+ return {
43
+ kind: 'component',
44
+ technology: '',
45
+ state: 'proposed',
46
+ ...over,
47
+ };
48
+ }
49
+
50
+ function external(
51
+ over: Partial<C4ExternalSystem> & Pick<C4ExternalSystem, 'id' | 'label'>,
52
+ ): C4ExternalSystem {
53
+ return { kind: 'external-system', state: 'proposed', ...over };
54
+ }
55
+
56
+ function person(
57
+ over: Partial<C4Person> & Pick<C4Person, 'id' | 'label'>,
58
+ ): C4Person {
59
+ return { kind: 'person', state: 'proposed', ...over };
60
+ }
61
+
62
+ let edgeSeq = 0;
63
+ function edge(
64
+ source: string,
65
+ target: string,
66
+ label: string,
67
+ over: Partial<C4Edge> = {},
68
+ ): C4Edge {
69
+ edgeSeq += 1;
70
+ return {
71
+ id: `e:${edgeSeq}`,
72
+ source,
73
+ target,
74
+ label,
75
+ protocol: label,
76
+ mechanisms: ['calls'],
77
+ count: 1,
78
+ ...over,
79
+ };
80
+ }
81
+
82
+ /** This repo's system containers, at the C4 container level. */
83
+ export const STUDIO_SKETCH: C4Sketch = {
84
+ id: 'c4s-gallery-studio',
85
+ title: 'Subsystem Modeling — system containers',
86
+ repoKeys: [PURL],
87
+ author: 'storybook',
88
+ description:
89
+ 'The shipped system: Studio host and renderer, the Principal CLI, the web site, and the on-disk model store they share.',
90
+ notes:
91
+ '## System containers\n\nThis sketch draws the containers this repository actually ships:\n\n- **Studio host** — Bun + Electrobun process that owns the disk store API.\n- **Studio renderer** — React surfaces for the model list and model tabs.\n- **Principal CLI** — the agent-facing author path.\n- **Site — web** — the public gist viewer.\n- **Model store** — JSON files under `~/.principal/subsystem-models`.\n\nEverything is `proposed`: a sketch is a hypothesis, never an accepted element.',
92
+ createdAt: '2026-11-01T00:00:00.000Z',
93
+ updatedAt: '2026-11-01T00:00:00.000Z',
94
+ model: {
95
+ view: 'container',
96
+ system: { id: 'system:subsystem-modeling', label: 'Subsystem Modeling', repoKey: PURL },
97
+ nodes: [
98
+ container({
99
+ id: 'container:studio-host',
100
+ label: 'Studio host',
101
+ technology: 'Bun + Electrobun',
102
+ process: 'subsystems-studio/host',
103
+ description: 'Owns the disk store API: create, update, get, index rows, tab opening.',
104
+ }),
105
+ component({
106
+ id: 'component:host-store',
107
+ label: 'Subsystem model store',
108
+ container: 'container:studio-host',
109
+ technology: 'Bun fs',
110
+ }),
111
+ component({
112
+ id: 'component:host-tabs',
113
+ label: 'Tab opening',
114
+ container: 'container:studio-host',
115
+ technology: 'Bun',
116
+ }),
117
+ container({
118
+ id: 'container:studio-renderer',
119
+ label: 'Studio renderer',
120
+ technology: 'Electrobun + React',
121
+ process: 'subsystems-studio/renderer',
122
+ description: 'Model list and model tab chrome.',
123
+ }),
124
+ component({
125
+ id: 'component:renderer-views',
126
+ label: 'Model views',
127
+ container: 'container:studio-renderer',
128
+ technology: 'React',
129
+ }),
130
+ component({
131
+ id: 'component:renderer-c4',
132
+ label: 'C4 views',
133
+ container: 'container:studio-renderer',
134
+ technology: 'React + React Flow',
135
+ }),
136
+ container({
137
+ id: 'container:principal-cli',
138
+ label: 'Principal CLI',
139
+ technology: 'Bun',
140
+ process: 'principal-studio-cli',
141
+ description: 'Agent-facing author path for subsystem models.',
142
+ }),
143
+ component({
144
+ id: 'component:cli-create',
145
+ label: 'subsystem-model command',
146
+ container: 'container:principal-cli',
147
+ technology: 'Bun',
148
+ }),
149
+ container({
150
+ id: 'container:site-web',
151
+ label: 'Site — web',
152
+ technology: 'React + Vite',
153
+ process: 'site/web',
154
+ description: 'The public gist viewer.',
155
+ }),
156
+ component({
157
+ id: 'component:site-gist',
158
+ label: 'Gist page & loader',
159
+ container: 'container:site-web',
160
+ technology: 'React',
161
+ }),
162
+ container({
163
+ id: 'container:model-store',
164
+ label: 'Model store',
165
+ containerKind: 'data-store',
166
+ technology: 'JSON on disk',
167
+ description: 'Shared on-disk store; not owned by any one process.',
168
+ }),
169
+ external({
170
+ id: 'external:github',
171
+ label: 'GitHub Gists API',
172
+ technology: 'REST',
173
+ members: ['github-gists-api'],
174
+ }),
175
+ person({ id: 'person:maintainer', label: 'Maintainer' }),
176
+ ],
177
+ edges: [
178
+ edge('person:maintainer', 'container:studio-renderer', 'uses'),
179
+ edge('container:studio-renderer', 'container:studio-host', 'RPC'),
180
+ edge('container:principal-cli', 'container:studio-host', 'calls'),
181
+ edge('container:studio-host', 'container:model-store', 'writes'),
182
+ edge('container:studio-host', 'external:github', 'HTTPS'),
183
+ edge('container:site-web', 'external:github', 'reads', { mechanisms: ['reads'] }),
184
+ ],
185
+ },
186
+ };
187
+
188
+ /**
189
+ * One row per drawer/row variant: application vs data-store, accepted vs
190
+ * proposed, technology brand vs missing, long labels, and 0 / 1 / 6 members.
191
+ */
192
+ export const CONTAINER_MATRIX_SKETCH: C4Sketch = {
193
+ id: 'c4s-gallery-matrix',
194
+ title: 'Container matrix',
195
+ repoKeys: [PURL],
196
+ author: 'storybook',
197
+ description:
198
+ 'Every container-row variant in one sketch: application/data-store, accepted/proposed, known/missing technology, long labels, and zero or many members.',
199
+ createdAt: '2026-11-01T00:00:00.000Z',
200
+ updatedAt: '2026-11-01T00:00:00.000Z',
201
+ model: {
202
+ view: 'container',
203
+ system: { id: 'system:matrix', label: 'Container matrix' },
204
+ nodes: [
205
+ container({
206
+ id: 'container:mono',
207
+ label: 'Bun service',
208
+ technology: 'Bun + Hono',
209
+ state: 'accepted',
210
+ description: 'Accepted application with a known technology brand.',
211
+ }),
212
+ component({
213
+ id: 'component:mono-handler',
214
+ label: 'HTTP handler',
215
+ container: 'container:mono',
216
+ technology: 'Hono',
217
+ state: 'accepted',
218
+ }),
219
+ container({
220
+ id: 'container:draft-worker',
221
+ label: 'Draft worker',
222
+ technology: 'Bun',
223
+ description: 'Proposed application — dashed card and a proposed chip in the row.',
224
+ }),
225
+ component({
226
+ id: 'component:worker-sweep',
227
+ label: 'Routine sweep',
228
+ container: 'container:draft-worker',
229
+ technology: 'Bun',
230
+ }),
231
+ component({
232
+ id: 'component:worker-queue',
233
+ label: 'Queue reader',
234
+ container: 'container:draft-worker',
235
+ technology: 'PostgreSQL',
236
+ }),
237
+ container({
238
+ id: 'container:postgres',
239
+ label: 'PostgreSQL + pgvector',
240
+ containerKind: 'data-store',
241
+ technology: 'PostgreSQL 17 + pgvector',
242
+ state: 'accepted',
243
+ description: 'Accepted data store with a long technology string.',
244
+ }),
245
+ component({
246
+ id: 'component:product-schema',
247
+ label: 'Product schema',
248
+ container: 'container:postgres',
249
+ technology: 'Drizzle + SQL',
250
+ state: 'accepted',
251
+ }),
252
+ container({
253
+ id: 'container:cache',
254
+ label: 'Ephemeral cache',
255
+ containerKind: 'data-store',
256
+ technology: '',
257
+ description: 'Data store with no stated technology — the card shows the gap.',
258
+ }),
259
+ container({
260
+ id: 'container:long-label',
261
+ label: 'An intentionally long container label that has to truncate in the sidebar',
262
+ technology: 'React 19 + Vite + TanStack Router + TypeScript',
263
+ state: 'accepted',
264
+ description: 'Long label and long technology; the row ellipsizes both.',
265
+ }),
266
+ component({
267
+ id: 'component:long-label-view',
268
+ label: 'Router view',
269
+ container: 'container:long-label',
270
+ technology: 'React',
271
+ state: 'accepted',
272
+ }),
273
+ container({
274
+ id: 'container:no-members',
275
+ label: 'Empty but accepted',
276
+ technology: 'Rust',
277
+ state: 'accepted',
278
+ description: 'Zero components — member count reads 0.',
279
+ }),
280
+ container({
281
+ id: 'container:many-members',
282
+ label: 'Crowded container',
283
+ technology: 'Bun',
284
+ state: 'accepted',
285
+ description: 'Six components, for the row count and the opened card.',
286
+ }),
287
+ ...[
288
+ ['orders', 'Orders service', 'Bun'],
289
+ ['billing', 'Billing service', 'Bun'],
290
+ ['audit', 'Audit trail', 'PostgreSQL'],
291
+ ['identity', 'Identity', 'better-auth'],
292
+ ['approvals', 'Approvals', 'Bun'],
293
+ ['delivery', 'Delivery', 'Hono'],
294
+ ].map(([slug, label, technology]) =>
295
+ component({
296
+ id: `component:many-${slug}`,
297
+ label: label!,
298
+ container: 'container:many-members',
299
+ technology: technology!,
300
+ state: 'accepted',
301
+ }),
302
+ ),
303
+ ],
304
+ edges: [
305
+ edge('container:mono', 'container:postgres', 'writes'),
306
+ edge('container:draft-worker', 'container:postgres', 'reads', { mechanisms: ['reads'] }),
307
+ edge('container:mono', 'container:cache', 'caches', { mechanisms: ['writes'] }),
308
+ edge('container:long-label', 'container:mono', 'calls'),
309
+ edge('container:many-members', 'container:postgres', 'writes'),
310
+ ],
311
+ },
312
+ };
313
+
314
+ /** A description at the 200-character boundary plus long Markdown notes. */
315
+ export const DESCRIPTION_BOUNDARY_SKETCH: C4Sketch = {
316
+ id: 'c4s-gallery-description',
317
+ title: 'Description boundary',
318
+ repoKeys: [PURL],
319
+ author: 'storybook',
320
+ description:
321
+ 'A deliberately long description that fills the 200-character budget so the sidebar header can be sized at its limit. It names the host, renderer, store, CLI, and sites without needing extended notes!',
322
+ notes:
323
+ '## Overview\n\nThe short description stays at the top of the sidebar and the header is sized by it. This extended document is what **Show more** opens.\n\n### What it covers\n\n- A description at the 200-character cap.\n- Markdown notes long enough to need the overlay.\n- A single container so the sidebar row is the only other content.\n\n### Why it matters\n\nThe cap makes the header height predictable; the extended notes keep the detail out of the canvas until someone asks for it.',
324
+ createdAt: '2026-11-01T00:00:00.000Z',
325
+ updatedAt: '2026-11-01T00:00:00.000Z',
326
+ model: {
327
+ view: 'container',
328
+ system: { id: 'system:boundary', label: 'Description boundary' },
329
+ nodes: [
330
+ container({
331
+ id: 'container:only',
332
+ label: 'Single container',
333
+ technology: 'Bun',
334
+ description: 'The one row under a long description.',
335
+ }),
336
+ component({
337
+ id: 'component:only-handler',
338
+ label: 'Handler',
339
+ container: 'container:only',
340
+ technology: 'Hono',
341
+ }),
342
+ ],
343
+ edges: [],
344
+ },
345
+ };
346
+
347
+ /** The real OpenBot architecture sketch (12 containers, 32 authored edges). */
348
+ export const OPENBOT_SKETCH = openbot as unknown as C4Sketch;
349
+
350
+ /** The real Studio → OpenBot maintenance bridge sketch (6 containers). */
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
+ };