@principal-ai/subsystems-react 0.56.35 → 0.56.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- 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 +9 -8
- package/dist/subsystem/nodes.d.ts.map +1 -1
- package/dist/subsystem/nodes.js +271 -338
- 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/index.ts +3 -1
- package/src/stories/Canvases/Subsystem/AgentDrivenWalkthrough.stories.tsx +1842 -279
- 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 +463 -435
- package/src/subsystem/stepEmphasis.ts +8 -0
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useCallback,
|
|
3
|
+
useEffect,
|
|
4
|
+
useMemo,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
} from "react";
|
|
2
8
|
import "@xyflow/react/dist/style.css";
|
|
3
9
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
10
|
import {
|
|
@@ -6,16 +12,22 @@ import {
|
|
|
6
12
|
defaultEditorTheme,
|
|
7
13
|
useTheme,
|
|
8
14
|
} from "@principal-ade/industry-theme";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
import {
|
|
16
|
+
SubsystemComponentGraph,
|
|
17
|
+
type SubsystemTrailStepHistory,
|
|
18
|
+
} from "../../../subsystem/SubsystemComponentGraph";
|
|
19
|
+
import {
|
|
20
|
+
HOST_PROPOSAL_COLOR,
|
|
21
|
+
trailStepGraphEdgeId,
|
|
22
|
+
type SubsystemComponent,
|
|
23
|
+
type SubsystemTrail,
|
|
24
|
+
type SubsystemTrailStep,
|
|
14
25
|
} from "../../../subsystem/model";
|
|
15
26
|
import {
|
|
16
27
|
buildStepEmphasisMap,
|
|
17
28
|
emphasisKey,
|
|
18
29
|
stepClaimKey,
|
|
30
|
+
variationStepNumber,
|
|
19
31
|
type StepEmphasisRecord,
|
|
20
32
|
} from "../../../subsystem/stepEmphasis";
|
|
21
33
|
|
|
@@ -60,7 +72,9 @@ export default meta;
|
|
|
60
72
|
type Story = StoryObj<typeof meta>;
|
|
61
73
|
|
|
62
74
|
const PURL = "pkg:github/acme/booking-web";
|
|
75
|
+
const PAY_PURL = "pkg:github/acme/payments";
|
|
63
76
|
const stepPurl = (file: string) => `${PURL}#${file}`;
|
|
77
|
+
const payStepPurl = (file: string) => `${PAY_PURL}#${file}`;
|
|
64
78
|
|
|
65
79
|
const seedComponents: SubsystemComponent[] = [
|
|
66
80
|
{
|
|
@@ -330,6 +344,27 @@ type DriveEvent =
|
|
|
330
344
|
rationale: string;
|
|
331
345
|
};
|
|
332
346
|
|
|
347
|
+
/**
|
|
348
|
+
* A proposal is a variation of the step currently under discussion, not the
|
|
349
|
+
* next sequential guide step. `2 · Where it stops` therefore yields `2a`.
|
|
350
|
+
*/
|
|
351
|
+
function stepNumberFromTitle(title: string): number | null {
|
|
352
|
+
const match = title.match(/^\s*(\d+)[a-z]?\s*(?:·|-|:|$)/i);
|
|
353
|
+
return match ? Number(match[1]) : null;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function proposalStepTitle(
|
|
357
|
+
walkthrough: { steps: readonly GuideStep[] } | null | undefined,
|
|
358
|
+
label: string,
|
|
359
|
+
): string {
|
|
360
|
+
const steps = walkthrough?.steps ?? [];
|
|
361
|
+
// The last authored guide step is the one the proposal responds to; autoplay
|
|
362
|
+
// may not have advanced the host's active step when the proposal lands.
|
|
363
|
+
const target = steps[steps.length - 1];
|
|
364
|
+
const base = target ? stepNumberFromTitle(target.title) : null;
|
|
365
|
+
return `${variationStepNumber(base ?? 1)} · ${label}`;
|
|
366
|
+
}
|
|
367
|
+
|
|
333
368
|
const trailProposalEvents: DriveEvent[] = [
|
|
334
369
|
{
|
|
335
370
|
kind: "prompt",
|
|
@@ -677,9 +712,694 @@ const componentDeclinedEvents = withFinalDecision(
|
|
|
677
712
|
"RefundService would duplicate the mailer's responsibility, so I am keeping the model as is.",
|
|
678
713
|
);
|
|
679
714
|
|
|
715
|
+
/**
|
|
716
|
+
* Multi-proposal prototype: a proposal is context (trail-step refs that may
|
|
717
|
+
* span models) plus a delta on node-captured entities. Several proposals can
|
|
718
|
+
* share one decision boundary — a `HostChange`. The graph the user sees is a
|
|
719
|
+
* host-local synthetic model projected from the affected source trails.
|
|
720
|
+
*/
|
|
721
|
+
type SourceModelId = "booking" | "payments";
|
|
722
|
+
type ProposalStatus = "staged" | "accepted" | "rejected";
|
|
723
|
+
|
|
724
|
+
type ContextRef = {
|
|
725
|
+
modelId: SourceModelId;
|
|
726
|
+
trailId: string;
|
|
727
|
+
/** Stable claim fingerprint; survives reordering of the source trail. */
|
|
728
|
+
stepKey: string;
|
|
729
|
+
label: string;
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
type HostProposalDelta =
|
|
733
|
+
| {
|
|
734
|
+
kind: "trail-replace";
|
|
735
|
+
beforeTrailId: string;
|
|
736
|
+
afterTrail: SubsystemTrail;
|
|
737
|
+
}
|
|
738
|
+
| {
|
|
739
|
+
kind: "component-add";
|
|
740
|
+
component: SubsystemComponent;
|
|
741
|
+
trail: SubsystemTrail;
|
|
742
|
+
}
|
|
743
|
+
| { kind: "component-remove"; componentAlias: string };
|
|
744
|
+
|
|
745
|
+
type HostProposal = {
|
|
746
|
+
id: string;
|
|
747
|
+
name: string;
|
|
748
|
+
context: ContextRef[];
|
|
749
|
+
delta: HostProposalDelta;
|
|
750
|
+
rationale: string;
|
|
751
|
+
status: ProposalStatus;
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
type HostChange = {
|
|
755
|
+
id: string;
|
|
756
|
+
name: string;
|
|
757
|
+
rationale: string;
|
|
758
|
+
proposals: HostProposal[];
|
|
759
|
+
status: ProposalStatus;
|
|
760
|
+
};
|
|
761
|
+
|
|
762
|
+
type SourceModel = {
|
|
763
|
+
id: SourceModelId;
|
|
764
|
+
name: string;
|
|
765
|
+
purl: string;
|
|
766
|
+
components: SubsystemComponent[];
|
|
767
|
+
trails: SubsystemTrail[];
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
type MultiDriveEvent =
|
|
771
|
+
| Extract<
|
|
772
|
+
DriveEvent,
|
|
773
|
+
{
|
|
774
|
+
kind:
|
|
775
|
+
| "prompt"
|
|
776
|
+
| "open-model"
|
|
777
|
+
| "agent"
|
|
778
|
+
| "agent-working"
|
|
779
|
+
| "agent-decision";
|
|
780
|
+
}
|
|
781
|
+
>
|
|
782
|
+
| {
|
|
783
|
+
kind: "open-proposal-context";
|
|
784
|
+
id: string;
|
|
785
|
+
tool: string;
|
|
786
|
+
text: string;
|
|
787
|
+
change: HostChange;
|
|
788
|
+
}
|
|
789
|
+
| {
|
|
790
|
+
kind: "activate-proposal";
|
|
791
|
+
id: string;
|
|
792
|
+
tool: string;
|
|
793
|
+
text: string;
|
|
794
|
+
proposalId: string;
|
|
795
|
+
}
|
|
796
|
+
| {
|
|
797
|
+
kind: "open-source-model";
|
|
798
|
+
id: string;
|
|
799
|
+
tool: string;
|
|
800
|
+
text: string;
|
|
801
|
+
sourceModelId: SourceModelId;
|
|
802
|
+
sourceTrailId: string;
|
|
803
|
+
}
|
|
804
|
+
| {
|
|
805
|
+
kind: "return-to-proposal";
|
|
806
|
+
id: string;
|
|
807
|
+
tool: string;
|
|
808
|
+
text: string;
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
const sourceModels: Record<SourceModelId, SourceModel> = {
|
|
812
|
+
booking: {
|
|
813
|
+
id: "booking",
|
|
814
|
+
name: "Booking web",
|
|
815
|
+
purl: PURL,
|
|
816
|
+
components: seedComponents,
|
|
817
|
+
trails: seedTrails,
|
|
818
|
+
},
|
|
819
|
+
payments: {
|
|
820
|
+
id: "payments",
|
|
821
|
+
name: "Payments service",
|
|
822
|
+
purl: PAY_PURL,
|
|
823
|
+
components: [
|
|
824
|
+
{
|
|
825
|
+
alias: "pay-api",
|
|
826
|
+
name: "RefundApi",
|
|
827
|
+
construct: "function",
|
|
828
|
+
file: "src/refund/refundApi.ts",
|
|
829
|
+
purl: PAY_PURL,
|
|
830
|
+
symbol: "RefundApi",
|
|
831
|
+
purpose: "starts a refund",
|
|
832
|
+
process: "payments/service",
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
alias: "pay-gateway",
|
|
836
|
+
name: "PaymentGateway",
|
|
837
|
+
construct: "external",
|
|
838
|
+
file: "src/gateway/paymentGateway.ts",
|
|
839
|
+
purl: PAY_PURL,
|
|
840
|
+
symbol: "PaymentGateway",
|
|
841
|
+
purpose: "reverses a charge",
|
|
842
|
+
role: "service",
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
alias: "pay-ledger",
|
|
846
|
+
name: "RefundLedger",
|
|
847
|
+
construct: "class",
|
|
848
|
+
file: "src/ledger/refundLedger.ts",
|
|
849
|
+
purl: PAY_PURL,
|
|
850
|
+
symbol: "RefundLedger",
|
|
851
|
+
purpose: "records reversals",
|
|
852
|
+
process: "payments/service",
|
|
853
|
+
},
|
|
854
|
+
],
|
|
855
|
+
trails: [
|
|
856
|
+
{
|
|
857
|
+
id: "pt-refund",
|
|
858
|
+
title: "Issue refund",
|
|
859
|
+
steps: [
|
|
860
|
+
{
|
|
861
|
+
from: "pay-api",
|
|
862
|
+
to: "pay-gateway",
|
|
863
|
+
mechanism: "calls",
|
|
864
|
+
file: "src/refund/refundApi.ts",
|
|
865
|
+
span: { startLine: 18, endLine: 18, contentHash: "fixture" },
|
|
866
|
+
purl: payStepPurl("src/refund/refundApi.ts"),
|
|
867
|
+
symbol: "RefundApi.refund",
|
|
868
|
+
annotation:
|
|
869
|
+
"The refund API asks the gateway to reverse the charge.",
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
from: "pay-gateway",
|
|
873
|
+
to: "pay-ledger",
|
|
874
|
+
mechanism: "writes",
|
|
875
|
+
file: "src/gateway/paymentGateway.ts",
|
|
876
|
+
span: { startLine: 24, endLine: 24, contentHash: "fixture" },
|
|
877
|
+
purl: payStepPurl("src/gateway/paymentGateway.ts"),
|
|
878
|
+
symbol: "PaymentGateway.reverse",
|
|
879
|
+
annotation:
|
|
880
|
+
"The gateway records the reversal in the refund ledger.",
|
|
881
|
+
},
|
|
882
|
+
],
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
id: "pt-settlement",
|
|
886
|
+
title: "Settle a reversal",
|
|
887
|
+
steps: [
|
|
888
|
+
{
|
|
889
|
+
from: "pay-ledger",
|
|
890
|
+
to: "pay-api",
|
|
891
|
+
mechanism: "produces",
|
|
892
|
+
file: "src/ledger/refundLedger.ts",
|
|
893
|
+
span: { startLine: 31, endLine: 31, contentHash: "fixture" },
|
|
894
|
+
purl: payStepPurl("src/ledger/refundLedger.ts"),
|
|
895
|
+
symbol: "RefundLedger.settled",
|
|
896
|
+
annotation: "The ledger reports settlement back to the refund API.",
|
|
897
|
+
},
|
|
898
|
+
],
|
|
899
|
+
},
|
|
900
|
+
],
|
|
901
|
+
},
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
const allSourceComponents = Object.values(sourceModels).flatMap(
|
|
905
|
+
(model) => model.components,
|
|
906
|
+
);
|
|
907
|
+
|
|
908
|
+
function findComponentByAlias(alias: string): SubsystemComponent | undefined {
|
|
909
|
+
return allSourceComponents.find((component) => component.alias === alias);
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
function contextRefFromSource(
|
|
913
|
+
modelId: SourceModelId,
|
|
914
|
+
trailId: string,
|
|
915
|
+
stepIndex: number,
|
|
916
|
+
label: string,
|
|
917
|
+
): ContextRef {
|
|
918
|
+
const step = sourceModels[modelId].trails.find(
|
|
919
|
+
(trail) => trail.id === trailId,
|
|
920
|
+
)?.steps[stepIndex];
|
|
921
|
+
if (!step) {
|
|
922
|
+
throw new Error(`Missing source step: ${modelId}/${trailId}/${stepIndex}`);
|
|
923
|
+
}
|
|
924
|
+
return { modelId, trailId, stepKey: stepClaimKey(step), label };
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
const proposedCancelRefundTrail: SubsystemTrail = {
|
|
928
|
+
id: "wt-cancel-refund",
|
|
929
|
+
title: "Cancel with a refund intent",
|
|
930
|
+
steps: [
|
|
931
|
+
{
|
|
932
|
+
from: "ui",
|
|
933
|
+
to: "api",
|
|
934
|
+
mechanism: "calls",
|
|
935
|
+
file: "src/ui/BookingPage.tsx",
|
|
936
|
+
span: { startLine: 61, endLine: 61, contentHash: "proposed" },
|
|
937
|
+
purl: stepPurl("src/ui/BookingPage.tsx"),
|
|
938
|
+
symbol: "BookingPage.cancel",
|
|
939
|
+
annotation: "Cancel still sends the booking id to the API.",
|
|
940
|
+
},
|
|
941
|
+
{
|
|
942
|
+
from: "api",
|
|
943
|
+
to: "pay-gateway",
|
|
944
|
+
mechanism: "produces",
|
|
945
|
+
file: "src/api/checkout.ts",
|
|
946
|
+
span: { startLine: 34, endLine: 34, contentHash: "proposed" },
|
|
947
|
+
purl: stepPurl("src/api/checkout.ts"),
|
|
948
|
+
symbol: "checkoutApi.refundIntent",
|
|
949
|
+
annotation: "Cancel emits a refund intent to the payments gateway.",
|
|
950
|
+
},
|
|
951
|
+
{
|
|
952
|
+
from: "pay-gateway",
|
|
953
|
+
to: "store",
|
|
954
|
+
mechanism: "writes",
|
|
955
|
+
file: "src/gateway/paymentGateway.ts",
|
|
956
|
+
span: { startLine: 25, endLine: 25, contentHash: "proposed" },
|
|
957
|
+
purl: payStepPurl("src/gateway/paymentGateway.ts"),
|
|
958
|
+
symbol: "PaymentGateway.recordRefund",
|
|
959
|
+
annotation: "The gateway records the reversal against the booking.",
|
|
960
|
+
},
|
|
961
|
+
],
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
const proposedAuditComponent: SubsystemComponent = {
|
|
965
|
+
alias: "pay-audit",
|
|
966
|
+
name: "RefundAudit",
|
|
967
|
+
construct: "class",
|
|
968
|
+
file: "src/audit/refundAudit.ts",
|
|
969
|
+
purl: PAY_PURL,
|
|
970
|
+
symbol: "RefundAudit",
|
|
971
|
+
purpose: "records refund decisions",
|
|
972
|
+
process: "payments/service",
|
|
973
|
+
};
|
|
974
|
+
|
|
975
|
+
const proposedAuditTrail: SubsystemTrail = {
|
|
976
|
+
id: "pt-refund-audit",
|
|
977
|
+
title: "Record a refund decision",
|
|
978
|
+
steps: [
|
|
979
|
+
{
|
|
980
|
+
from: "pay-api",
|
|
981
|
+
to: "pay-audit",
|
|
982
|
+
mechanism: "writes",
|
|
983
|
+
file: "src/refund/refundApi.ts",
|
|
984
|
+
span: { startLine: 27, endLine: 27, contentHash: "proposed" },
|
|
985
|
+
purl: payStepPurl("src/refund/refundApi.ts"),
|
|
986
|
+
symbol: "RefundApi.audit",
|
|
987
|
+
annotation: "The refund API records why the reversal was requested.",
|
|
988
|
+
},
|
|
989
|
+
{
|
|
990
|
+
from: "pay-audit",
|
|
991
|
+
to: "ui",
|
|
992
|
+
mechanism: "feeds",
|
|
993
|
+
file: "src/audit/refundAudit.ts",
|
|
994
|
+
span: { startLine: 12, endLine: 12, contentHash: "proposed" },
|
|
995
|
+
purl: payStepPurl("src/audit/refundAudit.ts"),
|
|
996
|
+
symbol: "RefundAudit.status",
|
|
997
|
+
annotation: "The audit decision returns to the booking page.",
|
|
998
|
+
},
|
|
999
|
+
],
|
|
1000
|
+
};
|
|
1001
|
+
|
|
1002
|
+
const refundHandlingChange: HostChange = {
|
|
1003
|
+
id: "chg-refund-handling",
|
|
1004
|
+
name: "Add refund handling",
|
|
1005
|
+
rationale:
|
|
1006
|
+
"Three context-specific proposals share one accept/reject decision.",
|
|
1007
|
+
status: "staged",
|
|
1008
|
+
proposals: [
|
|
1009
|
+
{
|
|
1010
|
+
id: "p-cancel-trail",
|
|
1011
|
+
name: "Replace cancel trail",
|
|
1012
|
+
context: [
|
|
1013
|
+
contextRefFromSource(
|
|
1014
|
+
"booking",
|
|
1015
|
+
"wt-cancel",
|
|
1016
|
+
1,
|
|
1017
|
+
"Cancel stops at the store",
|
|
1018
|
+
),
|
|
1019
|
+
contextRefFromSource(
|
|
1020
|
+
"payments",
|
|
1021
|
+
"pt-refund",
|
|
1022
|
+
0,
|
|
1023
|
+
"Payments already reverses charges",
|
|
1024
|
+
),
|
|
1025
|
+
],
|
|
1026
|
+
delta: {
|
|
1027
|
+
kind: "trail-replace",
|
|
1028
|
+
beforeTrailId: "wt-cancel",
|
|
1029
|
+
afterTrail: proposedCancelRefundTrail,
|
|
1030
|
+
},
|
|
1031
|
+
rationale:
|
|
1032
|
+
"One context covers the missing refund hop and the payments path that already knows how to reverse it.",
|
|
1033
|
+
status: "staged",
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
id: "p-refund-audit",
|
|
1037
|
+
name: "Add RefundAudit",
|
|
1038
|
+
context: [
|
|
1039
|
+
contextRefFromSource(
|
|
1040
|
+
"payments",
|
|
1041
|
+
"pt-refund",
|
|
1042
|
+
1,
|
|
1043
|
+
"The ledger has no audit owner",
|
|
1044
|
+
),
|
|
1045
|
+
contextRefFromSource(
|
|
1046
|
+
"booking",
|
|
1047
|
+
"wt-cancel",
|
|
1048
|
+
1,
|
|
1049
|
+
"Cancel needs a recorded reason",
|
|
1050
|
+
),
|
|
1051
|
+
],
|
|
1052
|
+
delta: {
|
|
1053
|
+
kind: "component-add",
|
|
1054
|
+
component: proposedAuditComponent,
|
|
1055
|
+
trail: proposedAuditTrail,
|
|
1056
|
+
},
|
|
1057
|
+
rationale:
|
|
1058
|
+
"The refund decision needs its own owner in the payments model, with a status seam back to booking.",
|
|
1059
|
+
status: "staged",
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
id: "p-retire-mailer",
|
|
1063
|
+
name: "Retire confirmation mailer",
|
|
1064
|
+
context: [
|
|
1065
|
+
contextRefFromSource(
|
|
1066
|
+
"booking",
|
|
1067
|
+
"wt-book",
|
|
1068
|
+
2,
|
|
1069
|
+
"Mailer is the final confirmation hop",
|
|
1070
|
+
),
|
|
1071
|
+
contextRefFromSource(
|
|
1072
|
+
"payments",
|
|
1073
|
+
"pt-settlement",
|
|
1074
|
+
0,
|
|
1075
|
+
"Settlement no longer needs it",
|
|
1076
|
+
),
|
|
1077
|
+
],
|
|
1078
|
+
delta: { kind: "component-remove", componentAlias: "mailer" },
|
|
1079
|
+
rationale:
|
|
1080
|
+
"Refund status now travels through the audit seam, so the old confirmation mailer can be retired.",
|
|
1081
|
+
status: "staged",
|
|
1082
|
+
},
|
|
1083
|
+
],
|
|
1084
|
+
};
|
|
1085
|
+
|
|
1086
|
+
const multiProposalEvents: MultiDriveEvent[] = [
|
|
1087
|
+
{
|
|
1088
|
+
kind: "prompt",
|
|
1089
|
+
id: "mp-prompt",
|
|
1090
|
+
text: "Show refund handling across booking and payments, then propose a change.",
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
kind: "agent",
|
|
1094
|
+
id: "mp-agent-1",
|
|
1095
|
+
text: "I will project the affected trails from both models into one synthetic view, then walk the proposals in that view.",
|
|
1096
|
+
},
|
|
1097
|
+
{
|
|
1098
|
+
kind: "open-model",
|
|
1099
|
+
id: "mp-open-model",
|
|
1100
|
+
tool: "open_subsystem_model",
|
|
1101
|
+
text: "Open the synthetic proposal context so the change has somewhere to land.",
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
kind: "agent-working",
|
|
1105
|
+
id: "mp-agent-2",
|
|
1106
|
+
text: "The affected trails come from two models. I am projecting them into one context view before I stage anything.",
|
|
1107
|
+
workingOn: "projecting affected trails from Booking and Payments",
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
kind: "open-proposal-context",
|
|
1111
|
+
id: "mp-open-proposal-context",
|
|
1112
|
+
tool: "open_proposal_context",
|
|
1113
|
+
text: "Open one change containing three proposals with their own trail contexts.",
|
|
1114
|
+
change: refundHandlingChange,
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
kind: "agent-working",
|
|
1118
|
+
id: "mp-agent-3",
|
|
1119
|
+
text: "The first proposal replaces the cancel trail. Its context includes the booking gap and the payments refund path.",
|
|
1120
|
+
workingOn: "reviewing the cancel-trail replacement",
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
kind: "activate-proposal",
|
|
1124
|
+
id: "mp-focus-audit",
|
|
1125
|
+
tool: "focus_proposal_context",
|
|
1126
|
+
text: "Switch the header to the RefundAudit proposal.",
|
|
1127
|
+
proposalId: "p-refund-audit",
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
kind: "agent-working",
|
|
1131
|
+
id: "mp-agent-4",
|
|
1132
|
+
text: "The audit proposal needs the payments trail in its own model. I am opening that source explicitly, not as a focus side effect.",
|
|
1133
|
+
workingOn: "checking the Payments refund trail in its own model",
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
kind: "open-source-model",
|
|
1137
|
+
id: "mp-open-source",
|
|
1138
|
+
tool: "open_source_model",
|
|
1139
|
+
text: "Open the Payments model for additional context on the ledger step.",
|
|
1140
|
+
sourceModelId: "payments",
|
|
1141
|
+
sourceTrailId: "pt-refund",
|
|
1142
|
+
},
|
|
1143
|
+
{
|
|
1144
|
+
kind: "return-to-proposal",
|
|
1145
|
+
id: "mp-return",
|
|
1146
|
+
tool: "return_to_proposal_view",
|
|
1147
|
+
text: "Return to the synthetic change view.",
|
|
1148
|
+
},
|
|
1149
|
+
{
|
|
1150
|
+
kind: "agent-working",
|
|
1151
|
+
id: "mp-agent-5",
|
|
1152
|
+
text: "The mailer retirement is the third proposal. It belongs in the same change, so it will share the same decision.",
|
|
1153
|
+
workingOn: "reviewing the mailer retirement",
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
kind: "activate-proposal",
|
|
1157
|
+
id: "mp-focus-mailer",
|
|
1158
|
+
tool: "focus_proposal_context",
|
|
1159
|
+
text: "Switch the header to the mailer retirement proposal.",
|
|
1160
|
+
proposalId: "p-retire-mailer",
|
|
1161
|
+
},
|
|
1162
|
+
{
|
|
1163
|
+
kind: "agent-decision",
|
|
1164
|
+
id: "mp-decision",
|
|
1165
|
+
text: "These three proposals answer one change request, so I am accepting them together.",
|
|
1166
|
+
decision: "accepted",
|
|
1167
|
+
},
|
|
1168
|
+
];
|
|
1169
|
+
|
|
1170
|
+
const multiProposalDeclinedEvents = multiProposalEvents.map((event) =>
|
|
1171
|
+
event.kind === "agent-decision"
|
|
1172
|
+
? {
|
|
1173
|
+
...event,
|
|
1174
|
+
decision: "rejected" as const,
|
|
1175
|
+
text: "The cancel path still needs its store write, so I am declining all three proposals together.",
|
|
1176
|
+
}
|
|
1177
|
+
: event,
|
|
1178
|
+
);
|
|
1179
|
+
|
|
1180
|
+
function buildSyntheticModel(
|
|
1181
|
+
change: HostChange,
|
|
1182
|
+
activeProposal: HostProposal | undefined,
|
|
1183
|
+
accepted: boolean,
|
|
1184
|
+
) {
|
|
1185
|
+
const components = new Map<string, SubsystemComponent>();
|
|
1186
|
+
const trails = new Map<string, SubsystemTrail>();
|
|
1187
|
+
const removedComponentAliases = new Set<string>();
|
|
1188
|
+
// Accepted changes keep their original steps as layout-only ghosts. The
|
|
1189
|
+
// sidebar still renders only the live trails; the graph frames the ghosts
|
|
1190
|
+
// with dim dashed `was …` edges beside the applied change.
|
|
1191
|
+
const stepHistory: SubsystemTrailStepHistory[] = [];
|
|
1192
|
+
|
|
1193
|
+
const addSourceTrail = (ref: ContextRef) => {
|
|
1194
|
+
const source = sourceModels[ref.modelId];
|
|
1195
|
+
const trail = source.trails.find(
|
|
1196
|
+
(candidate) => candidate.id === ref.trailId,
|
|
1197
|
+
);
|
|
1198
|
+
if (!trail) return;
|
|
1199
|
+
trails.set(trail.id, {
|
|
1200
|
+
...trail,
|
|
1201
|
+
title: `${trail.title} · ${source.name}`,
|
|
1202
|
+
});
|
|
1203
|
+
for (const step of trail.steps) {
|
|
1204
|
+
for (const alias of [step.from, step.to]) {
|
|
1205
|
+
const component = source.components.find(
|
|
1206
|
+
(candidate) => candidate.alias === alias,
|
|
1207
|
+
);
|
|
1208
|
+
if (component) components.set(alias, component);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
// The synthetic model always carries the union of context trails. Switching
|
|
1214
|
+
// proposals changes focus and chrome, not the underlying projection.
|
|
1215
|
+
change.proposals.forEach((proposal) =>
|
|
1216
|
+
proposal.context.forEach(addSourceTrail),
|
|
1217
|
+
);
|
|
1218
|
+
|
|
1219
|
+
for (const proposal of change.proposals) {
|
|
1220
|
+
const applyDelta = accepted || proposal.id === activeProposal?.id;
|
|
1221
|
+
if (!applyDelta) continue;
|
|
1222
|
+
|
|
1223
|
+
if (proposal.delta.kind === "trail-replace") {
|
|
1224
|
+
if (accepted) {
|
|
1225
|
+
const before = trails.get(proposal.delta.beforeTrailId);
|
|
1226
|
+
const liveEdgeIds = new Set(
|
|
1227
|
+
proposal.delta.afterTrail.steps.map(trailStepGraphEdgeId),
|
|
1228
|
+
);
|
|
1229
|
+
for (const [stepIndex, step] of (before?.steps ?? []).entries()) {
|
|
1230
|
+
// An unchanged step is already live in the replacement; ghosting it
|
|
1231
|
+
// would dim the applied edge. Only changed steps become `was` edges.
|
|
1232
|
+
if (liveEdgeIds.has(trailStepGraphEdgeId(step))) continue;
|
|
1233
|
+
stepHistory.push({
|
|
1234
|
+
trailId: proposal.delta.afterTrail.id,
|
|
1235
|
+
stepIndex,
|
|
1236
|
+
previous: step,
|
|
1237
|
+
kind: "changed",
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
trails.delete(proposal.delta.beforeTrailId);
|
|
1241
|
+
}
|
|
1242
|
+
trails.set(proposal.delta.afterTrail.id, proposal.delta.afterTrail);
|
|
1243
|
+
for (const step of proposal.delta.afterTrail.steps) {
|
|
1244
|
+
for (const alias of [step.from, step.to]) {
|
|
1245
|
+
const component = findComponentByAlias(alias);
|
|
1246
|
+
if (component) components.set(alias, component);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
} else if (proposal.delta.kind === "component-add") {
|
|
1250
|
+
components.set(proposal.delta.component.alias, proposal.delta.component);
|
|
1251
|
+
trails.set(proposal.delta.trail.id, proposal.delta.trail);
|
|
1252
|
+
for (const step of proposal.delta.trail.steps) {
|
|
1253
|
+
for (const alias of [step.from, step.to]) {
|
|
1254
|
+
const component =
|
|
1255
|
+
alias === proposal.delta.component.alias
|
|
1256
|
+
? proposal.delta.component
|
|
1257
|
+
: findComponentByAlias(alias);
|
|
1258
|
+
if (component) components.set(alias, component);
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
} else if (accepted) {
|
|
1262
|
+
removedComponentAliases.add(proposal.delta.componentAlias);
|
|
1263
|
+
for (const [trailId, trail] of trails) {
|
|
1264
|
+
const keptSteps: SubsystemTrailStep[] = [];
|
|
1265
|
+
trail.steps.forEach((step, stepIndex) => {
|
|
1266
|
+
if (
|
|
1267
|
+
step.from === proposal.delta.componentAlias ||
|
|
1268
|
+
step.to === proposal.delta.componentAlias
|
|
1269
|
+
) {
|
|
1270
|
+
stepHistory.push({
|
|
1271
|
+
trailId,
|
|
1272
|
+
stepIndex: Math.min(stepIndex, keptSteps.length),
|
|
1273
|
+
previous: step,
|
|
1274
|
+
kind: "removed",
|
|
1275
|
+
});
|
|
1276
|
+
} else {
|
|
1277
|
+
keptSteps.push(step);
|
|
1278
|
+
}
|
|
1279
|
+
});
|
|
1280
|
+
trails.set(trailId, { ...trail, steps: keptSteps });
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
return {
|
|
1286
|
+
components: [...components.values()],
|
|
1287
|
+
trails: [...trails.values()],
|
|
1288
|
+
removedComponentAliases,
|
|
1289
|
+
stepHistory,
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
function proposalWorkingAliases(proposal: HostProposal | undefined) {
|
|
1294
|
+
const aliases = new Set<string>();
|
|
1295
|
+
if (!proposal) return aliases;
|
|
1296
|
+
for (const ref of proposal.context) {
|
|
1297
|
+
const source = sourceModels[ref.modelId];
|
|
1298
|
+
const trail = source.trails.find(
|
|
1299
|
+
(candidate) => candidate.id === ref.trailId,
|
|
1300
|
+
);
|
|
1301
|
+
const step = trail?.steps.find(
|
|
1302
|
+
(candidate) => stepClaimKey(candidate) === ref.stepKey,
|
|
1303
|
+
);
|
|
1304
|
+
if (step) {
|
|
1305
|
+
aliases.add(step.from);
|
|
1306
|
+
aliases.add(step.to);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
if (proposal.delta.kind === "trail-replace") {
|
|
1310
|
+
proposal.delta.afterTrail.steps.forEach((step) => {
|
|
1311
|
+
aliases.add(step.from);
|
|
1312
|
+
aliases.add(step.to);
|
|
1313
|
+
});
|
|
1314
|
+
} else if (proposal.delta.kind === "component-add") {
|
|
1315
|
+
aliases.add(proposal.delta.component.alias);
|
|
1316
|
+
} else {
|
|
1317
|
+
aliases.add(proposal.delta.componentAlias);
|
|
1318
|
+
}
|
|
1319
|
+
return aliases;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
function proposalFocus(
|
|
1323
|
+
proposal: HostProposal | undefined,
|
|
1324
|
+
trails: readonly SubsystemTrail[],
|
|
1325
|
+
accepted: boolean,
|
|
1326
|
+
stepHistory: readonly SubsystemTrailStepHistory[],
|
|
1327
|
+
) {
|
|
1328
|
+
if (!proposal) return undefined;
|
|
1329
|
+
// After the decision, frame the applied change and its retained ghosts —
|
|
1330
|
+
// not a surviving piece of the original context that happens to resolve.
|
|
1331
|
+
if (accepted) {
|
|
1332
|
+
if (proposal.delta.kind === "trail-replace") {
|
|
1333
|
+
return {
|
|
1334
|
+
trailId: proposal.delta.afterTrail.id,
|
|
1335
|
+
stepIndex: 1,
|
|
1336
|
+
showFile: false,
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
if (proposal.delta.kind === "component-add") {
|
|
1340
|
+
return {
|
|
1341
|
+
trailId: proposal.delta.trail.id,
|
|
1342
|
+
stepIndex: 0,
|
|
1343
|
+
showFile: false,
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
const removed = stepHistory.find(
|
|
1347
|
+
(link) =>
|
|
1348
|
+
(link.previous.from === proposal.delta.componentAlias ||
|
|
1349
|
+
link.previous.to === proposal.delta.componentAlias) &&
|
|
1350
|
+
trails.some((trail) => trail.id === link.trailId),
|
|
1351
|
+
);
|
|
1352
|
+
if (removed) {
|
|
1353
|
+
return {
|
|
1354
|
+
trailId: removed.trailId,
|
|
1355
|
+
// Frame the last live step beside its ghost; the ghost itself joins
|
|
1356
|
+
// the camera bounds through the graph's linked-edge history.
|
|
1357
|
+
stepIndex: Math.max(0, removed.stepIndex - 1),
|
|
1358
|
+
showFile: false,
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
for (const ref of proposal.context) {
|
|
1363
|
+
const sourceTrail = sourceModels[ref.modelId].trails.find(
|
|
1364
|
+
(candidate) => candidate.id === ref.trailId,
|
|
1365
|
+
);
|
|
1366
|
+
const stepIndex = sourceTrail?.steps.findIndex(
|
|
1367
|
+
(candidate) => stepClaimKey(candidate) === ref.stepKey,
|
|
1368
|
+
);
|
|
1369
|
+
const projectedTrail = trails.find((trail) => trail.id === ref.trailId);
|
|
1370
|
+
if (
|
|
1371
|
+
stepIndex != null &&
|
|
1372
|
+
stepIndex >= 0 &&
|
|
1373
|
+
projectedTrail &&
|
|
1374
|
+
stepIndex < projectedTrail.steps.length
|
|
1375
|
+
) {
|
|
1376
|
+
return {
|
|
1377
|
+
trailId: ref.trailId,
|
|
1378
|
+
stepIndex,
|
|
1379
|
+
showFile: false,
|
|
1380
|
+
};
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
if (proposal.delta.kind === "trail-replace") {
|
|
1384
|
+
return {
|
|
1385
|
+
trailId: proposal.delta.afterTrail.id,
|
|
1386
|
+
stepIndex: 0,
|
|
1387
|
+
showFile: false,
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
if (proposal.delta.kind === "component-add") {
|
|
1391
|
+
return {
|
|
1392
|
+
trailId: proposal.delta.trail.id,
|
|
1393
|
+
stepIndex: 0,
|
|
1394
|
+
showFile: false,
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1397
|
+
return undefined;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
680
1400
|
// `Animate opening` replays through the open call so the artifact appears
|
|
681
1401
|
// immediately, then lets the rest of the stream continue behind it.
|
|
682
|
-
function openingEventCountFor(events:
|
|
1402
|
+
function openingEventCountFor(events: readonly { kind: string }[]) {
|
|
683
1403
|
const index = events.findIndex((event) => event.kind === "open-model");
|
|
684
1404
|
return index < 0 ? 0 : index + 1;
|
|
685
1405
|
}
|
|
@@ -719,8 +1439,8 @@ type DriveState = {
|
|
|
719
1439
|
lastDecision: "accepted" | "rejected" | null;
|
|
720
1440
|
/** Host-local comparison for an accepted step change. */
|
|
721
1441
|
stepChange: StepChange | null;
|
|
722
|
-
/**
|
|
723
|
-
|
|
1442
|
+
/** Unchanged steps linked to accepted changes, for shared layout + focus. */
|
|
1443
|
+
stepHistory: SubsystemTrailStepHistory[];
|
|
724
1444
|
};
|
|
725
1445
|
|
|
726
1446
|
const initialState = (): DriveState => ({
|
|
@@ -738,9 +1458,28 @@ const initialState = (): DriveState => ({
|
|
|
738
1458
|
agentWorkingOn: null,
|
|
739
1459
|
lastDecision: null,
|
|
740
1460
|
stepChange: null,
|
|
741
|
-
|
|
1461
|
+
stepHistory: [],
|
|
742
1462
|
});
|
|
743
1463
|
|
|
1464
|
+
// While staged, the step proposal guide step points at the inserted variation.
|
|
1465
|
+
// Once resolved the variation is gone, so point the same guide step back at the
|
|
1466
|
+
// real trail step — otherwise host focus would aim past the end of the trail.
|
|
1467
|
+
function retargetResolvedStepProposal(state: DriveState): DriveState {
|
|
1468
|
+
const pendingStep = state.pendingStep;
|
|
1469
|
+
if (!pendingStep || !state.walkthrough) return state;
|
|
1470
|
+
return {
|
|
1471
|
+
...state,
|
|
1472
|
+
walkthrough: {
|
|
1473
|
+
...state.walkthrough,
|
|
1474
|
+
steps: state.walkthrough.steps.map((step) =>
|
|
1475
|
+
step.proposal === "step"
|
|
1476
|
+
? { ...step, stepIndex: pendingStep.stepIndex }
|
|
1477
|
+
: step,
|
|
1478
|
+
),
|
|
1479
|
+
},
|
|
1480
|
+
};
|
|
1481
|
+
}
|
|
1482
|
+
|
|
744
1483
|
// The agent, not a button, resolves a staged proposal. Accepted proposals move
|
|
745
1484
|
// from host-local pending state into the visible graph; declined ones leave the
|
|
746
1485
|
// visible model unchanged.
|
|
@@ -750,11 +1489,26 @@ function resolveProposal(
|
|
|
750
1489
|
): DriveState {
|
|
751
1490
|
if (state.lastDecision) return state;
|
|
752
1491
|
if (decision === "rejected") {
|
|
753
|
-
return { ...state, lastDecision: "rejected" };
|
|
1492
|
+
return { ...retargetResolvedStepProposal(state), lastDecision: "rejected" };
|
|
754
1493
|
}
|
|
755
1494
|
|
|
756
1495
|
const pendingRemoval = state.pendingRemoval;
|
|
757
1496
|
if (pendingRemoval) {
|
|
1497
|
+
const removedSteps: SubsystemTrailStepHistory[] = state.trails.flatMap(
|
|
1498
|
+
(trail) =>
|
|
1499
|
+
trail.steps.flatMap((step, stepIndex) =>
|
|
1500
|
+
step.from === pendingRemoval || step.to === pendingRemoval
|
|
1501
|
+
? [
|
|
1502
|
+
{
|
|
1503
|
+
trailId: trail.id,
|
|
1504
|
+
stepIndex,
|
|
1505
|
+
previous: step,
|
|
1506
|
+
kind: "removed" as const,
|
|
1507
|
+
},
|
|
1508
|
+
]
|
|
1509
|
+
: [],
|
|
1510
|
+
),
|
|
1511
|
+
);
|
|
758
1512
|
return {
|
|
759
1513
|
...state,
|
|
760
1514
|
removedComponentAliases: new Set([
|
|
@@ -768,6 +1522,7 @@ function resolveProposal(
|
|
|
768
1522
|
),
|
|
769
1523
|
})),
|
|
770
1524
|
lastDecision: "accepted",
|
|
1525
|
+
stepHistory: [...state.stepHistory, ...removedSteps],
|
|
771
1526
|
};
|
|
772
1527
|
}
|
|
773
1528
|
|
|
@@ -804,15 +1559,19 @@ function resolveProposal(
|
|
|
804
1559
|
const previous = state.trails.find(
|
|
805
1560
|
(trail) => trail.id === pendingStep.trailId,
|
|
806
1561
|
)?.steps[pendingStep.stepIndex];
|
|
807
|
-
|
|
1562
|
+
const next: DriveState = {
|
|
808
1563
|
...state,
|
|
1564
|
+
// Keep the original step in place and leave its variation after it: the
|
|
1565
|
+
// accepted row never moves, only its proposal colour is dropped.
|
|
809
1566
|
trails: state.trails.map((trail) =>
|
|
810
1567
|
trail.id === pendingStep.trailId
|
|
811
1568
|
? {
|
|
812
1569
|
...trail,
|
|
813
|
-
steps:
|
|
814
|
-
|
|
815
|
-
|
|
1570
|
+
steps: [
|
|
1571
|
+
...trail.steps.slice(0, pendingStep.stepIndex + 1),
|
|
1572
|
+
pendingStep.step,
|
|
1573
|
+
...trail.steps.slice(pendingStep.stepIndex + 1),
|
|
1574
|
+
],
|
|
816
1575
|
}
|
|
817
1576
|
: trail,
|
|
818
1577
|
),
|
|
@@ -824,8 +1583,18 @@ function resolveProposal(
|
|
|
824
1583
|
previous,
|
|
825
1584
|
}
|
|
826
1585
|
: null,
|
|
827
|
-
|
|
1586
|
+
stepHistory: previous
|
|
1587
|
+
? [
|
|
1588
|
+
{
|
|
1589
|
+
trailId: pendingStep.trailId,
|
|
1590
|
+
stepIndex: pendingStep.stepIndex,
|
|
1591
|
+
previous,
|
|
1592
|
+
kind: "changed",
|
|
1593
|
+
},
|
|
1594
|
+
]
|
|
1595
|
+
: [],
|
|
828
1596
|
};
|
|
1597
|
+
return retargetResolvedStepProposal(next);
|
|
829
1598
|
}
|
|
830
1599
|
|
|
831
1600
|
function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
@@ -868,10 +1637,9 @@ function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
|
868
1637
|
case "propose-trail": {
|
|
869
1638
|
// Append the proposal to the same guide, but keep the user's current
|
|
870
1639
|
// step. The header advertises the new step so they can opt into it.
|
|
871
|
-
const stepNo = (state.walkthrough?.steps.length ?? 5) + 1;
|
|
872
1640
|
const proposalStep: GuideStep = {
|
|
873
1641
|
id: "gs-propose-refund",
|
|
874
|
-
title:
|
|
1642
|
+
title: proposalStepTitle(state.walkthrough, "Confirm refund trail"),
|
|
875
1643
|
trailId: event.trail.id,
|
|
876
1644
|
stepIndex: 0,
|
|
877
1645
|
showFile: false,
|
|
@@ -891,14 +1659,14 @@ function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
|
891
1659
|
};
|
|
892
1660
|
}
|
|
893
1661
|
case "propose-step": {
|
|
894
|
-
//
|
|
895
|
-
//
|
|
896
|
-
|
|
1662
|
+
// Focus the staged replacement, not the step it replaces. The graph's
|
|
1663
|
+
// before/after links keep the existing step framed beside it, and the
|
|
1664
|
+
// different index avoids re-triggering the previous step's focus toggle.
|
|
897
1665
|
const proposalStep: GuideStep = {
|
|
898
1666
|
id: "sp-propose-refund",
|
|
899
|
-
title:
|
|
1667
|
+
title: proposalStepTitle(state.walkthrough, "Confirm refund step"),
|
|
900
1668
|
trailId: event.trailId,
|
|
901
|
-
stepIndex: event.stepIndex,
|
|
1669
|
+
stepIndex: event.stepIndex + 1,
|
|
902
1670
|
showFile: false,
|
|
903
1671
|
proposal: "step",
|
|
904
1672
|
body: event.rationale,
|
|
@@ -911,7 +1679,7 @@ function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
|
911
1679
|
step: event.step,
|
|
912
1680
|
},
|
|
913
1681
|
stepChange: null,
|
|
914
|
-
|
|
1682
|
+
stepHistory: [],
|
|
915
1683
|
lastDecision: null,
|
|
916
1684
|
walkthrough: state.walkthrough
|
|
917
1685
|
? {
|
|
@@ -922,10 +1690,9 @@ function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
|
922
1690
|
};
|
|
923
1691
|
}
|
|
924
1692
|
case "propose-component": {
|
|
925
|
-
const stepNo = (state.walkthrough?.steps.length ?? 2) + 1;
|
|
926
1693
|
const proposalStep: GuideStep = {
|
|
927
1694
|
id: "cp-propose-refund-service",
|
|
928
|
-
title:
|
|
1695
|
+
title: proposalStepTitle(state.walkthrough, "Confirm component"),
|
|
929
1696
|
trailId: event.trail.id,
|
|
930
1697
|
stepIndex: 0,
|
|
931
1698
|
showFile: false,
|
|
@@ -946,10 +1713,12 @@ function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
|
946
1713
|
};
|
|
947
1714
|
}
|
|
948
1715
|
case "propose-component-removal": {
|
|
949
|
-
const stepNo = (state.walkthrough?.steps.length ?? 2) + 1;
|
|
950
1716
|
const proposalStep: GuideStep = {
|
|
951
1717
|
id: "mr-propose-remove-mailer",
|
|
952
|
-
title:
|
|
1718
|
+
title: proposalStepTitle(
|
|
1719
|
+
state.walkthrough,
|
|
1720
|
+
"Retire confirmation mailer",
|
|
1721
|
+
),
|
|
953
1722
|
trailId: "wt-book",
|
|
954
1723
|
showFile: false,
|
|
955
1724
|
proposal: "removal",
|
|
@@ -958,6 +1727,8 @@ function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
|
958
1727
|
return {
|
|
959
1728
|
...state,
|
|
960
1729
|
pendingRemoval: event.componentAlias,
|
|
1730
|
+
stepChange: null,
|
|
1731
|
+
stepHistory: [],
|
|
961
1732
|
lastDecision: null,
|
|
962
1733
|
walkthrough: state.walkthrough
|
|
963
1734
|
? {
|
|
@@ -972,7 +1743,7 @@ function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
|
972
1743
|
}
|
|
973
1744
|
}
|
|
974
1745
|
|
|
975
|
-
/** Shared theme tokens
|
|
1746
|
+
/** Shared theme tokens plus the host-local proposal color for prototype chrome. */
|
|
976
1747
|
function usePrototypeTheme() {
|
|
977
1748
|
const { theme } = useTheme();
|
|
978
1749
|
return {
|
|
@@ -980,7 +1751,7 @@ function usePrototypeTheme() {
|
|
|
980
1751
|
border: theme.colors.border ?? "#2d3034",
|
|
981
1752
|
muted: theme.colors.textMuted ?? theme.colors.textSecondary ?? "#8b95a3",
|
|
982
1753
|
accent: theme.colors.accent ?? theme.colors.primary ?? "#a78bfa",
|
|
983
|
-
|
|
1754
|
+
proposal: HOST_PROPOSAL_COLOR,
|
|
984
1755
|
mono: theme.fonts.monospace,
|
|
985
1756
|
small: theme.fontSizes[0],
|
|
986
1757
|
body: theme.fontSizes[1],
|
|
@@ -990,11 +1761,62 @@ function usePrototypeTheme() {
|
|
|
990
1761
|
// Slow enough to read each tool call and watch the camera settle between steps.
|
|
991
1762
|
const AUTOPLAY_INTERVAL_MS = 1800;
|
|
992
1763
|
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1764
|
+
const prototypeAnimationStyles = `
|
|
1765
|
+
@keyframes agent-working-star {
|
|
1766
|
+
0%, 100% { opacity: 0.45; }
|
|
1767
|
+
50% { opacity: 1; }
|
|
1768
|
+
}
|
|
1769
|
+
/* Only the sparkle arms twinkle; the wand, icon, and status dot stay put. */
|
|
1770
|
+
.agent-working-icon path:nth-of-type(n+3) {
|
|
1771
|
+
animation: agent-working-star 1.6s ease-in-out infinite;
|
|
1772
|
+
}
|
|
1773
|
+
.agent-working-icon path:nth-of-type(3),
|
|
1774
|
+
.agent-working-icon path:nth-of-type(6) {
|
|
1775
|
+
animation-delay: 0s;
|
|
1776
|
+
}
|
|
1777
|
+
.agent-working-icon path:nth-of-type(4),
|
|
1778
|
+
.agent-working-icon path:nth-of-type(7) {
|
|
1779
|
+
animation-delay: -0.55s;
|
|
1780
|
+
}
|
|
1781
|
+
.agent-working-icon path:nth-of-type(5),
|
|
1782
|
+
.agent-working-icon path:nth-of-type(8) {
|
|
1783
|
+
animation-delay: -1.1s;
|
|
1784
|
+
}
|
|
1785
|
+
@keyframes agent-model-opening-in {
|
|
1786
|
+
from {
|
|
1787
|
+
opacity: 0;
|
|
1788
|
+
transform: translateY(22px) scale(0.985);
|
|
1789
|
+
filter: blur(4px);
|
|
1790
|
+
}
|
|
1791
|
+
to {
|
|
1792
|
+
opacity: 1;
|
|
1793
|
+
transform: translateY(0) scale(1);
|
|
1794
|
+
filter: blur(0);
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
.agent-model-opening {
|
|
1798
|
+
animation: agent-model-opening-in 700ms cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
1799
|
+
transform-origin: 50% 35%;
|
|
1800
|
+
}
|
|
1801
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1802
|
+
.agent-working-dot,
|
|
1803
|
+
.agent-working-icon,
|
|
1804
|
+
.agent-working-icon path:nth-of-type(n+3) {
|
|
1805
|
+
animation: none !important;
|
|
1806
|
+
}
|
|
1807
|
+
.agent-model-opening {
|
|
1808
|
+
animation: none !important;
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
`;
|
|
1812
|
+
|
|
1813
|
+
type ToolStreamEvent = DriveEvent | MultiDriveEvent;
|
|
1814
|
+
|
|
1815
|
+
function ToolRow({ event }: { event: ToolStreamEvent }) {
|
|
1816
|
+
const { theme, border, muted, accent, mono, small } = usePrototypeTheme();
|
|
1817
|
+
const isAgentEvent =
|
|
1818
|
+
event.kind === "agent" ||
|
|
1819
|
+
event.kind === "agent-working" ||
|
|
998
1820
|
event.kind === "agent-decision";
|
|
999
1821
|
const label =
|
|
1000
1822
|
event.kind === "prompt"
|
|
@@ -1017,7 +1839,18 @@ function ToolRow({ event }: { event: DriveEvent }) {
|
|
|
1017
1839
|
? `add ${event.trail.id}`
|
|
1018
1840
|
: event.kind === "propose-component"
|
|
1019
1841
|
? `add ${event.component.alias} + ${event.trail.id}`
|
|
1020
|
-
:
|
|
1842
|
+
: event.kind === "propose-step" ||
|
|
1843
|
+
event.kind === "propose-component-removal"
|
|
1844
|
+
? `change ${event.kind === "propose-step" ? event.trailId : event.componentAlias}${event.kind === "propose-step" ? ` step ${event.stepIndex + 1}` : ""}`
|
|
1845
|
+
: event.kind === "open-proposal-context"
|
|
1846
|
+
? `${event.change.proposals.length} proposals · ${event.change.name}`
|
|
1847
|
+
: event.kind === "activate-proposal"
|
|
1848
|
+
? `focus ${event.proposalId}`
|
|
1849
|
+
: event.kind === "open-source-model"
|
|
1850
|
+
? `${event.sourceModelId} · ${event.sourceTrailId}`
|
|
1851
|
+
: event.kind === "return-to-proposal"
|
|
1852
|
+
? "return to proposal view"
|
|
1853
|
+
: event.text;
|
|
1021
1854
|
|
|
1022
1855
|
return (
|
|
1023
1856
|
<div
|
|
@@ -1065,7 +1898,7 @@ function Prototype({
|
|
|
1065
1898
|
persistKey: string;
|
|
1066
1899
|
description: string;
|
|
1067
1900
|
}) {
|
|
1068
|
-
const { theme, border, muted, accent,
|
|
1901
|
+
const { theme, border, muted, accent, proposal, mono, small, body } =
|
|
1069
1902
|
usePrototypeTheme();
|
|
1070
1903
|
const openingEventCount = useMemo(
|
|
1071
1904
|
() => openingEventCountFor(events),
|
|
@@ -1152,17 +1985,21 @@ function Prototype({
|
|
|
1152
1985
|
) {
|
|
1153
1986
|
return [...state.trails, pendingTrail];
|
|
1154
1987
|
}
|
|
1988
|
+
// The staged variation sits directly after the step it varies. It stays
|
|
1989
|
+
// there after acceptance — only its colour changes.
|
|
1155
1990
|
const pendingStep = state.pendingStep;
|
|
1156
|
-
if (!pendingStep || state.lastDecision
|
|
1991
|
+
if (!pendingStep || state.lastDecision) {
|
|
1157
1992
|
return state.trails;
|
|
1158
1993
|
}
|
|
1159
1994
|
return state.trails.map((trail) =>
|
|
1160
1995
|
trail.id === pendingStep.trailId
|
|
1161
1996
|
? {
|
|
1162
1997
|
...trail,
|
|
1163
|
-
steps:
|
|
1164
|
-
|
|
1165
|
-
|
|
1998
|
+
steps: [
|
|
1999
|
+
...trail.steps.slice(0, pendingStep.stepIndex + 1),
|
|
2000
|
+
pendingStep.step,
|
|
2001
|
+
...trail.steps.slice(pendingStep.stepIndex + 1),
|
|
2002
|
+
],
|
|
1166
2003
|
}
|
|
1167
2004
|
: trail,
|
|
1168
2005
|
);
|
|
@@ -1181,6 +2018,9 @@ function Prototype({
|
|
|
1181
2018
|
activeGuideIndex >= 0 && state.walkthrough
|
|
1182
2019
|
? state.walkthrough.steps[activeGuideIndex]
|
|
1183
2020
|
: undefined;
|
|
2021
|
+
const activeGuideLabel =
|
|
2022
|
+
activeGuideStep?.title.match(/^\s*(\d+[a-z]?)\s*·/i)?.[1] ??
|
|
2023
|
+
String(activeGuideIndex + 1);
|
|
1184
2024
|
const hasProposalStep =
|
|
1185
2025
|
state.walkthrough?.steps.some((s) => s.proposal) ?? false;
|
|
1186
2026
|
|
|
@@ -1254,6 +2094,30 @@ function Prototype({
|
|
|
1254
2094
|
});
|
|
1255
2095
|
}, [activeGuideStep, visibleTrails]);
|
|
1256
2096
|
|
|
2097
|
+
// The staged replacement variations of one step are a single focus group:
|
|
2098
|
+
// the guide names one of them, but the panel and camera frame them together.
|
|
2099
|
+
const focusedVariationStepIndexes = useMemo(() => {
|
|
2100
|
+
const pending = state.pendingStep;
|
|
2101
|
+
if (!pending || state.lastDecision === "rejected") return undefined;
|
|
2102
|
+
if (state.lastDecision && !state.stepChange) return undefined;
|
|
2103
|
+
return new Map<string, ReadonlySet<number>>([
|
|
2104
|
+
[pending.trailId, new Set([pending.stepIndex, pending.stepIndex + 1])],
|
|
2105
|
+
]);
|
|
2106
|
+
}, [state.pendingStep, state.lastDecision, state.stepChange]);
|
|
2107
|
+
|
|
2108
|
+
// Once accepted, the variation keeps its `2a` label in the panel even though
|
|
2109
|
+
// it is now an ordinary step in the host-local trails.
|
|
2110
|
+
const acceptedStepNumberLabels = useMemo(() => {
|
|
2111
|
+
const pending = state.pendingStep;
|
|
2112
|
+
if (!state.lastDecision || !pending || !state.stepChange) return undefined;
|
|
2113
|
+
return new Map<string, string>([
|
|
2114
|
+
[
|
|
2115
|
+
emphasisKey(pending.trailId, pending.step),
|
|
2116
|
+
variationStepNumber(pending.stepIndex + 1),
|
|
2117
|
+
],
|
|
2118
|
+
]);
|
|
2119
|
+
}, [state.lastDecision, state.pendingStep, state.stepChange]);
|
|
2120
|
+
|
|
1257
2121
|
const focusedTrailStep = useMemo(() => {
|
|
1258
2122
|
if (!state.walkthrough) return undefined;
|
|
1259
2123
|
if (!activeGuideStep) return null;
|
|
@@ -1282,13 +2146,6 @@ function Prototype({
|
|
|
1282
2146
|
[],
|
|
1283
2147
|
);
|
|
1284
2148
|
|
|
1285
|
-
const togglePreviousStep = useCallback(() => {
|
|
1286
|
-
setState((prev) => ({
|
|
1287
|
-
...prev,
|
|
1288
|
-
showPreviousStep: !prev.showPreviousStep,
|
|
1289
|
-
}));
|
|
1290
|
-
}, []);
|
|
1291
|
-
|
|
1292
2149
|
const moveWalkthroughStep = useCallback((delta: number) => {
|
|
1293
2150
|
setState((prev) => {
|
|
1294
2151
|
const walkthrough = prev.walkthrough;
|
|
@@ -1355,130 +2212,94 @@ function Prototype({
|
|
|
1355
2212
|
: "Awaiting agent decision";
|
|
1356
2213
|
|
|
1357
2214
|
const guidePanel =
|
|
2215
|
+
state.walkthrough && activeGuideStep && hasProposalStep ? (
|
|
2216
|
+
<div style={{ fontFamily: mono, color: theme.colors.text }}>
|
|
2217
|
+
<span
|
|
2218
|
+
style={{
|
|
2219
|
+
fontSize: small,
|
|
2220
|
+
letterSpacing: "0.04em",
|
|
2221
|
+
fontWeight: 600,
|
|
2222
|
+
color: proposal,
|
|
2223
|
+
whiteSpace: "nowrap",
|
|
2224
|
+
}}
|
|
2225
|
+
>
|
|
2226
|
+
PROPOSAL ADDED
|
|
2227
|
+
{state.lastDecision === "accepted"
|
|
2228
|
+
? " · ACCEPTED"
|
|
2229
|
+
: state.lastDecision === "rejected"
|
|
2230
|
+
? " · DECLINED"
|
|
2231
|
+
: ""}
|
|
2232
|
+
</span>
|
|
2233
|
+
</div>
|
|
2234
|
+
) : null;
|
|
2235
|
+
|
|
2236
|
+
// Navigation sits on the canvas, directly above the active step card.
|
|
2237
|
+
const stepNavigation =
|
|
1358
2238
|
state.walkthrough && activeGuideStep ? (
|
|
1359
2239
|
<div
|
|
1360
2240
|
style={{
|
|
1361
|
-
|
|
1362
|
-
|
|
2241
|
+
display: "flex",
|
|
2242
|
+
alignItems: "center",
|
|
2243
|
+
gap: 8,
|
|
2244
|
+
pointerEvents: "auto",
|
|
1363
2245
|
}}
|
|
1364
2246
|
>
|
|
1365
|
-
<
|
|
2247
|
+
<button
|
|
2248
|
+
type="button"
|
|
2249
|
+
onClick={() => moveWalkthroughStep(-1)}
|
|
2250
|
+
disabled={activeGuideIndex === 0}
|
|
1366
2251
|
style={{
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
2252
|
+
padding: "4px 10px",
|
|
2253
|
+
borderRadius: 4,
|
|
2254
|
+
border: `1px solid ${border}`,
|
|
2255
|
+
background: "transparent",
|
|
2256
|
+
color: muted,
|
|
2257
|
+
fontFamily: mono,
|
|
2258
|
+
fontSize: small,
|
|
2259
|
+
cursor: activeGuideIndex === 0 ? "default" : "pointer",
|
|
2260
|
+
opacity: activeGuideIndex === 0 ? 0.5 : 1,
|
|
1370
2261
|
}}
|
|
1371
2262
|
>
|
|
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
|
|
2263
|
+
Previous
|
|
2264
|
+
</button>
|
|
2265
|
+
<span
|
|
1415
2266
|
style={{
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
2267
|
+
textAlign: "center",
|
|
2268
|
+
fontSize: small,
|
|
2269
|
+
color: muted,
|
|
2270
|
+
whiteSpace: "nowrap",
|
|
1420
2271
|
}}
|
|
1421
2272
|
>
|
|
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>
|
|
2273
|
+
STEP {activeGuideLabel} OF {state.walkthrough.steps.length}
|
|
2274
|
+
</span>
|
|
2275
|
+
<button
|
|
2276
|
+
type="button"
|
|
2277
|
+
onClick={() => moveWalkthroughStep(1)}
|
|
2278
|
+
disabled={activeGuideIndex === state.walkthrough.steps.length - 1}
|
|
2279
|
+
style={{
|
|
2280
|
+
padding: "4px 10px",
|
|
2281
|
+
borderRadius: 4,
|
|
2282
|
+
border: `1px solid ${accent}`,
|
|
2283
|
+
background: `${accent}18`,
|
|
2284
|
+
color: accent,
|
|
2285
|
+
fontFamily: mono,
|
|
2286
|
+
fontSize: small,
|
|
2287
|
+
fontWeight: 600,
|
|
2288
|
+
cursor:
|
|
2289
|
+
activeGuideIndex === state.walkthrough.steps.length - 1
|
|
2290
|
+
? "default"
|
|
2291
|
+
: "pointer",
|
|
2292
|
+
opacity:
|
|
2293
|
+
activeGuideIndex === state.walkthrough.steps.length - 1 ? 0.5 : 1,
|
|
2294
|
+
}}
|
|
2295
|
+
>
|
|
2296
|
+
Next step
|
|
2297
|
+
</button>
|
|
1477
2298
|
</div>
|
|
1478
2299
|
) : null;
|
|
1479
2300
|
|
|
1480
2301
|
// The active step sits above the map so the instruction is read where the
|
|
1481
|
-
// camera is moving. The question
|
|
2302
|
+
// camera is moving. The question stays in the left rail.
|
|
1482
2303
|
const guideStepCard =
|
|
1483
2304
|
state.walkthrough && activeGuideStep ? (
|
|
1484
2305
|
<div
|
|
@@ -1517,7 +2338,7 @@ function Prototype({
|
|
|
1517
2338
|
{proposalPending ? (
|
|
1518
2339
|
<div
|
|
1519
2340
|
aria-live="polite"
|
|
1520
|
-
style={{ marginTop: 10, fontSize: small, color:
|
|
2341
|
+
style={{ marginTop: 10, fontSize: small, color: proposal }}
|
|
1521
2342
|
>
|
|
1522
2343
|
{proposalStatus}
|
|
1523
2344
|
</div>
|
|
@@ -1537,7 +2358,7 @@ function Prototype({
|
|
|
1537
2358
|
gap: 8,
|
|
1538
2359
|
padding: "6px 12px",
|
|
1539
2360
|
borderRadius: 999,
|
|
1540
|
-
border: `1px solid ${state.agentWorkingOn ? accent :
|
|
2361
|
+
border: `1px solid ${state.agentWorkingOn ? accent : proposal}`,
|
|
1541
2362
|
background:
|
|
1542
2363
|
theme.colors.backgroundSecondary ?? theme.colors.background,
|
|
1543
2364
|
boxShadow: "0 6px 20px rgba(0,0,0,0.35)",
|
|
@@ -1566,7 +2387,7 @@ function Prototype({
|
|
|
1566
2387
|
</span>
|
|
1567
2388
|
</>
|
|
1568
2389
|
) : (
|
|
1569
|
-
<span style={{ color:
|
|
2390
|
+
<span style={{ color: proposal, fontWeight: 600 }}>
|
|
1570
2391
|
{state.lastDecision === "accepted"
|
|
1571
2392
|
? "AGENT COMMITTED PROPOSAL"
|
|
1572
2393
|
: "AGENT DECLINED PROPOSAL"}
|
|
@@ -1575,10 +2396,10 @@ function Prototype({
|
|
|
1575
2396
|
</div>
|
|
1576
2397
|
) : null;
|
|
1577
2398
|
|
|
1578
|
-
//
|
|
1579
|
-
// status
|
|
2399
|
+
// Navigation, the step card and agent status float as one stack over the
|
|
2400
|
+
// map: buttons on top, status directly beneath the card.
|
|
1580
2401
|
const graphCardStack =
|
|
1581
|
-
guideStepCard || agentStatusOverlay ? (
|
|
2402
|
+
stepNavigation || guideStepCard || agentStatusOverlay ? (
|
|
1582
2403
|
<div
|
|
1583
2404
|
style={{
|
|
1584
2405
|
position: "absolute",
|
|
@@ -1595,6 +2416,7 @@ function Prototype({
|
|
|
1595
2416
|
maxWidth: "calc(100% - 32px)",
|
|
1596
2417
|
}}
|
|
1597
2418
|
>
|
|
2419
|
+
{stepNavigation}
|
|
1598
2420
|
{guideStepCard}
|
|
1599
2421
|
{agentStatusOverlay}
|
|
1600
2422
|
</div>
|
|
@@ -1678,54 +2500,7 @@ function Prototype({
|
|
|
1678
2500
|
background: theme.colors.background,
|
|
1679
2501
|
}}
|
|
1680
2502
|
>
|
|
1681
|
-
<style>{
|
|
1682
|
-
@keyframes agent-working-star {
|
|
1683
|
-
0%, 100% { opacity: 0.45; }
|
|
1684
|
-
50% { opacity: 1; }
|
|
1685
|
-
}
|
|
1686
|
-
/* Only the sparkle arms twinkle; the wand, icon, and status dot stay put. */
|
|
1687
|
-
.agent-working-icon path:nth-of-type(n+3) {
|
|
1688
|
-
animation: agent-working-star 1.6s ease-in-out infinite;
|
|
1689
|
-
}
|
|
1690
|
-
.agent-working-icon path:nth-of-type(3),
|
|
1691
|
-
.agent-working-icon path:nth-of-type(6) {
|
|
1692
|
-
animation-delay: 0s;
|
|
1693
|
-
}
|
|
1694
|
-
.agent-working-icon path:nth-of-type(4),
|
|
1695
|
-
.agent-working-icon path:nth-of-type(7) {
|
|
1696
|
-
animation-delay: -0.55s;
|
|
1697
|
-
}
|
|
1698
|
-
.agent-working-icon path:nth-of-type(5),
|
|
1699
|
-
.agent-working-icon path:nth-of-type(8) {
|
|
1700
|
-
animation-delay: -1.1s;
|
|
1701
|
-
}
|
|
1702
|
-
@keyframes agent-model-opening-in {
|
|
1703
|
-
from {
|
|
1704
|
-
opacity: 0;
|
|
1705
|
-
transform: translateY(22px) scale(0.985);
|
|
1706
|
-
filter: blur(4px);
|
|
1707
|
-
}
|
|
1708
|
-
to {
|
|
1709
|
-
opacity: 1;
|
|
1710
|
-
transform: translateY(0) scale(1);
|
|
1711
|
-
filter: blur(0);
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
.agent-model-opening {
|
|
1715
|
-
animation: agent-model-opening-in 700ms cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
1716
|
-
transform-origin: 50% 35%;
|
|
1717
|
-
}
|
|
1718
|
-
@media (prefers-reduced-motion: reduce) {
|
|
1719
|
-
.agent-working-dot,
|
|
1720
|
-
.agent-working-icon,
|
|
1721
|
-
.agent-working-icon path:nth-of-type(n+3) {
|
|
1722
|
-
animation: none !important;
|
|
1723
|
-
}
|
|
1724
|
-
.agent-model-opening {
|
|
1725
|
-
animation: none !important;
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
`}</style>
|
|
2503
|
+
<style>{prototypeAnimationStyles}</style>
|
|
1729
2504
|
{state.modelOpen ? (
|
|
1730
2505
|
<div
|
|
1731
2506
|
key={openingKey}
|
|
@@ -1743,6 +2518,7 @@ function Prototype({
|
|
|
1743
2518
|
components={visibleComponents}
|
|
1744
2519
|
trails={visibleTrails}
|
|
1745
2520
|
focusedTrailStep={focusedTrailStep}
|
|
2521
|
+
focusedVariationStepIndexes={focusedVariationStepIndexes}
|
|
1746
2522
|
proposedTrailIds={
|
|
1747
2523
|
state.pendingTrail && !state.lastDecision
|
|
1748
2524
|
? new Set([state.pendingTrail.id])
|
|
@@ -1758,9 +2534,14 @@ function Prototype({
|
|
|
1758
2534
|
])
|
|
1759
2535
|
: undefined
|
|
1760
2536
|
}
|
|
2537
|
+
stepNumberLabels={acceptedStepNumberLabels}
|
|
2538
|
+
proposedStep={
|
|
2539
|
+
state.pendingStep && !state.lastDecision
|
|
2540
|
+
? state.pendingStep
|
|
2541
|
+
: null
|
|
2542
|
+
}
|
|
1761
2543
|
stepChange={state.stepChange}
|
|
1762
|
-
|
|
1763
|
-
onTogglePreviousStep={togglePreviousStep}
|
|
2544
|
+
stepHistory={state.stepHistory}
|
|
1764
2545
|
proposedComponentAliases={
|
|
1765
2546
|
state.pendingComponent && !state.lastDecision
|
|
1766
2547
|
? new Set([state.pendingComponent.alias])
|
|
@@ -1929,79 +2710,861 @@ function Prototype({
|
|
|
1929
2710
|
);
|
|
1930
2711
|
}
|
|
1931
2712
|
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
2713
|
+
type MultiDriveState = {
|
|
2714
|
+
modelOpen: boolean;
|
|
2715
|
+
change: HostChange | null;
|
|
2716
|
+
activeProposalId: string | null;
|
|
2717
|
+
view: "proposal" | "source";
|
|
2718
|
+
sourceModelId: SourceModelId | null;
|
|
2719
|
+
sourceTrailId: string | null;
|
|
2720
|
+
agentWorkingOn: string | null;
|
|
2721
|
+
decision: "accepted" | "rejected" | null;
|
|
1941
2722
|
};
|
|
1942
2723
|
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
};
|
|
2724
|
+
const initialMultiState = (): MultiDriveState => ({
|
|
2725
|
+
modelOpen: false,
|
|
2726
|
+
change: null,
|
|
2727
|
+
activeProposalId: null,
|
|
2728
|
+
view: "proposal",
|
|
2729
|
+
sourceModelId: null,
|
|
2730
|
+
sourceTrailId: null,
|
|
2731
|
+
agentWorkingOn: null,
|
|
2732
|
+
decision: null,
|
|
2733
|
+
});
|
|
1953
2734
|
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
2735
|
+
function applyMultiEvent(
|
|
2736
|
+
event: MultiDriveEvent,
|
|
2737
|
+
state: MultiDriveState,
|
|
2738
|
+
): MultiDriveState {
|
|
2739
|
+
switch (event.kind) {
|
|
2740
|
+
case "open-model":
|
|
2741
|
+
return { ...state, modelOpen: true };
|
|
2742
|
+
case "agent":
|
|
2743
|
+
return { ...state, agentWorkingOn: null };
|
|
2744
|
+
case "agent-working":
|
|
2745
|
+
return { ...state, agentWorkingOn: event.workingOn };
|
|
2746
|
+
case "agent-decision":
|
|
2747
|
+
return {
|
|
2748
|
+
...state,
|
|
2749
|
+
decision: event.decision,
|
|
2750
|
+
agentWorkingOn: null,
|
|
2751
|
+
change: state.change
|
|
2752
|
+
? {
|
|
2753
|
+
...state.change,
|
|
2754
|
+
status: event.decision,
|
|
2755
|
+
proposals: state.change.proposals.map((proposal) => ({
|
|
2756
|
+
...proposal,
|
|
2757
|
+
status: event.decision,
|
|
2758
|
+
})),
|
|
2759
|
+
}
|
|
2760
|
+
: state.change,
|
|
2761
|
+
};
|
|
2762
|
+
case "open-proposal-context":
|
|
2763
|
+
return {
|
|
2764
|
+
...state,
|
|
2765
|
+
change: event.change,
|
|
2766
|
+
activeProposalId: event.change.proposals[0]?.id ?? null,
|
|
2767
|
+
view: "proposal",
|
|
2768
|
+
sourceModelId: null,
|
|
2769
|
+
sourceTrailId: null,
|
|
2770
|
+
};
|
|
2771
|
+
case "activate-proposal":
|
|
2772
|
+
return {
|
|
2773
|
+
...state,
|
|
2774
|
+
activeProposalId: event.proposalId,
|
|
2775
|
+
view: "proposal",
|
|
2776
|
+
sourceModelId: null,
|
|
2777
|
+
sourceTrailId: null,
|
|
2778
|
+
};
|
|
2779
|
+
case "open-source-model":
|
|
2780
|
+
return {
|
|
2781
|
+
...state,
|
|
2782
|
+
view: "source",
|
|
2783
|
+
sourceModelId: event.sourceModelId,
|
|
2784
|
+
sourceTrailId: event.sourceTrailId,
|
|
2785
|
+
agentWorkingOn: null,
|
|
2786
|
+
};
|
|
2787
|
+
case "return-to-proposal":
|
|
2788
|
+
return {
|
|
2789
|
+
...state,
|
|
2790
|
+
view: "proposal",
|
|
2791
|
+
sourceModelId: null,
|
|
2792
|
+
sourceTrailId: null,
|
|
2793
|
+
};
|
|
2794
|
+
default:
|
|
2795
|
+
return state;
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
1964
2798
|
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
2799
|
+
function MultiProposalPrototype({
|
|
2800
|
+
events,
|
|
2801
|
+
title,
|
|
2802
|
+
persistKey,
|
|
2803
|
+
description,
|
|
2804
|
+
}: {
|
|
2805
|
+
events: MultiDriveEvent[];
|
|
2806
|
+
title: string;
|
|
2807
|
+
persistKey: string;
|
|
2808
|
+
description: string;
|
|
2809
|
+
}) {
|
|
2810
|
+
const { theme, border, muted, accent, proposal, mono, small, body } =
|
|
2811
|
+
usePrototypeTheme();
|
|
2812
|
+
const openingEventCount = useMemo(
|
|
2813
|
+
() => openingEventCountFor(events),
|
|
2814
|
+
[events],
|
|
2815
|
+
);
|
|
2816
|
+
const [state, setState] = useState<MultiDriveState>(initialMultiState);
|
|
2817
|
+
const [cursor, setCursor] = useState(0);
|
|
2818
|
+
const [playing, setPlaying] = useState(false);
|
|
2819
|
+
const [openingKey, setOpeningKey] = useState(0);
|
|
2820
|
+
const [proposalMenuOpen, setProposalMenuOpen] = useState(false);
|
|
2821
|
+
const proposalMenuRef = useRef<HTMLDivElement>(null);
|
|
1975
2822
|
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
description="The same narrated trail proposal, but the agent declines it in conversation and the visible model stays unchanged."
|
|
1983
|
-
/>
|
|
1984
|
-
),
|
|
1985
|
-
};
|
|
2823
|
+
const applyDriveEvent = useCallback((event: MultiDriveEvent) => {
|
|
2824
|
+
setState((prev) => applyMultiEvent(event, prev));
|
|
2825
|
+
if (event.kind === "open-model") {
|
|
2826
|
+
setOpeningKey((prev) => prev + 1);
|
|
2827
|
+
}
|
|
2828
|
+
}, []);
|
|
1986
2829
|
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
title="Agent-driven step change · declined"
|
|
1992
|
-
persistKey="agent-driven-step-change-declined-prototype"
|
|
1993
|
-
description="The agent reviews the staged step change, declines it, and the original step remains in the trail."
|
|
1994
|
-
/>
|
|
1995
|
-
),
|
|
1996
|
-
};
|
|
2830
|
+
// Agent-driven proposal switches and source-model drill-outs close the menu.
|
|
2831
|
+
useEffect(() => {
|
|
2832
|
+
setProposalMenuOpen(false);
|
|
2833
|
+
}, [state.activeProposalId, state.view]);
|
|
1997
2834
|
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2835
|
+
useEffect(() => {
|
|
2836
|
+
if (!proposalMenuOpen) return;
|
|
2837
|
+
const onPointerDown = (event: PointerEvent) => {
|
|
2838
|
+
if (!proposalMenuRef.current?.contains(event.target as Node)) {
|
|
2839
|
+
setProposalMenuOpen(false);
|
|
2840
|
+
}
|
|
2841
|
+
};
|
|
2842
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
2843
|
+
if (event.key === "Escape") setProposalMenuOpen(false);
|
|
2844
|
+
};
|
|
2845
|
+
window.addEventListener("pointerdown", onPointerDown);
|
|
2846
|
+
window.addEventListener("keydown", onKeyDown);
|
|
2847
|
+
return () => {
|
|
2848
|
+
window.removeEventListener("pointerdown", onPointerDown);
|
|
2849
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
2850
|
+
};
|
|
2851
|
+
}, [proposalMenuOpen]);
|
|
2852
|
+
|
|
2853
|
+
useEffect(() => {
|
|
2854
|
+
if (!playing) return;
|
|
2855
|
+
if (cursor >= events.length) {
|
|
2856
|
+
setPlaying(false);
|
|
2857
|
+
return;
|
|
2858
|
+
}
|
|
2859
|
+
const timer = window.setTimeout(() => {
|
|
2860
|
+
applyDriveEvent(events[cursor]!);
|
|
2861
|
+
setCursor((prev) => prev + 1);
|
|
2862
|
+
}, AUTOPLAY_INTERVAL_MS);
|
|
2863
|
+
return () => window.clearTimeout(timer);
|
|
2864
|
+
}, [cursor, playing, events, applyDriveEvent]);
|
|
2865
|
+
|
|
2866
|
+
const reset = useCallback(() => {
|
|
2867
|
+
setState(initialMultiState());
|
|
2868
|
+
setCursor(0);
|
|
2869
|
+
setPlaying(false);
|
|
2870
|
+
}, []);
|
|
2871
|
+
|
|
2872
|
+
const animateOpening = useCallback(() => {
|
|
2873
|
+
setState(initialMultiState());
|
|
2874
|
+
events.slice(0, openingEventCount).forEach(applyDriveEvent);
|
|
2875
|
+
setCursor(openingEventCount);
|
|
2876
|
+
setPlaying(true);
|
|
2877
|
+
}, [applyDriveEvent, events, openingEventCount]);
|
|
2878
|
+
|
|
2879
|
+
const step = useCallback(() => {
|
|
2880
|
+
if (cursor >= events.length) return;
|
|
2881
|
+
applyDriveEvent(events[cursor]!);
|
|
2882
|
+
setCursor((prev) => prev + 1);
|
|
2883
|
+
}, [cursor, events, applyDriveEvent]);
|
|
2884
|
+
|
|
2885
|
+
const change = state.change;
|
|
2886
|
+
const activeProposal = change?.proposals.find(
|
|
2887
|
+
(candidate) => candidate.id === state.activeProposalId,
|
|
2888
|
+
);
|
|
2889
|
+
const activeIndex = change?.proposals.findIndex(
|
|
2890
|
+
(candidate) => candidate.id === state.activeProposalId,
|
|
2891
|
+
);
|
|
2892
|
+
const synthetic = useMemo(
|
|
2893
|
+
() =>
|
|
2894
|
+
change
|
|
2895
|
+
? buildSyntheticModel(
|
|
2896
|
+
change,
|
|
2897
|
+
activeProposal,
|
|
2898
|
+
state.decision === "accepted",
|
|
2899
|
+
)
|
|
2900
|
+
: {
|
|
2901
|
+
components: [],
|
|
2902
|
+
trails: [],
|
|
2903
|
+
removedComponentAliases: new Set<string>(),
|
|
2904
|
+
stepHistory: [] as SubsystemTrailStepHistory[],
|
|
2905
|
+
},
|
|
2906
|
+
[change, activeProposal, state.decision],
|
|
2907
|
+
);
|
|
2908
|
+
|
|
2909
|
+
const sourceModel = state.sourceModelId
|
|
2910
|
+
? sourceModels[state.sourceModelId]
|
|
2911
|
+
: undefined;
|
|
2912
|
+
const sourceTrail = sourceModel?.trails.find(
|
|
2913
|
+
(trail) => trail.id === state.sourceTrailId,
|
|
2914
|
+
);
|
|
2915
|
+
const activeSourceRef = activeProposal?.context.find(
|
|
2916
|
+
(ref) =>
|
|
2917
|
+
ref.modelId === state.sourceModelId &&
|
|
2918
|
+
ref.trailId === state.sourceTrailId,
|
|
2919
|
+
);
|
|
2920
|
+
const sourceStepIndex = sourceTrail?.steps.findIndex(
|
|
2921
|
+
(candidate) => stepClaimKey(candidate) === activeSourceRef?.stepKey,
|
|
2922
|
+
);
|
|
2923
|
+
|
|
2924
|
+
const graphComponents =
|
|
2925
|
+
state.view === "source" && sourceModel
|
|
2926
|
+
? sourceModel.components
|
|
2927
|
+
: synthetic.components;
|
|
2928
|
+
const graphTrails =
|
|
2929
|
+
state.view === "source" && sourceTrail ? [sourceTrail] : synthetic.trails;
|
|
2930
|
+
|
|
2931
|
+
const focusedTrailStep =
|
|
2932
|
+
state.view === "source" && sourceTrail
|
|
2933
|
+
? {
|
|
2934
|
+
trailId: sourceTrail.id,
|
|
2935
|
+
stepIndex:
|
|
2936
|
+
sourceStepIndex && sourceStepIndex >= 0 ? sourceStepIndex : 0,
|
|
2937
|
+
showFile: false,
|
|
2938
|
+
}
|
|
2939
|
+
: proposalFocus(
|
|
2940
|
+
activeProposal,
|
|
2941
|
+
synthetic.trails,
|
|
2942
|
+
state.decision === "accepted",
|
|
2943
|
+
synthetic.stepHistory,
|
|
2944
|
+
);
|
|
2945
|
+
|
|
2946
|
+
const workingAliases = useMemo(() => {
|
|
2947
|
+
if (!state.agentWorkingOn) return undefined;
|
|
2948
|
+
if (state.view === "source" && focusedTrailStep?.stepIndex != null) {
|
|
2949
|
+
const step = sourceTrail?.steps[focusedTrailStep.stepIndex];
|
|
2950
|
+
if (step) return new Set([step.from, step.to]);
|
|
2951
|
+
}
|
|
2952
|
+
const aliases = proposalWorkingAliases(activeProposal);
|
|
2953
|
+
return aliases.size ? aliases : undefined;
|
|
2954
|
+
}, [
|
|
2955
|
+
state.agentWorkingOn,
|
|
2956
|
+
state.view,
|
|
2957
|
+
focusedTrailStep,
|
|
2958
|
+
sourceTrail,
|
|
2959
|
+
activeProposal,
|
|
2960
|
+
]);
|
|
2961
|
+
|
|
2962
|
+
const proposalChromeActive = state.view === "proposal" && !state.decision;
|
|
2963
|
+
const proposedTrailIds =
|
|
2964
|
+
proposalChromeActive && activeProposal?.delta.kind === "trail-replace"
|
|
2965
|
+
? new Set([activeProposal.delta.afterTrail.id])
|
|
2966
|
+
: proposalChromeActive && activeProposal?.delta.kind === "component-add"
|
|
2967
|
+
? new Set([activeProposal.delta.trail.id])
|
|
2968
|
+
: undefined;
|
|
2969
|
+
const proposedComponentAliases =
|
|
2970
|
+
proposalChromeActive && activeProposal?.delta.kind === "component-add"
|
|
2971
|
+
? new Set([activeProposal.delta.component.alias])
|
|
2972
|
+
: undefined;
|
|
2973
|
+
|
|
2974
|
+
const selectProposal = useCallback((proposalId: string) => {
|
|
2975
|
+
setState((prev) => {
|
|
2976
|
+
if (
|
|
2977
|
+
prev.view !== "proposal" ||
|
|
2978
|
+
!prev.change?.proposals.some((candidate) => candidate.id === proposalId)
|
|
2979
|
+
) {
|
|
2980
|
+
return prev;
|
|
2981
|
+
}
|
|
2982
|
+
return { ...prev, activeProposalId: proposalId, agentWorkingOn: null };
|
|
2983
|
+
});
|
|
2984
|
+
setProposalMenuOpen(false);
|
|
2985
|
+
}, []);
|
|
2986
|
+
|
|
2987
|
+
const openSourceForActive = useCallback(() => {
|
|
2988
|
+
setState((prev) => {
|
|
2989
|
+
const ref = prev.change?.proposals.find(
|
|
2990
|
+
(candidate) => candidate.id === prev.activeProposalId,
|
|
2991
|
+
)?.context[0];
|
|
2992
|
+
if (!ref) return prev;
|
|
2993
|
+
return {
|
|
2994
|
+
...prev,
|
|
2995
|
+
view: "source",
|
|
2996
|
+
sourceModelId: ref.modelId,
|
|
2997
|
+
sourceTrailId: ref.trailId,
|
|
2998
|
+
agentWorkingOn: null,
|
|
2999
|
+
};
|
|
3000
|
+
});
|
|
3001
|
+
}, []);
|
|
3002
|
+
|
|
3003
|
+
const returnToProposal = useCallback(() => {
|
|
3004
|
+
setState((prev) => ({
|
|
3005
|
+
...prev,
|
|
3006
|
+
view: "proposal",
|
|
3007
|
+
sourceModelId: null,
|
|
3008
|
+
sourceTrailId: null,
|
|
3009
|
+
}));
|
|
3010
|
+
}, []);
|
|
3011
|
+
|
|
3012
|
+
const agentStatusOverlay =
|
|
3013
|
+
state.agentWorkingOn || state.decision ? (
|
|
3014
|
+
<div
|
|
3015
|
+
aria-live="polite"
|
|
3016
|
+
style={{
|
|
3017
|
+
display: "flex",
|
|
3018
|
+
alignItems: "center",
|
|
3019
|
+
gap: 8,
|
|
3020
|
+
padding: "6px 12px",
|
|
3021
|
+
borderRadius: 999,
|
|
3022
|
+
border: `1px solid ${state.agentWorkingOn ? accent : proposal}`,
|
|
3023
|
+
background:
|
|
3024
|
+
theme.colors.backgroundSecondary ?? theme.colors.background,
|
|
3025
|
+
boxShadow: "0 6px 20px rgba(0,0,0,0.35)",
|
|
3026
|
+
fontFamily: mono,
|
|
3027
|
+
fontSize: small,
|
|
3028
|
+
whiteSpace: "nowrap",
|
|
3029
|
+
}}
|
|
3030
|
+
>
|
|
3031
|
+
{state.agentWorkingOn ? (
|
|
3032
|
+
<>
|
|
3033
|
+
<span
|
|
3034
|
+
className="agent-working-dot"
|
|
3035
|
+
style={{
|
|
3036
|
+
width: 6,
|
|
3037
|
+
height: 6,
|
|
3038
|
+
borderRadius: "50%",
|
|
3039
|
+
background: accent,
|
|
3040
|
+
flexShrink: 0,
|
|
3041
|
+
}}
|
|
3042
|
+
/>
|
|
3043
|
+
<span style={{ color: accent, fontWeight: 600 }}>
|
|
3044
|
+
AGENT WORKING ON
|
|
3045
|
+
</span>
|
|
3046
|
+
<span style={{ color: theme.colors.text }}>
|
|
3047
|
+
{state.agentWorkingOn}
|
|
3048
|
+
</span>
|
|
3049
|
+
</>
|
|
3050
|
+
) : (
|
|
3051
|
+
<span style={{ color: proposal, fontWeight: 600 }}>
|
|
3052
|
+
{state.decision === "accepted"
|
|
3053
|
+
? "AGENT COMMITTED CHANGE"
|
|
3054
|
+
: "AGENT DECLINED CHANGE"}
|
|
3055
|
+
</span>
|
|
3056
|
+
)}
|
|
3057
|
+
</div>
|
|
3058
|
+
) : null;
|
|
3059
|
+
|
|
3060
|
+
const header =
|
|
3061
|
+
state.view === "source" ? (
|
|
3062
|
+
<header
|
|
3063
|
+
style={{
|
|
3064
|
+
position: "relative",
|
|
3065
|
+
zIndex: 30,
|
|
3066
|
+
flexShrink: 0,
|
|
3067
|
+
display: "flex",
|
|
3068
|
+
alignItems: "center",
|
|
3069
|
+
gap: 12,
|
|
3070
|
+
padding: "12px 16px",
|
|
3071
|
+
background: theme.colors.background,
|
|
3072
|
+
borderBottom: `1px solid ${border}`,
|
|
3073
|
+
fontFamily: mono,
|
|
3074
|
+
}}
|
|
3075
|
+
>
|
|
3076
|
+
<span
|
|
3077
|
+
style={{
|
|
3078
|
+
fontSize: small,
|
|
3079
|
+
letterSpacing: "0.08em",
|
|
3080
|
+
fontWeight: 600,
|
|
3081
|
+
color: proposal,
|
|
3082
|
+
whiteSpace: "nowrap",
|
|
3083
|
+
}}
|
|
3084
|
+
>
|
|
3085
|
+
SOURCE CONTEXT
|
|
3086
|
+
</span>
|
|
3087
|
+
<span
|
|
3088
|
+
style={{
|
|
3089
|
+
position: "absolute",
|
|
3090
|
+
left: "50%",
|
|
3091
|
+
transform: "translateX(-50%)",
|
|
3092
|
+
fontSize: theme.fontSizes[2],
|
|
3093
|
+
color: theme.colors.text,
|
|
3094
|
+
whiteSpace: "nowrap",
|
|
3095
|
+
}}
|
|
3096
|
+
>
|
|
3097
|
+
{sourceModel?.name ?? title}
|
|
3098
|
+
</span>
|
|
3099
|
+
<button
|
|
3100
|
+
type="button"
|
|
3101
|
+
onClick={returnToProposal}
|
|
3102
|
+
aria-label="Back to proposal"
|
|
3103
|
+
style={{
|
|
3104
|
+
marginLeft: "auto",
|
|
3105
|
+
padding: "4px 10px",
|
|
3106
|
+
borderRadius: 4,
|
|
3107
|
+
border: `1px solid ${accent}`,
|
|
3108
|
+
background: `${accent}18`,
|
|
3109
|
+
color: accent,
|
|
3110
|
+
fontFamily: mono,
|
|
3111
|
+
fontSize: small,
|
|
3112
|
+
fontWeight: 600,
|
|
3113
|
+
cursor: "pointer",
|
|
3114
|
+
whiteSpace: "nowrap",
|
|
3115
|
+
}}
|
|
3116
|
+
>
|
|
3117
|
+
Back to proposal
|
|
3118
|
+
</button>
|
|
3119
|
+
</header>
|
|
3120
|
+
) : (
|
|
3121
|
+
<header
|
|
3122
|
+
style={{
|
|
3123
|
+
position: "relative",
|
|
3124
|
+
zIndex: 30,
|
|
3125
|
+
flexShrink: 0,
|
|
3126
|
+
display: "flex",
|
|
3127
|
+
alignItems: "center",
|
|
3128
|
+
gap: 12,
|
|
3129
|
+
padding: "12px 16px",
|
|
3130
|
+
background: theme.colors.background,
|
|
3131
|
+
borderBottom: `1px solid ${border}`,
|
|
3132
|
+
fontFamily: mono,
|
|
3133
|
+
}}
|
|
3134
|
+
>
|
|
3135
|
+
<span
|
|
3136
|
+
style={{
|
|
3137
|
+
fontSize: small,
|
|
3138
|
+
letterSpacing: "0.08em",
|
|
3139
|
+
fontWeight: 600,
|
|
3140
|
+
color: accent,
|
|
3141
|
+
whiteSpace: "nowrap",
|
|
3142
|
+
}}
|
|
3143
|
+
>
|
|
3144
|
+
AGENT-DRIVEN · CHANGE
|
|
3145
|
+
</span>
|
|
3146
|
+
<div
|
|
3147
|
+
ref={proposalMenuRef}
|
|
3148
|
+
style={{
|
|
3149
|
+
position: "absolute",
|
|
3150
|
+
left: "50%",
|
|
3151
|
+
transform: "translateX(-50%)",
|
|
3152
|
+
}}
|
|
3153
|
+
>
|
|
3154
|
+
<button
|
|
3155
|
+
type="button"
|
|
3156
|
+
onClick={() => setProposalMenuOpen((prev) => !prev)}
|
|
3157
|
+
aria-label="Select proposal"
|
|
3158
|
+
aria-haspopup="listbox"
|
|
3159
|
+
aria-expanded={proposalMenuOpen}
|
|
3160
|
+
disabled={(change?.proposals.length ?? 0) < 2}
|
|
3161
|
+
style={{
|
|
3162
|
+
display: "flex",
|
|
3163
|
+
alignItems: "center",
|
|
3164
|
+
gap: 8,
|
|
3165
|
+
padding: "4px 10px",
|
|
3166
|
+
borderRadius: 4,
|
|
3167
|
+
border: `1px solid ${proposal}`,
|
|
3168
|
+
background: `${proposal}18`,
|
|
3169
|
+
color: proposal,
|
|
3170
|
+
fontFamily: mono,
|
|
3171
|
+
fontSize: theme.fontSizes[2],
|
|
3172
|
+
fontWeight: 600,
|
|
3173
|
+
whiteSpace: "nowrap",
|
|
3174
|
+
cursor:
|
|
3175
|
+
(change?.proposals.length ?? 0) < 2 ? "default" : "pointer",
|
|
3176
|
+
}}
|
|
3177
|
+
>
|
|
3178
|
+
<span style={{ color: theme.colors.text }}>
|
|
3179
|
+
{activeProposal?.name ?? title}
|
|
3180
|
+
</span>
|
|
3181
|
+
{(change?.proposals.length ?? 0) > 1 ? (
|
|
3182
|
+
<span style={{ fontSize: small, color: proposal }}>
|
|
3183
|
+
{(activeIndex ?? 0) + 1} / {change?.proposals.length}
|
|
3184
|
+
</span>
|
|
3185
|
+
) : null}
|
|
3186
|
+
<span
|
|
3187
|
+
aria-hidden="true"
|
|
3188
|
+
style={{ color: proposal, fontSize: small }}
|
|
3189
|
+
>
|
|
3190
|
+
▾
|
|
3191
|
+
</span>
|
|
3192
|
+
</button>
|
|
3193
|
+
{proposalMenuOpen && change && change.proposals.length > 1 ? (
|
|
3194
|
+
<div
|
|
3195
|
+
role="listbox"
|
|
3196
|
+
aria-label="Proposals"
|
|
3197
|
+
style={{
|
|
3198
|
+
position: "absolute",
|
|
3199
|
+
top: "calc(100% + 6px)",
|
|
3200
|
+
left: "50%",
|
|
3201
|
+
transform: "translateX(-50%)",
|
|
3202
|
+
zIndex: 20,
|
|
3203
|
+
minWidth: 260,
|
|
3204
|
+
display: "grid",
|
|
3205
|
+
gap: 2,
|
|
3206
|
+
padding: 4,
|
|
3207
|
+
borderRadius: 6,
|
|
3208
|
+
border: `1px solid ${proposal}`,
|
|
3209
|
+
background:
|
|
3210
|
+
theme.colors.backgroundSecondary ?? theme.colors.background,
|
|
3211
|
+
boxShadow: "0 10px 28px rgba(0,0,0,0.4)",
|
|
3212
|
+
}}
|
|
3213
|
+
>
|
|
3214
|
+
{change.proposals.map((candidate, index) => {
|
|
3215
|
+
const selected = candidate.id === state.activeProposalId;
|
|
3216
|
+
return (
|
|
3217
|
+
<button
|
|
3218
|
+
key={candidate.id}
|
|
3219
|
+
type="button"
|
|
3220
|
+
role="option"
|
|
3221
|
+
aria-selected={selected}
|
|
3222
|
+
onClick={() => selectProposal(candidate.id)}
|
|
3223
|
+
style={{
|
|
3224
|
+
display: "flex",
|
|
3225
|
+
alignItems: "center",
|
|
3226
|
+
gap: 8,
|
|
3227
|
+
padding: "6px 8px",
|
|
3228
|
+
borderRadius: 4,
|
|
3229
|
+
border: "none",
|
|
3230
|
+
background: selected ? `${proposal}25` : "transparent",
|
|
3231
|
+
color: selected ? proposal : theme.colors.text,
|
|
3232
|
+
fontFamily: mono,
|
|
3233
|
+
fontSize: small,
|
|
3234
|
+
textAlign: "left",
|
|
3235
|
+
whiteSpace: "nowrap",
|
|
3236
|
+
cursor: "pointer",
|
|
3237
|
+
}}
|
|
3238
|
+
>
|
|
3239
|
+
<span style={{ color: proposal, minWidth: 12 }}>
|
|
3240
|
+
{index + 1}
|
|
3241
|
+
</span>
|
|
3242
|
+
<span>{candidate.name}</span>
|
|
3243
|
+
</button>
|
|
3244
|
+
);
|
|
3245
|
+
})}
|
|
3246
|
+
</div>
|
|
3247
|
+
) : null}
|
|
3248
|
+
</div>
|
|
3249
|
+
{activeProposal ? (
|
|
3250
|
+
<button
|
|
3251
|
+
type="button"
|
|
3252
|
+
onClick={openSourceForActive}
|
|
3253
|
+
aria-label="Open source model"
|
|
3254
|
+
style={{
|
|
3255
|
+
marginLeft: "auto",
|
|
3256
|
+
padding: "4px 10px",
|
|
3257
|
+
borderRadius: 4,
|
|
3258
|
+
border: `1px solid ${border}`,
|
|
3259
|
+
background: "transparent",
|
|
3260
|
+
color: muted,
|
|
3261
|
+
fontFamily: mono,
|
|
3262
|
+
fontSize: small,
|
|
3263
|
+
cursor: "pointer",
|
|
3264
|
+
whiteSpace: "nowrap",
|
|
3265
|
+
}}
|
|
3266
|
+
>
|
|
3267
|
+
Open source model
|
|
3268
|
+
</button>
|
|
3269
|
+
) : null}
|
|
3270
|
+
</header>
|
|
3271
|
+
);
|
|
3272
|
+
|
|
3273
|
+
return (
|
|
3274
|
+
<div
|
|
3275
|
+
style={{
|
|
3276
|
+
display: "flex",
|
|
3277
|
+
height: "100vh",
|
|
3278
|
+
background: theme.colors.background,
|
|
3279
|
+
}}
|
|
3280
|
+
>
|
|
3281
|
+
<style>{prototypeAnimationStyles}</style>
|
|
3282
|
+
{state.modelOpen ? (
|
|
3283
|
+
<div
|
|
3284
|
+
key={openingKey}
|
|
3285
|
+
className="agent-model-opening"
|
|
3286
|
+
style={{
|
|
3287
|
+
flex: 1,
|
|
3288
|
+
minWidth: 0,
|
|
3289
|
+
display: "flex",
|
|
3290
|
+
flexDirection: "column",
|
|
3291
|
+
}}
|
|
3292
|
+
>
|
|
3293
|
+
{header}
|
|
3294
|
+
<div style={{ flex: 1, minHeight: 0, position: "relative" }}>
|
|
3295
|
+
<SubsystemComponentGraph
|
|
3296
|
+
components={graphComponents}
|
|
3297
|
+
trails={graphTrails}
|
|
3298
|
+
focusedTrailStep={focusedTrailStep}
|
|
3299
|
+
proposedTrailIds={proposedTrailIds}
|
|
3300
|
+
proposedComponentAliases={proposedComponentAliases}
|
|
3301
|
+
workingComponentAliases={workingAliases}
|
|
3302
|
+
removedComponentAliases={
|
|
3303
|
+
state.view === "proposal"
|
|
3304
|
+
? synthetic.removedComponentAliases
|
|
3305
|
+
: undefined
|
|
3306
|
+
}
|
|
3307
|
+
stepHistory={
|
|
3308
|
+
state.view === "proposal" ? synthetic.stepHistory : undefined
|
|
3309
|
+
}
|
|
3310
|
+
canvasOverlay={agentStatusOverlay}
|
|
3311
|
+
trailFocusDurationMs={600}
|
|
3312
|
+
focusVerticalBiasPx={96}
|
|
3313
|
+
persistKey={persistKey}
|
|
3314
|
+
hideHeader
|
|
3315
|
+
title={title}
|
|
3316
|
+
graphTitle={
|
|
3317
|
+
state.view === "source"
|
|
3318
|
+
? "SOURCE SUBSYSTEM MODEL"
|
|
3319
|
+
: "SYNTHETIC CONTEXT MODEL"
|
|
3320
|
+
}
|
|
3321
|
+
showTrailTitle
|
|
3322
|
+
description={
|
|
3323
|
+
state.view === "source"
|
|
3324
|
+
? "Original trail context. Focus here never opens files; use the header to return to the change."
|
|
3325
|
+
: description
|
|
3326
|
+
}
|
|
3327
|
+
notes="**Prototype boundary:** the synthetic graph and proposal state are host-local. The source subsystem models stay untouched."
|
|
3328
|
+
/>
|
|
3329
|
+
</div>
|
|
3330
|
+
</div>
|
|
3331
|
+
) : (
|
|
3332
|
+
<div
|
|
3333
|
+
style={{
|
|
3334
|
+
flex: 1,
|
|
3335
|
+
minWidth: 0,
|
|
3336
|
+
background: theme.colors.background,
|
|
3337
|
+
}}
|
|
3338
|
+
/>
|
|
3339
|
+
)}
|
|
3340
|
+
|
|
3341
|
+
<aside
|
|
3342
|
+
style={{
|
|
3343
|
+
width: 390,
|
|
3344
|
+
flexShrink: 0,
|
|
3345
|
+
display: "flex",
|
|
3346
|
+
flexDirection: "column",
|
|
3347
|
+
borderLeft: `1px solid ${border}`,
|
|
3348
|
+
background: theme.colors.background,
|
|
3349
|
+
overflow: "hidden",
|
|
3350
|
+
}}
|
|
3351
|
+
>
|
|
3352
|
+
<header
|
|
3353
|
+
style={{
|
|
3354
|
+
padding: "14px 16px 10px",
|
|
3355
|
+
borderBottom: `1px solid ${border}`,
|
|
3356
|
+
}}
|
|
3357
|
+
>
|
|
3358
|
+
<div
|
|
3359
|
+
style={{
|
|
3360
|
+
fontFamily: mono,
|
|
3361
|
+
fontSize: body,
|
|
3362
|
+
color: theme.colors.text,
|
|
3363
|
+
}}
|
|
3364
|
+
>
|
|
3365
|
+
Agent tool stream
|
|
3366
|
+
</div>
|
|
3367
|
+
<p
|
|
3368
|
+
style={{
|
|
3369
|
+
margin: "6px 0 0",
|
|
3370
|
+
fontSize: small,
|
|
3371
|
+
lineHeight: 1.5,
|
|
3372
|
+
color: muted,
|
|
3373
|
+
}}
|
|
3374
|
+
>
|
|
3375
|
+
Step through the fake calls or play them like a live session.
|
|
3376
|
+
</p>
|
|
3377
|
+
<div style={{ display: "flex", gap: 6, marginTop: 10 }}>
|
|
3378
|
+
<button
|
|
3379
|
+
type="button"
|
|
3380
|
+
onClick={step}
|
|
3381
|
+
disabled={cursor >= events.length}
|
|
3382
|
+
style={{
|
|
3383
|
+
padding: "4px 10px",
|
|
3384
|
+
borderRadius: 4,
|
|
3385
|
+
border: `1px solid ${border}`,
|
|
3386
|
+
background:
|
|
3387
|
+
theme.colors.backgroundSecondary ?? theme.colors.background,
|
|
3388
|
+
color: theme.colors.text,
|
|
3389
|
+
fontFamily: mono,
|
|
3390
|
+
fontSize: small,
|
|
3391
|
+
cursor: cursor >= events.length ? "default" : "pointer",
|
|
3392
|
+
opacity: cursor >= events.length ? 0.5 : 1,
|
|
3393
|
+
}}
|
|
3394
|
+
>
|
|
3395
|
+
Next tool call
|
|
3396
|
+
</button>
|
|
3397
|
+
<button
|
|
3398
|
+
type="button"
|
|
3399
|
+
onClick={() => setPlaying((prev) => !prev)}
|
|
3400
|
+
disabled={cursor >= events.length && !playing}
|
|
3401
|
+
style={{
|
|
3402
|
+
padding: "4px 10px",
|
|
3403
|
+
borderRadius: 4,
|
|
3404
|
+
border: `1px solid ${accent}`,
|
|
3405
|
+
background: `${accent}18`,
|
|
3406
|
+
color: accent,
|
|
3407
|
+
fontFamily: mono,
|
|
3408
|
+
fontSize: small,
|
|
3409
|
+
fontWeight: 600,
|
|
3410
|
+
cursor: "pointer",
|
|
3411
|
+
}}
|
|
3412
|
+
>
|
|
3413
|
+
{playing ? "Pause" : "Play"}
|
|
3414
|
+
</button>
|
|
3415
|
+
<button
|
|
3416
|
+
type="button"
|
|
3417
|
+
onClick={reset}
|
|
3418
|
+
style={{
|
|
3419
|
+
padding: "4px 10px",
|
|
3420
|
+
borderRadius: 4,
|
|
3421
|
+
border: `1px solid ${border}`,
|
|
3422
|
+
background: "transparent",
|
|
3423
|
+
color: muted,
|
|
3424
|
+
fontFamily: mono,
|
|
3425
|
+
fontSize: small,
|
|
3426
|
+
cursor: "pointer",
|
|
3427
|
+
}}
|
|
3428
|
+
>
|
|
3429
|
+
Reset
|
|
3430
|
+
</button>
|
|
3431
|
+
<button
|
|
3432
|
+
type="button"
|
|
3433
|
+
onClick={animateOpening}
|
|
3434
|
+
style={{
|
|
3435
|
+
padding: "4px 10px",
|
|
3436
|
+
borderRadius: 4,
|
|
3437
|
+
border: `1px solid ${border}`,
|
|
3438
|
+
background: "transparent",
|
|
3439
|
+
color: muted,
|
|
3440
|
+
fontFamily: mono,
|
|
3441
|
+
fontSize: small,
|
|
3442
|
+
cursor: "pointer",
|
|
3443
|
+
}}
|
|
3444
|
+
>
|
|
3445
|
+
Animate opening
|
|
3446
|
+
</button>
|
|
3447
|
+
</div>
|
|
3448
|
+
<div style={{ marginTop: 8, fontSize: small, color: muted }}>
|
|
3449
|
+
{cursor} / {events.length} calls replayed
|
|
3450
|
+
</div>
|
|
3451
|
+
</header>
|
|
3452
|
+
|
|
3453
|
+
<div
|
|
3454
|
+
style={{
|
|
3455
|
+
flex: 1,
|
|
3456
|
+
minHeight: 0,
|
|
3457
|
+
overflow: "auto",
|
|
3458
|
+
padding: "12px 16px",
|
|
3459
|
+
display: "grid",
|
|
3460
|
+
gap: 8,
|
|
3461
|
+
alignContent: "start",
|
|
3462
|
+
}}
|
|
3463
|
+
>
|
|
3464
|
+
{events.slice(0, cursor).map((event) => (
|
|
3465
|
+
<ToolRow key={event.id} event={event} />
|
|
3466
|
+
))}
|
|
3467
|
+
</div>
|
|
3468
|
+
</aside>
|
|
3469
|
+
</div>
|
|
3470
|
+
);
|
|
3471
|
+
}
|
|
3472
|
+
|
|
3473
|
+
export const Walkthrough: Story = {
|
|
3474
|
+
render: () => (
|
|
3475
|
+
<Prototype
|
|
3476
|
+
events={trailProposalEvents}
|
|
3477
|
+
title="Agent-driven walkthrough · prototype"
|
|
3478
|
+
persistKey="agent-driven-walkthrough-prototype"
|
|
3479
|
+
description="A simulated agent stream narrates what it is working on, focuses trails, walks across trails, then reviews and commits a trail proposal in conversation. All state is host-local."
|
|
3480
|
+
/>
|
|
3481
|
+
),
|
|
3482
|
+
};
|
|
3483
|
+
|
|
3484
|
+
export const StepChangeProposal: Story = {
|
|
3485
|
+
render: () => (
|
|
3486
|
+
<Prototype
|
|
3487
|
+
events={stepProposalEvents}
|
|
3488
|
+
title="Agent-driven step change · prototype"
|
|
3489
|
+
persistKey="agent-driven-step-change-prototype"
|
|
3490
|
+
description="A simulated agent stream narrates its focus, stages a step replacement, then reviews and applies it in conversation. The proposed step text stays host-local until committed."
|
|
3491
|
+
/>
|
|
3492
|
+
),
|
|
3493
|
+
};
|
|
3494
|
+
|
|
3495
|
+
export const ComponentProposal: Story = {
|
|
3496
|
+
render: () => (
|
|
3497
|
+
<Prototype
|
|
3498
|
+
events={componentProposalEvents}
|
|
3499
|
+
title="Agent-driven component proposal · prototype"
|
|
3500
|
+
persistKey="agent-driven-component-proposal-prototype"
|
|
3501
|
+
description="A simulated agent stream focuses the refund gap, stages a new component, then reviews and commits it in conversation. Its box is dashed, badged and proposal-colored until committed."
|
|
3502
|
+
/>
|
|
3503
|
+
),
|
|
3504
|
+
};
|
|
3505
|
+
|
|
3506
|
+
export const ComponentRemoval: Story = {
|
|
3507
|
+
render: () => (
|
|
3508
|
+
<Prototype
|
|
3509
|
+
events={componentRemovalEvents}
|
|
3510
|
+
title="Agent-driven component removal · prototype"
|
|
3511
|
+
persistKey="agent-driven-component-removal-prototype"
|
|
3512
|
+
description="A simulated agent retires the confirmation mailer. Its steps leave the trails, while its box stays in place as a dim REMOVED ghost."
|
|
3513
|
+
/>
|
|
3514
|
+
),
|
|
3515
|
+
};
|
|
3516
|
+
|
|
3517
|
+
export const TrailProposalDeclined: Story = {
|
|
3518
|
+
render: () => (
|
|
3519
|
+
<Prototype
|
|
3520
|
+
events={trailDeclinedEvents}
|
|
3521
|
+
title="Agent-driven walkthrough · declined"
|
|
3522
|
+
persistKey="agent-driven-walkthrough-declined-prototype"
|
|
3523
|
+
description="The same narrated trail proposal, but the agent declines it in conversation and the visible model stays unchanged."
|
|
3524
|
+
/>
|
|
3525
|
+
),
|
|
3526
|
+
};
|
|
3527
|
+
|
|
3528
|
+
export const StepProposalDeclined: Story = {
|
|
3529
|
+
render: () => (
|
|
3530
|
+
<Prototype
|
|
3531
|
+
events={stepDeclinedEvents}
|
|
3532
|
+
title="Agent-driven step change · declined"
|
|
3533
|
+
persistKey="agent-driven-step-change-declined-prototype"
|
|
3534
|
+
description="The agent reviews the staged step change, declines it, and the original step remains in the trail."
|
|
3535
|
+
/>
|
|
3536
|
+
),
|
|
3537
|
+
};
|
|
3538
|
+
|
|
3539
|
+
export const ComponentProposalDeclined: Story = {
|
|
3540
|
+
render: () => (
|
|
3541
|
+
<Prototype
|
|
3542
|
+
events={componentDeclinedEvents}
|
|
3543
|
+
title="Agent-driven component proposal · declined"
|
|
3544
|
+
persistKey="agent-driven-component-proposal-declined-prototype"
|
|
3545
|
+
description="The agent reviews the staged component and trail, declines them, and no new box appears in the model."
|
|
3546
|
+
/>
|
|
3547
|
+
),
|
|
3548
|
+
};
|
|
3549
|
+
|
|
3550
|
+
export const MultiProposalChange: Story = {
|
|
3551
|
+
render: () => (
|
|
3552
|
+
<MultiProposalPrototype
|
|
3553
|
+
events={multiProposalEvents}
|
|
3554
|
+
title="Refund handling · synthetic change"
|
|
3555
|
+
persistKey="agent-driven-multi-proposal-change-prototype"
|
|
3556
|
+
description="One change groups three proposals from Booking and Payments. Click the header name to choose a proposal from the dropdown; source models open only through explicit agent steps or the header control."
|
|
3557
|
+
/>
|
|
3558
|
+
),
|
|
3559
|
+
};
|
|
3560
|
+
|
|
3561
|
+
export const MultiProposalChangeDeclined: Story = {
|
|
3562
|
+
render: () => (
|
|
3563
|
+
<MultiProposalPrototype
|
|
3564
|
+
events={multiProposalDeclinedEvents}
|
|
3565
|
+
title="Refund handling · declined change"
|
|
3566
|
+
persistKey="agent-driven-multi-proposal-change-declined-prototype"
|
|
3567
|
+
description="The same three proposals are declined as one change, so the synthetic model keeps its original source trails and components."
|
|
2005
3568
|
/>
|
|
2006
3569
|
),
|
|
2007
3570
|
};
|