@principal-ai/subsystems-react 0.56.34 → 0.56.35

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.
@@ -20,6 +20,7 @@ import {
20
20
  reorderTrails,
21
21
  trailStepGraphEdgeId,
22
22
  type SubsystemTrail,
23
+ type SubsystemTrailStep,
23
24
  } from './model';
24
25
  import { buildStepBrief } from './trailBrief';
25
26
  import { emphasisKey, type StepEmphasisMap } from './stepEmphasis';
@@ -45,6 +46,13 @@ const EMPHASIS_COLOR = '#f5a524';
45
46
  */
46
47
  export const TRAIL_HOVER_PREVIEW_MS = 150;
47
48
 
49
+ /** Host-local before/after view retained when a step replacement is accepted. */
50
+ export interface TrailsStepChange {
51
+ trailId: string;
52
+ stepIndex: number;
53
+ previous: SubsystemTrailStep;
54
+ }
55
+
48
56
  /** How long a step's number shows its "copied" checkmark (ms). */
49
57
  export const STEP_COPY_FEEDBACK_MS = 2000;
50
58
 
@@ -85,6 +93,11 @@ function TrailFlow({
85
93
  onRemoveStepEmphasis,
86
94
  componentByAlias,
87
95
  hideHeader = false,
96
+ proposed = false,
97
+ proposedStepKeys,
98
+ stepChange,
99
+ showPreviousStep = true,
100
+ onTogglePreviousStep,
88
101
  }: {
89
102
  trail: SubsystemTrail;
90
103
  collapsed: boolean;
@@ -125,8 +138,19 @@ function TrailFlow({
125
138
  componentByAlias?: TrailComponentLabels;
126
139
  /** The shared drill-down navigation supplies the trail header. */
127
140
  hideHeader?: boolean;
141
+ /** Host-local proposal: colour the flow icon without changing the title. */
142
+ proposed?: boolean;
143
+ /** Host-local proposed steps, keyed by `emphasisKey(trailId, step)`. */
144
+ proposedStepKeys?: Set<string>;
145
+ /** Host-local before/after view for an accepted step replacement. */
146
+ stepChange?: TrailsStepChange | null;
147
+ /** Whether the previous-state ghost is visible. @default true */
148
+ showPreviousStep?: boolean;
149
+ /** Dismiss or restore just the previous-state ghost. */
150
+ onTogglePreviousStep?: () => void;
128
151
  }) {
129
152
  const { theme } = useTheme();
153
+ const proposalColor = theme.colors.warning ?? '#d4a017';
130
154
  const muted = theme.colors.textMuted ?? theme.colors.textSecondary;
131
155
  const hoverBg = theme.colors.background;
132
156
  const wholeFlowActive = active !== null && active.stepIndex === null;
@@ -329,7 +353,11 @@ function TrailFlow({
329
353
  style={{
330
354
  flexShrink: 0,
331
355
  marginTop: 3,
332
- color: headerHover || (!collapsed && wholeFlowActive) ? theme.colors.primary : muted,
356
+ color: proposed
357
+ ? proposalColor
358
+ : headerHover || (!collapsed && wholeFlowActive)
359
+ ? theme.colors.primary
360
+ : muted,
333
361
  }}
334
362
  />
335
363
  <span
@@ -511,7 +539,16 @@ function TrailFlow({
511
539
  const stepActive = active !== null && active.stepIndex === i;
512
540
  const copied = copiedStep === i;
513
541
  const record = stepEmphasis?.get(emphasisKey(trail.id, step));
542
+ const stepProposed =
543
+ proposed || (proposedStepKeys?.has(emphasisKey(trail.id, step)) ?? false);
514
544
  const display = trailStepDisplay(step, componentByAlias);
545
+ const previousStep =
546
+ stepChange?.trailId === trail.id && stepChange.stepIndex === i
547
+ ? stepChange.previous
548
+ : null;
549
+ const previousDisplay = previousStep
550
+ ? trailStepDisplay(previousStep, componentByAlias)
551
+ : null;
515
552
  // Calls nest; uses/data steps sit at their anchor frame's depth.
516
553
  const stackDepth = buildTrailStack(
517
554
  trail,
@@ -579,13 +616,15 @@ function TrailFlow({
579
616
  fontSize: theme.fontSizes[0],
580
617
  fontFamily: theme.fonts.monospace,
581
618
  fontWeight: record ? 700 : undefined,
582
- color: copied
583
- ? theme.colors.primary
584
- : record
585
- ? EMPHASIS_COLOR
586
- : stepActive
587
- ? theme.colors.text
588
- : muted,
619
+ color: stepProposed
620
+ ? proposalColor
621
+ : copied
622
+ ? theme.colors.primary
623
+ : record
624
+ ? EMPHASIS_COLOR
625
+ : stepActive
626
+ ? theme.colors.text
627
+ : muted,
589
628
  }}
590
629
  >
591
630
  {copied ? <Check size={12} strokeWidth={2} aria-hidden /> : i + 1}
@@ -608,7 +647,7 @@ function TrailFlow({
608
647
  overflowWrap: 'anywhere',
609
648
  fontSize: theme.fontSizes[1],
610
649
  fontFamily: theme.fonts.monospace,
611
- color: theme.colors.primary,
650
+ color: stepProposed ? proposalColor : theme.colors.primary,
612
651
  lineHeight: 1.35,
613
652
  }}
614
653
  >
@@ -628,6 +667,69 @@ function TrailFlow({
628
667
  </span>
629
668
  </span>
630
669
  </button>
670
+ {previousStep && previousDisplay && (
671
+ <div
672
+ style={{
673
+ display: 'flex',
674
+ alignItems: 'flex-start',
675
+ gap: 8,
676
+ padding: `0 12px 10px ${stepInset + 14 + 8}px`,
677
+ }}
678
+ >
679
+ {showPreviousStep ? (
680
+ <span
681
+ aria-label="previous step state"
682
+ style={{
683
+ flex: 1,
684
+ minWidth: 0,
685
+ borderLeft: `1px dashed ${theme.colors.border ?? '#2d3034'}`,
686
+ paddingLeft: 8,
687
+ color: muted,
688
+ fontFamily: theme.fonts.monospace,
689
+ fontSize: theme.fontSizes[0],
690
+ lineHeight: 1.5,
691
+ opacity: 0.85,
692
+ }}
693
+ >
694
+ <span style={{ textDecoration: 'line-through' }}>
695
+ Was: {previousStep.annotation ?? previousDisplay.primary}
696
+ </span>
697
+ {previousStep.annotation && (
698
+ <span
699
+ style={{ display: 'block', textDecoration: 'line-through' }}
700
+ >
701
+ {previousDisplay.primary}
702
+ </span>
703
+ )}
704
+ </span>
705
+ ) : null}
706
+ {onTogglePreviousStep && (
707
+ <button
708
+ type="button"
709
+ onClick={onTogglePreviousStep}
710
+ aria-label={
711
+ showPreviousStep
712
+ ? 'Hide previous step state'
713
+ : 'Show previous step state'
714
+ }
715
+ style={{
716
+ flexShrink: 0,
717
+ padding: '2px 6px',
718
+ borderRadius: 4,
719
+ border: `1px solid ${theme.colors.border ?? '#2d3034'}`,
720
+ background: 'transparent',
721
+ color: muted,
722
+ fontFamily: theme.fonts.monospace,
723
+ fontSize: theme.fontSizes[0],
724
+ cursor: 'pointer',
725
+ whiteSpace: 'nowrap',
726
+ }}
727
+ >
728
+ {showPreviousStep ? 'Hide old' : 'Show old'}
729
+ </button>
730
+ )}
731
+ </div>
732
+ )}
631
733
  {record && (
632
734
  <span
633
735
  aria-hidden
@@ -741,6 +843,16 @@ export interface TrailsPanelProps {
741
843
  drilldown?: boolean;
742
844
  /** Files or issues for the selected trail, beneath its shared header. */
743
845
  detailContent?: ReactNode;
846
+ /** Host-local trails awaiting confirmation; their icons use proposal color. */
847
+ proposedTrailIds?: Set<string>;
848
+ /** Host-local steps awaiting confirmation, keyed by `emphasisKey`. */
849
+ proposedStepKeys?: Set<string>;
850
+ /** Host-local before/after view for an accepted step replacement. */
851
+ stepChange?: TrailsStepChange | null;
852
+ /** Whether the previous-state ghost is visible. @default true */
853
+ showPreviousStep?: boolean;
854
+ /** Dismiss or restore just the previous-state ghost. */
855
+ onTogglePreviousStep?: () => void;
744
856
  }
745
857
 
746
858
  /**
@@ -769,6 +881,11 @@ export function TrailsPanel({
769
881
  componentByAlias,
770
882
  drilldown = false,
771
883
  detailContent,
884
+ proposedTrailIds,
885
+ proposedStepKeys,
886
+ stepChange,
887
+ showPreviousStep,
888
+ onTogglePreviousStep,
772
889
  }: TrailsPanelProps) {
773
890
  const { theme } = useTheme();
774
891
  // Reordering is offered only while every row is collapsed: the compact list
@@ -956,6 +1073,11 @@ export function TrailsPanel({
956
1073
  }
957
1074
  stepEmphasis={stepEmphasis}
958
1075
  onRemoveStepEmphasis={onRemoveStepEmphasis}
1076
+ proposed={proposedTrailIds?.has(tl.id) ?? false}
1077
+ proposedStepKeys={proposedStepKeys}
1078
+ stepChange={stepChange}
1079
+ showPreviousStep={showPreviousStep}
1080
+ onTogglePreviousStep={onTogglePreviousStep}
959
1081
  />
960
1082
  </div>
961
1083
  );
@@ -980,6 +1102,7 @@ export function TrailsPanel({
980
1102
  componentByAlias={componentByAlias}
981
1103
  listContent={list}
982
1104
  detailContent={detailContent}
1105
+ proposedTrailIds={proposedTrailIds}
983
1106
  renderSteps={(trail) => (
984
1107
  <TrailFlow
985
1108
  key={trail.id}
@@ -1004,6 +1127,11 @@ export function TrailsPanel({
1004
1127
  componentByAlias={componentByAlias}
1005
1128
  stepEmphasis={stepEmphasis}
1006
1129
  onRemoveStepEmphasis={onRemoveStepEmphasis}
1130
+ proposed={proposedTrailIds?.has(trail.id) ?? false}
1131
+ proposedStepKeys={proposedStepKeys}
1132
+ stepChange={stepChange}
1133
+ showPreviousStep={showPreviousStep}
1134
+ onTogglePreviousStep={onTogglePreviousStep}
1007
1135
  />
1008
1136
  )}
1009
1137
  />
@@ -1241,6 +1241,12 @@ export interface SubsystemGraphNodeData extends Record<string, unknown> {
1241
1241
  fileMatch?: boolean;
1242
1242
  /** True while this node is on an opened-but-unselected flow. */
1243
1243
  dimmed?: boolean;
1244
+ /** Host-local proposal: the component box is awaiting confirmation. */
1245
+ proposed?: boolean;
1246
+ /** Host-local working indicator: the agent is working on this component. */
1247
+ working?: boolean;
1248
+ /** Host-local removal ghost: the component was removed but stays dimmed in place. */
1249
+ removed?: boolean;
1244
1250
  /** Diagnostics badge — see `SubsystemNodeIssue`. Absent when no findings. */
1245
1251
  issue?: SubsystemNodeIssue;
1246
1252
  /**
@@ -58,7 +58,7 @@ import {
58
58
  } from './containerCard';
59
59
  import { MORPH_MS } from './graphMorph';
60
60
  import { technologyBrand } from './techIcons';
61
- import { AppWindow, Component, Database, Maximize2, Minimize2, Package, Search } from 'lucide-react';
61
+ import { AppWindow, Component, Database, Maximize2, Minimize2, Package, Search, WandSparkles } from 'lucide-react';
62
62
  import type { LucideIcon } from 'lucide-react';
63
63
 
64
64
  export const CONSTRUCT_LABEL: Record<string, string> = {
@@ -225,6 +225,19 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
225
225
  // shows as the hover badge, not as color — for now; a role glyph/accent may
226
226
  // come later. A component-authored `color` override wins over the construct.
227
227
  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
+ 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.
235
+ 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.
239
+ const removed = data.removed === true;
240
+ const removedColor = DEPRECATED_COLOR;
228
241
  // Left badge: framework brand (e.g. React cyan) when the label is a
229
242
  // framework stereotype; otherwise the same construct color as the border.
230
243
  const badgeColor = constructBadgeColor(c) ?? color;
@@ -234,6 +247,10 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
234
247
  const displayName = deriveNameFromSymbol(c.symbol, c.construct, c.name, c.file, c.stereotype);
235
248
  // Top badges are absolutely positioned — widen the node so they nowrap
236
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.
237
254
  const badgeMinWidth = nodeMinWidthForBadges(c);
238
255
  const topRightLabel = rightBadgeLabel(c);
239
256
  const topRightColor = rightBadgeColor(c);
@@ -258,11 +275,15 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
258
275
  // Border: deprecated uses the slate accent (dotted, same family as issue)
259
276
  // since it means "not a live claim"; construct color stays on the left
260
277
  // badge. File-open spotlight still wins with primary.
261
- const borderColor = fileMatch
262
- ? theme.colors.primary
263
- : c.deprecated
264
- ? DEPRECATED_COLOR
265
- : color;
278
+ const borderColor = removed
279
+ ? removedColor
280
+ : proposed
281
+ ? proposalColor
282
+ : fileMatch
283
+ ? theme.colors.primary
284
+ : c.deprecated
285
+ ? DEPRECATED_COLOR
286
+ : color;
266
287
  // Selection is stamped into data by the graph component — React Flow's own
267
288
  // `selected` never updates because the node stops click propagation.
268
289
  const isSelected = selected || (data.isSelected as boolean | undefined) === true;
@@ -275,7 +296,7 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
275
296
  // `top` / `left` would slide with the border. Anchor them to the border box
276
297
  // instead, offsetting by the border width. Side badges sit flush with the
277
298
  // node's left / right edge (`-borderW`); the top reference stays at -9.
278
- const borderW = isSelected || fileMatch ? 4 : 2;
299
+ const borderW = proposed ? 3 : isSelected || fileMatch ? 4 : 2;
279
300
  const badgeTop = -9 - borderW;
280
301
  const badgeEdge = -borderW;
281
302
  // A node with diagnostics turns its border dotted — an "something's off"
@@ -286,11 +307,15 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
286
307
  // Deprecated is dotted like issue but slate rather than construct-colored:
287
308
  // "this claim was retired" is closer to a diagnostic than to a placeholder,
288
309
  // and verification skips deprecated nodes so the two never stack in practice.
289
- const borderStyle = hasIssue
290
- ? 'dotted'
291
- : c.deprecated
292
- ? 'dotted'
293
- : 'solid';
310
+ const borderStyle = removed
311
+ ? 'dashed'
312
+ : proposed
313
+ ? 'dashed'
314
+ : hasIssue
315
+ ? 'dotted'
316
+ : c.deprecated
317
+ ? 'dotted'
318
+ : 'solid';
294
319
 
295
320
  return (
296
321
  <div
@@ -324,10 +349,16 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
324
349
  // use a dashed goldenrod border, issue nodes a dotted construct-colored
325
350
  // one; the left construct badge keeps construct color either way.
326
351
  border: `${borderW}px ${borderStyle} ${borderColor}`,
327
- boxShadow: fileMatch
328
- ? `0 1px 4px rgba(0,0,0,0.25), 0 0 12px ${theme.colors.primary}55`
329
- : '0 1px 4px rgba(0,0,0,0.25)',
330
- opacity: fileMatch === false || data.dimmed === true ? 0.18 : 1,
352
+ boxShadow: working
353
+ ? `0 0 0 3px ${workingColor}55, 0 0 18px ${workingColor}44`
354
+ : fileMatch
355
+ ? `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)',
357
+ opacity: removed
358
+ ? 0.45
359
+ : working || (fileMatch !== false && data.dimmed !== true)
360
+ ? 1
361
+ : 0.18,
331
362
  transition: 'opacity 150ms ease, background-color 120ms ease',
332
363
  cursor: 'pointer',
333
364
  fontFamily: theme.fonts.body,
@@ -359,6 +390,98 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
359
390
  {constructBadgeLabel(c)}
360
391
  </div>
361
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"
398
+ style={{
399
+ position: 'absolute',
400
+ top: 18,
401
+ right: badgeEdge,
402
+ zIndex: 1,
403
+ fontFamily: theme.fonts.monospace,
404
+ 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',
415
+ }}
416
+ >
417
+ removed
418
+ </div>
419
+ )}
420
+
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. */}
426
+ {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>
449
+ )}
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>
483
+ )}
484
+
362
485
  {/* Secondary badge cluster — the role badge, with store storage
363
486
  (retention backing) beside it since it is orthogonal to topology.
364
487
  Persistent; pointer-events pass through.
@@ -519,7 +642,8 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
519
642
  style={{
520
643
  fontSize: theme.fontSizes[2],
521
644
  fontWeight: 600,
522
- color: theme.colors.text,
645
+ color: proposed ? proposalColor : theme.colors.text,
646
+ textDecoration: removed ? 'line-through' : undefined,
523
647
  lineHeight: 1.2,
524
648
  textAlign: 'center',
525
649
  // Let long names wrap within the node's capped width (instead of
@@ -545,7 +669,8 @@ export function SubsystemComponentNode(props: NodeProps<Node<SubsystemGraphNodeD
545
669
  style={{
546
670
  fontSize: theme.fontSizes[0],
547
671
  fontFamily: theme.fonts.monospace,
548
- color: color,
672
+ color: proposed ? proposalColor : color,
673
+ textDecoration: removed ? 'line-through' : undefined,
549
674
  marginTop: 1,
550
675
  textAlign: 'center',
551
676
  whiteSpace: 'nowrap',