@principal-ai/subsystems-react 0.56.38 → 0.56.40
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.
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts +12 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +2 -2
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/TrailIcon.d.ts +36 -0
- package/dist/subsystem/TrailIcon.d.ts.map +1 -0
- package/dist/subsystem/TrailIcon.js +61 -0
- package/dist/subsystem/TrailIcon.js.map +1 -0
- package/dist/subsystem/TrailStepsNav.d.ts +4 -1
- package/dist/subsystem/TrailStepsNav.d.ts.map +1 -1
- package/dist/subsystem/TrailStepsNav.js +6 -16
- package/dist/subsystem/TrailStepsNav.js.map +1 -1
- package/dist/subsystem/TrailsPanel.d.ts +6 -1
- package/dist/subsystem/TrailsPanel.d.ts.map +1 -1
- package/dist/subsystem/TrailsPanel.js +35 -27
- package/dist/subsystem/TrailsPanel.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/subsystem/SubsystemComponentGraph.tsx +15 -1
- package/src/subsystem/TrailIcon.tsx +116 -0
- package/src/subsystem/TrailStepsNav.tsx +13 -18
- package/src/subsystem/TrailsPanel.test.tsx +102 -0
- package/src/subsystem/TrailsPanel.tsx +56 -19
|
@@ -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,
|
|
@@ -459,6 +460,17 @@ export interface SubsystemComponentGraphProps {
|
|
|
459
460
|
* the graph's own trail hover wins while it lasts. Empty or absent = none.
|
|
460
461
|
*/
|
|
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>;
|
|
469
|
+
/**
|
|
470
|
+
* The same, per step: trail id → step index → `added` / `removed` / `changed`. The
|
|
471
|
+
* step's number is drawn in that colour with the same badge. Steps not listed are unmarked.
|
|
472
|
+
*/
|
|
473
|
+
stepChanges?: ReadonlyMap<string, ReadonlyMap<number, TrailChange>>;
|
|
462
474
|
/**
|
|
463
475
|
* Called with the next trail order after a drag in the sidebar's
|
|
464
476
|
* flows panel. When set, each row grows a drag grip and a drop emits the
|
|
@@ -876,7 +888,7 @@ interface InnerProps extends SubsystemComponentGraphProps {
|
|
|
876
888
|
onSidebarTrailChange: (trailId: string | null) => void;
|
|
877
889
|
}
|
|
878
890
|
|
|
879
|
-
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, 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) {
|
|
891
|
+
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, stepChanges, 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) {
|
|
880
892
|
const { theme } = useTheme();
|
|
881
893
|
const { fitView, fitBounds, setViewport } = useReactFlow();
|
|
882
894
|
const flowWidth = useStore((state) => state.width);
|
|
@@ -3792,6 +3804,8 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
3792
3804
|
focusedStepIndex={!sidebarTrail || focusedTrailId === sidebarTrail.id ? focusedStepIndex : null}
|
|
3793
3805
|
proposedTrailIds={proposedTrailIds}
|
|
3794
3806
|
highlightedTrailIds={highlightedTrailIds}
|
|
3807
|
+
trailChanges={trailChanges}
|
|
3808
|
+
stepChanges={stepChanges}
|
|
3795
3809
|
proposedStepKeys={proposedStepKeys}
|
|
3796
3810
|
focusedVariationStepIndexes={panelFocusedVariationStepIndexes}
|
|
3797
3811
|
stepNumberLabels={panelStepNumberLabels}
|
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
type Theme = ReturnType<typeof useTheme>['theme'];
|
|
19
|
+
|
|
20
|
+
/** The colour for a change: green added, red removed, yellow changed. */
|
|
21
|
+
export function trailChangeColor(theme: Theme, change: TrailChange): string {
|
|
22
|
+
return change === 'added'
|
|
23
|
+
? (theme.colors.success ?? '#22c55e')
|
|
24
|
+
: change === 'removed'
|
|
25
|
+
? (theme.colors.error ?? '#ef4444')
|
|
26
|
+
: (theme.colors.warning ?? '#eab308');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The small corner badge for a change — + added, − removed, a plain dot changed —
|
|
31
|
+
* so the meaning does not rest on colour alone. Position it over a relatively
|
|
32
|
+
* positioned parent of `size`; `ring` is the surface colour it sits on.
|
|
33
|
+
*/
|
|
34
|
+
export function ChangeBadge({
|
|
35
|
+
change,
|
|
36
|
+
size,
|
|
37
|
+
tone,
|
|
38
|
+
ring,
|
|
39
|
+
}: {
|
|
40
|
+
change: TrailChange;
|
|
41
|
+
size: number;
|
|
42
|
+
tone: string;
|
|
43
|
+
ring: string;
|
|
44
|
+
}) {
|
|
45
|
+
const badge = Math.max(8, Math.round(size * 0.55));
|
|
46
|
+
return (
|
|
47
|
+
<span
|
|
48
|
+
aria-hidden
|
|
49
|
+
style={{
|
|
50
|
+
position: 'absolute',
|
|
51
|
+
right: -badge / 3,
|
|
52
|
+
bottom: -badge / 3,
|
|
53
|
+
width: badge,
|
|
54
|
+
height: badge,
|
|
55
|
+
borderRadius: '50%',
|
|
56
|
+
background: tone,
|
|
57
|
+
color: ring,
|
|
58
|
+
display: 'flex',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
justifyContent: 'center',
|
|
61
|
+
boxShadow: `0 0 0 1px ${ring}`,
|
|
62
|
+
pointerEvents: 'none',
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
{change === 'added' ? (
|
|
66
|
+
<Plus size={badge - 2} strokeWidth={4} />
|
|
67
|
+
) : change === 'removed' ? (
|
|
68
|
+
<Minus size={badge - 2} strokeWidth={4} />
|
|
69
|
+
) : null}
|
|
70
|
+
</span>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The trail icon. With a `change` it is drawn in that change's colour with a
|
|
76
|
+
* corner badge. Without one it is exactly the plain icon.
|
|
77
|
+
*/
|
|
78
|
+
export function TrailIcon({
|
|
79
|
+
change,
|
|
80
|
+
size = 14,
|
|
81
|
+
strokeWidth = 2,
|
|
82
|
+
color,
|
|
83
|
+
style,
|
|
84
|
+
}: {
|
|
85
|
+
change?: TrailChange;
|
|
86
|
+
size?: number;
|
|
87
|
+
strokeWidth?: number;
|
|
88
|
+
/** Colour of the plain icon; a change overrides it. */
|
|
89
|
+
color?: string;
|
|
90
|
+
style?: CSSProperties;
|
|
91
|
+
}) {
|
|
92
|
+
const { theme } = useTheme();
|
|
93
|
+
if (!change) {
|
|
94
|
+
return <Route size={size} strokeWidth={strokeWidth} aria-hidden style={{ ...style, color }} />;
|
|
95
|
+
}
|
|
96
|
+
const tone = trailChangeColor(theme, change);
|
|
97
|
+
// The badge sits on the icon's corner, ringed in the panel colour to separate the two.
|
|
98
|
+
const ring = theme.colors.backgroundSecondary ?? theme.colors.background;
|
|
99
|
+
return (
|
|
100
|
+
<span
|
|
101
|
+
role="img"
|
|
102
|
+
aria-label={CHANGE_LABEL[change]}
|
|
103
|
+
style={{
|
|
104
|
+
position: 'relative',
|
|
105
|
+
display: 'inline-flex',
|
|
106
|
+
width: size,
|
|
107
|
+
height: size,
|
|
108
|
+
...style,
|
|
109
|
+
color: tone,
|
|
110
|
+
}}
|
|
111
|
+
>
|
|
112
|
+
<Route size={size} strokeWidth={strokeWidth} aria-hidden />
|
|
113
|
+
<ChangeBadge change={change} size={size} tone={tone} ring={ring} />
|
|
114
|
+
</span>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import type { CSSProperties, ReactNode } from 'react';
|
|
3
|
-
import { ChevronRight,
|
|
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
|
-
<
|
|
178
|
+
<TrailIcon
|
|
179
|
+
change={trailChanges?.get(trail.id)}
|
|
175
180
|
size={14}
|
|
176
181
|
strokeWidth={2}
|
|
177
|
-
|
|
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
|
-
<
|
|
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
|
-
|
|
246
|
-
|
|
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. */}
|
|
@@ -555,3 +555,105 @@ describe('TrailsPanel host emphasis', () => {
|
|
|
555
555
|
}
|
|
556
556
|
});
|
|
557
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
|
+
});
|
|
609
|
+
|
|
610
|
+
describe('TrailsPanel step changes', () => {
|
|
611
|
+
const step = trails[0]!.steps[0]!;
|
|
612
|
+
const three: SubsystemTrail = {
|
|
613
|
+
id: 'three',
|
|
614
|
+
title: 'Three steps',
|
|
615
|
+
steps: [step, { ...step, symbol: 'second' }, { ...step, symbol: 'third' }],
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
test('a marked step shows its change on the number; unmarked steps are untouched', () => {
|
|
619
|
+
const { getByTitle, queryByTitle, getAllByText } = renderPanel({
|
|
620
|
+
trails: [three],
|
|
621
|
+
expandedTrails: new Set(['three']),
|
|
622
|
+
stepChanges: new Map([['three', new Map([[1, 'removed' as const]])]]),
|
|
623
|
+
});
|
|
624
|
+
const mark = getByTitle('Removed step');
|
|
625
|
+
expect(mark.textContent).toContain('2'); // still the step's number
|
|
626
|
+
expect(queryByTitle('Added step')).toBeNull();
|
|
627
|
+
expect(queryByTitle('Changed step')).toBeNull();
|
|
628
|
+
// The other two numbers are plain text with no title.
|
|
629
|
+
expect(getAllByText('1')[0]!.getAttribute('title')).toBeNull();
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
test('added, removed and changed steps get three different colours', () => {
|
|
633
|
+
const { getByTitle } = renderPanel({
|
|
634
|
+
trails: [three],
|
|
635
|
+
expandedTrails: new Set(['three']),
|
|
636
|
+
stepChanges: new Map([
|
|
637
|
+
[
|
|
638
|
+
'three',
|
|
639
|
+
new Map([
|
|
640
|
+
[0, 'added' as const],
|
|
641
|
+
[1, 'removed' as const],
|
|
642
|
+
[2, 'changed' as const],
|
|
643
|
+
]),
|
|
644
|
+
],
|
|
645
|
+
]),
|
|
646
|
+
});
|
|
647
|
+
const colours = ['Added step', 'Removed step', 'Changed step'].map((t) => getByTitle(t).style.color);
|
|
648
|
+
expect(new Set(colours).size).toBe(3);
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
test("only the named trail's steps are marked", () => {
|
|
652
|
+
const { queryByTitle } = renderPanel({
|
|
653
|
+
trails: [trails[0]!],
|
|
654
|
+
expandedTrails: new Set(['auth-flow']),
|
|
655
|
+
stepChanges: new Map([['some-other-trail', new Map([[0, 'added' as const]])]]),
|
|
656
|
+
});
|
|
657
|
+
expect(queryByTitle('Added step')).toBeNull();
|
|
658
|
+
});
|
|
659
|
+
});
|
|
@@ -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,
|
|
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 { ChangeBadge, TrailIcon, trailChangeColor, 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;
|
|
@@ -54,6 +55,13 @@ export interface TrailsStepChange {
|
|
|
54
55
|
previous: SubsystemTrailStep;
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
/** Tooltip for a step the host marks as changed. */
|
|
59
|
+
const STEP_CHANGE_LABEL: Record<TrailChange, string> = {
|
|
60
|
+
added: 'Added step',
|
|
61
|
+
removed: 'Removed step',
|
|
62
|
+
changed: 'Changed step',
|
|
63
|
+
};
|
|
64
|
+
|
|
57
65
|
/** How long a step's number shows its "copied" checkmark (ms). */
|
|
58
66
|
export const STEP_COPY_FEEDBACK_MS = 2000;
|
|
59
67
|
|
|
@@ -95,6 +103,8 @@ function TrailFlow({
|
|
|
95
103
|
componentByAlias,
|
|
96
104
|
hideHeader = false,
|
|
97
105
|
proposed = false,
|
|
106
|
+
change,
|
|
107
|
+
stepChanges,
|
|
98
108
|
proposedStepKeys,
|
|
99
109
|
focusedVariationStepIndexes,
|
|
100
110
|
stepNumberLabels,
|
|
@@ -141,6 +151,10 @@ function TrailFlow({
|
|
|
141
151
|
hideHeader?: boolean;
|
|
142
152
|
/** Host-local proposal: colour the flow icon without changing the title. */
|
|
143
153
|
proposed?: boolean;
|
|
154
|
+
/** What the host says is happening to this trail; its icon shows it. */
|
|
155
|
+
change?: TrailChange;
|
|
156
|
+
/** What the host says is happening to individual steps, by index; the step's number shows it. */
|
|
157
|
+
stepChanges?: ReadonlyMap<number, TrailChange>;
|
|
144
158
|
/** Host-local proposed steps, keyed by `emphasisKey(trailId, step)`. */
|
|
145
159
|
proposedStepKeys?: Set<string>;
|
|
146
160
|
/** Step indexes that belong to one focused variation group in this flow. */
|
|
@@ -347,19 +361,18 @@ function TrailFlow({
|
|
|
347
361
|
cursor: 'pointer',
|
|
348
362
|
}}
|
|
349
363
|
>
|
|
350
|
-
<
|
|
364
|
+
<TrailIcon
|
|
365
|
+
change={change}
|
|
351
366
|
size={14}
|
|
352
367
|
strokeWidth={2}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
marginTop: 3,
|
|
357
|
-
color: proposed
|
|
368
|
+
style={{ flexShrink: 0, marginTop: 3 }}
|
|
369
|
+
color={
|
|
370
|
+
proposed
|
|
358
371
|
? proposalColor
|
|
359
372
|
: headerHover || (!collapsed && wholeFlowActive)
|
|
360
373
|
? theme.colors.primary
|
|
361
|
-
: muted
|
|
362
|
-
}
|
|
374
|
+
: muted
|
|
375
|
+
}
|
|
363
376
|
/>
|
|
364
377
|
<span
|
|
365
378
|
style={{
|
|
@@ -547,6 +560,8 @@ function TrailFlow({
|
|
|
547
560
|
const record = stepEmphasis?.get(stepKey);
|
|
548
561
|
const stepProposed = proposed || (proposedStepKeys?.has(stepKey) ?? false);
|
|
549
562
|
const stepNumber = stepNumberLabels?.get(stepKey) ?? String(i + 1);
|
|
563
|
+
const stepChangeMark = stepChanges?.get(i);
|
|
564
|
+
const stepTone = stepChangeMark ? trailChangeColor(theme, stepChangeMark) : null;
|
|
550
565
|
const display = trailStepDisplay(step, componentByAlias);
|
|
551
566
|
// The original step keeps its row after acceptance; only its
|
|
552
567
|
// annotation is greyed. Its `2a` variation stays beside it.
|
|
@@ -613,26 +628,38 @@ function TrailFlow({
|
|
|
613
628
|
<span
|
|
614
629
|
role={copied ? 'status' : undefined}
|
|
615
630
|
aria-label={copied ? 'Copied' : undefined}
|
|
631
|
+
title={stepChangeMark ? STEP_CHANGE_LABEL[stepChangeMark] : undefined}
|
|
616
632
|
style={{
|
|
633
|
+
position: 'relative',
|
|
617
634
|
flexShrink: 0,
|
|
618
635
|
width: 14,
|
|
619
636
|
textAlign: 'center',
|
|
620
637
|
paddingTop: 1,
|
|
621
638
|
fontSize: theme.fontSizes[0],
|
|
622
639
|
fontFamily: theme.fonts.monospace,
|
|
623
|
-
fontWeight: record ? 700 : undefined,
|
|
624
|
-
color:
|
|
625
|
-
?
|
|
626
|
-
:
|
|
627
|
-
?
|
|
628
|
-
:
|
|
629
|
-
?
|
|
630
|
-
:
|
|
631
|
-
?
|
|
632
|
-
:
|
|
640
|
+
fontWeight: record || stepTone ? 700 : undefined,
|
|
641
|
+
color: copied
|
|
642
|
+
? theme.colors.primary
|
|
643
|
+
: stepTone
|
|
644
|
+
? stepTone
|
|
645
|
+
: stepProposed
|
|
646
|
+
? proposalColor
|
|
647
|
+
: record
|
|
648
|
+
? EMPHASIS_COLOR
|
|
649
|
+
: stepActive
|
|
650
|
+
? theme.colors.text
|
|
651
|
+
: muted,
|
|
633
652
|
}}
|
|
634
653
|
>
|
|
635
654
|
{copied ? <Check size={12} strokeWidth={2} aria-hidden /> : stepNumber}
|
|
655
|
+
{stepChangeMark && stepTone && !copied && (
|
|
656
|
+
<ChangeBadge
|
|
657
|
+
change={stepChangeMark}
|
|
658
|
+
size={14}
|
|
659
|
+
tone={stepTone}
|
|
660
|
+
ring={theme.colors.backgroundSecondary ?? theme.colors.background}
|
|
661
|
+
/>
|
|
662
|
+
)}
|
|
636
663
|
</span>
|
|
637
664
|
<span
|
|
638
665
|
style={{
|
|
@@ -796,6 +823,10 @@ export interface TrailsPanelProps {
|
|
|
796
823
|
* recede. Rows are never hidden or reordered.
|
|
797
824
|
*/
|
|
798
825
|
highlightedTrailIds?: ReadonlySet<string>;
|
|
826
|
+
/** What the host says is happening to each trail, by id. Marks the trail's icon. */
|
|
827
|
+
trailChanges?: ReadonlyMap<string, TrailChange>;
|
|
828
|
+
/** What the host says is happening to individual steps: trail id → step index → change. */
|
|
829
|
+
stepChanges?: ReadonlyMap<string, ReadonlyMap<number, TrailChange>>;
|
|
799
830
|
/** Host-local steps awaiting confirmation, keyed by `emphasisKey`. */
|
|
800
831
|
proposedStepKeys?: Set<string>;
|
|
801
832
|
/** Step indexes that belong to one focused variation group, by trail id. */
|
|
@@ -834,6 +865,8 @@ export function TrailsPanel({
|
|
|
834
865
|
detailContent,
|
|
835
866
|
proposedTrailIds,
|
|
836
867
|
highlightedTrailIds,
|
|
868
|
+
trailChanges,
|
|
869
|
+
stepChanges,
|
|
837
870
|
proposedStepKeys,
|
|
838
871
|
focusedVariationStepIndexes,
|
|
839
872
|
stepNumberLabels,
|
|
@@ -1030,6 +1063,8 @@ export function TrailsPanel({
|
|
|
1030
1063
|
stepEmphasis={stepEmphasis}
|
|
1031
1064
|
onRemoveStepEmphasis={onRemoveStepEmphasis}
|
|
1032
1065
|
proposed={proposedTrailIds?.has(tl.id) ?? false}
|
|
1066
|
+
change={trailChanges?.get(tl.id)}
|
|
1067
|
+
stepChanges={stepChanges?.get(tl.id)}
|
|
1033
1068
|
proposedStepKeys={proposedStepKeys}
|
|
1034
1069
|
focusedVariationStepIndexes={focusedVariationStepIndexes?.get(tl.id)}
|
|
1035
1070
|
stepNumberLabels={stepNumberLabels}
|
|
@@ -1059,6 +1094,7 @@ export function TrailsPanel({
|
|
|
1059
1094
|
listContent={list}
|
|
1060
1095
|
detailContent={detailContent}
|
|
1061
1096
|
proposedTrailIds={proposedTrailIds}
|
|
1097
|
+
trailChanges={trailChanges}
|
|
1062
1098
|
renderSteps={(trail) => (
|
|
1063
1099
|
<TrailFlow
|
|
1064
1100
|
key={trail.id}
|
|
@@ -1084,6 +1120,7 @@ export function TrailsPanel({
|
|
|
1084
1120
|
stepEmphasis={stepEmphasis}
|
|
1085
1121
|
onRemoveStepEmphasis={onRemoveStepEmphasis}
|
|
1086
1122
|
proposed={proposedTrailIds?.has(trail.id) ?? false}
|
|
1123
|
+
stepChanges={stepChanges?.get(trail.id)}
|
|
1087
1124
|
proposedStepKeys={proposedStepKeys}
|
|
1088
1125
|
focusedVariationStepIndexes={focusedVariationStepIndexes?.get(trail.id)}
|
|
1089
1126
|
stepNumberLabels={stepNumberLabels}
|