@principal-ai/subsystems-react 0.56.35 → 0.56.37

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 (48) hide show
  1. package/dist/index.d.ts +3 -3
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +2 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/subsystem/SubsystemComponentGraph.d.ts +50 -8
  6. package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
  7. package/dist/subsystem/SubsystemComponentGraph.js +291 -50
  8. package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
  9. package/dist/subsystem/TrailStepsNav.d.ts +1 -1
  10. package/dist/subsystem/TrailStepsNav.d.ts.map +1 -1
  11. package/dist/subsystem/TrailStepsNav.js +2 -1
  12. package/dist/subsystem/TrailStepsNav.js.map +1 -1
  13. package/dist/subsystem/TrailsPanel.d.ts +5 -5
  14. package/dist/subsystem/TrailsPanel.d.ts.map +1 -1
  15. package/dist/subsystem/TrailsPanel.js +23 -43
  16. package/dist/subsystem/TrailsPanel.js.map +1 -1
  17. package/dist/subsystem/model.d.ts +21 -6
  18. package/dist/subsystem/model.d.ts.map +1 -1
  19. package/dist/subsystem/model.js +48 -45
  20. package/dist/subsystem/model.js.map +1 -1
  21. package/dist/subsystem/nodeIconography.d.ts +25 -0
  22. package/dist/subsystem/nodeIconography.d.ts.map +1 -0
  23. package/dist/subsystem/nodeIconography.js +55 -0
  24. package/dist/subsystem/nodeIconography.js.map +1 -0
  25. package/dist/subsystem/nodes.d.ts +9 -8
  26. package/dist/subsystem/nodes.d.ts.map +1 -1
  27. package/dist/subsystem/nodes.js +271 -338
  28. package/dist/subsystem/nodes.js.map +1 -1
  29. package/dist/subsystem/stepEmphasis.d.ts +5 -0
  30. package/dist/subsystem/stepEmphasis.d.ts.map +1 -1
  31. package/dist/subsystem/stepEmphasis.js +7 -0
  32. package/dist/subsystem/stepEmphasis.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/index.ts +3 -1
  35. package/src/stories/Canvases/Subsystem/AgentDrivenWalkthrough.stories.tsx +1842 -279
  36. package/src/stories/Canvases/Subsystem/Deprecated.stories.tsx +1 -1
  37. package/src/stories/Canvases/Subsystem/NodeAnatomy.stories.tsx +17 -21
  38. package/src/stories/Canvases/Subsystem/NodeIconography.stories.tsx +791 -21
  39. package/src/stories/Canvases/Subsystem/Spotlights.stories.tsx +1 -1
  40. package/src/subsystem/SubsystemComponentGraph.tsx +359 -62
  41. package/src/subsystem/TrailStepsNav.tsx +2 -2
  42. package/src/subsystem/TrailsPanel.tsx +35 -89
  43. package/src/subsystem/model.test.ts +17 -13
  44. package/src/subsystem/model.ts +60 -48
  45. package/src/subsystem/nodeIconography.ts +88 -0
  46. package/src/subsystem/nodes.component.test.tsx +177 -0
  47. package/src/subsystem/nodes.tsx +463 -435
  48. package/src/subsystem/stepEmphasis.ts +8 -0
@@ -2,20 +2,27 @@
2
2
  * Subsystem component/group node + edge renderers.
3
3
  *
4
4
  * Lightweight, purpose-built for the subsystem component graph: a component
5
- * renders its name (kind-tagged, colored by package) plus its symbol/purpose.
6
- * Groups render as package containers. Clicking
7
- * a component calls `onSelect` (to open the entry point / file).
5
+ * renders a primary construct icon + label above its name, with secondary
6
+ * role/storage/deprecation badges below and host-local state markers at the
7
+ * corners. Groups render as package containers. Clicking a component calls
8
+ * `onSelect` (to open the entry point / file).
8
9
  */
9
10
 
10
- import { createContext, useContext, useState, type ReactNode } from 'react';
11
+ import {
12
+ createContext,
13
+ useContext,
14
+ useState,
15
+ type CSSProperties,
16
+ type ReactNode,
17
+ } from "react";
11
18
  import {
12
19
  Handle,
13
20
  Position,
14
21
  type Node,
15
22
  type NodeProps,
16
23
  type EdgeProps,
17
- } from '@xyflow/react';
18
- import { useTheme } from '@principal-ade/industry-theme';
24
+ } from "@xyflow/react";
25
+ import { useTheme } from "@principal-ade/industry-theme";
19
26
  import {
20
27
  edgeColor,
21
28
  edgeStrokeStyle,
@@ -35,17 +42,17 @@ import {
35
42
  moduleBadgeHoverLabel,
36
43
  moduleBadgeWidth,
37
44
  packageColor,
45
+ HOST_PROPOSAL_COLOR,
38
46
  FOLDER_FRAME_COLOR,
39
47
  isFolderFrame,
40
48
  isCardFrame,
41
49
  type SubsystemGraphNodeData,
42
50
  type SubsystemGroupNodeData,
43
51
  type SubsystemGraphEdge,
44
- type SubsystemNodeIssue,
45
- } from './model';
46
- import { componentColor } from '../pierre/constructColors';
47
- import { resolvePierreSyntaxThemeName } from '../pierre/pierreSyntaxTheme';
48
- import { ISSUE_KIND_ICON, ISSUE_RUNG_ICON } from './IssueList';
52
+ } from "./model";
53
+ import { componentColor } from "../pierre/constructColors";
54
+ import { resolvePierreSyntaxThemeName } from "../pierre/pierreSyntaxTheme";
55
+ import { ISSUE_KIND_ICON } from "./IssueList";
49
56
  import {
50
57
  CARD_GAP,
51
58
  CARD_PAD_X,
@@ -55,36 +62,55 @@ import {
55
62
  NODE_W,
56
63
  TOGGLE_INSET,
57
64
  TOGGLE_SIZE,
58
- } from './containerCard';
59
- import { MORPH_MS } from './graphMorph';
60
- import { technologyBrand } from './techIcons';
61
- import { AppWindow, Component, Database, Maximize2, Minimize2, Package, Search, WandSparkles } from 'lucide-react';
62
- import type { LucideIcon } from 'lucide-react';
65
+ } from "./containerCard";
66
+ import { MORPH_MS } from "./graphMorph";
67
+ import { TechMark, technologyBrand } from "./techIcons";
68
+ import {
69
+ DEPRECATED_ICON,
70
+ ROLE_ICON,
71
+ STORAGE_ICON,
72
+ iconForComponent,
73
+ } from "./nodeIconography";
74
+ import {
75
+ AppWindow,
76
+ CirclePlus,
77
+ CircleX,
78
+ Component,
79
+ Database,
80
+ Maximize2,
81
+ Minimize2,
82
+ Package,
83
+ TriangleAlert,
84
+ WandSparkles,
85
+ } from "lucide-react";
86
+ import type { LucideIcon } from "lucide-react";
63
87
 
64
88
  export const CONSTRUCT_LABEL: Record<string, string> = {
65
- class: 'class',
66
- function: 'function',
67
- method: 'method',
68
- interface: 'interface',
69
- type_alias: 'type alias',
70
- enum: 'enum',
71
- store: 'store',
72
- external: 'external',
73
- custom_entity: 'entity',
89
+ class: "class",
90
+ function: "function",
91
+ method: "method",
92
+ interface: "interface",
93
+ type_alias: "type alias",
94
+ enum: "enum",
95
+ store: "store",
96
+ external: "external",
97
+ custom_entity: "entity",
74
98
  };
75
99
 
76
100
  /** Insert zero-width spaces at identifier word boundaries so long names wrap
77
101
  * on naming conventions (snake_case `foo_`|`bar`, camelCase `foo`|`Bar`,
78
102
  * PascalCase `Foo`|`Bar`, acronym `ABC`|`Def`) instead of mid-character. */
79
103
  function breakWords(s: string): string {
80
- const zwsp = '\u200b';
81
- return s
82
- // camelCase: lower/digit → Upper (and the boundary before it holds)
83
- .replace(/([a-z0-9])([A-Z])/g, `$1${zwsp}$2`)
84
- // acronym → word: `ABC`|`Def` (two Uppercase then a lowercase)
85
- .replace(/([A-Z])([A-Z][a-z])/g, `$1${zwsp}$2`)
86
- // separators: break after `_`, `-`, `.`
87
- .replace(/([_\-.])([^_\-.\u200b])/g, `$1${zwsp}$2`);
104
+ const zwsp = "\u200b";
105
+ return (
106
+ s
107
+ // camelCase: lower/digit → Upper (and the boundary before it holds)
108
+ .replace(/([a-z0-9])([A-Z])/g, `$1${zwsp}$2`)
109
+ // acronym → word: `ABC`|`Def` (two Uppercase then a lowercase)
110
+ .replace(/([A-Z])([A-Z][a-z])/g, `$1${zwsp}$2`)
111
+ // separators: break after `_`, `-`, `.`
112
+ .replace(/([_\-.])([^_\-.\u200b])/g, `$1${zwsp}$2`)
113
+ );
88
114
  }
89
115
 
90
116
  export interface SubsystemGraphCallbacks {
@@ -133,34 +159,63 @@ function useSubsystemCallbacks(): SubsystemGraphCallbacks {
133
159
  return useContext(SubsystemCallbacksContext) ?? SUBSYSTEM_CALLBACKS;
134
160
  }
135
161
 
136
- /**
137
- * The diagnostics overlay for a component node: the node's own border turns
138
- * dotted (see the node's `borderStyle`) and a severity-colored corner chip
139
- * carries the count. The chip's icon is the earliest-failing construct rung
140
- * (file → symbol → declaration → type → signature); a finding with no rung
141
- * (e.g. a C4 process gap) wears its kind icon instead — see
142
- * `SubsystemNodeIssue.kind`. The chip is purely additive and non-interactive;
143
- * the border stays construct-colored, so severity never has to compete with
144
- * the construct palette.
145
- */
146
- function NodeIssueOverlay({ issue }: { issue: SubsystemNodeIssue }) {
162
+ /** A compact host-local state marker, anchored over a node corner. */
163
+ function NodeStateMarker({
164
+ label,
165
+ color,
166
+ Icon,
167
+ anchor,
168
+ count,
169
+ }: {
170
+ label: string;
171
+ color: string;
172
+ Icon: LucideIcon;
173
+ anchor: "top-right" | "top-left" | "bottom-right";
174
+ count?: number;
175
+ }) {
147
176
  const { theme } = useTheme();
148
- const isError = issue.severity === 'error';
149
- const color = isError
150
- ? (theme.colors.error ?? '#e5534b')
151
- : (theme.colors.warning ?? '#d4a017');
152
- const Icon = issue.rung
153
- ? ISSUE_RUNG_ICON[issue.rung]
154
- : issue.kind
155
- ? (ISSUE_KIND_ICON[issue.kind] ?? Search)
156
- : Search;
177
+ const nodeBg = theme.colors.backgroundSecondary ?? theme.colors.background;
178
+ const showCount = (count ?? 0) > 1;
157
179
  return (
158
- <IssueChip
159
- color={color}
160
- Icon={Icon}
161
- count={issue.count}
162
- anchor={{ right: -9, bottom: -8 }}
163
- />
180
+ <div
181
+ title={label}
182
+ aria-label={showCount ? `${label}: ${count}` : label}
183
+ style={{
184
+ position: "absolute",
185
+ zIndex: 2,
186
+ display: "inline-flex",
187
+ alignItems: "center",
188
+ justifyContent: "center",
189
+ gap: showCount ? 4 : 0,
190
+ width: showCount ? undefined : 26,
191
+ minWidth: 26,
192
+ height: 26,
193
+ boxSizing: "border-box",
194
+ padding: showCount ? "0 5px" : 0,
195
+ border: `2px solid ${color}`,
196
+ borderRadius: 5,
197
+ background: nodeBg,
198
+ color,
199
+ fontFamily: theme.fonts.monospace,
200
+ fontSize: theme.fontSizes[1],
201
+ fontWeight: 700,
202
+ lineHeight: 1.1,
203
+ pointerEvents: "none",
204
+ ...(anchor === "top-right"
205
+ ? { top: -10, right: -8 }
206
+ : anchor === "top-left"
207
+ ? { top: -10, left: -8 }
208
+ : { bottom: -8, right: -8 }),
209
+ }}
210
+ >
211
+ <Icon
212
+ className={label === "working" ? "agent-working-icon" : undefined}
213
+ size={14}
214
+ strokeWidth={2}
215
+ aria-hidden="true"
216
+ />
217
+ {showCount ? <span>{count}</span> : null}
218
+ </div>
164
219
  );
165
220
  }
166
221
 
@@ -188,14 +243,14 @@ function IssueChip({
188
243
  <div
189
244
  aria-hidden
190
245
  style={{
191
- position: 'absolute',
246
+ position: "absolute",
192
247
  zIndex: 2,
193
- display: 'inline-flex',
194
- alignItems: 'center',
195
- justifyContent: 'center',
248
+ display: "inline-flex",
249
+ alignItems: "center",
250
+ justifyContent: "center",
196
251
  gap: 4,
197
252
  minWidth: 22,
198
- padding: '3px 5px',
253
+ padding: "3px 5px",
199
254
  borderRadius: 5,
200
255
  border: `2px solid ${color}`,
201
256
  background: badgeBg,
@@ -204,7 +259,7 @@ function IssueChip({
204
259
  fontSize: theme.fontSizes[1],
205
260
  fontWeight: 700,
206
261
  lineHeight: 1.1,
207
- pointerEvents: 'none',
262
+ pointerEvents: "none",
208
263
  ...anchor,
209
264
  }}
210
265
  >
@@ -214,108 +269,98 @@ function IssueChip({
214
269
  );
215
270
  }
216
271
 
217
- export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeData, 'subsystem-component'>>) {
272
+ export function SubsystemComponentNode(
273
+ props: NodeProps<Node<SubsystemGraphNodeData, "subsystem-component">>,
274
+ ) {
218
275
  const { theme, mode } = useTheme();
219
276
  const callbacks = useSubsystemCallbacks();
220
277
  const { data, selected, width: nodeWidth, height: nodeHeight } = props;
221
278
  const c = data.component;
222
279
  const [hover, setHover] = useState(false);
223
280
  // Construct owns node color, derived from the active Pierre syntax theme —
224
- // the same palette the declaration panel and file drawer render with. Role
225
- // shows as the hover badge, not as color — for now; a role glyph/accent may
226
- // come later. A component-authored `color` override wins over the construct.
281
+ // the same palette the declaration panel and file drawer render with. A
282
+ // component-authored `color` override wins over the construct.
227
283
  const color = componentColor(c, resolvePierreSyntaxThemeName(mode));
228
- // Host-local proposals use the same warning color as the Trails panel. The
229
- // box keeps its construct badge, but its border/name/badge mark it as not yet
230
- // part of the portable model.
231
284
  const proposed = data.proposed === true;
232
- const proposalColor = theme.colors.warning ?? '#d4a017';
233
- // Host-local working indicator: a static ring plus a compact icon on the
234
- // component the agent is currently working on.
285
+ const proposalColor = HOST_PROPOSAL_COLOR;
235
286
  const working = data.working === true;
236
- const workingColor = theme.colors.accent ?? theme.colors.primary ?? '#a78bfa';
237
- // Host-local removal ghost: the box stays in its slot, dimmed and badged,
238
- // so the user can see what disappeared instead of only the surviving graph.
287
+ const workingColor = theme.colors.accent ?? theme.colors.primary ?? "#a78bfa";
239
288
  const removed = data.removed === true;
240
289
  const removedColor = DEPRECATED_COLOR;
241
- // Left badge: framework brand (e.g. React cyan) when the label is a
242
- // framework stereotype; otherwise the same construct color as the border.
243
- const badgeColor = constructBadgeColor(c) ?? color;
290
+ const issue = data.issue;
291
+ const issueColor =
292
+ issue?.severity === "error"
293
+ ? (theme.colors.error ?? "#e5534b")
294
+ : (theme.colors.warning ?? "#d4a017");
295
+ // Primary identity: framework stereotypes may override the construct glyph
296
+ // with an official technology mark; custom entities use their authored kind.
297
+ const PrimaryIcon = iconForComponent(c);
298
+ const primaryBrand =
299
+ c.framework && c.stereotype ? technologyBrand(c.framework) : undefined;
300
+ const primaryLabel = constructBadgeLabel(c);
301
+ const primaryColor = constructBadgeColor(c) ?? color;
244
302
  const configuredMax = callbacks.maxNodeWidth;
245
303
  const maxWidth = configuredMax ?? 300;
246
- // `symbol` is the source of truth; `name` is derived from it consistently.
247
- const displayName = deriveNameFromSymbol(c.symbol, c.construct, c.name, c.file, c.stereotype);
248
- // Top badges are absolutely positioned — widen the node so they nowrap
249
- // instead of wrapping, including when construct + role share the top.
250
- // Host-local badges must not feed back into geometry: proposal/working flags
251
- // are stamped after ELK has sized the frames and after the camera has fit
252
- // those rects. Growing the box here would overflow the container and leave
253
- // the newly proposed node clipped. They use stacked vertical slots instead.
304
+ const displayName = deriveNameFromSymbol(
305
+ c.symbol,
306
+ c.construct,
307
+ c.name,
308
+ c.file,
309
+ c.stereotype,
310
+ );
254
311
  const badgeMinWidth = nodeMinWidthForBadges(c);
255
- const topRightLabel = rightBadgeLabel(c);
256
- const topRightColor = rightBadgeColor(c);
257
- // Store retention backing badge — memory/disk/db, beside role (orthogonal).
312
+ const roleLabel = rightBadgeLabel(c);
313
+ const roleColor = rightBadgeColor(c);
314
+ const RoleIcon =
315
+ roleLabel === "entry" || roleLabel === "service"
316
+ ? ROLE_ICON[roleLabel]
317
+ : undefined;
258
318
  const storageLabel = storageBadgeLabel(c);
259
319
  const storageColor = storageBadgeColor(c);
260
- // Deprecated badge — clickable, unlike every other badge here (they opt out
261
- // of pointer events so clicks fall through to the node). Clicking opens the
262
- // removal provenance, which is the whole reason the badge exists.
320
+ const storageIconKey =
321
+ storageLabel === "db" ? "external" : storageLabel?.toLowerCase();
322
+ const StorageIcon = storageIconKey ? STORAGE_ICON[storageIconKey] : undefined;
263
323
  const deprecatedLabel = deprecatedBadgeLabel(c);
264
324
  const deprecatedColor = deprecatedBadgeColor(c);
265
325
  const removal = c.removedIn;
266
326
  const [showRemoval, setShowRemoval] = useState(false);
267
- // Set while a file is open in the drawer: true → spotlight, false → dim,
268
- // absent (no file open) → neutral.
269
327
  const fileMatch = data.fileMatch as boolean | undefined;
270
- // Node fill lifts on hover as the clickability affordance; badges share it
271
- // so they read as tabs on the same surface rather than floating patches.
272
328
  const nodeBg = theme.colors.backgroundSecondary ?? theme.colors.background;
273
329
  const hoverBg =
274
330
  theme.colors.backgroundHover ?? theme.colors.backgroundTertiary ?? nodeBg;
275
- // Border: deprecated uses the slate accent (dotted, same family as issue)
276
- // since it means "not a live claim"; construct color stays on the left
277
- // badge. File-open spotlight still wins with primary.
331
+ // State rides on markers and the name, not on a different border hue.
278
332
  const borderColor = removed
279
333
  ? removedColor
280
- : proposed
281
- ? proposalColor
282
- : fileMatch
283
- ? theme.colors.primary
284
- : c.deprecated
285
- ? DEPRECATED_COLOR
286
- : color;
287
- // Selection is stamped into data by the graph component — React Flow's own
288
- // `selected` never updates because the node stops click propagation.
289
- const isSelected = selected || (data.isSelected as boolean | undefined) === true;
290
- // Externals are "outside" the system — square corners on the node + badges.
291
- const isExternal = c.construct === 'external';
334
+ : fileMatch
335
+ ? theme.colors.primary
336
+ : color;
337
+ const isSelected =
338
+ selected || (data.isSelected as boolean | undefined) === true;
339
+ const isExternal = c.construct === "external";
292
340
  const nodeRadius = isExternal ? 0 : 8;
293
341
  const badgeRadius = isExternal ? 0 : 4;
294
- // The border thickens on selection / file-match. Absolutely-positioned
295
- // badges are laid out from the padding box (inside the border), so a raw
296
- // `top` / `left` would slide with the border. Anchor them to the border box
297
- // instead, offsetting by the border width. Side badges sit flush with the
298
- // node's left / right edge (`-borderW`); the top reference stays at -9.
299
342
  const borderW = proposed ? 3 : isSelected || fileMatch ? 4 : 2;
300
- const badgeTop = -9 - borderW;
301
- const badgeEdge = -borderW;
302
- // A node with diagnostics turns its border dotted — an "something's off"
303
- // signal. The border keeps its construct color; the severity rides on the
304
- // chip. Deprecated is also dotted, but slate rather than construct-colored:
305
- // "this claim was retired" is closer to a diagnostic than to a placeholder.
306
- const hasIssue = data.issue != null;
307
- // Deprecated is dotted like issue but slate rather than construct-colored:
308
- // "this claim was retired" is closer to a diagnostic than to a placeholder,
309
- // and verification skips deprecated nodes so the two never stack in practice.
310
- const borderStyle = removed
311
- ? 'dashed'
312
- : proposed
313
- ? 'dashed'
314
- : hasIssue
315
- ? 'dotted'
316
- : c.deprecated
317
- ? 'dotted'
318
- : 'solid';
343
+ const badgeBottom = -9 - borderW;
344
+ const borderStyle = removed || proposed ? "dashed" : "solid";
345
+ const secondaryBadgeStyle: CSSProperties = {
346
+ display: "inline-flex",
347
+ alignItems: "center",
348
+ justifyContent: "center",
349
+ boxSizing: "border-box",
350
+ gap: 5,
351
+ height: 26,
352
+ padding: "2px 8px",
353
+ fontFamily: theme.fonts.monospace,
354
+ fontSize: theme.fontSizes[1],
355
+ fontWeight: 700,
356
+ letterSpacing: 0.5,
357
+ lineHeight: "17px",
358
+ textTransform: "uppercase",
359
+ whiteSpace: "nowrap",
360
+ background: nodeBg,
361
+ border: `2px solid currentColor`,
362
+ borderRadius: badgeRadius,
363
+ };
319
364
 
320
365
  return (
321
366
  <div
@@ -332,214 +377,153 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
332
377
  callbacks.onSelect?.(c.alias);
333
378
  }}
334
379
  style={{
335
- position: 'relative',
336
- display: 'flex',
337
- flexDirection: 'column',
338
- justifyContent: 'center',
339
- alignItems: 'center',
340
- boxSizing: 'border-box',
380
+ position: "relative",
381
+ display: "flex",
382
+ flexDirection: "column",
383
+ justifyContent: "flex-start",
384
+ alignItems: "center",
385
+ boxSizing: "border-box",
341
386
  width: nodeWidth,
342
387
  height: nodeHeight,
343
388
  minWidth: badgeMinWidth,
344
389
  maxWidth,
345
- padding: '6px 10px',
390
+ gap: 8,
391
+ padding: "14px 16px 0",
392
+ overflow: "visible",
346
393
  borderRadius: nodeRadius,
347
394
  background: hover ? hoverBg : nodeBg,
348
- // Selected / file-matched nodes get a thicker border. Proposed nodes
349
- // use a dashed goldenrod border, issue nodes a dotted construct-colored
350
- // one; the left construct badge keeps construct color either way.
395
+ // Selection / file-match thickens the border. Proposed and removed
396
+ // ghosts are dashed; all other states keep the construct-colored border.
351
397
  border: `${borderW}px ${borderStyle} ${borderColor}`,
352
398
  boxShadow: working
353
399
  ? `0 0 0 3px ${workingColor}55, 0 0 18px ${workingColor}44`
354
400
  : fileMatch
355
401
  ? `0 1px 4px rgba(0,0,0,0.25), 0 0 12px ${theme.colors.primary}55`
356
- : '0 1px 4px rgba(0,0,0,0.25)',
402
+ : "0 1px 4px rgba(0,0,0,0.25)",
357
403
  opacity: removed
358
404
  ? 0.45
359
405
  : working || (fileMatch !== false && data.dimmed !== true)
360
406
  ? 1
361
407
  : 0.18,
362
- transition: 'opacity 150ms ease, background-color 120ms ease',
363
- cursor: 'pointer',
408
+ transition: "opacity 150ms ease, background-color 120ms ease",
409
+ cursor: "pointer",
364
410
  fontFamily: theme.fonts.body,
365
411
  }}
366
412
  >
367
- {/* Construct / stereotype badge — prefers framework stereotype so a
368
- React UI unit reads as "react · component" instead of "function".
369
- Persistent; pointer-events none so clicks pass through to the node.
370
- Framework badges use brand color; border stays construct-colored. */}
413
+ {/* Primary identity — construct / framework / entity icon and label. */}
371
414
  <div
415
+ title={primaryLabel}
416
+ aria-label={primaryLabel}
372
417
  style={{
373
- position: 'absolute',
374
- top: badgeTop,
375
- left: badgeEdge,
376
- zIndex: 1,
377
- fontFamily: theme.fonts.monospace,
378
- fontSize: theme.fontSizes[1],
379
- letterSpacing: 0.5,
380
- textTransform: 'uppercase',
381
- lineHeight: '17px',
382
- whiteSpace: 'nowrap',
383
- color: badgeColor,
384
- background: nodeBg,
385
- border: `2px solid ${badgeColor}`,
386
- borderRadius: badgeRadius,
387
- padding: '2px 8px',
418
+ display: "inline-flex",
419
+ alignItems: "center",
420
+ justifyContent: "center",
421
+ gap: 6,
422
+ maxWidth: "100%",
423
+ height: 24,
424
+ flex: "0 0 auto",
425
+ color: primaryColor,
426
+ lineHeight: 1,
388
427
  }}
389
428
  >
390
- {constructBadgeLabel(c)}
391
- </div>
392
-
393
- {/* Host-local removal flag. Same fixed, width-neutral slot as PROPOSED:
394
- the box stays measurable while the rest of the graph moves on. */}
395
- {removed && (
396
- <div
397
- aria-label="removed"
429
+ {primaryBrand ? (
430
+ <TechMark brand={primaryBrand} size={24} showTitle={false} />
431
+ ) : (
432
+ <PrimaryIcon
433
+ size={c.construct === "function" ? 34 : 24}
434
+ strokeWidth={2}
435
+ aria-hidden="true"
436
+ />
437
+ )}
438
+ <span
398
439
  style={{
399
- position: 'absolute',
400
- top: 18,
401
- right: badgeEdge,
402
- zIndex: 1,
440
+ minWidth: 0,
441
+ overflow: "hidden",
442
+ textOverflow: "ellipsis",
403
443
  fontFamily: theme.fonts.monospace,
404
444
  fontSize: theme.fontSizes[1],
405
- letterSpacing: 0.5,
406
- textTransform: 'uppercase',
407
- lineHeight: '17px',
408
- whiteSpace: 'nowrap',
409
- color: removedColor,
410
- background: nodeBg,
411
- border: `2px solid ${removedColor}`,
412
- borderRadius: badgeRadius,
413
- padding: '2px 8px',
414
- pointerEvents: 'none',
445
+ fontWeight: 600,
446
+ letterSpacing: 0.25,
447
+ lineHeight: "16px",
448
+ textTransform: "uppercase",
449
+ whiteSpace: "nowrap",
415
450
  }}
416
451
  >
417
- removed
418
- </div>
419
- )}
452
+ {primaryLabel.toUpperCase()}
453
+ </span>
454
+ </div>
420
455
 
421
- {/* Host-local proposal flag — mirrors the proposal colour used by the
422
- Trails panel, so a box awaiting confirmation reads as uncommitted.
423
- It sits in the first right-hand slot below the persistent top badge:
424
- host-local flags never change the node's measured width, or the
425
- camera would frame the pre-proposal rect and clip the box. */}
456
+ {working && (
457
+ <NodeStateMarker
458
+ label="working"
459
+ color={workingColor}
460
+ Icon={WandSparkles}
461
+ anchor="top-right"
462
+ />
463
+ )}
464
+ {issue && (
465
+ <NodeStateMarker
466
+ label="issue"
467
+ color={issueColor}
468
+ Icon={TriangleAlert}
469
+ anchor="bottom-right"
470
+ count={issue.count}
471
+ />
472
+ )}
426
473
  {proposed && (
427
- <div
428
- style={{
429
- position: 'absolute',
430
- top: 18,
431
- right: badgeEdge,
432
- zIndex: 1,
433
- fontFamily: theme.fonts.monospace,
434
- fontSize: theme.fontSizes[1],
435
- letterSpacing: 0.5,
436
- textTransform: 'uppercase',
437
- lineHeight: '17px',
438
- whiteSpace: 'nowrap',
439
- color: proposalColor,
440
- background: nodeBg,
441
- border: `2px solid ${proposalColor}`,
442
- borderRadius: badgeRadius,
443
- padding: '2px 8px',
444
- pointerEvents: 'none',
445
- }}
446
- >
447
- proposed
448
- </div>
474
+ <NodeStateMarker
475
+ label="proposed"
476
+ color={proposalColor}
477
+ Icon={CirclePlus}
478
+ anchor={working ? "top-left" : "top-right"}
479
+ />
449
480
  )}
450
-
451
- {/* Host-local working icon. Sits astride the top-right corner, mirroring
452
- the construct badge on the left, so it reads as a node-level state.
453
- An icon instead of a word keeps the marker compact and geometry-neutral;
454
- the label is exposed to assistive tech only. */}
455
- {working && (
456
- <div
457
- aria-label="working"
458
- title="working"
459
- style={{
460
- position: 'absolute',
461
- top: badgeTop,
462
- right: badgeEdge,
463
- zIndex: 1,
464
- display: 'flex',
465
- alignItems: 'center',
466
- justifyContent: 'center',
467
- width: 24,
468
- height: 24,
469
- color: workingColor,
470
- background: nodeBg,
471
- border: `1px solid ${workingColor}66`,
472
- borderRadius: badgeRadius,
473
- pointerEvents: 'none',
474
- }}
475
- >
476
- <WandSparkles
477
- className="agent-working-icon"
478
- size={14}
479
- strokeWidth={2}
480
- aria-hidden="true"
481
- />
482
- </div>
481
+ {removed && (
482
+ <NodeStateMarker
483
+ label="removed"
484
+ color={removedColor}
485
+ Icon={CircleX}
486
+ anchor={working ? "top-left" : "top-right"}
487
+ />
483
488
  )}
484
489
 
485
- {/* Secondary badge cluster — the role badge, with store storage
486
- (retention backing) beside it since it is orthogonal to topology.
487
- Persistent; pointer-events pass through.
488
- Sits astride the bottom edge, centered (mirroring the top construct
489
- badge's straddle), so the top edge stays free for the construct tag. */}
490
- {(topRightLabel != null || storageLabel != null || deprecatedLabel != null) && (
490
+ {/* Secondary badges — orthogonal role, storage backing, and deprecation. */}
491
+ {(roleLabel != null ||
492
+ storageLabel != null ||
493
+ deprecatedLabel != null) && (
491
494
  <div
492
495
  style={{
493
- position: 'absolute',
494
- bottom: badgeTop,
495
- left: '50%',
496
- transform: 'translateX(-50%)',
496
+ position: "absolute",
497
+ bottom: badgeBottom,
498
+ left: "50%",
499
+ transform: "translateX(-50%)",
497
500
  zIndex: 1,
498
- display: 'flex',
501
+ display: "flex",
499
502
  gap: 6,
500
- whiteSpace: 'nowrap',
503
+ whiteSpace: "nowrap",
501
504
  }}
502
505
  >
503
- {storageLabel != null && storageColor != null && (
506
+ {storageLabel != null && storageColor != null && StorageIcon && (
504
507
  <span
505
- style={{
506
- fontFamily: theme.fonts.monospace,
507
- fontSize: theme.fontSizes[1],
508
- letterSpacing: 0.5,
509
- textTransform: 'uppercase',
510
- lineHeight: '17px',
511
- color: storageColor,
512
- background: nodeBg,
513
- border: `2px solid ${storageColor}`,
514
- borderRadius: badgeRadius,
515
- padding: '2px 8px',
516
- }}
508
+ title={storageLabel}
509
+ aria-label={storageLabel}
510
+ style={{ ...secondaryBadgeStyle, color: storageColor }}
517
511
  >
518
- {storageLabel}
512
+ <StorageIcon size={14} strokeWidth={2} aria-hidden="true" />
513
+ <span>{storageLabel}</span>
519
514
  </span>
520
515
  )}
521
- {topRightLabel != null && topRightColor != null && (
516
+ {roleLabel != null && roleColor != null && RoleIcon && (
522
517
  <span
523
- style={{
524
- fontFamily: theme.fonts.monospace,
525
- fontSize: theme.fontSizes[1],
526
- letterSpacing: 0.5,
527
- textTransform: 'uppercase',
528
- lineHeight: '17px',
529
- color: topRightColor,
530
- background: nodeBg,
531
- border: `2px solid ${topRightColor}`,
532
- borderRadius: badgeRadius,
533
- padding: '2px 8px',
534
- }}
518
+ title={roleLabel}
519
+ aria-label={roleLabel}
520
+ style={{ ...secondaryBadgeStyle, color: roleColor }}
535
521
  >
536
- {topRightLabel}
522
+ <RoleIcon size={14} strokeWidth={2} aria-hidden="true" />
523
+ <span>{roleLabel}</span>
537
524
  </span>
538
525
  )}
539
526
  {deprecatedLabel != null && deprecatedColor != null && (
540
- // Its own click target: stops propagation so opening the provenance
541
- // doesn't also select the node, and toggles a popover rather than
542
- // leaning on a title tooltip (which truncates the commit subject).
543
527
  <span
544
528
  role="button"
545
529
  tabIndex={0}
@@ -547,35 +531,27 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
547
531
  aria-label={
548
532
  removal
549
533
  ? `Deprecated — removed in ${removal.commit}. Show removal details.`
550
- : 'Deprecated — show removal details.'
534
+ : "Deprecated — show removal details."
551
535
  }
552
536
  onClick={(e) => {
553
537
  e.stopPropagation();
554
538
  setShowRemoval((v) => !v);
555
539
  }}
556
540
  onKeyDown={(e) => {
557
- if (e.key === 'Enter' || e.key === ' ') {
541
+ if (e.key === "Enter" || e.key === " ") {
558
542
  e.stopPropagation();
559
543
  e.preventDefault();
560
544
  setShowRemoval((v) => !v);
561
545
  }
562
546
  }}
563
547
  style={{
564
- position: 'relative',
565
- fontFamily: theme.fonts.monospace,
566
- fontSize: theme.fontSizes[1],
567
- letterSpacing: 0.5,
568
- textTransform: 'uppercase',
569
- lineHeight: '17px',
548
+ ...secondaryBadgeStyle,
570
549
  color: deprecatedColor,
571
- background: nodeBg,
572
- border: `2px solid ${deprecatedColor}`,
573
- borderRadius: badgeRadius,
574
- padding: '2px 8px',
575
- cursor: 'pointer',
550
+ cursor: "pointer",
576
551
  }}
577
552
  >
578
- {deprecatedLabel}
553
+ <DEPRECATED_ICON size={14} strokeWidth={2} aria-hidden="true" />
554
+ <span>{deprecatedLabel}</span>
579
555
  </span>
580
556
  )}
581
557
  </div>
@@ -589,24 +565,24 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
589
565
  aria-label="Removal provenance"
590
566
  onClick={(e) => e.stopPropagation()}
591
567
  style={{
592
- position: 'absolute',
593
- bottom: '100%',
594
- left: '50%',
595
- transform: 'translateX(-50%)',
568
+ position: "absolute",
569
+ bottom: "100%",
570
+ left: "50%",
571
+ transform: "translateX(-50%)",
596
572
  marginBottom: 6,
597
573
  zIndex: 20,
598
574
  width: 260,
599
- padding: '8px 10px',
575
+ padding: "8px 10px",
600
576
  borderRadius: 6,
601
577
  background: nodeBg,
602
578
  border: `1px solid ${DEPRECATED_COLOR}`,
603
- boxShadow: '0 6px 20px rgba(0,0,0,0.35)',
579
+ boxShadow: "0 6px 20px rgba(0,0,0,0.35)",
604
580
  fontFamily: theme.fonts.body,
605
581
  fontSize: theme.fontSizes[1],
606
582
  color: theme.colors.text,
607
- textAlign: 'left',
608
- whiteSpace: 'normal',
609
- cursor: 'default',
583
+ textAlign: "left",
584
+ whiteSpace: "normal",
585
+ cursor: "default",
610
586
  }}
611
587
  >
612
588
  <div
@@ -620,11 +596,15 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
620
596
  </div>
621
597
  {removal ? (
622
598
  <>
623
- <div style={{ fontFamily: theme.fonts.monospace, marginBottom: 4 }}>
599
+ <div
600
+ style={{ fontFamily: theme.fonts.monospace, marginBottom: 4 }}
601
+ >
624
602
  removed in {removal.commit}
625
603
  </div>
626
604
  {removal.reason && (
627
- <div style={{ color: theme.colors.textSecondary }}>{removal.reason}</div>
605
+ <div style={{ color: theme.colors.textSecondary }}>
606
+ {removal.reason}
607
+ </div>
628
608
  )}
629
609
  </>
630
610
  ) : (
@@ -643,14 +623,14 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
643
623
  fontSize: theme.fontSizes[2],
644
624
  fontWeight: 600,
645
625
  color: proposed ? proposalColor : theme.colors.text,
646
- textDecoration: removed ? 'line-through' : undefined,
626
+ textDecoration: removed ? "line-through" : undefined,
647
627
  lineHeight: 1.2,
648
- textAlign: 'center',
628
+ textAlign: "center",
649
629
  // Let long names wrap within the node's capped width (instead of
650
630
  // truncating), but cap each line so the node doesn't grow unbounded.
651
- whiteSpace: 'normal',
652
- overflowWrap: 'anywhere',
653
- maxWidth: '100%',
631
+ whiteSpace: "normal",
632
+ overflowWrap: "anywhere",
633
+ maxWidth: "100%",
654
634
  fontFamily: theme.fonts.body,
655
635
  }}
656
636
  >
@@ -662,29 +642,25 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
662
642
  (e.g. the dotted host on methods, or a different code identity). */}
663
643
  {c.symbol &&
664
644
  c.symbol !==
665
- displayName
666
- .replace(/ ?\{\}$/, '')
667
- .replace(/\(\)$/, '') && (
668
- <div
669
- style={{
670
- fontSize: theme.fontSizes[0],
671
- fontFamily: theme.fonts.monospace,
672
- color: proposed ? proposalColor : color,
673
- textDecoration: removed ? 'line-through' : undefined,
674
- marginTop: 1,
675
- textAlign: 'center',
676
- whiteSpace: 'nowrap',
677
- overflow: 'hidden',
678
- textOverflow: 'ellipsis',
679
- maxWidth: '100%',
680
- }}
681
- title={c.symbol}
682
- >
683
- {c.symbol}
684
- </div>
685
- )}
686
-
687
- {data.issue && <NodeIssueOverlay issue={data.issue} />}
645
+ displayName.replace(/ ?\{\}$/, "").replace(/\(\)$/, "") && (
646
+ <div
647
+ style={{
648
+ fontSize: theme.fontSizes[0],
649
+ fontFamily: theme.fonts.monospace,
650
+ color: proposed ? proposalColor : color,
651
+ textDecoration: removed ? "line-through" : undefined,
652
+ marginTop: 1,
653
+ textAlign: "center",
654
+ whiteSpace: "nowrap",
655
+ overflow: "hidden",
656
+ textOverflow: "ellipsis",
657
+ maxWidth: "100%",
658
+ }}
659
+ title={c.symbol}
660
+ >
661
+ {c.symbol}
662
+ </div>
663
+ )}
688
664
 
689
665
  <Handle type="target" position={Position.Left} style={{ opacity: 0 }} />
690
666
  <Handle type="source" position={Position.Right} style={{ opacity: 0 }} />
@@ -703,10 +679,16 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
703
679
  * code folder, not a container, so it keeps the bare dashed frame with a
704
680
  * collapsible path badge.
705
681
  */
706
- export function SubsystemGroupNode(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-group'>>) {
682
+ export function SubsystemGroupNode(
683
+ props: NodeProps<Node<SubsystemGroupNodeData, "subsystem-group">>,
684
+ ) {
707
685
  const region = props.data.region;
708
686
  if (!region) return null;
709
- return isCardFrame(region) ? <CardFrame {...props} /> : <BadgeFrame {...props} />;
687
+ return isCardFrame(region) ? (
688
+ <CardFrame {...props} />
689
+ ) : (
690
+ <BadgeFrame {...props} />
691
+ );
710
692
  }
711
693
 
712
694
  /**
@@ -719,7 +701,9 @@ export function SubsystemGroupNode(props: NodeProps<Node<SubsystemGroupNodeData,
719
701
  * encoding: a process is a deployment unit (solid, slight radius), a package is
720
702
  * code organisation (dashed, rounded).
721
703
  */
722
- function CardFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-group'>>) {
704
+ function CardFrame(
705
+ props: NodeProps<Node<SubsystemGroupNodeData, "subsystem-group">>,
706
+ ) {
723
707
  const { theme } = useTheme();
724
708
  const { data, width, height, selected } = props as unknown as {
725
709
  data: SubsystemGroupNodeData;
@@ -734,34 +718,38 @@ function CardFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-grou
734
718
  const dimmed = data.dimmed === true;
735
719
  const hidden = (data as { hidden?: boolean }).hidden === true;
736
720
  const collapsed = data.collapsed === true;
737
- const isPackage = region.kind === 'package' || region.chrome === 'package';
738
- const frameStyle = !isPackage || selected ? 'solid' : 'dashed';
721
+ const isPackage = region.kind === "package" || region.chrome === "package";
722
+ const frameStyle = !isPackage || selected ? "solid" : "dashed";
739
723
  const frameRadius = isPackage ? 12 : 4;
740
- const containerKind = region.containerKind ?? 'application';
741
- const Icon = isPackage ? Package : containerKind === 'data-store' ? Database : AppWindow;
724
+ const containerKind = region.containerKind ?? "application";
725
+ const Icon = isPackage
726
+ ? Package
727
+ : containerKind === "data-store"
728
+ ? Database
729
+ : AppWindow;
742
730
  // The technology row falls back to the kind so it is never blank — the same
743
731
  // fallback the C4 card uses.
744
- const topLabel = region.technology ?? (isPackage ? 'package' : containerKind);
732
+ const topLabel = region.technology ?? (isPackage ? "package" : containerKind);
745
733
  const ToggleIcon = collapsed ? Maximize2 : Minimize2;
746
734
 
747
735
  return (
748
736
  <div
749
737
  title={region.description}
750
738
  style={{
751
- position: 'relative',
739
+ position: "relative",
752
740
  width: width ?? (collapsed ? NODE_W : 400),
753
741
  height: height ?? (collapsed ? NODE_H : 300),
754
- boxSizing: 'border-box',
742
+ boxSizing: "border-box",
755
743
  borderRadius: frameRadius,
756
744
  border: `2px ${frameStyle} ${color}`,
757
745
  background: theme.colors.backgroundSecondary ?? theme.colors.background,
758
- boxShadow: '0 1px 4px rgba(0,0,0,0.25)',
746
+ boxShadow: "0 1px 4px rgba(0,0,0,0.25)",
759
747
  opacity: hidden ? 0 : dimmed ? 0.35 : 1,
760
748
  // React Flow snaps the wrapper to the new size; this box eases between
761
749
  // the open frame and the closed card so the toggle reads as a grow /
762
750
  // shrink rather than a swap.
763
751
  transition: `opacity 150ms ease, width ${MORPH_MS}ms ease, height ${MORPH_MS}ms ease`,
764
- pointerEvents: 'none',
752
+ pointerEvents: "none",
765
753
  fontFamily: theme.fonts.body,
766
754
  }}
767
755
  >
@@ -769,21 +757,21 @@ function CardFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-grou
769
757
  (`OPEN_HEADER_PAD`), inset by the card's own padding. */}
770
758
  <div
771
759
  style={{
772
- position: 'absolute',
760
+ position: "absolute",
773
761
  top: 0,
774
762
  left: 0,
775
763
  right: 0,
776
- display: 'flex',
777
- flexDirection: 'column',
764
+ display: "flex",
765
+ flexDirection: "column",
778
766
  gap: CARD_GAP,
779
767
  padding: `${CARD_PAD_Y}px ${CARD_PAD_X}px`,
780
- boxSizing: 'border-box',
768
+ boxSizing: "border-box",
781
769
  }}
782
770
  >
783
771
  <ContainerCardHeader
784
772
  label={region.label}
785
773
  Icon={Icon}
786
- iconLabel={isPackage ? 'package' : containerKind}
774
+ iconLabel={isPackage ? "package" : containerKind}
787
775
  color={color}
788
776
  topLabel={topLabel}
789
777
  brand={brand}
@@ -800,25 +788,26 @@ function CardFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-grou
800
788
  data.onToggleCollapse?.();
801
789
  }}
802
790
  onDoubleClick={(e) => e.stopPropagation()}
803
- aria-label={collapsed ? 'Show members' : 'Hide members'}
791
+ aria-label={collapsed ? "Show members" : "Hide members"}
804
792
  aria-pressed={collapsed}
805
793
  style={{
806
- position: 'absolute',
794
+ position: "absolute",
807
795
  right: TOGGLE_INSET,
808
796
  bottom: TOGGLE_INSET,
809
- display: 'inline-flex',
810
- alignItems: 'center',
811
- justifyContent: 'center',
797
+ display: "inline-flex",
798
+ alignItems: "center",
799
+ justifyContent: "center",
812
800
  width: TOGGLE_SIZE,
813
801
  height: TOGGLE_SIZE,
814
802
  padding: 0,
815
803
  borderRadius: 4,
816
804
  border: `1px solid ${color}`,
817
- background: theme.colors.backgroundSecondary ?? theme.colors.background,
805
+ background:
806
+ theme.colors.backgroundSecondary ?? theme.colors.background,
818
807
  color,
819
- cursor: 'pointer',
808
+ cursor: "pointer",
820
809
  lineHeight: 1,
821
- pointerEvents: 'auto',
810
+ pointerEvents: "auto",
822
811
  }}
823
812
  >
824
813
  <ToggleIcon size={13} strokeWidth={2.25} />
@@ -827,9 +816,9 @@ function CardFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-grou
827
816
  {data.issue && ISSUE_KIND_ICON[data.issue.kind] && (
828
817
  <IssueChip
829
818
  color={
830
- data.issue.severity === 'error'
831
- ? (theme.colors.error ?? '#e5534b')
832
- : (theme.colors.warning ?? '#d4a017')
819
+ data.issue.severity === "error"
820
+ ? (theme.colors.error ?? "#e5534b")
821
+ : (theme.colors.warning ?? "#d4a017")
833
822
  }
834
823
  Icon={ISSUE_KIND_ICON[data.issue.kind]!}
835
824
  count={data.issue.count}
@@ -840,8 +829,16 @@ function CardFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-grou
840
829
  up onto it, and React Flow needs a handle on each end to draw them. */}
841
830
  {collapsed && (
842
831
  <>
843
- <Handle type="target" position={Position.Left} style={{ opacity: 0 }} />
844
- <Handle type="source" position={Position.Right} style={{ opacity: 0 }} />
832
+ <Handle
833
+ type="target"
834
+ position={Position.Left}
835
+ style={{ opacity: 0 }}
836
+ />
837
+ <Handle
838
+ type="source"
839
+ position={Position.Right}
840
+ style={{ opacity: 0 }}
841
+ />
845
842
  </>
846
843
  )}
847
844
  </div>
@@ -852,7 +849,9 @@ function CardFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-grou
852
849
  * transparent body, and a path badge astride the top edge that collapses a long
853
850
  * path to `first/…/last` and expands on click.
854
851
  */
855
- function BadgeFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-group'>>) {
852
+ function BadgeFrame(
853
+ props: NodeProps<Node<SubsystemGroupNodeData, "subsystem-group">>,
854
+ ) {
856
855
  const { theme } = useTheme();
857
856
  const { data, width, height, selected } = props as unknown as {
858
857
  data: SubsystemGroupNodeData;
@@ -865,7 +864,8 @@ function BadgeFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-gro
865
864
  // (directory, or a module whose key names a folder) share one neutral hue;
866
865
  // everything else hashes per key.
867
866
  const color =
868
- data.color ?? (isFolderFrame(region) ? FOLDER_FRAME_COLOR : packageColor(region.key));
867
+ data.color ??
868
+ (isFolderFrame(region) ? FOLDER_FRAME_COLOR : packageColor(region.key));
869
869
  const dimmed = data.dimmed === true;
870
870
  const hidden = (data as { hidden?: boolean }).hidden === true;
871
871
  // Label is the region identity alone (the path). Kind is carried by the
@@ -873,7 +873,10 @@ function BadgeFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-gro
873
873
  const label = region.label;
874
874
  const [expandedLabel, setExpandedLabel] = useState<string | null>(null);
875
875
  const expanded = expandedLabel === label;
876
- const availableBadgeWidth = Math.max(0, (width ?? 400) - MODULE_BADGE_INSET * 2 - 4);
876
+ const availableBadgeWidth = Math.max(
877
+ 0,
878
+ (width ?? 400) - MODULE_BADGE_INSET * 2 - 4,
879
+ );
877
880
  const collapsedLabel = moduleBadgeLabel(label, availableBadgeWidth);
878
881
  // A module badge is collapsible while something collapsed, and stays
879
882
  // togglable while expanded (so the full path can collapse back).
@@ -881,57 +884,71 @@ function BadgeFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-gro
881
884
  // Hover affords clickability by revealing more of the path — the badge
882
885
  // widens to fit real text (never stretched), hinting before the click.
883
886
  const [hover, setHover] = useState(false);
884
- const hoveredLabel = canToggle ? moduleBadgeHoverLabel(label, availableBadgeWidth) : label;
887
+ const hoveredLabel = canToggle
888
+ ? moduleBadgeHoverLabel(label, availableBadgeWidth)
889
+ : label;
885
890
  const badgeBg = theme.colors.backgroundSecondary ?? theme.colors.background;
886
891
  // Code folders stay dashed until selected; the body is transparent so nested
887
892
  // frames don't stack washes.
888
- const frameStyle = selected ? 'solid' : 'dashed';
893
+ const frameStyle = selected ? "solid" : "dashed";
889
894
 
890
895
  return (
891
896
  <div
892
897
  style={{
893
- position: 'relative',
898
+ position: "relative",
894
899
  width: width ?? 400,
895
900
  height: height ?? 300,
896
- boxSizing: 'border-box',
901
+ boxSizing: "border-box",
897
902
  borderRadius: 12,
898
903
  border: `2px ${frameStyle} ${color}`,
899
- background: 'transparent',
904
+ background: "transparent",
900
905
  opacity: hidden ? 0 : dimmed ? 0.35 : 1,
901
- transition: 'opacity 150ms ease',
902
- pointerEvents: 'none',
906
+ transition: "opacity 150ms ease",
907
+ pointerEvents: "none",
903
908
  }}
904
909
  >
905
910
  <div
906
911
  className="nodrag nopan"
907
- role={canToggle ? 'button' : undefined}
912
+ role={canToggle ? "button" : undefined}
908
913
  tabIndex={canToggle && !hidden ? 0 : undefined}
909
914
  aria-expanded={canToggle ? expanded : undefined}
910
- aria-label={canToggle ? `${expanded ? 'Collapse' : 'Expand'} module path: ${label}` : undefined}
915
+ aria-label={
916
+ canToggle
917
+ ? `${expanded ? "Collapse" : "Expand"} module path: ${label}`
918
+ : undefined
919
+ }
911
920
  onMouseEnter={canToggle ? () => setHover(true) : undefined}
912
921
  onMouseLeave={canToggle ? () => setHover(false) : undefined}
913
- onClick={canToggle ? (event) => {
914
- event.stopPropagation();
915
- setExpandedLabel(expanded ? null : label);
916
- } : undefined}
917
- onKeyDown={canToggle ? (event) => {
918
- if (event.key === 'Enter' || event.key === ' ') {
919
- event.preventDefault();
920
- event.stopPropagation();
921
- setExpandedLabel(expanded ? null : label);
922
- } else if (event.key === 'Escape' && expanded) {
923
- event.stopPropagation();
924
- setExpandedLabel(null);
925
- }
926
- } : undefined}
922
+ onClick={
923
+ canToggle
924
+ ? (event) => {
925
+ event.stopPropagation();
926
+ setExpandedLabel(expanded ? null : label);
927
+ }
928
+ : undefined
929
+ }
930
+ onKeyDown={
931
+ canToggle
932
+ ? (event) => {
933
+ if (event.key === "Enter" || event.key === " ") {
934
+ event.preventDefault();
935
+ event.stopPropagation();
936
+ setExpandedLabel(expanded ? null : label);
937
+ } else if (event.key === "Escape" && expanded) {
938
+ event.stopPropagation();
939
+ setExpandedLabel(null);
940
+ }
941
+ }
942
+ : undefined
943
+ }
927
944
  style={{
928
- position: 'absolute',
945
+ position: "absolute",
929
946
  // Centred astride the top edge like component badges. Always set
930
947
  // left/transform explicitly — React Flow reuses group DOM nodes and
931
948
  // `undefined` does not clear a prior value.
932
949
  top: 0,
933
950
  left: 12,
934
- transform: 'translateY(-50%)',
951
+ transform: "translateY(-50%)",
935
952
  zIndex: canToggle ? 10 : undefined,
936
953
  // Width is explicit while collapsible so hover-reveal of more path
937
954
  // text animates; the cap keeps both states inside the frame.
@@ -939,13 +956,16 @@ function BadgeFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-gro
939
956
  canToggle && !expanded
940
957
  ? hover
941
958
  ? Math.min(availableBadgeWidth, moduleBadgeWidth(hoveredLabel))
942
- : Math.min(availableBadgeWidth, moduleBadgeWidth(collapsedLabel))
959
+ : Math.min(
960
+ availableBadgeWidth,
961
+ moduleBadgeWidth(collapsedLabel),
962
+ )
943
963
  : undefined,
944
- transition: 'width 140ms ease, box-shadow 120ms ease',
945
- cursor: canToggle ? 'pointer' : undefined,
964
+ transition: "width 140ms ease, box-shadow 120ms ease",
965
+ cursor: canToggle ? "pointer" : undefined,
946
966
  // The trailing halo squares the rounded corners back off in the fill
947
967
  // colour, so an edge crossing a corner can't show through the notch.
948
- boxShadow: `${canToggle && hover ? `0 2px 10px ${color}55, ` : ''}0 0 0 1.5px ${badgeBg}`,
968
+ boxShadow: `${canToggle && hover ? `0 2px 10px ${color}55, ` : ""}0 0 0 1.5px ${badgeBg}`,
949
969
  fontFamily: theme.fonts.monospace,
950
970
  fontSize: theme.fontSizes[3],
951
971
  fontWeight: 700,
@@ -954,12 +974,12 @@ function BadgeFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-gro
954
974
  background: badgeBg,
955
975
  border: `2px solid ${color}`,
956
976
  borderRadius: 4,
957
- padding: '3px 9px',
958
- whiteSpace: 'nowrap',
959
- overflow: 'hidden',
960
- textOverflow: 'ellipsis',
961
- boxSizing: 'border-box',
962
- pointerEvents: hidden ? 'none' : 'auto',
977
+ padding: "3px 9px",
978
+ whiteSpace: "nowrap",
979
+ overflow: "hidden",
980
+ textOverflow: "ellipsis",
981
+ boxSizing: "border-box",
982
+ pointerEvents: hidden ? "none" : "auto",
963
983
  // Cap the collapsed badge at the frame's inner width so it never
964
984
  // spills past the module — it gets the `…`/click-to-expand treatment
965
985
  // instead. Expanding lifts the cap so the full path grows the badge
@@ -968,7 +988,7 @@ function BadgeFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-gro
968
988
  }}
969
989
  >
970
990
  {canToggle ? (
971
- <span style={{ whiteSpace: 'nowrap' }}>
991
+ <span style={{ whiteSpace: "nowrap" }}>
972
992
  {expanded ? label : hover ? hoveredLabel : collapsedLabel}
973
993
  </span>
974
994
  ) : (
@@ -980,9 +1000,9 @@ function BadgeFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-gro
980
1000
  {data.issue && ISSUE_KIND_ICON[data.issue.kind] && (
981
1001
  <IssueChip
982
1002
  color={
983
- data.issue.severity === 'error'
984
- ? (theme.colors.error ?? '#e5534b')
985
- : (theme.colors.warning ?? '#d4a017')
1003
+ data.issue.severity === "error"
1004
+ ? (theme.colors.error ?? "#e5534b")
1005
+ : (theme.colors.warning ?? "#d4a017")
986
1006
  }
987
1007
  Icon={ISSUE_KIND_ICON[data.issue.kind]!}
988
1008
  count={data.issue.count}
@@ -996,12 +1016,12 @@ function BadgeFrame(props: NodeProps<Node<SubsystemGroupNodeData, 'subsystem-gro
996
1016
  * each opacity gets its own SVG marker id — path `opacity` leaks across every
997
1017
  * edge that shares a `url(#marker)` (the focused edge's arrowhead dims). */
998
1018
  export function hexWithAlpha(hex: string, alpha: number): string {
999
- const raw = hex.replace('#', '');
1000
- const full = raw.length === 3 ? [...raw].map((c) => c + c).join('') : raw;
1019
+ const raw = hex.replace("#", "");
1020
+ const full = raw.length === 3 ? [...raw].map((c) => c + c).join("") : raw;
1001
1021
  if (!/^[0-9a-fA-F]{6}$/.test(full)) return hex;
1002
1022
  const a = Math.round(Math.min(1, Math.max(0, alpha)) * 255)
1003
1023
  .toString(16)
1004
- .padStart(2, '0');
1024
+ .padStart(2, "0");
1005
1025
  return `#${full}${a}`;
1006
1026
  }
1007
1027
 
@@ -1090,21 +1110,30 @@ export function SubsystemEdge({
1090
1110
  data,
1091
1111
  markerEnd,
1092
1112
  }: EdgeProps<SubsystemGraphEdge>) {
1093
- const path = data?.elkPath ?? '';
1094
- const mechanism = data?.mechanism ?? 'uses';
1113
+ const path = data?.elkPath ?? "";
1114
+ const mechanism = data?.mechanism ?? "uses";
1095
1115
  // Color + dash resolve from provenance: subsystem mechanisms use the
1096
1116
  // MECHANISM_* tables, graphify-native relations use the separate
1097
1117
  // GRAPHIFY_RELATION_* palette (see edgeColor / edgeStrokeStyle).
1098
1118
  const edgeRef = { mechanism, provenance: data?.provenance };
1099
- const color = edgeColor(edgeRef);
1119
+ const ghost = data?.ghost === true;
1120
+ const proposed = data?.proposed === true;
1121
+ const color = proposed ? HOST_PROPOSAL_COLOR : edgeColor(edgeRef);
1100
1122
  // Dash style encodes provenance (graphify) and relationship kind (dashed =
1101
1123
  // inverted-control or observational: hierarchy, registration, watches).
1102
- const isDashed = edgeStrokeStyle(edgeRef) === 'dashed';
1124
+ // Host-local proposal/previous-state edges are dashed too.
1125
+ const isDashed = proposed || ghost || edgeStrokeStyle(edgeRef) === "dashed";
1103
1126
  const dimmed = data?.dimmed === true;
1104
1127
  // Dim the stroke by color, never via path `opacity`. SVG markers are shared
1105
1128
  // by id; opacity on the referencing path paints every arrowhead that uses
1106
1129
  // the same marker — including the focused edge's target.
1107
- const stroke = dimmed ? hexWithAlpha(color, EDGE_DIM_ALPHA) : color;
1130
+ const stroke = proposed
1131
+ ? color
1132
+ : ghost
1133
+ ? hexWithAlpha(color, 0.45)
1134
+ : dimmed
1135
+ ? hexWithAlpha(color, EDGE_DIM_ALPHA)
1136
+ : color;
1108
1137
 
1109
1138
  return (
1110
1139
  <>
@@ -1124,12 +1153,11 @@ export function SubsystemEdge({
1124
1153
  d={path}
1125
1154
  fill="none"
1126
1155
  stroke={stroke}
1127
- strokeWidth={1.5}
1128
- strokeDasharray={isDashed ? '6 4' : undefined}
1156
+ strokeWidth={ghost || proposed ? 1 : 1.5}
1157
+ strokeDasharray={isDashed ? "6 4" : undefined}
1129
1158
  markerEnd={markerEnd}
1130
- style={{ pointerEvents: 'none' }}
1159
+ style={{ pointerEvents: "none" }}
1131
1160
  />
1132
1161
  </>
1133
1162
  );
1134
1163
  }
1135
-