@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
@@ -56,7 +56,7 @@ function Demo() {
56
56
  }
57
57
 
58
58
  const meta = {
59
- title: 'Canvases/Subsystem/TrailSidebarViews',
59
+ title: 'Canvases/Subsystem/Views/TrailSidebarViews',
60
60
  component: SubsystemComponentGraph,
61
61
  parameters: { layout: 'fullscreen' },
62
62
  decorators: [(Story) => (
@@ -8,7 +8,7 @@ import { PierreTrailCodeView } from '../../../pierre';
8
8
  import type { TrailViewerContext } from '../../../subsystem/SubsystemComponentGraph';
9
9
 
10
10
  const meta = {
11
- title: 'Canvases/Subsystem/Trails',
11
+ title: 'Canvases/Subsystem/Views/Trails',
12
12
  component: SubsystemComponentGraph,
13
13
  parameters: {
14
14
  layout: 'fullscreen',
@@ -194,7 +194,8 @@ function TrailsDemo() {
194
194
  components={drawingComponents}
195
195
  trails={drawingTrails}
196
196
  title="drawing-files flow"
197
- description="Three trails over one graph — opening, saving, and deleting a drawing. The sidebar's **Trails** panel lists each step by **symbol**; clicking a step focuses that step and scrolls the bottom CodeView to that snippet."
197
+ description="Three trails over one graph — opening, saving, and deleting a drawing."
198
+ notes="The sidebar's **Trails** panel lists each step by **symbol**; clicking a step focuses that step and scrolls the bottom CodeView to that snippet."
198
199
  renderTrailViewer={renderTrailViewer}
199
200
  renderFileViewer={(file, opts) => (
200
201
  <div
@@ -411,7 +412,8 @@ function ClickableConstructsDemo() {
411
412
  trails={clickableTrails}
412
413
  initialTrailId="tl-load"
413
414
  title="clickable constructs"
414
- description="A trail step's line is an edge to a construct. Tokens that name the step's `from`/`to` components are clickable and open that construct's declaration line in the file drawer — including a **method** endpoint (click `list` to jump to `DrawingStore.list`)."
415
+ description="A trail step's line is an edge to a construct."
416
+ notes="Tokens that name the step's `from`/`to` components are clickable and open that construct's declaration line in the file drawer — including a **method** endpoint (click `list` to jump to `DrawingStore.list`)."
415
417
  renderTrailViewer={renderTrailViewer}
416
418
  onFileSelect={setOpened}
417
419
  renderFileViewer={(file, opts) => (
@@ -6,7 +6,7 @@ import type { SubsystemComponent } from '../../../subsystem/model';
6
6
  import { graphSpecFromSteps } from './fixtures';
7
7
 
8
8
  const meta = {
9
- title: 'Canvases/Subsystem/WorkspacePackages',
9
+ title: 'Canvases/Subsystem/Views/WorkspacePackages',
10
10
  component: SubsystemComponentGraph,
11
11
  parameters: { layout: 'fullscreen' },
12
12
  tags: ['autodocs'],
@@ -0,0 +1,192 @@
1
+ import type { SubsystemIssue } from '../../../subsystem/IssueList';
2
+
3
+ export const ISSUES: SubsystemIssue[] = [
4
+ {
5
+ id: 'i1',
6
+ severity: 'error',
7
+ kind: 'missing_file',
8
+ message: 'File src/checkout/cartStore.ts is not present on disk (repo pkg:github/you/your-app).',
9
+ target: { kind: 'component', id: 'store', label: 'cartStore' },
10
+ fix: { label: 'Use graphify file' },
11
+ },
12
+ {
13
+ id: 'i2',
14
+ severity: 'error',
15
+ kind: 'construct_mismatch',
16
+ message: 'Claimed function but graphify infers class.',
17
+ target: { kind: 'component', id: 'entry', label: 'checkoutApi' },
18
+ },
19
+ {
20
+ id: 'i3',
21
+ severity: 'info',
22
+ kind: 'signature_unconfirmed',
23
+ message: 'Named parameter types are not present in the graphify cache.',
24
+ target: { kind: 'component', id: 'entry', label: 'checkoutApi' },
25
+ },
26
+ {
27
+ id: 'i5',
28
+ severity: 'info',
29
+ kind: 'boundary_module_file_mismatch',
30
+ message: 'Module "src/checkout" contains a file outside its declared root.',
31
+ target: { kind: 'module', id: 'src/checkout', label: 'src/checkout' },
32
+ },
33
+ {
34
+ id: 'i6',
35
+ severity: 'info',
36
+ kind: 'trail',
37
+ message: 'Step 2 references a line that moved (was :42).',
38
+ target: {
39
+ kind: 'step',
40
+ id: 'story-steps',
41
+ label: 'Story steps',
42
+ detail: 'step 2',
43
+ stepIndex: 1,
44
+ },
45
+ },
46
+ {
47
+ id: 'i20',
48
+ severity: 'error',
49
+ kind: 'step_span_unconfirmed',
50
+ message: 'Trail "Story steps" step 1: step span not captured (entry → store via writes)',
51
+ target: {
52
+ kind: 'step',
53
+ id: 'story-steps',
54
+ label: 'Story steps',
55
+ detail: 'step 1',
56
+ stepIndex: 0,
57
+ },
58
+ },
59
+ {
60
+ id: 'i21',
61
+ severity: 'info',
62
+ kind: 'step_span_stale',
63
+ message: 'Trail "Story steps" step 2: step span changed since verification (lines 42-44 in src/checkout/api.ts)',
64
+ target: {
65
+ kind: 'step',
66
+ id: 'story-steps',
67
+ label: 'Story steps',
68
+ detail: 'step 2',
69
+ stepIndex: 1,
70
+ },
71
+ },
72
+ {
73
+ id: 'i7',
74
+ severity: 'info',
75
+ kind: 'boundary_process_nest_disagree',
76
+ message:
77
+ 'module "src/host/main.ts" members claim different processes: "host", "renderer"',
78
+ target: { kind: 'module', id: 'src/host/main.ts', label: 'src/host/main.ts' },
79
+ },
80
+ {
81
+ id: 'i17',
82
+ severity: 'error',
83
+ kind: 'symbol_ambiguous',
84
+ message: 'Multiple Graphify nodes match readSession (3 candidates)',
85
+ target: { kind: 'component', id: 'session-reader', label: 'SessionReader' },
86
+ },
87
+ {
88
+ id: 'i18',
89
+ severity: 'error',
90
+ kind: 'symbol_unmatched',
91
+ message: 'No Graphify node matches symbol persistSession in src/session/SessionStore.ts',
92
+ target: { kind: 'component', id: 'session-store', label: 'SessionStore' },
93
+ },
94
+ {
95
+ id: 'i9',
96
+ severity: 'info',
97
+ kind: 'construct_span_stale',
98
+ message: 'Declaration moved since capture — recorded start line 42, now 57.',
99
+ target: { kind: 'component', id: 'session-store', label: 'SessionStore' },
100
+ fix: { label: 'Re-pin declaration' },
101
+ },
102
+ {
103
+ id: 'i10',
104
+ severity: 'info',
105
+ kind: 'construct_unconfirmed',
106
+ message: 'Graphify anchored the node but left the construct unclassified (interface vs type alias).',
107
+ target: { kind: 'component', id: 'host-info', label: 'HostInfo' },
108
+ },
109
+ {
110
+ id: 'i22',
111
+ severity: 'error',
112
+ kind: 'construct_span_unconfirmed',
113
+ message: 'HostInfo has no captured source span — its declaration extent is unpinned until an agent proposes start/end lines.',
114
+ target: { kind: 'component', id: 'host-info', label: 'HostInfo' },
115
+ },
116
+ {
117
+ id: 'i11',
118
+ severity: 'error',
119
+ kind: 'signature_mismatch',
120
+ message: 'Claimed (req: HostInfo) => Session; Graphify has (string) => void.',
121
+ target: { kind: 'component', id: 'entry', label: 'checkoutApi' },
122
+ },
123
+ {
124
+ id: 'i13',
125
+ severity: 'info',
126
+ kind: 'repo_unresolved',
127
+ message: 'Repo pkg:github/acme/worker is not available locally — clone it to verify its components',
128
+ target: { kind: 'repo', id: 'pkg:github/acme/worker', label: 'pkg:github/acme/worker' },
129
+ },
130
+ {
131
+ id: 'i19',
132
+ severity: 'info',
133
+ kind: 'graphify_unavailable',
134
+ message: 'Graphify cache missing for pkg:github/you/your-app — build it to verify constructs and anchors',
135
+ target: { kind: 'repo', id: 'pkg:github/you/your-app', label: 'pkg:github/you/your-app' },
136
+ },
137
+ ];
138
+
139
+ export const TRAIL_STEP_ISSUES: SubsystemIssue[] = [
140
+ {
141
+ id: 'ts1',
142
+ severity: 'info',
143
+ kind: 'step_span_unconfirmed',
144
+ message: 'Trail "Add to Cart" step 1: call site not verified (addToCart → cartStore via writes)',
145
+ target: {
146
+ kind: 'step',
147
+ id: 'add-to-cart',
148
+ label: 'Add to Cart',
149
+ detail: 'step 1',
150
+ stepIndex: 0,
151
+ },
152
+ },
153
+ {
154
+ id: 'ts2',
155
+ severity: 'info',
156
+ kind: 'step_span_unconfirmed',
157
+ message: 'Trail "Add to Cart" step 2: call site not verified (cartStore → inventoryService via calls)',
158
+ target: {
159
+ kind: 'step',
160
+ id: 'add-to-cart',
161
+ label: 'Add to Cart',
162
+ detail: 'step 2',
163
+ stepIndex: 1,
164
+ },
165
+ },
166
+ {
167
+ id: 'ts3',
168
+ severity: 'info',
169
+ kind: 'step_span_stale',
170
+ message: 'Trail "Checkout" step 1: call site changed since verification (lines 42-44 in src/checkout/api.ts)',
171
+ target: {
172
+ kind: 'step',
173
+ id: 'checkout',
174
+ label: 'Checkout',
175
+ detail: 'step 1',
176
+ stepIndex: 0,
177
+ },
178
+ },
179
+ {
180
+ id: 'ts4',
181
+ severity: 'info',
182
+ kind: 'step_span_stale',
183
+ message: 'Trail "Checkout" step 3: call site changed since verification (lines 78-82 in src/checkout/api.ts)',
184
+ target: {
185
+ kind: 'step',
186
+ id: 'checkout',
187
+ label: 'Checkout',
188
+ detail: 'step 3',
189
+ stepIndex: 2,
190
+ },
191
+ },
192
+ ];
@@ -0,0 +1,125 @@
1
+ import type {
2
+ SubsystemComponent,
3
+ SubsystemTrail,
4
+ SubsystemTrailMechanism,
5
+ SubsystemTrailStep,
6
+ } from '../../../subsystem/model';
7
+
8
+ /** One authored trail step; `line` becomes the seam span the viewers read. */
9
+ function step(
10
+ from: string,
11
+ to: string,
12
+ mechanism: SubsystemTrailMechanism,
13
+ file: string,
14
+ line: number,
15
+ symbol: string,
16
+ ): SubsystemTrailStep {
17
+ return {
18
+ from,
19
+ to,
20
+ mechanism,
21
+ file,
22
+ span: { startLine: line, endLine: line, contentHash: 'fixture' },
23
+ purl: `pkg:github/storybook/fixture#${file}`,
24
+ symbol,
25
+ };
26
+ }
27
+
28
+ export const components: SubsystemComponent[] = [
29
+ {
30
+ alias: 'panel',
31
+ name: 'DrawingsLeftPanel',
32
+ construct: 'class',
33
+ file: 'src/panels/DrawingsLeftPanel.tsx',
34
+ purl: 'pkg:github/principal-ai/desktop-app',
35
+ purpose: 'lists drawings; emits open/delete intents',
36
+ symbol: 'DrawingsLeftPanel',
37
+ process: 'draw-list',
38
+ },
39
+ {
40
+ alias: 'host',
41
+ name: 'useDrawingsHost',
42
+ construct: 'function',
43
+ file: 'src/hooks/useDrawingsHost.ts',
44
+ purl: 'pkg:github/principal-ai/desktop-app',
45
+ purpose: 'hosts drawing CRUD; dispatches to storage and shell',
46
+ symbol: 'useDrawingsHost',
47
+ process: 'draw-list',
48
+ },
49
+ {
50
+ alias: 'storage',
51
+ name: 'DrawingsStorage',
52
+ construct: 'class',
53
+ file: 'src/storage/drawingsStorage.ts',
54
+ purl: 'pkg:github/principal-ai/desktop-app',
55
+ purpose: 'persists drawings as files',
56
+ symbol: 'DrawingsStorage',
57
+ process: 'draw-host',
58
+ },
59
+ {
60
+ alias: 'fs',
61
+ name: 'FileSystemService',
62
+ construct: 'external',
63
+ file: 'src/services/fileSystem.ts',
64
+ purl: 'pkg:github/principal-ai/desktop-app',
65
+ purpose: 'sandboxed host fd/fs access',
66
+ symbol: 'FileSystemService',
67
+ role: 'service',
68
+ },
69
+ ];
70
+
71
+ export const initialTrails: SubsystemTrail[] = [
72
+ {
73
+ id: 'tl-open-drawing',
74
+ title: 'Open drawing',
75
+ steps: [
76
+ step('panel', 'storage', 'calls', 'src/panels/DrawingsLeftPanel.tsx', 56, 'DrawingsLeftPanel.scan'),
77
+ step('panel', 'host', 'produces', 'src/panels/DrawingsLeftPanel.tsx', 85, 'DrawingsLeftPanel.openDrawing'),
78
+ step('host', 'storage', 'calls', 'src/hooks/useDrawingsHost.ts', 45, 'useDrawingsHost.openDrawing'),
79
+ ],
80
+ },
81
+ {
82
+ id: 'tl-save-drawing',
83
+ title: 'Save drawing',
84
+ steps: [
85
+ step('host', 'storage', 'calls', 'src/hooks/useDrawingsHost.ts', 64, 'useDrawingsHost.saveDrawing'),
86
+ step('storage', 'fs', 'calls', 'src/storage/drawingsStorage.ts', 90, 'DrawingsStorage.write'),
87
+ ],
88
+ },
89
+ {
90
+ id: 'tl-delete-drawing',
91
+ title: 'Delete drawing',
92
+ steps: [
93
+ step('host', 'fs', 'calls', 'src/hooks/useDrawingsHost.ts', 66, 'useDrawingsHost.deleteDrawing'),
94
+ step('host', 'panel', 'produces', 'src/hooks/useDrawingsHost.ts', 64, 'useDrawingsHost.refreshList'),
95
+ ],
96
+ },
97
+ {
98
+ id: 'tl-refresh-list',
99
+ title: 'Refresh list',
100
+ steps: [
101
+ step('panel', 'storage', 'calls', 'src/panels/DrawingsLeftPanel.tsx', 56, 'DrawingsLeftPanel.scan'),
102
+ ],
103
+ },
104
+ ];
105
+
106
+ const orderLabel = (list: SubsystemTrail[]) => list.map((w) => w.title).join(' → ');
107
+
108
+ export function OrderHeader({ list }: { list: SubsystemTrail[] }) {
109
+ return (
110
+ <div
111
+ style={{
112
+ padding: '8px 12px',
113
+ borderBottom: '1px solid #2a2a2a',
114
+ fontFamily: 'monospace',
115
+ fontSize: 12,
116
+ color: '#9aa4b2',
117
+ whiteSpace: 'nowrap',
118
+ overflow: 'hidden',
119
+ textOverflow: 'ellipsis',
120
+ }}
121
+ >
122
+ array order: {orderLabel(list)}
123
+ </div>
124
+ );
125
+ }
@@ -413,7 +413,8 @@ function CatalogDemo({
413
413
  <ConstructsCatalog
414
414
  components={comps}
415
415
  title="Notes intake — constructs"
416
- description="Nothing is selected, so every construct is listed and searchable; pick a file on the left to narrow. Every file stacks under one combined header (path + a description toggle for the whole stack), each declaration labeling the line that holds the construct in a file-like gutter; external constructs get a header naming their kind with the body naming the construct. Click the header or a line to open the file."
416
+ description="Nothing is selected, so every construct is listed and searchable; pick a file on the left to narrow."
417
+ notes="Every file stacks under one combined header (path + a notes link for the whole stack), each declaration labeling the line that holds the construct in a file-like gutter; external constructs get a header naming their kind with the body naming the construct. Click the header or a line to open the file."
417
418
  hideSidebar={hideSidebar}
418
419
  onSelect={(id) => setSelected(id)}
419
420
  renderFileViewer={renderFileViewer}
@@ -0,0 +1,151 @@
1
+ import { afterEach, describe, expect, test } from 'bun:test';
2
+ import { createElement } from 'react';
3
+ import { Window } from 'happy-dom';
4
+ import { cleanup, fireEvent, render } from '@testing-library/react/pure';
5
+ import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
6
+ import { C4ContainersPanel, type C4ContainerListItem } from './C4ContainersPanel';
7
+
8
+ // Bun's happy-dom test environment isn't registered (no @happy-dom/global-
9
+ // registrator), so wire the DOM primitives React DOM needs before rendering.
10
+ const dom = new Window();
11
+ const globals = globalThis as unknown as Record<string, unknown>;
12
+ globals.window = dom;
13
+ globals.document = dom.document;
14
+ globals.navigator = dom.navigator;
15
+ globals.HTMLElement = dom.HTMLElement;
16
+ globals.customElements = dom.customElements;
17
+ globals.Node = dom.Node;
18
+ globals.Element = dom.Element;
19
+ globals.Event = dom.Event;
20
+ globals.getComputedStyle = dom.getComputedStyle.bind(dom);
21
+ globals.requestAnimationFrame = dom.requestAnimationFrame.bind(dom);
22
+ globals.cancelAnimationFrame = dom.cancelAnimationFrame.bind(dom);
23
+ globals.localStorage = dom.localStorage;
24
+ globals.matchMedia = dom.matchMedia.bind(dom);
25
+
26
+ afterEach(cleanup);
27
+
28
+ const ITEMS: C4ContainerListItem[] = [
29
+ {
30
+ container: {
31
+ kind: 'container',
32
+ id: 'container:host',
33
+ label: 'Host',
34
+ containerKind: 'application',
35
+ technology: 'Bun',
36
+ state: 'accepted',
37
+ },
38
+ open: false,
39
+ members: [
40
+ {
41
+ kind: 'component',
42
+ id: 'component:host-api',
43
+ label: 'Host API',
44
+ container: 'container:host',
45
+ technology: 'Bun',
46
+ state: 'accepted',
47
+ },
48
+ ],
49
+ },
50
+ {
51
+ container: {
52
+ kind: 'container',
53
+ id: 'container:store',
54
+ label: 'Session store',
55
+ containerKind: 'data-store',
56
+ technology: 'SQLite',
57
+ state: 'proposed',
58
+ },
59
+ open: true,
60
+ members: [],
61
+ },
62
+ ];
63
+
64
+ function renderPanel(items: C4ContainerListItem[], handlers = {}) {
65
+ const props = {
66
+ containers: items,
67
+ activeId: null,
68
+ onActivate: () => {},
69
+ onSelect: () => {},
70
+ onOpenAll: () => {},
71
+ onCloseAll: () => {},
72
+ ...handlers,
73
+ };
74
+ return render(
75
+ createElement(
76
+ ThemeProvider,
77
+ { theme: defaultEditorTheme },
78
+ createElement(C4ContainersPanel as never, props as never),
79
+ ),
80
+ );
81
+ }
82
+
83
+ describe('C4ContainersPanel', () => {
84
+ test('lists every container and its state', () => {
85
+ const view = renderPanel(ITEMS);
86
+ expect(view.getByText('2 containers')).toBeTruthy();
87
+ expect(view.getByText('Host')).toBeTruthy();
88
+ expect(view.getByText('Session store')).toBeTruthy();
89
+ expect(view.getByText('proposed')).toBeTruthy();
90
+ expect(view.queryByText('Host API')).toBeNull();
91
+ const row = view.getByText('Host').closest('li');
92
+ expect(row?.className).toContain('c4-containers-row');
93
+ expect(row?.hasAttribute('title')).toBe(false);
94
+ expect(row?.querySelector('button')?.hasAttribute('title')).toBe(false);
95
+ });
96
+
97
+ test('an open container lists its components', () => {
98
+ const view = renderPanel([{ ...ITEMS[0]!, open: true }]);
99
+ expect(view.getByText('Host API')).toBeTruthy();
100
+ expect(view.queryByText('No components')).toBeNull();
101
+ });
102
+
103
+ test('activating a row opens/frames that container', () => {
104
+ const activated: string[] = [];
105
+ const view = renderPanel(ITEMS, { onActivate: (id: string) => activated.push(id) });
106
+ fireEvent.click(view.getByRole('button', { name: /^Host/ }));
107
+ expect(activated).toEqual(['container:host']);
108
+ });
109
+
110
+ test('rows with members are dropdowns; empty rows are select-only', () => {
111
+ const view = renderPanel(ITEMS);
112
+ const closed = view.getByRole('button', { name: /^Host/ });
113
+ expect(closed.getAttribute('aria-expanded')).toBe('false');
114
+ const empty = view.getByRole('button', { name: /^Session store/ });
115
+ expect(empty.hasAttribute('aria-expanded')).toBe(false);
116
+ });
117
+
118
+ test('selecting an empty container frames it without toggling', () => {
119
+ let selected = '';
120
+ let activated = 0;
121
+ const view = renderPanel(ITEMS, {
122
+ onSelect: (id: string) => {
123
+ selected = id;
124
+ },
125
+ onActivate: () => {
126
+ activated += 1;
127
+ },
128
+ });
129
+ fireEvent.click(view.getByRole('button', { name: /^Session store/ }));
130
+ expect(selected).toBe('container:store');
131
+ expect(activated).toBe(0);
132
+ });
133
+
134
+ test('bulk controls reflect the open set and invoke their handlers', () => {
135
+ const opened: string[] = [];
136
+ const closed: string[] = [];
137
+ const view = renderPanel(ITEMS, {
138
+ onOpenAll: () => opened.push('open'),
139
+ onCloseAll: () => closed.push('close'),
140
+ });
141
+ fireEvent.click(view.getByRole('button', { name: 'Open all' }));
142
+ fireEvent.click(view.getByRole('button', { name: 'Close all' }));
143
+ expect(opened).toEqual(['open']);
144
+ expect(closed).toEqual(['close']);
145
+ });
146
+
147
+ test('an empty model says so instead of drawing an empty list', () => {
148
+ const view = renderPanel([]);
149
+ expect(view.getByText('No containers.')).toBeTruthy();
150
+ });
151
+ });