@principal-ai/subsystems-react 0.56.37 → 0.56.39

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.
@@ -114,6 +114,7 @@ import {
114
114
  type TrailsStepChange,
115
115
  } from './TrailsPanel';
116
116
  import { emphasisKey, variationStepNumber, type StepEmphasisMap } from './stepEmphasis';
117
+ import type { TrailChange } from './TrailIcon';
117
118
  import {
118
119
  EDGE_LABEL_WIDTH,
119
120
  EDGE_LABEL_HEIGHT,
@@ -446,6 +447,25 @@ export interface SubsystemComponentGraphProps {
446
447
  * a step row, and fall back to the focused trail on leave.
447
448
  */
448
449
  onTrailStepHover?: (ref: { trailId: string; stepIndex: number } | null) => void;
450
+ /**
451
+ * Reports the trail under the pointer in the Trails panel — its header row or
452
+ * one of its steps — and `null` when the pointer leaves. Unlike
453
+ * `onTrailStepHover`, a whole-flow hover is reported too.
454
+ */
455
+ onTrailHover?: (trailId: string | null) => void;
456
+ /**
457
+ * Host-driven emphasis, the way hovering a trail does it: these trails' edges
458
+ * and components stay bright and everything else dims, and the Trails panel
459
+ * dims the other rows. It never moves the camera or changes selection, and
460
+ * the graph's own trail hover wins while it lasts. Empty or absent = none.
461
+ */
462
+ highlightedTrailIds?: ReadonlySet<string>;
463
+ /**
464
+ * What the host says is happening to each trail, by id: `added`, `removed` or
465
+ * `changed`. The trail's icon in the Trails list is drawn in that colour (green,
466
+ * red, yellow) with a +, − or dot badge. Trails not in the map are unmarked.
467
+ */
468
+ trailChanges?: ReadonlyMap<string, TrailChange>;
449
469
  /**
450
470
  * Called with the next trail order after a drag in the sidebar's
451
471
  * flows panel. When set, each row grows a drag grip and a drop emits the
@@ -863,7 +883,7 @@ interface InnerProps extends SubsystemComponentGraphProps {
863
883
  onSidebarTrailChange: (trailId: string | null) => void;
864
884
  }
865
885
 
866
- function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirection: layoutDirectionProp, defaultLayoutDirection = 'horizontal', onLayoutDirectionChange, hideLayoutToggle = false, refocusOnLayoutFlip = true, initialTrailId, onTrailSelect, focusedTrailStep, proposedTrailIds, proposedStepKeys, stepChange, stepNumberLabels: hostStepNumberLabels, stepHistory, proposedStep, focusedVariationStepIndexes, proposedComponentAliases, workingComponentAliases, removedComponentAliases, onTrailStepHover, onReorderTrails, stepEmphasis, onRemoveStepEmphasis, onSelect, onEdgeSelect, measured: _measured, maxNodeWidth, showEdgeLabels, showSingletonFrames = true, moduleNesting, edgeView, hideSidebar, trailStepMode = 'focus', autoPlayTrails = false, trailAutoPlayIntervalMs = TRAIL_PLAY_PAUSE_MS, onAutoPlayStep, zoomOnTrailFocus = true, trailFocusDurationMs = 300, focusVerticalBiasPx = 0, graphTitle, showTrailTitle = false, description, notes, canvasOverlay, interactive = true, canvasBackground = 'theme', onLayoutReady, onNodeRects, sidebarExtra, sidebarAfterDescription, issues, showIssues, filesActive, sidebarScope, onSidebarTrailChange, focusIssueCategory, laneStatus, onSelectIssue, onApplyIssueFix, onHoverIssue, renderFileViewer, renderTrailViewer, onFileSelect, componentVerification, onInspectSymbol, boundaryColors, codeProcessKeys, regionDetails, defaultFramesCollapsed, containersActive, hideDrawer = false, persistKey, liveEvents, agentsPanel }: InnerProps) {
886
+ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirection: layoutDirectionProp, defaultLayoutDirection = 'horizontal', onLayoutDirectionChange, hideLayoutToggle = false, refocusOnLayoutFlip = true, initialTrailId, onTrailSelect, focusedTrailStep, proposedTrailIds, proposedStepKeys, stepChange, stepNumberLabels: hostStepNumberLabels, stepHistory, proposedStep, focusedVariationStepIndexes, proposedComponentAliases, workingComponentAliases, removedComponentAliases, onTrailStepHover, onTrailHover, highlightedTrailIds, trailChanges, onReorderTrails, stepEmphasis, onRemoveStepEmphasis, onSelect, onEdgeSelect, measured: _measured, maxNodeWidth, showEdgeLabels, showSingletonFrames = true, moduleNesting, edgeView, hideSidebar, trailStepMode = 'focus', autoPlayTrails = false, trailAutoPlayIntervalMs = TRAIL_PLAY_PAUSE_MS, onAutoPlayStep, zoomOnTrailFocus = true, trailFocusDurationMs = 300, focusVerticalBiasPx = 0, graphTitle, showTrailTitle = false, description, notes, canvasOverlay, interactive = true, canvasBackground = 'theme', onLayoutReady, onNodeRects, sidebarExtra, sidebarAfterDescription, issues, showIssues, filesActive, sidebarScope, onSidebarTrailChange, focusIssueCategory, laneStatus, onSelectIssue, onApplyIssueFix, onHoverIssue, renderFileViewer, renderTrailViewer, onFileSelect, componentVerification, onInspectSymbol, boundaryColors, codeProcessKeys, regionDetails, defaultFramesCollapsed, containersActive, hideDrawer = false, persistKey, liveEvents, agentsPanel }: InnerProps) {
867
887
  const { theme } = useTheme();
868
888
  const { fitView, fitBounds, setViewport } = useReactFlow();
869
889
  const flowWidth = useStore((state) => state.width);
@@ -2266,6 +2286,37 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
2266
2286
  }
2267
2287
  return ids.size > 0 ? ids : null;
2268
2288
  }, [trails, hoveredTrailStep]);
2289
+ // Host-driven emphasis (`highlightedTrailIds`): the same bright set a trail hover
2290
+ // builds, but for several trails and without the camera following it.
2291
+ const externalHighlightEdgeIds = useMemo(() => {
2292
+ if (!highlightedTrailIds || highlightedTrailIds.size === 0 || !trails) return null;
2293
+ const ids = new Set<string>();
2294
+ for (const tl of trails) {
2295
+ if (!highlightedTrailIds.has(tl.id)) continue;
2296
+ for (const s of tl.steps) ids.add(trailStepGraphEdgeId(s));
2297
+ for (const g of linkedEdgeIdsByTrail.get(tl.id) ?? []) ids.add(g);
2298
+ }
2299
+ return ids.size > 0 ? ids : null;
2300
+ }, [trails, highlightedTrailIds, linkedEdgeIdsByTrail]);
2301
+ const externalHighlightNodeIds = useMemo(
2302
+ () => endpointsOf(externalHighlightEdgeIds),
2303
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2304
+ [baseEdges, externalHighlightEdgeIds],
2305
+ );
2306
+ const externalHighlightAliases = useMemo(() => {
2307
+ if (!highlightedTrailIds || highlightedTrailIds.size === 0 || !trails) return null;
2308
+ const ids = new Set<string>();
2309
+ for (const tl of trails) {
2310
+ if (!highlightedTrailIds.has(tl.id)) continue;
2311
+ for (const s of tl.steps) {
2312
+ ids.add(s.from);
2313
+ ids.add(s.to);
2314
+ }
2315
+ }
2316
+ return ids.size > 0 ? ids : null;
2317
+ }, [trails, highlightedTrailIds]);
2318
+ /** A real trail hover wins over the host's emphasis while it lasts. */
2319
+ const spotlightAliases = hoverTrailAliases ?? externalHighlightAliases;
2269
2320
  const aliasToComponent = useMemo(
2270
2321
  () => new Map(components.map((c) => [c.alias, c])),
2271
2322
  [components],
@@ -2314,14 +2365,14 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
2314
2365
  // spotlight member as well as a bright set: without an expanded flow
2315
2366
  // there is no opened set, so dimming has to be driven from the
2316
2367
  // participants or nothing outside the focused step would dim.
2317
- const dimSource = previewNodeIds ?? brightNodeIds ?? issueFocusNodeIds;
2368
+ const dimSource = previewNodeIds ?? externalHighlightNodeIds ?? brightNodeIds ?? issueFocusNodeIds;
2318
2369
  // Hover keeps a container bright when any of its contents is in the
2319
2370
  // hovered trail — read off component membership so nesting is
2320
2371
  // transitive and internally-folded trails still count.
2321
- const touchesHover = regionTouchesTrailAliases(region, hoverTrailAliases, aliasToComponent);
2372
+ const touchesHover = regionTouchesTrailAliases(region, spotlightAliases, aliasToComponent);
2322
2373
  const inSpotlight =
2323
2374
  memberAliases.some((alias) => dimSource?.has(alias) === true) || touchesHover;
2324
- const anySpotlight = dimSource != null || hoverTrailAliases != null;
2375
+ const anySpotlight = dimSource != null || spotlightAliases != null;
2325
2376
  const { hidden, dimmed } = flowNodeVisibility({
2326
2377
  inOpened: memberAliases.some((alias) => openedNodeIds?.has(alias) === true),
2327
2378
  inSelected: memberAliases.some((alias) => brightNodeIds?.has(alias) === true),
@@ -2365,14 +2416,14 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
2365
2416
  const isSelected = selected?.alias !== undefined && comp?.alias === selected.alias;
2366
2417
  // `brightNodeIds` (the focused step's endpoints) is a spotlight member as
2367
2418
  // well as a bright set — see the group branch above.
2368
- const dimSource = previewNodeIds ?? brightNodeIds ?? issueFocusNodeIds;
2419
+ const dimSource = previewNodeIds ?? externalHighlightNodeIds ?? brightNodeIds ?? issueFocusNodeIds;
2369
2420
  const flowVisibility = flowNodeVisibility({
2370
2421
  inOpened: openedNodeIds?.has(n.id) === true,
2371
2422
  inSelected: brightNodeIds?.has(n.id) === true,
2372
- inSpotlight: dimSource?.has(n.id) === true || (hoverTrailAliases?.has(n.id) === true),
2423
+ inSpotlight: dimSource?.has(n.id) === true || (spotlightAliases?.has(n.id) === true),
2373
2424
  anyOpened: openedNodeIds != null,
2374
2425
  anySelected: brightNodeIds != null,
2375
- anySpotlight: dimSource != null || hoverTrailAliases != null,
2426
+ anySpotlight: dimSource != null || spotlightAliases != null,
2376
2427
  });
2377
2428
  // A removed ghost is never hidden by flow focus — the whole point is to
2378
2429
  // keep it visible as a dim record of what the agent took out.
@@ -2410,7 +2461,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
2410
2461
  },
2411
2462
  };
2412
2463
  });
2413
- }, [xyflowNodesBase, openFile, selected, focusNodeIds, openedNodeIds, brightNodeIds, previewNodeIds, hoverTrailAliases, aliasToComponent, issueFocusNodeIds, issueBadgeByAlias, regionIssueByNodeId, boundaryColors, proposedComponentAliases, workingComponentAliases, removedComponentAliases, toggleCollapsed]);
2464
+ }, [xyflowNodesBase, openFile, selected, focusNodeIds, openedNodeIds, brightNodeIds, previewNodeIds, externalHighlightNodeIds, spotlightAliases, aliasToComponent, issueFocusNodeIds, issueBadgeByAlias, regionIssueByNodeId, boundaryColors, proposedComponentAliases, workingComponentAliases, removedComponentAliases, toggleCollapsed]);
2414
2465
 
2415
2466
  const baseNodesKey = useMemo(() => nodes.map((n) => n.id).sort().join(','), [nodes]);
2416
2467
  const baseEdgesKey = useMemo(
@@ -2453,7 +2504,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
2453
2504
  };
2454
2505
  const inSet = (set: ReadonlySet<string> | null | undefined, e: Edge): boolean =>
2455
2506
  set != null && edgeMatches(set, e);
2456
- if (openedEdgeIds || focusEdgeIds || previewEdgeIds || issueFocusEdgeIds) {
2507
+ if (openedEdgeIds || focusEdgeIds || previewEdgeIds || externalHighlightEdgeIds || issueFocusEdgeIds) {
2457
2508
  return baseEdges.map((e) => {
2458
2509
  const ghost = ghostEdgeIds.has(e.id);
2459
2510
  const proposed = !ghost && proposedEdgeIds.has(e.id);
@@ -2463,7 +2514,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
2463
2514
  anyOpened: openedEdgeIds != null,
2464
2515
  anySelected: focusEdgeIds != null,
2465
2516
  });
2466
- const dimSource = previewEdgeIds ?? issueFocusEdgeIds;
2517
+ const dimSource = previewEdgeIds ?? externalHighlightEdgeIds ?? issueFocusEdgeIds;
2467
2518
  const dimmed = dimSource
2468
2519
  ? vis.hidden || !inSet(dimSource, e)
2469
2520
  : vis.dimmed || ghost;
@@ -2496,7 +2547,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
2496
2547
  hidden: !edgeInView(e),
2497
2548
  };
2498
2549
  });
2499
- }, [baseEdges, selectedEdgeId, openedEdgeIds, focusEdgeIds, previewEdgeIds, issueFocusEdgeIds, resolvedEdgeView, ghostEdgeIds, proposedEdgeIds]);
2550
+ }, [baseEdges, selectedEdgeId, openedEdgeIds, focusEdgeIds, previewEdgeIds, externalHighlightEdgeIds, issueFocusEdgeIds, resolvedEdgeView, ghostEdgeIds, proposedEdgeIds]);
2500
2551
 
2501
2552
  // Gated on layoutReady so the pre-reveal Pass 1 swap never flashes a count.
2502
2553
  const unroutedIds = useMemo(
@@ -3008,7 +3059,8 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
3008
3059
  setSelectedEdgeId(null);
3009
3060
  setHoveredTrailStep(null);
3010
3061
  onTrailStepHover?.(null);
3011
- }, [filesActive, clearTrailFocus, onTrailStepHover, sidebarTrail]);
3062
+ onTrailHover?.(null);
3063
+ }, [filesActive, clearTrailFocus, onTrailStepHover, onTrailHover, sidebarTrail]);
3012
3064
 
3013
3065
  // Host deep-link: opening the graph from a trail row selects that
3014
3066
  // flow — expand its steps and focus its edges.
@@ -3746,6 +3798,8 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
3746
3798
  focusedTrailId={sidebarTrail?.id ?? focusedTrailId}
3747
3799
  focusedStepIndex={!sidebarTrail || focusedTrailId === sidebarTrail.id ? focusedStepIndex : null}
3748
3800
  proposedTrailIds={proposedTrailIds}
3801
+ highlightedTrailIds={highlightedTrailIds}
3802
+ trailChanges={trailChanges}
3749
3803
  proposedStepKeys={proposedStepKeys}
3750
3804
  focusedVariationStepIndexes={panelFocusedVariationStepIndexes}
3751
3805
  stepNumberLabels={panelStepNumberLabels}
@@ -3760,15 +3814,18 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
3760
3814
  cancelPendingHoverLeave();
3761
3815
  setHoveredTrailStep({ trailId: tl.id, stepIndex: i });
3762
3816
  onTrailStepHover?.({ trailId: tl.id, stepIndex: i });
3817
+ onTrailHover?.(tl.id);
3763
3818
  }}
3764
3819
  onHoverFlow={(tl) => {
3765
3820
  cancelPendingHoverLeave();
3766
3821
  setHoveredTrailStep({ trailId: tl.id, stepIndex: null });
3767
3822
  onTrailStepHover?.(null);
3823
+ onTrailHover?.(tl.id);
3768
3824
  }}
3769
3825
  onLeaveStep={() => {
3770
3826
  scheduleHoverLeave(hoveredTrailStep);
3771
3827
  onTrailStepHover?.(null);
3828
+ onTrailHover?.(null);
3772
3829
  }}
3773
3830
  onReorder={onReorderTrails}
3774
3831
  componentByAlias={componentByAlias}
@@ -0,0 +1,90 @@
1
+ import type { CSSProperties } from 'react';
2
+ import { Minus, Plus, Route } from 'lucide-react';
3
+ import { useTheme } from '@principal-ade/industry-theme';
4
+
5
+ /**
6
+ * What a host says it does to a trail, deliberately coarse: the trail is new
7
+ * (`added`), gone (`removed`), or changed in some way (`changed`). Hosts use it
8
+ * to show a proposed or applied change in the Trails list.
9
+ */
10
+ export type TrailChange = 'added' | 'removed' | 'changed';
11
+
12
+ const CHANGE_LABEL: Record<TrailChange, string> = {
13
+ added: 'Added trail',
14
+ removed: 'Removed trail',
15
+ changed: 'Changed trail',
16
+ };
17
+
18
+ /**
19
+ * The trail icon. With a `change` it is drawn in that change's colour (green,
20
+ * red, yellow) with a small badge — + for added, − for removed, a plain dot for
21
+ * changed — so the meaning does not rest on colour alone. Without one it is
22
+ * exactly the plain icon.
23
+ */
24
+ export function TrailIcon({
25
+ change,
26
+ size = 14,
27
+ strokeWidth = 2,
28
+ color,
29
+ style,
30
+ }: {
31
+ change?: TrailChange;
32
+ size?: number;
33
+ strokeWidth?: number;
34
+ /** Colour of the plain icon; a change overrides it. */
35
+ color?: string;
36
+ style?: CSSProperties;
37
+ }) {
38
+ const { theme } = useTheme();
39
+ if (!change) {
40
+ return <Route size={size} strokeWidth={strokeWidth} aria-hidden style={{ ...style, color }} />;
41
+ }
42
+ const tone =
43
+ change === 'added'
44
+ ? (theme.colors.success ?? '#22c55e')
45
+ : change === 'removed'
46
+ ? (theme.colors.error ?? '#ef4444')
47
+ : (theme.colors.warning ?? '#eab308');
48
+ // The badge sits on the icon's corner, ringed in the panel colour to separate the two.
49
+ const ring = theme.colors.backgroundSecondary ?? theme.colors.background;
50
+ const badge = Math.max(8, Math.round(size * 0.55));
51
+ return (
52
+ <span
53
+ role="img"
54
+ aria-label={CHANGE_LABEL[change]}
55
+ style={{
56
+ position: 'relative',
57
+ display: 'inline-flex',
58
+ width: size,
59
+ height: size,
60
+ ...style,
61
+ color: tone,
62
+ }}
63
+ >
64
+ <Route size={size} strokeWidth={strokeWidth} aria-hidden />
65
+ <span
66
+ aria-hidden
67
+ style={{
68
+ position: 'absolute',
69
+ right: -badge / 3,
70
+ bottom: -badge / 3,
71
+ width: badge,
72
+ height: badge,
73
+ borderRadius: '50%',
74
+ background: tone,
75
+ color: ring,
76
+ display: 'flex',
77
+ alignItems: 'center',
78
+ justifyContent: 'center',
79
+ boxShadow: `0 0 0 1px ${ring}`,
80
+ }}
81
+ >
82
+ {change === 'added' ? (
83
+ <Plus size={badge - 2} strokeWidth={4} />
84
+ ) : change === 'removed' ? (
85
+ <Minus size={badge - 2} strokeWidth={4} />
86
+ ) : null}
87
+ </span>
88
+ </span>
89
+ );
90
+ }
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useState } from 'react';
2
2
  import type { CSSProperties, ReactNode } from 'react';
3
- import { ChevronRight, Route, X } from 'lucide-react';
3
+ import { ChevronRight, X } from 'lucide-react';
4
4
  import { useTheme } from '@principal-ade/industry-theme';
5
5
  import { HOST_PROPOSAL_COLOR, type SubsystemTrail } from './model';
6
6
  import {
@@ -8,6 +8,7 @@ import {
8
8
  type TrailComponentLabels,
9
9
  } from './trailStepDisplay';
10
10
  import { buildTrailStack } from './trailStack';
11
+ import { TrailIcon, type TrailChange } from './TrailIcon';
11
12
 
12
13
  /**
13
14
  * TrailStepsNav — the trails side panel as a two-step slide: a list of trails,
@@ -58,6 +59,8 @@ export interface TrailStepsNavProps {
58
59
  detailContent?: ReactNode;
59
60
  /** Host-local trails awaiting confirmation; their header icon uses proposal color. */
60
61
  proposedTrailIds?: Set<string>;
62
+ /** What the host says is happening to each trail, by id. Marks the trail's icon. */
63
+ trailChanges?: ReadonlyMap<string, TrailChange>;
61
64
  }
62
65
 
63
66
  const PANE: CSSProperties = {
@@ -86,6 +89,7 @@ export function TrailStepsNav({
86
89
  renderSteps,
87
90
  detailContent,
88
91
  proposedTrailIds,
92
+ trailChanges,
89
93
  }: TrailStepsNavProps) {
90
94
  const { theme } = useTheme();
91
95
  const muted = theme.colors.textMuted ?? theme.colors.textSecondary;
@@ -171,16 +175,12 @@ export function TrailStepsNav({
171
175
  transition: 'background 120ms ease',
172
176
  }}
173
177
  >
174
- <Route
178
+ <TrailIcon
179
+ change={trailChanges?.get(trail.id)}
175
180
  size={14}
176
181
  strokeWidth={2}
177
- aria-hidden
178
- style={{
179
- flexShrink: 0,
180
- marginTop: 3,
181
- color: focusedRow || hovered ? theme.colors.primary : muted,
182
- transition: 'color 120ms ease',
183
- }}
182
+ color={focusedRow || hovered ? theme.colors.primary : muted}
183
+ style={{ flexShrink: 0, marginTop: 3, transition: 'color 120ms ease' }}
184
184
  />
185
185
  <span
186
186
  style={{
@@ -236,19 +236,14 @@ export function TrailStepsNav({
236
236
  padding: '14px 12px',
237
237
  }}
238
238
  >
239
- <Route
239
+ <TrailIcon
240
+ change={displayedTrail ? trailChanges?.get(displayedTrail.id) : undefined}
240
241
  size={14}
241
242
  strokeWidth={2}
242
- aria-hidden
243
243
  // A proposed trail keeps the proposal colour here too, matching
244
244
  // its row icon in the list it came from.
245
- style={{
246
- flexShrink: 0,
247
- marginTop: 3,
248
- color: proposed
249
- ? HOST_PROPOSAL_COLOR
250
- : theme.colors.primary,
251
- }}
245
+ color={proposed ? HOST_PROPOSAL_COLOR : theme.colors.primary}
246
+ style={{ flexShrink: 0, marginTop: 3 }}
252
247
  />
253
248
  {/* The title is the back affordance too: clicking it goes back to
254
249
  the list, like the trailing close. */}
@@ -523,3 +523,86 @@ describe('TrailsPanel step emphasis', () => {
523
523
  expect(queryByTitle('Key step')).toBeNull();
524
524
  });
525
525
  });
526
+
527
+ describe('TrailsPanel host emphasis', () => {
528
+ /** Opacity of the row that contains `el`: the nearest ancestor that sets one. */
529
+ function rowOpacity(el: HTMLElement): string {
530
+ let node: HTMLElement | null = el;
531
+ while (node && node.style.opacity === '') node = node.parentElement;
532
+ return node?.style.opacity ?? '';
533
+ }
534
+
535
+ test('rows outside highlightedTrailIds recede; highlighted rows stay full', () => {
536
+ const { getByText } = renderPanel({
537
+ trails: [trails[0]!, usesTrail],
538
+ expandedTrails: new Set(),
539
+ highlightedTrailIds: new Set(['auth-flow']),
540
+ });
541
+ expect(rowOpacity(getByText('Auth flow'))).toBe('1');
542
+ expect(rowOpacity(getByText('Uses flow'))).toBe('0.35');
543
+ });
544
+
545
+ test('an empty or absent set highlights nothing, so no row recedes', () => {
546
+ for (const highlightedTrailIds of [new Set<string>(), undefined]) {
547
+ const { getByText, unmount } = renderPanel({
548
+ trails: [trails[0]!, usesTrail],
549
+ expandedTrails: new Set(),
550
+ highlightedTrailIds,
551
+ });
552
+ expect(rowOpacity(getByText('Auth flow'))).toBe('1');
553
+ expect(rowOpacity(getByText('Uses flow'))).toBe('1');
554
+ unmount();
555
+ }
556
+ });
557
+ });
558
+
559
+ describe('TrailsPanel trail changes', () => {
560
+ test('a trail with a change gets a labelled, coloured icon in the list; others keep the plain one', () => {
561
+ const { getAllByLabelText, queryAllByLabelText, getByText } = renderPanel({
562
+ trails: [trails[0]!, usesTrail],
563
+ expandedTrails: new Set(),
564
+ trailChanges: new Map([['auth-flow', 'added']]),
565
+ });
566
+ expect(getAllByLabelText('Added trail')).toHaveLength(1);
567
+ expect(queryAllByLabelText('Removed trail')).toHaveLength(0);
568
+ expect(queryAllByLabelText('Changed trail')).toHaveLength(0);
569
+ // The marked trail's icon is wrapped; the unmarked one is still the bare icon.
570
+ const marked = getByText('Auth flow').closest('button')!.firstElementChild as HTMLElement;
571
+ expect(marked.getAttribute('aria-label')).toBe('Added trail');
572
+ const plain = getByText('Uses flow').closest('button')!.firstElementChild as SVGElement;
573
+ expect(plain.tagName.toLowerCase()).toBe('svg');
574
+ });
575
+
576
+ test('each change has its own label and colour', () => {
577
+ const { getByLabelText } = renderPanel({
578
+ trails: [trails[0]!, usesTrail, { ...usesTrail, id: 'third', title: 'Third flow' }],
579
+ expandedTrails: new Set(),
580
+ trailChanges: new Map([
581
+ ['auth-flow', 'added'],
582
+ ['uses-flow', 'removed'],
583
+ ['third', 'changed'],
584
+ ]),
585
+ });
586
+ const colours = ['Added trail', 'Removed trail', 'Changed trail'].map(
587
+ (label) => getByLabelText(label).style.color,
588
+ );
589
+ expect(new Set(colours).size).toBe(3);
590
+ });
591
+
592
+ test('the selected trail header shows its change', () => {
593
+ const { getAllByLabelText } = renderPanel({
594
+ drilldown: true,
595
+ focusedTrailId: 'auth-flow',
596
+ trailChanges: new Map([['auth-flow', 'changed']]),
597
+ });
598
+ // One in the list pane (the slid-out list), one in the step pane's header.
599
+ expect(getAllByLabelText('Changed trail').length).toBeGreaterThanOrEqual(1);
600
+ });
601
+
602
+ test('no trailChanges, no marks', () => {
603
+ const { queryAllByLabelText } = renderPanel({ trails: [trails[0]!, usesTrail], expandedTrails: new Set() });
604
+ for (const label of ['Added trail', 'Removed trail', 'Changed trail']) {
605
+ expect(queryAllByLabelText(label)).toHaveLength(0);
606
+ }
607
+ });
608
+ });
@@ -13,7 +13,7 @@
13
13
  import { useCallback, useEffect, useRef, useState } from 'react';
14
14
  import type { DragEvent as ReactDragEvent, ReactNode } from 'react';
15
15
  import { useTheme } from '@principal-ade/industry-theme';
16
- import { Check, ChevronDown, Focus, GripVertical, Minimize2, Pause, Play, Route, Star } from 'lucide-react';
16
+ import { Check, ChevronDown, Focus, GripVertical, Minimize2, Pause, Play, Star } from 'lucide-react';
17
17
  import { IndustryMarkdownSlide } from 'themed-markdown';
18
18
  import {
19
19
  reorderTargetIndex,
@@ -31,6 +31,7 @@ import {
31
31
  } from './trailStepDisplay';
32
32
  import { buildTrailStack } from './trailStack';
33
33
  import { TrailStepsNav } from './TrailStepsNav';
34
+ import { TrailIcon, type TrailChange } from './TrailIcon';
34
35
 
35
36
  /** Pause (ms) between steps when a trail autoplays. */
36
37
  export const TRAIL_PLAY_PAUSE_MS = 2500;
@@ -95,6 +96,7 @@ function TrailFlow({
95
96
  componentByAlias,
96
97
  hideHeader = false,
97
98
  proposed = false,
99
+ change,
98
100
  proposedStepKeys,
99
101
  focusedVariationStepIndexes,
100
102
  stepNumberLabels,
@@ -141,6 +143,8 @@ function TrailFlow({
141
143
  hideHeader?: boolean;
142
144
  /** Host-local proposal: colour the flow icon without changing the title. */
143
145
  proposed?: boolean;
146
+ /** What the host says is happening to this trail; its icon shows it. */
147
+ change?: TrailChange;
144
148
  /** Host-local proposed steps, keyed by `emphasisKey(trailId, step)`. */
145
149
  proposedStepKeys?: Set<string>;
146
150
  /** Step indexes that belong to one focused variation group in this flow. */
@@ -347,19 +351,18 @@ function TrailFlow({
347
351
  cursor: 'pointer',
348
352
  }}
349
353
  >
350
- <Route
354
+ <TrailIcon
355
+ change={change}
351
356
  size={14}
352
357
  strokeWidth={2}
353
- aria-hidden
354
- style={{
355
- flexShrink: 0,
356
- marginTop: 3,
357
- color: proposed
358
+ style={{ flexShrink: 0, marginTop: 3 }}
359
+ color={
360
+ proposed
358
361
  ? proposalColor
359
362
  : headerHover || (!collapsed && wholeFlowActive)
360
363
  ? theme.colors.primary
361
- : muted,
362
- }}
364
+ : muted
365
+ }
363
366
  />
364
367
  <span
365
368
  style={{
@@ -791,6 +794,13 @@ export interface TrailsPanelProps {
791
794
  detailContent?: ReactNode;
792
795
  /** Host-local trails awaiting confirmation; their icons use proposal color. */
793
796
  proposedTrailIds?: Set<string>;
797
+ /**
798
+ * Host-driven emphasis: when set (and non-empty), rows for trails outside it
799
+ * recede. Rows are never hidden or reordered.
800
+ */
801
+ highlightedTrailIds?: ReadonlySet<string>;
802
+ /** What the host says is happening to each trail, by id. Marks the trail's icon. */
803
+ trailChanges?: ReadonlyMap<string, TrailChange>;
794
804
  /** Host-local steps awaiting confirmation, keyed by `emphasisKey`. */
795
805
  proposedStepKeys?: Set<string>;
796
806
  /** Step indexes that belong to one focused variation group, by trail id. */
@@ -828,6 +838,8 @@ export function TrailsPanel({
828
838
  drilldown = false,
829
839
  detailContent,
830
840
  proposedTrailIds,
841
+ highlightedTrailIds,
842
+ trailChanges,
831
843
  proposedStepKeys,
832
844
  focusedVariationStepIndexes,
833
845
  stepNumberLabels,
@@ -947,7 +959,11 @@ export function TrailsPanel({
947
959
  onDrop={reorderable ? handleDrop : undefined}
948
960
  style={{
949
961
  position: 'relative',
950
- opacity: isDragging ? 0.45 : 1,
962
+ opacity: isDragging
963
+ ? 0.45
964
+ : highlightedTrailIds && highlightedTrailIds.size > 0 && !highlightedTrailIds.has(tl.id)
965
+ ? 0.35
966
+ : 1,
951
967
  transition: 'opacity 120ms ease',
952
968
  }}
953
969
  >
@@ -1020,6 +1036,7 @@ export function TrailsPanel({
1020
1036
  stepEmphasis={stepEmphasis}
1021
1037
  onRemoveStepEmphasis={onRemoveStepEmphasis}
1022
1038
  proposed={proposedTrailIds?.has(tl.id) ?? false}
1039
+ change={trailChanges?.get(tl.id)}
1023
1040
  proposedStepKeys={proposedStepKeys}
1024
1041
  focusedVariationStepIndexes={focusedVariationStepIndexes?.get(tl.id)}
1025
1042
  stepNumberLabels={stepNumberLabels}
@@ -1049,6 +1066,7 @@ export function TrailsPanel({
1049
1066
  listContent={list}
1050
1067
  detailContent={detailContent}
1051
1068
  proposedTrailIds={proposedTrailIds}
1069
+ trailChanges={trailChanges}
1052
1070
  renderSteps={(trail) => (
1053
1071
  <TrailFlow
1054
1072
  key={trail.id}