@principal-ai/subsystems-react 0.56.35 → 0.56.36
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/subsystem/SubsystemComponentGraph.d.ts +50 -8
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +291 -50
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/TrailStepsNav.d.ts +1 -1
- package/dist/subsystem/TrailStepsNav.d.ts.map +1 -1
- package/dist/subsystem/TrailStepsNav.js +2 -1
- package/dist/subsystem/TrailStepsNav.js.map +1 -1
- package/dist/subsystem/TrailsPanel.d.ts +5 -5
- package/dist/subsystem/TrailsPanel.d.ts.map +1 -1
- package/dist/subsystem/TrailsPanel.js +23 -43
- package/dist/subsystem/TrailsPanel.js.map +1 -1
- package/dist/subsystem/model.d.ts +21 -6
- package/dist/subsystem/model.d.ts.map +1 -1
- package/dist/subsystem/model.js +48 -45
- package/dist/subsystem/model.js.map +1 -1
- package/dist/subsystem/nodeIconography.d.ts +25 -0
- package/dist/subsystem/nodeIconography.d.ts.map +1 -0
- package/dist/subsystem/nodeIconography.js +55 -0
- package/dist/subsystem/nodeIconography.js.map +1 -0
- package/dist/subsystem/nodes.d.ts +4 -3
- package/dist/subsystem/nodes.d.ts.map +1 -1
- package/dist/subsystem/nodes.js +125 -211
- package/dist/subsystem/nodes.js.map +1 -1
- package/dist/subsystem/stepEmphasis.d.ts +5 -0
- package/dist/subsystem/stepEmphasis.d.ts.map +1 -1
- package/dist/subsystem/stepEmphasis.js +7 -0
- package/dist/subsystem/stepEmphasis.js.map +1 -1
- package/package.json +1 -1
- package/src/stories/Canvases/Subsystem/AgentDrivenWalkthrough.stories.tsx +229 -157
- package/src/stories/Canvases/Subsystem/Deprecated.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/NodeAnatomy.stories.tsx +17 -21
- package/src/stories/Canvases/Subsystem/NodeIconography.stories.tsx +791 -21
- package/src/stories/Canvases/Subsystem/Spotlights.stories.tsx +1 -1
- package/src/subsystem/SubsystemComponentGraph.tsx +359 -62
- package/src/subsystem/TrailStepsNav.tsx +2 -2
- package/src/subsystem/TrailsPanel.tsx +35 -89
- package/src/subsystem/model.test.ts +17 -13
- package/src/subsystem/model.ts +60 -48
- package/src/subsystem/nodeIconography.ts +88 -0
- package/src/subsystem/nodes.component.test.tsx +177 -0
- package/src/subsystem/nodes.tsx +225 -268
- package/src/subsystem/stepEmphasis.ts +8 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stepEmphasis.js","sourceRoot":"","sources":["../../src/subsystem/stepEmphasis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AA2CH,kFAAkF;AAClF,SAAS,WAAW,CAAC,IAAwF;IAC3G,OAAO;QACL,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,EAAE;QACP,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,IAAI,EAAE,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;QAC/D,IAAI,CAAC,IAAI,EAAE,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QAC3D,IAAI,CAAC,IAAI,EAAE,WAAW,IAAI,EAAE;KAC7B,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,KAAK,CAAC,KAAa;IAC1B,IAAI,IAAI,GAAG,UAAU,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACrC,IAAI,IAAI,KAAK,CAAC,UAAU,CA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8
|
} from "@principal-ade/industry-theme";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
import {
|
|
10
|
+
SubsystemComponentGraph,
|
|
11
|
+
type SubsystemTrailStepHistory,
|
|
12
|
+
} from "../../../subsystem/SubsystemComponentGraph";
|
|
13
|
+
import {
|
|
14
|
+
HOST_PROPOSAL_COLOR,
|
|
15
|
+
type SubsystemComponent,
|
|
16
|
+
type SubsystemTrail,
|
|
17
|
+
type SubsystemTrailStep,
|
|
14
18
|
} from "../../../subsystem/model";
|
|
15
19
|
import {
|
|
16
20
|
buildStepEmphasisMap,
|
|
17
21
|
emphasisKey,
|
|
18
22
|
stepClaimKey,
|
|
23
|
+
variationStepNumber,
|
|
19
24
|
type StepEmphasisRecord,
|
|
20
25
|
} from "../../../subsystem/stepEmphasis";
|
|
21
26
|
|
|
@@ -330,6 +335,27 @@ type DriveEvent =
|
|
|
330
335
|
rationale: string;
|
|
331
336
|
};
|
|
332
337
|
|
|
338
|
+
/**
|
|
339
|
+
* A proposal is a variation of the step currently under discussion, not the
|
|
340
|
+
* next sequential guide step. `2 · Where it stops` therefore yields `2a`.
|
|
341
|
+
*/
|
|
342
|
+
function stepNumberFromTitle(title: string): number | null {
|
|
343
|
+
const match = title.match(/^\s*(\d+)[a-z]?\s*(?:·|-|:|$)/i);
|
|
344
|
+
return match ? Number(match[1]) : null;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function proposalStepTitle(
|
|
348
|
+
walkthrough: { steps: readonly GuideStep[] } | null | undefined,
|
|
349
|
+
label: string,
|
|
350
|
+
): string {
|
|
351
|
+
const steps = walkthrough?.steps ?? [];
|
|
352
|
+
// The last authored guide step is the one the proposal responds to; autoplay
|
|
353
|
+
// may not have advanced the host's active step when the proposal lands.
|
|
354
|
+
const target = steps[steps.length - 1];
|
|
355
|
+
const base = target ? stepNumberFromTitle(target.title) : null;
|
|
356
|
+
return `${variationStepNumber(base ?? 1)} · ${label}`;
|
|
357
|
+
}
|
|
358
|
+
|
|
333
359
|
const trailProposalEvents: DriveEvent[] = [
|
|
334
360
|
{
|
|
335
361
|
kind: "prompt",
|
|
@@ -719,8 +745,8 @@ type DriveState = {
|
|
|
719
745
|
lastDecision: "accepted" | "rejected" | null;
|
|
720
746
|
/** Host-local comparison for an accepted step change. */
|
|
721
747
|
stepChange: StepChange | null;
|
|
722
|
-
/**
|
|
723
|
-
|
|
748
|
+
/** Unchanged steps linked to accepted changes, for shared layout + focus. */
|
|
749
|
+
stepHistory: SubsystemTrailStepHistory[];
|
|
724
750
|
};
|
|
725
751
|
|
|
726
752
|
const initialState = (): DriveState => ({
|
|
@@ -738,9 +764,28 @@ const initialState = (): DriveState => ({
|
|
|
738
764
|
agentWorkingOn: null,
|
|
739
765
|
lastDecision: null,
|
|
740
766
|
stepChange: null,
|
|
741
|
-
|
|
767
|
+
stepHistory: [],
|
|
742
768
|
});
|
|
743
769
|
|
|
770
|
+
// While staged, the step proposal guide step points at the inserted variation.
|
|
771
|
+
// Once resolved the variation is gone, so point the same guide step back at the
|
|
772
|
+
// real trail step — otherwise host focus would aim past the end of the trail.
|
|
773
|
+
function retargetResolvedStepProposal(state: DriveState): DriveState {
|
|
774
|
+
const pendingStep = state.pendingStep;
|
|
775
|
+
if (!pendingStep || !state.walkthrough) return state;
|
|
776
|
+
return {
|
|
777
|
+
...state,
|
|
778
|
+
walkthrough: {
|
|
779
|
+
...state.walkthrough,
|
|
780
|
+
steps: state.walkthrough.steps.map((step) =>
|
|
781
|
+
step.proposal === "step"
|
|
782
|
+
? { ...step, stepIndex: pendingStep.stepIndex }
|
|
783
|
+
: step,
|
|
784
|
+
),
|
|
785
|
+
},
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
|
|
744
789
|
// The agent, not a button, resolves a staged proposal. Accepted proposals move
|
|
745
790
|
// from host-local pending state into the visible graph; declined ones leave the
|
|
746
791
|
// visible model unchanged.
|
|
@@ -750,11 +795,26 @@ function resolveProposal(
|
|
|
750
795
|
): DriveState {
|
|
751
796
|
if (state.lastDecision) return state;
|
|
752
797
|
if (decision === "rejected") {
|
|
753
|
-
return { ...state, lastDecision: "rejected" };
|
|
798
|
+
return { ...retargetResolvedStepProposal(state), lastDecision: "rejected" };
|
|
754
799
|
}
|
|
755
800
|
|
|
756
801
|
const pendingRemoval = state.pendingRemoval;
|
|
757
802
|
if (pendingRemoval) {
|
|
803
|
+
const removedSteps: SubsystemTrailStepHistory[] = state.trails.flatMap(
|
|
804
|
+
(trail) =>
|
|
805
|
+
trail.steps.flatMap((step, stepIndex) =>
|
|
806
|
+
step.from === pendingRemoval || step.to === pendingRemoval
|
|
807
|
+
? [
|
|
808
|
+
{
|
|
809
|
+
trailId: trail.id,
|
|
810
|
+
stepIndex,
|
|
811
|
+
previous: step,
|
|
812
|
+
kind: "removed" as const,
|
|
813
|
+
},
|
|
814
|
+
]
|
|
815
|
+
: [],
|
|
816
|
+
),
|
|
817
|
+
);
|
|
758
818
|
return {
|
|
759
819
|
...state,
|
|
760
820
|
removedComponentAliases: new Set([
|
|
@@ -768,6 +828,7 @@ function resolveProposal(
|
|
|
768
828
|
),
|
|
769
829
|
})),
|
|
770
830
|
lastDecision: "accepted",
|
|
831
|
+
stepHistory: [...state.stepHistory, ...removedSteps],
|
|
771
832
|
};
|
|
772
833
|
}
|
|
773
834
|
|
|
@@ -804,15 +865,19 @@ function resolveProposal(
|
|
|
804
865
|
const previous = state.trails.find(
|
|
805
866
|
(trail) => trail.id === pendingStep.trailId,
|
|
806
867
|
)?.steps[pendingStep.stepIndex];
|
|
807
|
-
|
|
868
|
+
const next: DriveState = {
|
|
808
869
|
...state,
|
|
870
|
+
// Keep the original step in place and leave its variation after it: the
|
|
871
|
+
// accepted row never moves, only its proposal colour is dropped.
|
|
809
872
|
trails: state.trails.map((trail) =>
|
|
810
873
|
trail.id === pendingStep.trailId
|
|
811
874
|
? {
|
|
812
875
|
...trail,
|
|
813
|
-
steps:
|
|
814
|
-
|
|
815
|
-
|
|
876
|
+
steps: [
|
|
877
|
+
...trail.steps.slice(0, pendingStep.stepIndex + 1),
|
|
878
|
+
pendingStep.step,
|
|
879
|
+
...trail.steps.slice(pendingStep.stepIndex + 1),
|
|
880
|
+
],
|
|
816
881
|
}
|
|
817
882
|
: trail,
|
|
818
883
|
),
|
|
@@ -824,8 +889,18 @@ function resolveProposal(
|
|
|
824
889
|
previous,
|
|
825
890
|
}
|
|
826
891
|
: null,
|
|
827
|
-
|
|
892
|
+
stepHistory: previous
|
|
893
|
+
? [
|
|
894
|
+
{
|
|
895
|
+
trailId: pendingStep.trailId,
|
|
896
|
+
stepIndex: pendingStep.stepIndex,
|
|
897
|
+
previous,
|
|
898
|
+
kind: "changed",
|
|
899
|
+
},
|
|
900
|
+
]
|
|
901
|
+
: [],
|
|
828
902
|
};
|
|
903
|
+
return retargetResolvedStepProposal(next);
|
|
829
904
|
}
|
|
830
905
|
|
|
831
906
|
function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
@@ -868,10 +943,9 @@ function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
|
868
943
|
case "propose-trail": {
|
|
869
944
|
// Append the proposal to the same guide, but keep the user's current
|
|
870
945
|
// step. The header advertises the new step so they can opt into it.
|
|
871
|
-
const stepNo = (state.walkthrough?.steps.length ?? 5) + 1;
|
|
872
946
|
const proposalStep: GuideStep = {
|
|
873
947
|
id: "gs-propose-refund",
|
|
874
|
-
title:
|
|
948
|
+
title: proposalStepTitle(state.walkthrough, "Confirm refund trail"),
|
|
875
949
|
trailId: event.trail.id,
|
|
876
950
|
stepIndex: 0,
|
|
877
951
|
showFile: false,
|
|
@@ -891,14 +965,14 @@ function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
|
891
965
|
};
|
|
892
966
|
}
|
|
893
967
|
case "propose-step": {
|
|
894
|
-
//
|
|
895
|
-
//
|
|
896
|
-
|
|
968
|
+
// Focus the staged replacement, not the step it replaces. The graph's
|
|
969
|
+
// before/after links keep the existing step framed beside it, and the
|
|
970
|
+
// different index avoids re-triggering the previous step's focus toggle.
|
|
897
971
|
const proposalStep: GuideStep = {
|
|
898
972
|
id: "sp-propose-refund",
|
|
899
|
-
title:
|
|
973
|
+
title: proposalStepTitle(state.walkthrough, "Confirm refund step"),
|
|
900
974
|
trailId: event.trailId,
|
|
901
|
-
stepIndex: event.stepIndex,
|
|
975
|
+
stepIndex: event.stepIndex + 1,
|
|
902
976
|
showFile: false,
|
|
903
977
|
proposal: "step",
|
|
904
978
|
body: event.rationale,
|
|
@@ -911,7 +985,7 @@ function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
|
911
985
|
step: event.step,
|
|
912
986
|
},
|
|
913
987
|
stepChange: null,
|
|
914
|
-
|
|
988
|
+
stepHistory: [],
|
|
915
989
|
lastDecision: null,
|
|
916
990
|
walkthrough: state.walkthrough
|
|
917
991
|
? {
|
|
@@ -922,10 +996,9 @@ function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
|
922
996
|
};
|
|
923
997
|
}
|
|
924
998
|
case "propose-component": {
|
|
925
|
-
const stepNo = (state.walkthrough?.steps.length ?? 2) + 1;
|
|
926
999
|
const proposalStep: GuideStep = {
|
|
927
1000
|
id: "cp-propose-refund-service",
|
|
928
|
-
title:
|
|
1001
|
+
title: proposalStepTitle(state.walkthrough, "Confirm component"),
|
|
929
1002
|
trailId: event.trail.id,
|
|
930
1003
|
stepIndex: 0,
|
|
931
1004
|
showFile: false,
|
|
@@ -946,10 +1019,12 @@ function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
|
946
1019
|
};
|
|
947
1020
|
}
|
|
948
1021
|
case "propose-component-removal": {
|
|
949
|
-
const stepNo = (state.walkthrough?.steps.length ?? 2) + 1;
|
|
950
1022
|
const proposalStep: GuideStep = {
|
|
951
1023
|
id: "mr-propose-remove-mailer",
|
|
952
|
-
title:
|
|
1024
|
+
title: proposalStepTitle(
|
|
1025
|
+
state.walkthrough,
|
|
1026
|
+
"Retire confirmation mailer",
|
|
1027
|
+
),
|
|
953
1028
|
trailId: "wt-book",
|
|
954
1029
|
showFile: false,
|
|
955
1030
|
proposal: "removal",
|
|
@@ -958,6 +1033,8 @@ function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
|
958
1033
|
return {
|
|
959
1034
|
...state,
|
|
960
1035
|
pendingRemoval: event.componentAlias,
|
|
1036
|
+
stepChange: null,
|
|
1037
|
+
stepHistory: [],
|
|
961
1038
|
lastDecision: null,
|
|
962
1039
|
walkthrough: state.walkthrough
|
|
963
1040
|
? {
|
|
@@ -972,7 +1049,7 @@ function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
|
972
1049
|
}
|
|
973
1050
|
}
|
|
974
1051
|
|
|
975
|
-
/** Shared theme tokens
|
|
1052
|
+
/** Shared theme tokens plus the host-local proposal color for prototype chrome. */
|
|
976
1053
|
function usePrototypeTheme() {
|
|
977
1054
|
const { theme } = useTheme();
|
|
978
1055
|
return {
|
|
@@ -980,7 +1057,7 @@ function usePrototypeTheme() {
|
|
|
980
1057
|
border: theme.colors.border ?? "#2d3034",
|
|
981
1058
|
muted: theme.colors.textMuted ?? theme.colors.textSecondary ?? "#8b95a3",
|
|
982
1059
|
accent: theme.colors.accent ?? theme.colors.primary ?? "#a78bfa",
|
|
983
|
-
|
|
1060
|
+
proposal: HOST_PROPOSAL_COLOR,
|
|
984
1061
|
mono: theme.fonts.monospace,
|
|
985
1062
|
small: theme.fontSizes[0],
|
|
986
1063
|
body: theme.fontSizes[1],
|
|
@@ -1065,7 +1142,7 @@ function Prototype({
|
|
|
1065
1142
|
persistKey: string;
|
|
1066
1143
|
description: string;
|
|
1067
1144
|
}) {
|
|
1068
|
-
const { theme, border, muted, accent,
|
|
1145
|
+
const { theme, border, muted, accent, proposal, mono, small, body } =
|
|
1069
1146
|
usePrototypeTheme();
|
|
1070
1147
|
const openingEventCount = useMemo(
|
|
1071
1148
|
() => openingEventCountFor(events),
|
|
@@ -1152,17 +1229,21 @@ function Prototype({
|
|
|
1152
1229
|
) {
|
|
1153
1230
|
return [...state.trails, pendingTrail];
|
|
1154
1231
|
}
|
|
1232
|
+
// The staged variation sits directly after the step it varies. It stays
|
|
1233
|
+
// there after acceptance — only its colour changes.
|
|
1155
1234
|
const pendingStep = state.pendingStep;
|
|
1156
|
-
if (!pendingStep || state.lastDecision
|
|
1235
|
+
if (!pendingStep || state.lastDecision) {
|
|
1157
1236
|
return state.trails;
|
|
1158
1237
|
}
|
|
1159
1238
|
return state.trails.map((trail) =>
|
|
1160
1239
|
trail.id === pendingStep.trailId
|
|
1161
1240
|
? {
|
|
1162
1241
|
...trail,
|
|
1163
|
-
steps:
|
|
1164
|
-
|
|
1165
|
-
|
|
1242
|
+
steps: [
|
|
1243
|
+
...trail.steps.slice(0, pendingStep.stepIndex + 1),
|
|
1244
|
+
pendingStep.step,
|
|
1245
|
+
...trail.steps.slice(pendingStep.stepIndex + 1),
|
|
1246
|
+
],
|
|
1166
1247
|
}
|
|
1167
1248
|
: trail,
|
|
1168
1249
|
);
|
|
@@ -1181,6 +1262,9 @@ function Prototype({
|
|
|
1181
1262
|
activeGuideIndex >= 0 && state.walkthrough
|
|
1182
1263
|
? state.walkthrough.steps[activeGuideIndex]
|
|
1183
1264
|
: undefined;
|
|
1265
|
+
const activeGuideLabel =
|
|
1266
|
+
activeGuideStep?.title.match(/^\s*(\d+[a-z]?)\s*·/i)?.[1] ??
|
|
1267
|
+
String(activeGuideIndex + 1);
|
|
1184
1268
|
const hasProposalStep =
|
|
1185
1269
|
state.walkthrough?.steps.some((s) => s.proposal) ?? false;
|
|
1186
1270
|
|
|
@@ -1254,6 +1338,30 @@ function Prototype({
|
|
|
1254
1338
|
});
|
|
1255
1339
|
}, [activeGuideStep, visibleTrails]);
|
|
1256
1340
|
|
|
1341
|
+
// The staged replacement variations of one step are a single focus group:
|
|
1342
|
+
// the guide names one of them, but the panel and camera frame them together.
|
|
1343
|
+
const focusedVariationStepIndexes = useMemo(() => {
|
|
1344
|
+
const pending = state.pendingStep;
|
|
1345
|
+
if (!pending || state.lastDecision === "rejected") return undefined;
|
|
1346
|
+
if (state.lastDecision && !state.stepChange) return undefined;
|
|
1347
|
+
return new Map<string, ReadonlySet<number>>([
|
|
1348
|
+
[pending.trailId, new Set([pending.stepIndex, pending.stepIndex + 1])],
|
|
1349
|
+
]);
|
|
1350
|
+
}, [state.pendingStep, state.lastDecision, state.stepChange]);
|
|
1351
|
+
|
|
1352
|
+
// Once accepted, the variation keeps its `2a` label in the panel even though
|
|
1353
|
+
// it is now an ordinary step in the host-local trails.
|
|
1354
|
+
const acceptedStepNumberLabels = useMemo(() => {
|
|
1355
|
+
const pending = state.pendingStep;
|
|
1356
|
+
if (!state.lastDecision || !pending || !state.stepChange) return undefined;
|
|
1357
|
+
return new Map<string, string>([
|
|
1358
|
+
[
|
|
1359
|
+
emphasisKey(pending.trailId, pending.step),
|
|
1360
|
+
variationStepNumber(pending.stepIndex + 1),
|
|
1361
|
+
],
|
|
1362
|
+
]);
|
|
1363
|
+
}, [state.lastDecision, state.pendingStep, state.stepChange]);
|
|
1364
|
+
|
|
1257
1365
|
const focusedTrailStep = useMemo(() => {
|
|
1258
1366
|
if (!state.walkthrough) return undefined;
|
|
1259
1367
|
if (!activeGuideStep) return null;
|
|
@@ -1282,13 +1390,6 @@ function Prototype({
|
|
|
1282
1390
|
[],
|
|
1283
1391
|
);
|
|
1284
1392
|
|
|
1285
|
-
const togglePreviousStep = useCallback(() => {
|
|
1286
|
-
setState((prev) => ({
|
|
1287
|
-
...prev,
|
|
1288
|
-
showPreviousStep: !prev.showPreviousStep,
|
|
1289
|
-
}));
|
|
1290
|
-
}, []);
|
|
1291
|
-
|
|
1292
1393
|
const moveWalkthroughStep = useCallback((delta: number) => {
|
|
1293
1394
|
setState((prev) => {
|
|
1294
1395
|
const walkthrough = prev.walkthrough;
|
|
@@ -1355,130 +1456,94 @@ function Prototype({
|
|
|
1355
1456
|
: "Awaiting agent decision";
|
|
1356
1457
|
|
|
1357
1458
|
const guidePanel =
|
|
1459
|
+
state.walkthrough && activeGuideStep && hasProposalStep ? (
|
|
1460
|
+
<div style={{ fontFamily: mono, color: theme.colors.text }}>
|
|
1461
|
+
<span
|
|
1462
|
+
style={{
|
|
1463
|
+
fontSize: small,
|
|
1464
|
+
letterSpacing: "0.04em",
|
|
1465
|
+
fontWeight: 600,
|
|
1466
|
+
color: proposal,
|
|
1467
|
+
whiteSpace: "nowrap",
|
|
1468
|
+
}}
|
|
1469
|
+
>
|
|
1470
|
+
PROPOSAL ADDED
|
|
1471
|
+
{state.lastDecision === "accepted"
|
|
1472
|
+
? " · ACCEPTED"
|
|
1473
|
+
: state.lastDecision === "rejected"
|
|
1474
|
+
? " · DECLINED"
|
|
1475
|
+
: ""}
|
|
1476
|
+
</span>
|
|
1477
|
+
</div>
|
|
1478
|
+
) : null;
|
|
1479
|
+
|
|
1480
|
+
// Navigation sits on the canvas, directly above the active step card.
|
|
1481
|
+
const stepNavigation =
|
|
1358
1482
|
state.walkthrough && activeGuideStep ? (
|
|
1359
1483
|
<div
|
|
1360
1484
|
style={{
|
|
1361
|
-
|
|
1362
|
-
|
|
1485
|
+
display: "flex",
|
|
1486
|
+
alignItems: "center",
|
|
1487
|
+
gap: 8,
|
|
1488
|
+
pointerEvents: "auto",
|
|
1363
1489
|
}}
|
|
1364
1490
|
>
|
|
1365
|
-
<
|
|
1491
|
+
<button
|
|
1492
|
+
type="button"
|
|
1493
|
+
onClick={() => moveWalkthroughStep(-1)}
|
|
1494
|
+
disabled={activeGuideIndex === 0}
|
|
1366
1495
|
style={{
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1496
|
+
padding: "4px 10px",
|
|
1497
|
+
borderRadius: 4,
|
|
1498
|
+
border: `1px solid ${border}`,
|
|
1499
|
+
background: "transparent",
|
|
1500
|
+
color: muted,
|
|
1501
|
+
fontFamily: mono,
|
|
1502
|
+
fontSize: small,
|
|
1503
|
+
cursor: activeGuideIndex === 0 ? "default" : "pointer",
|
|
1504
|
+
opacity: activeGuideIndex === 0 ? 0.5 : 1,
|
|
1370
1505
|
}}
|
|
1371
1506
|
>
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
fontSize: small,
|
|
1376
|
-
letterSpacing: "0.04em",
|
|
1377
|
-
fontWeight: 600,
|
|
1378
|
-
color: warning,
|
|
1379
|
-
whiteSpace: "nowrap",
|
|
1380
|
-
}}
|
|
1381
|
-
>
|
|
1382
|
-
PROPOSAL ADDED
|
|
1383
|
-
{state.lastDecision === "accepted"
|
|
1384
|
-
? " · ACCEPTED"
|
|
1385
|
-
: state.lastDecision === "rejected"
|
|
1386
|
-
? " · DECLINED"
|
|
1387
|
-
: ""}
|
|
1388
|
-
</span>
|
|
1389
|
-
) : (
|
|
1390
|
-
<span />
|
|
1391
|
-
)}
|
|
1392
|
-
<span style={{ display: "flex", gap: 4 }} aria-hidden="true">
|
|
1393
|
-
{state.walkthrough.steps.map((s, i) => (
|
|
1394
|
-
<span
|
|
1395
|
-
key={s.id}
|
|
1396
|
-
style={{
|
|
1397
|
-
width: 5,
|
|
1398
|
-
height: 5,
|
|
1399
|
-
borderRadius: "50%",
|
|
1400
|
-
background: s.proposal
|
|
1401
|
-
? state.lastDecision === "accepted"
|
|
1402
|
-
? accent
|
|
1403
|
-
: state.lastDecision === "rejected"
|
|
1404
|
-
? border
|
|
1405
|
-
: warning
|
|
1406
|
-
: i === activeGuideIndex
|
|
1407
|
-
? accent
|
|
1408
|
-
: border,
|
|
1409
|
-
}}
|
|
1410
|
-
/>
|
|
1411
|
-
))}
|
|
1412
|
-
</span>
|
|
1413
|
-
</div>
|
|
1414
|
-
<div
|
|
1507
|
+
Previous
|
|
1508
|
+
</button>
|
|
1509
|
+
<span
|
|
1415
1510
|
style={{
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1511
|
+
textAlign: "center",
|
|
1512
|
+
fontSize: small,
|
|
1513
|
+
color: muted,
|
|
1514
|
+
whiteSpace: "nowrap",
|
|
1420
1515
|
}}
|
|
1421
1516
|
>
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
}}
|
|
1448
|
-
>
|
|
1449
|
-
STEP {activeGuideIndex + 1} OF {state.walkthrough.steps.length}
|
|
1450
|
-
</span>
|
|
1451
|
-
<button
|
|
1452
|
-
type="button"
|
|
1453
|
-
onClick={() => moveWalkthroughStep(1)}
|
|
1454
|
-
disabled={activeGuideIndex === state.walkthrough.steps.length - 1}
|
|
1455
|
-
style={{
|
|
1456
|
-
padding: "4px 10px",
|
|
1457
|
-
borderRadius: 4,
|
|
1458
|
-
border: `1px solid ${accent}`,
|
|
1459
|
-
background: `${accent}18`,
|
|
1460
|
-
color: accent,
|
|
1461
|
-
fontFamily: mono,
|
|
1462
|
-
fontSize: small,
|
|
1463
|
-
fontWeight: 600,
|
|
1464
|
-
cursor:
|
|
1465
|
-
activeGuideIndex === state.walkthrough.steps.length - 1
|
|
1466
|
-
? "default"
|
|
1467
|
-
: "pointer",
|
|
1468
|
-
opacity:
|
|
1469
|
-
activeGuideIndex === state.walkthrough.steps.length - 1
|
|
1470
|
-
? 0.5
|
|
1471
|
-
: 1,
|
|
1472
|
-
}}
|
|
1473
|
-
>
|
|
1474
|
-
Next step
|
|
1475
|
-
</button>
|
|
1476
|
-
</div>
|
|
1517
|
+
STEP {activeGuideLabel} OF {state.walkthrough.steps.length}
|
|
1518
|
+
</span>
|
|
1519
|
+
<button
|
|
1520
|
+
type="button"
|
|
1521
|
+
onClick={() => moveWalkthroughStep(1)}
|
|
1522
|
+
disabled={activeGuideIndex === state.walkthrough.steps.length - 1}
|
|
1523
|
+
style={{
|
|
1524
|
+
padding: "4px 10px",
|
|
1525
|
+
borderRadius: 4,
|
|
1526
|
+
border: `1px solid ${accent}`,
|
|
1527
|
+
background: `${accent}18`,
|
|
1528
|
+
color: accent,
|
|
1529
|
+
fontFamily: mono,
|
|
1530
|
+
fontSize: small,
|
|
1531
|
+
fontWeight: 600,
|
|
1532
|
+
cursor:
|
|
1533
|
+
activeGuideIndex === state.walkthrough.steps.length - 1
|
|
1534
|
+
? "default"
|
|
1535
|
+
: "pointer",
|
|
1536
|
+
opacity:
|
|
1537
|
+
activeGuideIndex === state.walkthrough.steps.length - 1 ? 0.5 : 1,
|
|
1538
|
+
}}
|
|
1539
|
+
>
|
|
1540
|
+
Next step
|
|
1541
|
+
</button>
|
|
1477
1542
|
</div>
|
|
1478
1543
|
) : null;
|
|
1479
1544
|
|
|
1480
1545
|
// The active step sits above the map so the instruction is read where the
|
|
1481
|
-
// camera is moving. The question
|
|
1546
|
+
// camera is moving. The question stays in the left rail.
|
|
1482
1547
|
const guideStepCard =
|
|
1483
1548
|
state.walkthrough && activeGuideStep ? (
|
|
1484
1549
|
<div
|
|
@@ -1517,7 +1582,7 @@ function Prototype({
|
|
|
1517
1582
|
{proposalPending ? (
|
|
1518
1583
|
<div
|
|
1519
1584
|
aria-live="polite"
|
|
1520
|
-
style={{ marginTop: 10, fontSize: small, color:
|
|
1585
|
+
style={{ marginTop: 10, fontSize: small, color: proposal }}
|
|
1521
1586
|
>
|
|
1522
1587
|
{proposalStatus}
|
|
1523
1588
|
</div>
|
|
@@ -1537,7 +1602,7 @@ function Prototype({
|
|
|
1537
1602
|
gap: 8,
|
|
1538
1603
|
padding: "6px 12px",
|
|
1539
1604
|
borderRadius: 999,
|
|
1540
|
-
border: `1px solid ${state.agentWorkingOn ? accent :
|
|
1605
|
+
border: `1px solid ${state.agentWorkingOn ? accent : proposal}`,
|
|
1541
1606
|
background:
|
|
1542
1607
|
theme.colors.backgroundSecondary ?? theme.colors.background,
|
|
1543
1608
|
boxShadow: "0 6px 20px rgba(0,0,0,0.35)",
|
|
@@ -1566,7 +1631,7 @@ function Prototype({
|
|
|
1566
1631
|
</span>
|
|
1567
1632
|
</>
|
|
1568
1633
|
) : (
|
|
1569
|
-
<span style={{ color:
|
|
1634
|
+
<span style={{ color: proposal, fontWeight: 600 }}>
|
|
1570
1635
|
{state.lastDecision === "accepted"
|
|
1571
1636
|
? "AGENT COMMITTED PROPOSAL"
|
|
1572
1637
|
: "AGENT DECLINED PROPOSAL"}
|
|
@@ -1575,10 +1640,10 @@ function Prototype({
|
|
|
1575
1640
|
</div>
|
|
1576
1641
|
) : null;
|
|
1577
1642
|
|
|
1578
|
-
//
|
|
1579
|
-
// status
|
|
1643
|
+
// Navigation, the step card and agent status float as one stack over the
|
|
1644
|
+
// map: buttons on top, status directly beneath the card.
|
|
1580
1645
|
const graphCardStack =
|
|
1581
|
-
guideStepCard || agentStatusOverlay ? (
|
|
1646
|
+
stepNavigation || guideStepCard || agentStatusOverlay ? (
|
|
1582
1647
|
<div
|
|
1583
1648
|
style={{
|
|
1584
1649
|
position: "absolute",
|
|
@@ -1595,6 +1660,7 @@ function Prototype({
|
|
|
1595
1660
|
maxWidth: "calc(100% - 32px)",
|
|
1596
1661
|
}}
|
|
1597
1662
|
>
|
|
1663
|
+
{stepNavigation}
|
|
1598
1664
|
{guideStepCard}
|
|
1599
1665
|
{agentStatusOverlay}
|
|
1600
1666
|
</div>
|
|
@@ -1743,6 +1809,7 @@ function Prototype({
|
|
|
1743
1809
|
components={visibleComponents}
|
|
1744
1810
|
trails={visibleTrails}
|
|
1745
1811
|
focusedTrailStep={focusedTrailStep}
|
|
1812
|
+
focusedVariationStepIndexes={focusedVariationStepIndexes}
|
|
1746
1813
|
proposedTrailIds={
|
|
1747
1814
|
state.pendingTrail && !state.lastDecision
|
|
1748
1815
|
? new Set([state.pendingTrail.id])
|
|
@@ -1758,9 +1825,14 @@ function Prototype({
|
|
|
1758
1825
|
])
|
|
1759
1826
|
: undefined
|
|
1760
1827
|
}
|
|
1828
|
+
stepNumberLabels={acceptedStepNumberLabels}
|
|
1829
|
+
proposedStep={
|
|
1830
|
+
state.pendingStep && !state.lastDecision
|
|
1831
|
+
? state.pendingStep
|
|
1832
|
+
: null
|
|
1833
|
+
}
|
|
1761
1834
|
stepChange={state.stepChange}
|
|
1762
|
-
|
|
1763
|
-
onTogglePreviousStep={togglePreviousStep}
|
|
1835
|
+
stepHistory={state.stepHistory}
|
|
1764
1836
|
proposedComponentAliases={
|
|
1765
1837
|
state.pendingComponent && !state.lastDecision
|
|
1766
1838
|
? new Set([state.pendingComponent.alias])
|