@principal-ai/subsystems-react 0.56.34 → 0.56.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/subsystem/SubsystemComponentGraph.d.ts +62 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +175 -32
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/TrailStepsNav.d.ts +3 -1
- package/dist/subsystem/TrailStepsNav.d.ts.map +1 -1
- package/dist/subsystem/TrailStepsNav.js +13 -4
- package/dist/subsystem/TrailStepsNav.js.map +1 -1
- package/dist/subsystem/TrailsPanel.d.ts +18 -2
- package/dist/subsystem/TrailsPanel.d.ts.map +1 -1
- package/dist/subsystem/TrailsPanel.js +57 -15
- package/dist/subsystem/TrailsPanel.js.map +1 -1
- package/dist/subsystem/model.d.ts +6 -0
- package/dist/subsystem/model.d.ts.map +1 -1
- package/dist/subsystem/model.js.map +1 -1
- package/dist/subsystem/nodes.d.ts.map +1 -1
- package/dist/subsystem/nodes.js +101 -19
- package/dist/subsystem/nodes.js.map +1 -1
- package/package.json +1 -1
- package/src/stories/Canvases/Subsystem/AgentDrivenWalkthrough.stories.tsx +2007 -0
- package/src/stories/Canvases/Subsystem/NodeIconography.stories.tsx +190 -0
- package/src/subsystem/SubsystemComponentGraph.tsx +273 -31
- package/src/subsystem/TrailStepsNav.tsx +15 -3
- package/src/subsystem/TrailsPanel.tsx +137 -9
- package/src/subsystem/model.ts +6 -0
- package/src/subsystem/nodes.tsx +143 -18
|
@@ -0,0 +1,2007 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import "@xyflow/react/dist/style.css";
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
import {
|
|
5
|
+
ThemeProvider,
|
|
6
|
+
defaultEditorTheme,
|
|
7
|
+
useTheme,
|
|
8
|
+
} from "@principal-ade/industry-theme";
|
|
9
|
+
import { SubsystemComponentGraph } from "../../../subsystem/SubsystemComponentGraph";
|
|
10
|
+
import type {
|
|
11
|
+
SubsystemComponent,
|
|
12
|
+
SubsystemTrail,
|
|
13
|
+
SubsystemTrailStep,
|
|
14
|
+
} from "../../../subsystem/model";
|
|
15
|
+
import {
|
|
16
|
+
buildStepEmphasisMap,
|
|
17
|
+
emphasisKey,
|
|
18
|
+
stepClaimKey,
|
|
19
|
+
type StepEmphasisRecord,
|
|
20
|
+
} from "../../../subsystem/stepEmphasis";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* PROTOTYPE: simulate an agent driving a subsystem model without ACP.
|
|
24
|
+
*
|
|
25
|
+
* The fake tool-call stream below mirrors the shape the electron host will
|
|
26
|
+
* eventually emit. It drives the graph with `focusedTrailStep`, `stepEmphasis`,
|
|
27
|
+
* and `sidebarAfterDescription`. A proposed trail, step replacement or new
|
|
28
|
+
* component is appended as the final guided-walkthrough step and announced in
|
|
29
|
+
* the guide header, without stealing the current step. A `walk-steps` call
|
|
30
|
+
* advances the guide on its own `pauseMs` clock; manual navigation cancels that
|
|
31
|
+
* run. Plain `agent` events narrate; separate `agent-working` events turn on the
|
|
32
|
+
* working indicator; separate `agent-decision` events resolve proposals in
|
|
33
|
+
* conversation. An accepted step change keeps a host-local previous-state ghost
|
|
34
|
+
* beneath the committed step, with a Hide/Show toggle. An accepted component
|
|
35
|
+
* removal leaves a dim REMOVED ghost in the graph. There are no confirm/decline
|
|
36
|
+
* buttons. Nothing here changes the portable model document.
|
|
37
|
+
*/
|
|
38
|
+
const meta = {
|
|
39
|
+
title: "Canvases/Subsystem/Prototypes/Agent-Driven Walkthrough",
|
|
40
|
+
component: SubsystemComponentGraph,
|
|
41
|
+
parameters: {
|
|
42
|
+
layout: "fullscreen",
|
|
43
|
+
docs: {
|
|
44
|
+
description: {
|
|
45
|
+
component:
|
|
46
|
+
"Story-only driving harness: a fake agent stream opens the subsystem model, focuses trails, walks guide steps on a configurable pause, and appends a host-local proposal as the final guide step. Distinct agent-working events turn on the working indicator, and distinct agent-decision events accept or decline the proposal in conversation; there are no decision buttons. Accepted step changes show a host-local before/after ghost with a Hide/Show toggle; accepted removals stay as dim REMOVED nodes. Use Animate opening to replay the opening tool call.",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
decorators: [
|
|
51
|
+
(Story) => (
|
|
52
|
+
<ThemeProvider theme={defaultEditorTheme}>
|
|
53
|
+
<Story />
|
|
54
|
+
</ThemeProvider>
|
|
55
|
+
),
|
|
56
|
+
],
|
|
57
|
+
} satisfies Meta<typeof SubsystemComponentGraph>;
|
|
58
|
+
|
|
59
|
+
export default meta;
|
|
60
|
+
type Story = StoryObj<typeof meta>;
|
|
61
|
+
|
|
62
|
+
const PURL = "pkg:github/acme/booking-web";
|
|
63
|
+
const stepPurl = (file: string) => `${PURL}#${file}`;
|
|
64
|
+
|
|
65
|
+
const seedComponents: SubsystemComponent[] = [
|
|
66
|
+
{
|
|
67
|
+
alias: "ui",
|
|
68
|
+
name: "BookingPage",
|
|
69
|
+
construct: "function",
|
|
70
|
+
file: "src/ui/BookingPage.tsx",
|
|
71
|
+
purl: PURL,
|
|
72
|
+
symbol: "BookingPage",
|
|
73
|
+
purpose: "picks a slot and submits the booking",
|
|
74
|
+
process: "booking-web/client",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
alias: "api",
|
|
78
|
+
name: "checkoutApi",
|
|
79
|
+
construct: "function",
|
|
80
|
+
file: "src/api/checkout.ts",
|
|
81
|
+
purl: PURL,
|
|
82
|
+
symbol: "checkoutApi",
|
|
83
|
+
purpose: "validates and books a slot",
|
|
84
|
+
process: "booking-web/server",
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
alias: "store",
|
|
88
|
+
name: "BookingStore",
|
|
89
|
+
construct: "class",
|
|
90
|
+
file: "src/store/bookingStore.ts",
|
|
91
|
+
purl: PURL,
|
|
92
|
+
symbol: "BookingStore",
|
|
93
|
+
purpose: "retains bookings",
|
|
94
|
+
process: "booking-web/server",
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
alias: "mailer",
|
|
98
|
+
name: "Mailer",
|
|
99
|
+
construct: "external",
|
|
100
|
+
file: "src/services/mailer.ts",
|
|
101
|
+
purl: PURL,
|
|
102
|
+
symbol: "Mailer",
|
|
103
|
+
purpose: "sends confirmations and refunds",
|
|
104
|
+
role: "service",
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
|
|
108
|
+
const seedTrails: SubsystemTrail[] = [
|
|
109
|
+
{
|
|
110
|
+
id: "wt-book",
|
|
111
|
+
title: "Book a slot",
|
|
112
|
+
steps: [
|
|
113
|
+
{
|
|
114
|
+
from: "ui",
|
|
115
|
+
to: "api",
|
|
116
|
+
mechanism: "calls",
|
|
117
|
+
file: "src/ui/BookingPage.tsx",
|
|
118
|
+
span: { startLine: 42, endLine: 42, contentHash: "fixture" },
|
|
119
|
+
purl: stepPurl("src/ui/BookingPage.tsx"),
|
|
120
|
+
symbol: "BookingPage.submit",
|
|
121
|
+
annotation: "Submit hands the picked slot to the API.",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
from: "api",
|
|
125
|
+
to: "store",
|
|
126
|
+
mechanism: "writes",
|
|
127
|
+
file: "src/api/checkout.ts",
|
|
128
|
+
span: { startLine: 18, endLine: 18, contentHash: "fixture" },
|
|
129
|
+
purl: stepPurl("src/api/checkout.ts"),
|
|
130
|
+
symbol: "checkoutApi.book",
|
|
131
|
+
annotation: "The API writes the booking into the store.",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
from: "store",
|
|
135
|
+
to: "mailer",
|
|
136
|
+
mechanism: "produces",
|
|
137
|
+
file: "src/store/bookingStore.ts",
|
|
138
|
+
span: { startLine: 27, endLine: 27, contentHash: "fixture" },
|
|
139
|
+
purl: stepPurl("src/store/bookingStore.ts"),
|
|
140
|
+
symbol: "BookingStore.confirm",
|
|
141
|
+
annotation: "The stored booking triggers the confirmation email.",
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
id: "wt-cancel",
|
|
147
|
+
title: "Cancel a booking",
|
|
148
|
+
steps: [
|
|
149
|
+
{
|
|
150
|
+
from: "ui",
|
|
151
|
+
to: "api",
|
|
152
|
+
mechanism: "calls",
|
|
153
|
+
file: "src/ui/BookingPage.tsx",
|
|
154
|
+
span: { startLine: 61, endLine: 61, contentHash: "fixture" },
|
|
155
|
+
purl: stepPurl("src/ui/BookingPage.tsx"),
|
|
156
|
+
symbol: "BookingPage.cancel",
|
|
157
|
+
annotation: "Cancel sends the booking id to the API.",
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
from: "api",
|
|
161
|
+
to: "store",
|
|
162
|
+
mechanism: "writes",
|
|
163
|
+
file: "src/api/checkout.ts",
|
|
164
|
+
span: { startLine: 33, endLine: 33, contentHash: "fixture" },
|
|
165
|
+
purl: stepPurl("src/api/checkout.ts"),
|
|
166
|
+
symbol: "checkoutApi.cancel",
|
|
167
|
+
annotation: "The API marks the stored booking cancelled.",
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
];
|
|
172
|
+
|
|
173
|
+
const proposedTrail: SubsystemTrail = {
|
|
174
|
+
id: "wt-refund",
|
|
175
|
+
title: "Refund a cancelled booking",
|
|
176
|
+
steps: [
|
|
177
|
+
{
|
|
178
|
+
from: "store",
|
|
179
|
+
to: "mailer",
|
|
180
|
+
mechanism: "produces",
|
|
181
|
+
file: "src/store/bookingStore.ts",
|
|
182
|
+
span: { startLine: 44, endLine: 44, contentHash: "proposed" },
|
|
183
|
+
purl: stepPurl("src/store/bookingStore.ts"),
|
|
184
|
+
symbol: "BookingStore.refund",
|
|
185
|
+
annotation: "Emit a refund intent once the cancellation is committed.",
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
from: "mailer",
|
|
189
|
+
to: "ui",
|
|
190
|
+
mechanism: "feeds",
|
|
191
|
+
file: "src/services/mailer.ts",
|
|
192
|
+
span: { startLine: 12, endLine: 12, contentHash: "proposed" },
|
|
193
|
+
purl: stepPurl("src/services/mailer.ts"),
|
|
194
|
+
symbol: "Mailer.refundNotice",
|
|
195
|
+
annotation: "Return the refund status to the booking page.",
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
// Host-local replacement for one step of an existing trail. Only the step text
|
|
201
|
+
// changes; the trail and the portable model document stay as authored.
|
|
202
|
+
const proposedCancelStep: SubsystemTrailStep = {
|
|
203
|
+
from: "api",
|
|
204
|
+
to: "mailer",
|
|
205
|
+
mechanism: "produces",
|
|
206
|
+
file: "src/api/checkout.ts",
|
|
207
|
+
span: { startLine: 33, endLine: 33, contentHash: "proposed" },
|
|
208
|
+
purl: stepPurl("src/api/checkout.ts"),
|
|
209
|
+
symbol: "checkoutApi.refundNotice",
|
|
210
|
+
annotation: "Cancel emits a refund notice instead of stopping at the store.",
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
// Host-local component proposal. It exists only while the host is showing the
|
|
214
|
+
// proposal (and after the user accepts it), never in the portable document.
|
|
215
|
+
const proposedRefundService: SubsystemComponent = {
|
|
216
|
+
alias: "refund",
|
|
217
|
+
name: "RefundService",
|
|
218
|
+
construct: "class",
|
|
219
|
+
file: "src/services/refundService.ts",
|
|
220
|
+
purl: PURL,
|
|
221
|
+
symbol: "RefundService",
|
|
222
|
+
purpose: "owns refund notices for cancelled bookings",
|
|
223
|
+
process: "booking-web/server",
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const proposedRefundServiceTrail: SubsystemTrail = {
|
|
227
|
+
id: "wt-refund-service",
|
|
228
|
+
title: "Refund a cancelled booking",
|
|
229
|
+
steps: [
|
|
230
|
+
{
|
|
231
|
+
from: "store",
|
|
232
|
+
to: "refund",
|
|
233
|
+
mechanism: "produces",
|
|
234
|
+
file: "src/store/bookingStore.ts",
|
|
235
|
+
span: { startLine: 44, endLine: 44, contentHash: "proposed" },
|
|
236
|
+
purl: stepPurl("src/store/bookingStore.ts"),
|
|
237
|
+
symbol: "BookingStore.refundRequested",
|
|
238
|
+
annotation: "Emit a refund intent once the cancellation is committed.",
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
from: "refund",
|
|
242
|
+
to: "ui",
|
|
243
|
+
mechanism: "feeds",
|
|
244
|
+
file: "src/services/refundService.ts",
|
|
245
|
+
span: { startLine: 12, endLine: 12, contentHash: "proposed" },
|
|
246
|
+
purl: stepPurl("src/services/refundService.ts"),
|
|
247
|
+
symbol: "RefundService.refundNotice",
|
|
248
|
+
annotation: "Return the refund status to the booking page.",
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
type GuideStep = {
|
|
254
|
+
id: string;
|
|
255
|
+
title: string;
|
|
256
|
+
trailId: string;
|
|
257
|
+
/** Omit for whole-trail focus (no file drawer). */
|
|
258
|
+
stepIndex?: number;
|
|
259
|
+
/** Host-driven focus is file-free; set true only to demo an explicit open. */
|
|
260
|
+
showFile?: boolean;
|
|
261
|
+
body: string;
|
|
262
|
+
/** Added as step emphasis when this step becomes active. */
|
|
263
|
+
guidance?: string;
|
|
264
|
+
/** Marks the step as a host-local proposal awaiting agent resolution. */
|
|
265
|
+
proposal?: "trail" | "step" | "component" | "removal";
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
type DriveEvent =
|
|
269
|
+
| { kind: "open-model"; id: string; tool: string; text: string }
|
|
270
|
+
| { kind: "prompt"; id: string; text: string }
|
|
271
|
+
/** Plain narration. It does not change the working indicator. */
|
|
272
|
+
| { kind: "agent"; id: string; text: string }
|
|
273
|
+
/** The agent explicitly starts working on a named part of the model. */
|
|
274
|
+
| {
|
|
275
|
+
kind: "agent-working";
|
|
276
|
+
id: string;
|
|
277
|
+
text: string;
|
|
278
|
+
workingOn: string;
|
|
279
|
+
}
|
|
280
|
+
/** The agent resolves the current proposal in conversation. */
|
|
281
|
+
| {
|
|
282
|
+
kind: "agent-decision";
|
|
283
|
+
id: string;
|
|
284
|
+
text: string;
|
|
285
|
+
decision: "accepted" | "rejected";
|
|
286
|
+
}
|
|
287
|
+
| {
|
|
288
|
+
kind: "guide";
|
|
289
|
+
id: string;
|
|
290
|
+
tool: string;
|
|
291
|
+
question: string;
|
|
292
|
+
steps: GuideStep[];
|
|
293
|
+
}
|
|
294
|
+
| {
|
|
295
|
+
kind: "walk-steps";
|
|
296
|
+
id: string;
|
|
297
|
+
tool: string;
|
|
298
|
+
pauseMs: number;
|
|
299
|
+
stepIds: string[];
|
|
300
|
+
}
|
|
301
|
+
| {
|
|
302
|
+
kind: "propose-trail";
|
|
303
|
+
id: string;
|
|
304
|
+
tool: string;
|
|
305
|
+
trail: SubsystemTrail;
|
|
306
|
+
rationale: string;
|
|
307
|
+
}
|
|
308
|
+
| {
|
|
309
|
+
kind: "propose-step";
|
|
310
|
+
id: string;
|
|
311
|
+
tool: string;
|
|
312
|
+
trailId: string;
|
|
313
|
+
stepIndex: number;
|
|
314
|
+
step: SubsystemTrailStep;
|
|
315
|
+
rationale: string;
|
|
316
|
+
}
|
|
317
|
+
| {
|
|
318
|
+
kind: "propose-component";
|
|
319
|
+
id: string;
|
|
320
|
+
tool: string;
|
|
321
|
+
component: SubsystemComponent;
|
|
322
|
+
trail: SubsystemTrail;
|
|
323
|
+
rationale: string;
|
|
324
|
+
}
|
|
325
|
+
| {
|
|
326
|
+
kind: "propose-component-removal";
|
|
327
|
+
id: string;
|
|
328
|
+
tool: string;
|
|
329
|
+
componentAlias: string;
|
|
330
|
+
rationale: string;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
const trailProposalEvents: DriveEvent[] = [
|
|
334
|
+
{
|
|
335
|
+
kind: "prompt",
|
|
336
|
+
id: "ev-prompt",
|
|
337
|
+
text: "Walk me through how a booking is confirmed, then suggest what is missing for refunds.",
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
kind: "agent",
|
|
341
|
+
id: "ev-agent-1",
|
|
342
|
+
text: "I found a path through the booking flow. I will frame the whole trail first, then walk it step by step and call out the confirmation hop when we reach it.",
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
kind: "open-model",
|
|
346
|
+
id: "ev-open-model",
|
|
347
|
+
tool: "open_subsystem_model",
|
|
348
|
+
text: "Open the subsystem model artifact so the walkthrough has somewhere to land.",
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
kind: "guide",
|
|
352
|
+
id: "ev-guide",
|
|
353
|
+
tool: "subsystem_model_guided_walkthrough",
|
|
354
|
+
question:
|
|
355
|
+
"Where does confirmation happen, and what is missing for refunds?",
|
|
356
|
+
steps: [
|
|
357
|
+
{
|
|
358
|
+
id: "gs-frame",
|
|
359
|
+
title: "1 · Frame the trail",
|
|
360
|
+
trailId: "wt-book",
|
|
361
|
+
body: "Select the whole booking flow first. No file opens — this is trail-level focus.",
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
id: "gs-submit",
|
|
365
|
+
title: "2 · Submit",
|
|
366
|
+
trailId: "wt-book",
|
|
367
|
+
stepIndex: 0,
|
|
368
|
+
body: "The page sends the selected slot to the API. Nothing is durable yet.",
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
id: "gs-book",
|
|
372
|
+
title: "3 · Persist",
|
|
373
|
+
trailId: "wt-book",
|
|
374
|
+
stepIndex: 1,
|
|
375
|
+
body: "The API writes the booking. This is the source of truth for the next hop.",
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
id: "gs-confirm",
|
|
379
|
+
title: "4 · Confirm",
|
|
380
|
+
trailId: "wt-book",
|
|
381
|
+
stepIndex: 2,
|
|
382
|
+
body: "The store emits the confirmation email — the user-visible signal.",
|
|
383
|
+
guidance:
|
|
384
|
+
"This is the hop that turns a stored booking into a user-visible confirmation. It is the answer to “how do I know it succeeded?”",
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
id: "gs-cancel",
|
|
388
|
+
title: "5 · Compare with cancel",
|
|
389
|
+
trailId: "wt-cancel",
|
|
390
|
+
stepIndex: 1,
|
|
391
|
+
body: "Cancellation stops at the store. There is no refund hop anywhere in the model.",
|
|
392
|
+
},
|
|
393
|
+
],
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
kind: "walk-steps",
|
|
397
|
+
id: "ev-walk-steps",
|
|
398
|
+
tool: "subsystem_model_walkthrough_steps",
|
|
399
|
+
pauseMs: 1800,
|
|
400
|
+
stepIds: ["gs-frame", "gs-submit", "gs-book", "gs-confirm", "gs-cancel"],
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
kind: "agent-working",
|
|
404
|
+
id: "ev-agent-2",
|
|
405
|
+
text: "I have walked the booking trail and compared it with cancellation. The cancellation path has no refund step, so I have appended it as the last walkthrough step.",
|
|
406
|
+
workingOn: "comparing cancellation with confirmation",
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
kind: "propose-trail",
|
|
410
|
+
id: "ev-propose-refund",
|
|
411
|
+
tool: "propose_subsystem_model_trail",
|
|
412
|
+
trail: proposedTrail,
|
|
413
|
+
rationale:
|
|
414
|
+
"Cancellation currently ends in the store with no user-visible refund. These two hops close that gap and reuse existing components.",
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
kind: "agent-working",
|
|
418
|
+
id: "ev-agent-3",
|
|
419
|
+
text: "I have the refund trail staged. I am checking its hops against the cancellation flow before I commit anything.",
|
|
420
|
+
workingOn: "reviewing the proposed refund trail",
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
kind: "agent-decision",
|
|
424
|
+
id: "ev-agent-4",
|
|
425
|
+
text: "The refund trail reuses components already in the model, so I am committing it to this host-local view.",
|
|
426
|
+
decision: "accepted",
|
|
427
|
+
},
|
|
428
|
+
];
|
|
429
|
+
|
|
430
|
+
const stepProposalEvents: DriveEvent[] = [
|
|
431
|
+
{
|
|
432
|
+
kind: "prompt",
|
|
433
|
+
id: "sp-prompt",
|
|
434
|
+
text: "Show me where cancellation stops, then propose a better final step.",
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
kind: "agent",
|
|
438
|
+
id: "sp-agent-1",
|
|
439
|
+
text: "The cancel trail has two steps. I will frame the flow, stop on the store write, then propose replacing that hop with a refund notification.",
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
kind: "open-model",
|
|
443
|
+
id: "sp-open-model",
|
|
444
|
+
tool: "open_subsystem_model",
|
|
445
|
+
text: "Open the subsystem model artifact so the step change has somewhere to land.",
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
kind: "guide",
|
|
449
|
+
id: "sp-guide",
|
|
450
|
+
tool: "subsystem_model_guided_walkthrough",
|
|
451
|
+
question: "What should the cancel trail's final hop do?",
|
|
452
|
+
steps: [
|
|
453
|
+
{
|
|
454
|
+
id: "sp-frame",
|
|
455
|
+
title: "1 · Frame cancellation",
|
|
456
|
+
trailId: "wt-cancel",
|
|
457
|
+
body: "Select the existing cancel flow first. No new trail is added here.",
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
id: "sp-stop",
|
|
461
|
+
title: "2 · Where it stops",
|
|
462
|
+
trailId: "wt-cancel",
|
|
463
|
+
stepIndex: 1,
|
|
464
|
+
body: "The API writes the cancellation to the store. The flow ends with no user-visible refund.",
|
|
465
|
+
},
|
|
466
|
+
],
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
kind: "walk-steps",
|
|
470
|
+
id: "sp-walk-steps",
|
|
471
|
+
tool: "subsystem_model_walkthrough_steps",
|
|
472
|
+
pauseMs: 1800,
|
|
473
|
+
stepIds: ["sp-frame", "sp-stop"],
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
kind: "agent-working",
|
|
477
|
+
id: "sp-agent-2",
|
|
478
|
+
text: "That final hop is the gap. I have appended its replacement as the last guide step — the step text turns proposal-colored until the proposal is resolved.",
|
|
479
|
+
workingOn: "preparing the refund step change",
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
kind: "propose-step",
|
|
483
|
+
id: "sp-propose-refund",
|
|
484
|
+
tool: "propose_subsystem_model_step_change",
|
|
485
|
+
trailId: "wt-cancel",
|
|
486
|
+
stepIndex: 1,
|
|
487
|
+
step: proposedCancelStep,
|
|
488
|
+
rationale:
|
|
489
|
+
"Replace the store write with a refund notification so cancellation has a user-visible outcome. The existing trail keeps its place in the model.",
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
kind: "agent-working",
|
|
493
|
+
id: "sp-agent-3",
|
|
494
|
+
text: "The replacement is staged on the existing trail. I am checking that the old hop is fully covered before applying it.",
|
|
495
|
+
workingOn: "reviewing the refund step change",
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
kind: "agent-decision",
|
|
499
|
+
id: "sp-agent-4",
|
|
500
|
+
text: "The replacement keeps the trail's place and gives cancellation a user-visible outcome, so I am applying it.",
|
|
501
|
+
decision: "accepted",
|
|
502
|
+
},
|
|
503
|
+
];
|
|
504
|
+
|
|
505
|
+
const componentProposalEvents: DriveEvent[] = [
|
|
506
|
+
{
|
|
507
|
+
kind: "prompt",
|
|
508
|
+
id: "cp-prompt",
|
|
509
|
+
text: "Show me the refund gap, then propose a component that should own it.",
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
kind: "agent",
|
|
513
|
+
id: "cp-agent-1",
|
|
514
|
+
text: "Cancellation stops at BookingStore. I will frame that flow, stop on the gap, then propose a new RefundService box and the trail that uses it.",
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
kind: "open-model",
|
|
518
|
+
id: "cp-open-model",
|
|
519
|
+
tool: "open_subsystem_model",
|
|
520
|
+
text: "Open the subsystem model artifact so the new box has somewhere to land.",
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
kind: "guide",
|
|
524
|
+
id: "cp-guide",
|
|
525
|
+
tool: "subsystem_model_guided_walkthrough",
|
|
526
|
+
question: "Which component should own refunds after cancellation?",
|
|
527
|
+
steps: [
|
|
528
|
+
{
|
|
529
|
+
id: "cp-frame",
|
|
530
|
+
title: "1 · Frame cancellation",
|
|
531
|
+
trailId: "wt-cancel",
|
|
532
|
+
body: "Start with the existing cancel flow. The model has no refund owner yet.",
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
id: "cp-stop",
|
|
536
|
+
title: "2 · Where it stops",
|
|
537
|
+
trailId: "wt-cancel",
|
|
538
|
+
stepIndex: 1,
|
|
539
|
+
body: "The API writes the cancellation to BookingStore. Nothing here owns a refund.",
|
|
540
|
+
},
|
|
541
|
+
],
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
kind: "walk-steps",
|
|
545
|
+
id: "cp-walk-steps",
|
|
546
|
+
tool: "subsystem_model_walkthrough_steps",
|
|
547
|
+
pauseMs: 1800,
|
|
548
|
+
stepIds: ["cp-frame", "cp-stop"],
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
kind: "agent-working",
|
|
552
|
+
id: "cp-agent-2",
|
|
553
|
+
text: "The missing piece is a refund owner. I have appended a proposal that adds RefundService as a new box and reuses the existing booking page.",
|
|
554
|
+
workingOn: "staging the RefundService box",
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
kind: "propose-component",
|
|
558
|
+
id: "cp-propose-refund-service",
|
|
559
|
+
tool: "propose_subsystem_model_component",
|
|
560
|
+
component: proposedRefundService,
|
|
561
|
+
trail: proposedRefundServiceTrail,
|
|
562
|
+
rationale:
|
|
563
|
+
"Add RefundService as the owner of refund notices. The proposed box is dashed and badged until it is committed.",
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
kind: "agent-working",
|
|
567
|
+
id: "cp-agent-3",
|
|
568
|
+
text: "The new box and its trail are staged. I am checking that no existing component already owns refunds.",
|
|
569
|
+
workingOn: "reviewing the RefundService proposal",
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
kind: "agent-decision",
|
|
573
|
+
id: "cp-agent-4",
|
|
574
|
+
text: "No existing component owns refunds, so I am committing the RefundService box and its trail.",
|
|
575
|
+
decision: "accepted",
|
|
576
|
+
},
|
|
577
|
+
];
|
|
578
|
+
|
|
579
|
+
const componentRemovalEvents: DriveEvent[] = [
|
|
580
|
+
{
|
|
581
|
+
kind: "prompt",
|
|
582
|
+
id: "mr-prompt",
|
|
583
|
+
text: "The confirmation mailer is being retired. Show the impact on this model.",
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
kind: "agent",
|
|
587
|
+
id: "mr-agent-1",
|
|
588
|
+
text: "I will frame the booking flow, then stage the mailer removal for review.",
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
kind: "open-model",
|
|
592
|
+
id: "mr-open-model",
|
|
593
|
+
tool: "open_subsystem_model",
|
|
594
|
+
text: "Open the model so the removal can be seen in context.",
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
kind: "agent",
|
|
598
|
+
id: "mr-agent-2",
|
|
599
|
+
text: "The mailer only carries confirmation and refund notices, so the rest of the booking path stays.",
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
kind: "guide",
|
|
603
|
+
id: "mr-guide",
|
|
604
|
+
tool: "subsystem_model_guided_walkthrough",
|
|
605
|
+
question: "Which parts of the model disappear when the mailer is retired?",
|
|
606
|
+
steps: [
|
|
607
|
+
{
|
|
608
|
+
id: "mr-frame",
|
|
609
|
+
title: "1 · Frame confirmation",
|
|
610
|
+
trailId: "wt-book",
|
|
611
|
+
body: "Look at the booking flow before the removal. The mailer is the final hop.",
|
|
612
|
+
},
|
|
613
|
+
],
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
kind: "walk-steps",
|
|
617
|
+
id: "mr-walk-steps",
|
|
618
|
+
tool: "subsystem_model_walkthrough_steps",
|
|
619
|
+
pauseMs: 1800,
|
|
620
|
+
stepIds: ["mr-frame"],
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
kind: "agent-working",
|
|
624
|
+
id: "mr-agent-3",
|
|
625
|
+
text: "I have staged the mailer removal as a host-local change — its box stays as a dim record.",
|
|
626
|
+
workingOn: "staging the confirmation mailer removal",
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
kind: "propose-component-removal",
|
|
630
|
+
id: "mr-propose-removal",
|
|
631
|
+
tool: "propose_subsystem_model_component_removal",
|
|
632
|
+
componentAlias: "mailer",
|
|
633
|
+
rationale:
|
|
634
|
+
"Retire the confirmation mailer. Its steps leave the trails, but its box remains dimmed so the removed state is visible.",
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
kind: "agent-working",
|
|
638
|
+
id: "mr-agent-4",
|
|
639
|
+
text: "The dependent steps are gone and no other component owns the mailer's seam. I am checking the result.",
|
|
640
|
+
workingOn: "reviewing the confirmation mailer removal",
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
kind: "agent-decision",
|
|
644
|
+
id: "mr-agent-5",
|
|
645
|
+
text: "The mailer is retired; I am applying the removal and keeping its node as a dim ghost.",
|
|
646
|
+
decision: "accepted",
|
|
647
|
+
},
|
|
648
|
+
];
|
|
649
|
+
|
|
650
|
+
// Declined variants reuse the same staged proposal but resolve it in
|
|
651
|
+
// conversation: the agent reviews it, then leaves the model untouched.
|
|
652
|
+
function withFinalDecision(
|
|
653
|
+
events: DriveEvent[],
|
|
654
|
+
decision: "accepted" | "rejected",
|
|
655
|
+
text: string,
|
|
656
|
+
): DriveEvent[] {
|
|
657
|
+
return events.map((event, index) =>
|
|
658
|
+
index === events.length - 1 && event.kind === "agent-decision"
|
|
659
|
+
? { ...event, decision, text }
|
|
660
|
+
: event,
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
const trailDeclinedEvents = withFinalDecision(
|
|
665
|
+
trailProposalEvents,
|
|
666
|
+
"rejected",
|
|
667
|
+
"The refund trail assumes an owner that is not in the model yet, so I am keeping the model as is.",
|
|
668
|
+
);
|
|
669
|
+
const stepDeclinedEvents = withFinalDecision(
|
|
670
|
+
stepProposalEvents,
|
|
671
|
+
"rejected",
|
|
672
|
+
"The replacement would hide the store write, so I am keeping the original step.",
|
|
673
|
+
);
|
|
674
|
+
const componentDeclinedEvents = withFinalDecision(
|
|
675
|
+
componentProposalEvents,
|
|
676
|
+
"rejected",
|
|
677
|
+
"RefundService would duplicate the mailer's responsibility, so I am keeping the model as is.",
|
|
678
|
+
);
|
|
679
|
+
|
|
680
|
+
// `Animate opening` replays through the open call so the artifact appears
|
|
681
|
+
// immediately, then lets the rest of the stream continue behind it.
|
|
682
|
+
function openingEventCountFor(events: DriveEvent[]) {
|
|
683
|
+
const index = events.findIndex((event) => event.kind === "open-model");
|
|
684
|
+
return index < 0 ? 0 : index + 1;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/** Host-local before/after view retained when a step replacement is accepted. */
|
|
688
|
+
type StepChange = {
|
|
689
|
+
trailId: string;
|
|
690
|
+
stepIndex: number;
|
|
691
|
+
previous: SubsystemTrailStep;
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
type DriveState = {
|
|
695
|
+
modelOpen: boolean;
|
|
696
|
+
components: SubsystemComponent[];
|
|
697
|
+
trails: SubsystemTrail[];
|
|
698
|
+
records: StepEmphasisRecord[];
|
|
699
|
+
walkthrough: {
|
|
700
|
+
question: string;
|
|
701
|
+
steps: GuideStep[];
|
|
702
|
+
activeStepId?: string;
|
|
703
|
+
} | null;
|
|
704
|
+
pendingTrail: SubsystemTrail | null;
|
|
705
|
+
pendingComponent: SubsystemComponent | null;
|
|
706
|
+
/** Host-local component alias staged for removal. */
|
|
707
|
+
pendingRemoval: string | null;
|
|
708
|
+
/** Accepted removals: their nodes stay in place as dim ghosts. */
|
|
709
|
+
removedComponentAliases: Set<string>;
|
|
710
|
+
pendingStep: {
|
|
711
|
+
trailId: string;
|
|
712
|
+
stepIndex: number;
|
|
713
|
+
step: SubsystemTrailStep;
|
|
714
|
+
} | null;
|
|
715
|
+
/** Host-local auto-walk started by a `walk-steps` tool call. */
|
|
716
|
+
walkRun: { stepIds: string[]; pauseMs: number; index: number } | null;
|
|
717
|
+
/** Narrated focus from the latest agent message. */
|
|
718
|
+
agentWorkingOn: string | null;
|
|
719
|
+
lastDecision: "accepted" | "rejected" | null;
|
|
720
|
+
/** Host-local comparison for an accepted step change. */
|
|
721
|
+
stepChange: StepChange | null;
|
|
722
|
+
/** The user can dismiss just the previous-state ghost, not the committed step. */
|
|
723
|
+
showPreviousStep: boolean;
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
const initialState = (): DriveState => ({
|
|
727
|
+
modelOpen: false,
|
|
728
|
+
components: seedComponents,
|
|
729
|
+
trails: seedTrails,
|
|
730
|
+
records: [],
|
|
731
|
+
walkthrough: null,
|
|
732
|
+
pendingTrail: null,
|
|
733
|
+
pendingComponent: null,
|
|
734
|
+
pendingRemoval: null,
|
|
735
|
+
removedComponentAliases: new Set<string>(),
|
|
736
|
+
pendingStep: null,
|
|
737
|
+
walkRun: null,
|
|
738
|
+
agentWorkingOn: null,
|
|
739
|
+
lastDecision: null,
|
|
740
|
+
stepChange: null,
|
|
741
|
+
showPreviousStep: true,
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
// The agent, not a button, resolves a staged proposal. Accepted proposals move
|
|
745
|
+
// from host-local pending state into the visible graph; declined ones leave the
|
|
746
|
+
// visible model unchanged.
|
|
747
|
+
function resolveProposal(
|
|
748
|
+
state: DriveState,
|
|
749
|
+
decision: "accepted" | "rejected",
|
|
750
|
+
): DriveState {
|
|
751
|
+
if (state.lastDecision) return state;
|
|
752
|
+
if (decision === "rejected") {
|
|
753
|
+
return { ...state, lastDecision: "rejected" };
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
const pendingRemoval = state.pendingRemoval;
|
|
757
|
+
if (pendingRemoval) {
|
|
758
|
+
return {
|
|
759
|
+
...state,
|
|
760
|
+
removedComponentAliases: new Set([
|
|
761
|
+
...state.removedComponentAliases,
|
|
762
|
+
pendingRemoval,
|
|
763
|
+
]),
|
|
764
|
+
trails: state.trails.map((trail) => ({
|
|
765
|
+
...trail,
|
|
766
|
+
steps: trail.steps.filter(
|
|
767
|
+
(step) => step.from !== pendingRemoval && step.to !== pendingRemoval,
|
|
768
|
+
),
|
|
769
|
+
})),
|
|
770
|
+
lastDecision: "accepted",
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
const pendingComponent = state.pendingComponent;
|
|
775
|
+
if (pendingComponent) {
|
|
776
|
+
const pendingTrail = state.pendingTrail;
|
|
777
|
+
return {
|
|
778
|
+
...state,
|
|
779
|
+
components: state.components.some(
|
|
780
|
+
(c) => c.alias === pendingComponent.alias,
|
|
781
|
+
)
|
|
782
|
+
? state.components
|
|
783
|
+
: [...state.components, pendingComponent],
|
|
784
|
+
trails:
|
|
785
|
+
pendingTrail && !state.trails.some((t) => t.id === pendingTrail.id)
|
|
786
|
+
? [...state.trails, pendingTrail]
|
|
787
|
+
: state.trails,
|
|
788
|
+
lastDecision: "accepted",
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
const pendingTrail = state.pendingTrail;
|
|
793
|
+
if (pendingTrail) {
|
|
794
|
+
if (state.trails.some((t) => t.id === pendingTrail.id)) return state;
|
|
795
|
+
return {
|
|
796
|
+
...state,
|
|
797
|
+
trails: [...state.trails, pendingTrail],
|
|
798
|
+
lastDecision: "accepted",
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
const pendingStep = state.pendingStep;
|
|
803
|
+
if (!pendingStep) return state;
|
|
804
|
+
const previous = state.trails.find(
|
|
805
|
+
(trail) => trail.id === pendingStep.trailId,
|
|
806
|
+
)?.steps[pendingStep.stepIndex];
|
|
807
|
+
return {
|
|
808
|
+
...state,
|
|
809
|
+
trails: state.trails.map((trail) =>
|
|
810
|
+
trail.id === pendingStep.trailId
|
|
811
|
+
? {
|
|
812
|
+
...trail,
|
|
813
|
+
steps: trail.steps.map((step, i) =>
|
|
814
|
+
i === pendingStep.stepIndex ? pendingStep.step : step,
|
|
815
|
+
),
|
|
816
|
+
}
|
|
817
|
+
: trail,
|
|
818
|
+
),
|
|
819
|
+
lastDecision: "accepted",
|
|
820
|
+
stepChange: previous
|
|
821
|
+
? {
|
|
822
|
+
trailId: pendingStep.trailId,
|
|
823
|
+
stepIndex: pendingStep.stepIndex,
|
|
824
|
+
previous,
|
|
825
|
+
}
|
|
826
|
+
: null,
|
|
827
|
+
showPreviousStep: true,
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
function applyEvent(event: DriveEvent, state: DriveState): DriveState {
|
|
832
|
+
switch (event.kind) {
|
|
833
|
+
case "open-model":
|
|
834
|
+
return { ...state, modelOpen: true };
|
|
835
|
+
case "agent":
|
|
836
|
+
return { ...state, agentWorkingOn: null };
|
|
837
|
+
case "agent-working":
|
|
838
|
+
return { ...state, agentWorkingOn: event.workingOn };
|
|
839
|
+
case "agent-decision":
|
|
840
|
+
return {
|
|
841
|
+
...resolveProposal(state, event.decision),
|
|
842
|
+
agentWorkingOn: null,
|
|
843
|
+
};
|
|
844
|
+
case "guide":
|
|
845
|
+
return {
|
|
846
|
+
...state,
|
|
847
|
+
walkthrough: {
|
|
848
|
+
question: event.question,
|
|
849
|
+
steps: event.steps,
|
|
850
|
+
activeStepId: event.steps[0]?.id,
|
|
851
|
+
},
|
|
852
|
+
};
|
|
853
|
+
case "walk-steps":
|
|
854
|
+
return {
|
|
855
|
+
...state,
|
|
856
|
+
walkRun: {
|
|
857
|
+
stepIds: event.stepIds,
|
|
858
|
+
pauseMs: event.pauseMs,
|
|
859
|
+
index: 0,
|
|
860
|
+
},
|
|
861
|
+
walkthrough: state.walkthrough
|
|
862
|
+
? {
|
|
863
|
+
...state.walkthrough,
|
|
864
|
+
activeStepId: event.stepIds[0] ?? state.walkthrough.activeStepId,
|
|
865
|
+
}
|
|
866
|
+
: state.walkthrough,
|
|
867
|
+
};
|
|
868
|
+
case "propose-trail": {
|
|
869
|
+
// Append the proposal to the same guide, but keep the user's current
|
|
870
|
+
// step. The header advertises the new step so they can opt into it.
|
|
871
|
+
const stepNo = (state.walkthrough?.steps.length ?? 5) + 1;
|
|
872
|
+
const proposalStep: GuideStep = {
|
|
873
|
+
id: "gs-propose-refund",
|
|
874
|
+
title: `${stepNo} · Confirm refund trail`,
|
|
875
|
+
trailId: event.trail.id,
|
|
876
|
+
stepIndex: 0,
|
|
877
|
+
showFile: false,
|
|
878
|
+
proposal: "trail",
|
|
879
|
+
body: event.rationale,
|
|
880
|
+
};
|
|
881
|
+
return {
|
|
882
|
+
...state,
|
|
883
|
+
pendingTrail: event.trail,
|
|
884
|
+
lastDecision: null,
|
|
885
|
+
walkthrough: state.walkthrough
|
|
886
|
+
? {
|
|
887
|
+
...state.walkthrough,
|
|
888
|
+
steps: [...state.walkthrough.steps, proposalStep],
|
|
889
|
+
}
|
|
890
|
+
: state.walkthrough,
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
case "propose-step": {
|
|
894
|
+
// The step change lands in the same guide at the same focus, so the
|
|
895
|
+
// replacement text is visible in place before it is committed.
|
|
896
|
+
const stepNo = (state.walkthrough?.steps.length ?? 2) + 1;
|
|
897
|
+
const proposalStep: GuideStep = {
|
|
898
|
+
id: "sp-propose-refund",
|
|
899
|
+
title: `${stepNo} · Confirm refund step`,
|
|
900
|
+
trailId: event.trailId,
|
|
901
|
+
stepIndex: event.stepIndex,
|
|
902
|
+
showFile: false,
|
|
903
|
+
proposal: "step",
|
|
904
|
+
body: event.rationale,
|
|
905
|
+
};
|
|
906
|
+
return {
|
|
907
|
+
...state,
|
|
908
|
+
pendingStep: {
|
|
909
|
+
trailId: event.trailId,
|
|
910
|
+
stepIndex: event.stepIndex,
|
|
911
|
+
step: event.step,
|
|
912
|
+
},
|
|
913
|
+
stepChange: null,
|
|
914
|
+
showPreviousStep: true,
|
|
915
|
+
lastDecision: null,
|
|
916
|
+
walkthrough: state.walkthrough
|
|
917
|
+
? {
|
|
918
|
+
...state.walkthrough,
|
|
919
|
+
steps: [...state.walkthrough.steps, proposalStep],
|
|
920
|
+
}
|
|
921
|
+
: state.walkthrough,
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
case "propose-component": {
|
|
925
|
+
const stepNo = (state.walkthrough?.steps.length ?? 2) + 1;
|
|
926
|
+
const proposalStep: GuideStep = {
|
|
927
|
+
id: "cp-propose-refund-service",
|
|
928
|
+
title: `${stepNo} · Confirm component`,
|
|
929
|
+
trailId: event.trail.id,
|
|
930
|
+
stepIndex: 0,
|
|
931
|
+
showFile: false,
|
|
932
|
+
proposal: "component",
|
|
933
|
+
body: event.rationale,
|
|
934
|
+
};
|
|
935
|
+
return {
|
|
936
|
+
...state,
|
|
937
|
+
pendingComponent: event.component,
|
|
938
|
+
pendingTrail: event.trail,
|
|
939
|
+
lastDecision: null,
|
|
940
|
+
walkthrough: state.walkthrough
|
|
941
|
+
? {
|
|
942
|
+
...state.walkthrough,
|
|
943
|
+
steps: [...state.walkthrough.steps, proposalStep],
|
|
944
|
+
}
|
|
945
|
+
: state.walkthrough,
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
case "propose-component-removal": {
|
|
949
|
+
const stepNo = (state.walkthrough?.steps.length ?? 2) + 1;
|
|
950
|
+
const proposalStep: GuideStep = {
|
|
951
|
+
id: "mr-propose-remove-mailer",
|
|
952
|
+
title: `${stepNo} · Retire confirmation mailer`,
|
|
953
|
+
trailId: "wt-book",
|
|
954
|
+
showFile: false,
|
|
955
|
+
proposal: "removal",
|
|
956
|
+
body: event.rationale,
|
|
957
|
+
};
|
|
958
|
+
return {
|
|
959
|
+
...state,
|
|
960
|
+
pendingRemoval: event.componentAlias,
|
|
961
|
+
lastDecision: null,
|
|
962
|
+
walkthrough: state.walkthrough
|
|
963
|
+
? {
|
|
964
|
+
...state.walkthrough,
|
|
965
|
+
steps: [...state.walkthrough.steps, proposalStep],
|
|
966
|
+
}
|
|
967
|
+
: state.walkthrough,
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
default:
|
|
971
|
+
return state;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
/** Shared theme tokens so the prototype cards match the rest of the canvas. */
|
|
976
|
+
function usePrototypeTheme() {
|
|
977
|
+
const { theme } = useTheme();
|
|
978
|
+
return {
|
|
979
|
+
theme,
|
|
980
|
+
border: theme.colors.border ?? "#2d3034",
|
|
981
|
+
muted: theme.colors.textMuted ?? theme.colors.textSecondary ?? "#8b95a3",
|
|
982
|
+
accent: theme.colors.accent ?? theme.colors.primary ?? "#a78bfa",
|
|
983
|
+
warning: theme.colors.warning ?? "#d4a017",
|
|
984
|
+
mono: theme.fonts.monospace,
|
|
985
|
+
small: theme.fontSizes[0],
|
|
986
|
+
body: theme.fontSizes[1],
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
// Slow enough to read each tool call and watch the camera settle between steps.
|
|
991
|
+
const AUTOPLAY_INTERVAL_MS = 1800;
|
|
992
|
+
|
|
993
|
+
function ToolRow({ event }: { event: DriveEvent }) {
|
|
994
|
+
const { theme, border, muted, accent, mono, small } = usePrototypeTheme();
|
|
995
|
+
const isAgentEvent =
|
|
996
|
+
event.kind === "agent" ||
|
|
997
|
+
event.kind === "agent-working" ||
|
|
998
|
+
event.kind === "agent-decision";
|
|
999
|
+
const label =
|
|
1000
|
+
event.kind === "prompt"
|
|
1001
|
+
? "prompt"
|
|
1002
|
+
: event.kind === "agent"
|
|
1003
|
+
? "agent"
|
|
1004
|
+
: event.kind === "agent-working"
|
|
1005
|
+
? "agent · working"
|
|
1006
|
+
: event.kind === "agent-decision"
|
|
1007
|
+
? "agent · decision"
|
|
1008
|
+
: event.tool;
|
|
1009
|
+
const detail =
|
|
1010
|
+
event.kind === "prompt" || isAgentEvent || event.kind === "open-model"
|
|
1011
|
+
? event.text
|
|
1012
|
+
: event.kind === "guide"
|
|
1013
|
+
? `${event.steps.length} steps · ${event.question}`
|
|
1014
|
+
: event.kind === "walk-steps"
|
|
1015
|
+
? `${event.pauseMs}ms · ${event.stepIds.length} steps`
|
|
1016
|
+
: event.kind === "propose-trail"
|
|
1017
|
+
? `add ${event.trail.id}`
|
|
1018
|
+
: event.kind === "propose-component"
|
|
1019
|
+
? `add ${event.component.alias} + ${event.trail.id}`
|
|
1020
|
+
: `change ${event.trailId} step ${event.stepIndex + 1}`;
|
|
1021
|
+
|
|
1022
|
+
return (
|
|
1023
|
+
<div
|
|
1024
|
+
style={{
|
|
1025
|
+
border: `1px solid ${border}`,
|
|
1026
|
+
borderRadius: 6,
|
|
1027
|
+
padding: "8px 10px",
|
|
1028
|
+
display: "grid",
|
|
1029
|
+
gap: 4,
|
|
1030
|
+
background: isAgentEvent
|
|
1031
|
+
? (theme.colors.backgroundHover ??
|
|
1032
|
+
theme.colors.backgroundSecondary ??
|
|
1033
|
+
theme.colors.background)
|
|
1034
|
+
: (theme.colors.backgroundSecondary ?? theme.colors.background),
|
|
1035
|
+
}}
|
|
1036
|
+
>
|
|
1037
|
+
<div
|
|
1038
|
+
style={{
|
|
1039
|
+
display: "flex",
|
|
1040
|
+
justifyContent: "space-between",
|
|
1041
|
+
gap: 8,
|
|
1042
|
+
fontFamily: mono,
|
|
1043
|
+
fontSize: small,
|
|
1044
|
+
color: isAgentEvent ? theme.colors.text : accent,
|
|
1045
|
+
}}
|
|
1046
|
+
>
|
|
1047
|
+
<span>{label}</span>
|
|
1048
|
+
<span style={{ color: muted }}>completed</span>
|
|
1049
|
+
</div>
|
|
1050
|
+
<div style={{ fontSize: small, lineHeight: 1.5, color: muted }}>
|
|
1051
|
+
{detail}
|
|
1052
|
+
</div>
|
|
1053
|
+
</div>
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
function Prototype({
|
|
1058
|
+
events,
|
|
1059
|
+
title,
|
|
1060
|
+
persistKey,
|
|
1061
|
+
description,
|
|
1062
|
+
}: {
|
|
1063
|
+
events: DriveEvent[];
|
|
1064
|
+
title: string;
|
|
1065
|
+
persistKey: string;
|
|
1066
|
+
description: string;
|
|
1067
|
+
}) {
|
|
1068
|
+
const { theme, border, muted, accent, warning, mono, small, body } =
|
|
1069
|
+
usePrototypeTheme();
|
|
1070
|
+
const openingEventCount = useMemo(
|
|
1071
|
+
() => openingEventCountFor(events),
|
|
1072
|
+
[events],
|
|
1073
|
+
);
|
|
1074
|
+
const [state, setState] = useState<DriveState>(initialState);
|
|
1075
|
+
const [cursor, setCursor] = useState(0);
|
|
1076
|
+
const [playing, setPlaying] = useState(false);
|
|
1077
|
+
const [openingKey, setOpeningKey] = useState(0);
|
|
1078
|
+
const [drivenHeaderMode, setDrivenHeaderMode] = useState(true);
|
|
1079
|
+
|
|
1080
|
+
// Applying the open call remounts the artifact so its entrance replays each
|
|
1081
|
+
// time the host emits it.
|
|
1082
|
+
const applyDriveEvent = useCallback((event: DriveEvent) => {
|
|
1083
|
+
setState((prev) => applyEvent(event, prev));
|
|
1084
|
+
if (event.kind === "open-model") {
|
|
1085
|
+
setOpeningKey((prev) => prev + 1);
|
|
1086
|
+
}
|
|
1087
|
+
}, []);
|
|
1088
|
+
|
|
1089
|
+
useEffect(() => {
|
|
1090
|
+
if (!playing) return;
|
|
1091
|
+
if (cursor >= events.length) {
|
|
1092
|
+
setPlaying(false);
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
const timer = window.setTimeout(() => {
|
|
1096
|
+
const event = events[cursor]!;
|
|
1097
|
+
applyDriveEvent(event);
|
|
1098
|
+
setCursor((prev) => prev + 1);
|
|
1099
|
+
}, AUTOPLAY_INTERVAL_MS);
|
|
1100
|
+
return () => window.clearTimeout(timer);
|
|
1101
|
+
}, [cursor, playing, events, applyDriveEvent]);
|
|
1102
|
+
|
|
1103
|
+
const reset = useCallback(() => {
|
|
1104
|
+
setState(initialState());
|
|
1105
|
+
setCursor(0);
|
|
1106
|
+
setPlaying(false);
|
|
1107
|
+
}, []);
|
|
1108
|
+
|
|
1109
|
+
// Replay the host moment: prompt and agent land first, then the open call
|
|
1110
|
+
// reveals the artifact, then the rest of the stream arrives behind it.
|
|
1111
|
+
const animateOpening = useCallback(() => {
|
|
1112
|
+
setState(initialState());
|
|
1113
|
+
events.slice(0, openingEventCount).forEach(applyDriveEvent);
|
|
1114
|
+
setCursor(openingEventCount);
|
|
1115
|
+
setPlaying(true);
|
|
1116
|
+
}, [applyDriveEvent, events, openingEventCount]);
|
|
1117
|
+
|
|
1118
|
+
const step = useCallback(() => {
|
|
1119
|
+
if (cursor >= events.length) return;
|
|
1120
|
+
applyDriveEvent(events[cursor]!);
|
|
1121
|
+
setCursor((prev) => prev + 1);
|
|
1122
|
+
}, [cursor, events, applyDriveEvent]);
|
|
1123
|
+
|
|
1124
|
+
const emphasis = useMemo(
|
|
1125
|
+
() => buildStepEmphasisMap(state.records),
|
|
1126
|
+
[state.records],
|
|
1127
|
+
);
|
|
1128
|
+
|
|
1129
|
+
// A proposed component stays host-local. It is visible while awaiting a
|
|
1130
|
+
// decision (and after acceptance) so its box can be decorated/committed, but
|
|
1131
|
+
// disappears entirely on rejection.
|
|
1132
|
+
const visibleComponents = useMemo(() => {
|
|
1133
|
+
const pending = state.pendingComponent;
|
|
1134
|
+
if (
|
|
1135
|
+
!pending ||
|
|
1136
|
+
state.lastDecision === "rejected" ||
|
|
1137
|
+
state.components.some((c) => c.alias === pending.alias)
|
|
1138
|
+
) {
|
|
1139
|
+
return state.components;
|
|
1140
|
+
}
|
|
1141
|
+
return [...state.components, pending];
|
|
1142
|
+
}, [state.components, state.pendingComponent, state.lastDecision]);
|
|
1143
|
+
|
|
1144
|
+
// Proposals are host-local until confirmed, but they still need to be in the
|
|
1145
|
+
// graph so the guide can focus their trail/step before the decision.
|
|
1146
|
+
const visibleTrails = useMemo(() => {
|
|
1147
|
+
const pendingTrail = state.pendingTrail;
|
|
1148
|
+
if (
|
|
1149
|
+
pendingTrail &&
|
|
1150
|
+
state.lastDecision !== "rejected" &&
|
|
1151
|
+
!state.trails.some((t) => t.id === pendingTrail.id)
|
|
1152
|
+
) {
|
|
1153
|
+
return [...state.trails, pendingTrail];
|
|
1154
|
+
}
|
|
1155
|
+
const pendingStep = state.pendingStep;
|
|
1156
|
+
if (!pendingStep || state.lastDecision === "rejected") {
|
|
1157
|
+
return state.trails;
|
|
1158
|
+
}
|
|
1159
|
+
return state.trails.map((trail) =>
|
|
1160
|
+
trail.id === pendingStep.trailId
|
|
1161
|
+
? {
|
|
1162
|
+
...trail,
|
|
1163
|
+
steps: trail.steps.map((step, i) =>
|
|
1164
|
+
i === pendingStep.stepIndex ? pendingStep.step : step,
|
|
1165
|
+
),
|
|
1166
|
+
}
|
|
1167
|
+
: trail,
|
|
1168
|
+
);
|
|
1169
|
+
}, [state.trails, state.pendingTrail, state.pendingStep, state.lastDecision]);
|
|
1170
|
+
|
|
1171
|
+
const activeGuideIndex = useMemo(
|
|
1172
|
+
() =>
|
|
1173
|
+
state.walkthrough
|
|
1174
|
+
? state.walkthrough.steps.findIndex(
|
|
1175
|
+
(s) => s.id === state.walkthrough?.activeStepId,
|
|
1176
|
+
)
|
|
1177
|
+
: -1,
|
|
1178
|
+
[state.walkthrough],
|
|
1179
|
+
);
|
|
1180
|
+
const activeGuideStep =
|
|
1181
|
+
activeGuideIndex >= 0 && state.walkthrough
|
|
1182
|
+
? state.walkthrough.steps[activeGuideIndex]
|
|
1183
|
+
: undefined;
|
|
1184
|
+
const hasProposalStep =
|
|
1185
|
+
state.walkthrough?.steps.some((s) => s.proposal) ?? false;
|
|
1186
|
+
|
|
1187
|
+
// While an agent-working event is active, light up the components it is
|
|
1188
|
+
// working on: the pending proposal's participants, or the current step's.
|
|
1189
|
+
const workingComponentAliases = useMemo(() => {
|
|
1190
|
+
if (!state.agentWorkingOn) return undefined;
|
|
1191
|
+
const aliases = new Set<string>();
|
|
1192
|
+
const addStep = (step?: SubsystemTrailStep) => {
|
|
1193
|
+
if (!step) return;
|
|
1194
|
+
aliases.add(step.from);
|
|
1195
|
+
aliases.add(step.to);
|
|
1196
|
+
};
|
|
1197
|
+
if (state.pendingComponent) aliases.add(state.pendingComponent.alias);
|
|
1198
|
+
if (state.pendingRemoval) aliases.add(state.pendingRemoval);
|
|
1199
|
+
state.pendingTrail?.steps.forEach(addStep);
|
|
1200
|
+
if (state.pendingStep) {
|
|
1201
|
+
addStep(state.pendingStep.step);
|
|
1202
|
+
} else if (activeGuideStep?.trailId) {
|
|
1203
|
+
const trail = visibleTrails.find((t) => t.id === activeGuideStep.trailId);
|
|
1204
|
+
if (activeGuideStep.stepIndex == null) {
|
|
1205
|
+
trail?.steps.forEach(addStep);
|
|
1206
|
+
} else {
|
|
1207
|
+
addStep(trail?.steps[activeGuideStep.stepIndex]);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
return aliases.size ? aliases : undefined;
|
|
1211
|
+
}, [
|
|
1212
|
+
state.agentWorkingOn,
|
|
1213
|
+
state.pendingComponent,
|
|
1214
|
+
state.pendingRemoval,
|
|
1215
|
+
state.pendingTrail,
|
|
1216
|
+
state.pendingStep,
|
|
1217
|
+
activeGuideStep,
|
|
1218
|
+
visibleTrails,
|
|
1219
|
+
]);
|
|
1220
|
+
|
|
1221
|
+
// Emphasis is a step effect, not a separate tool call: guidance is attached
|
|
1222
|
+
// to a walkthrough step and lands on the model when that step becomes active.
|
|
1223
|
+
useEffect(() => {
|
|
1224
|
+
if (!activeGuideStep?.guidance) return;
|
|
1225
|
+
const trail = visibleTrails.find((t) => t.id === activeGuideStep.trailId);
|
|
1226
|
+
const step = trail?.steps[activeGuideStep.stepIndex ?? -1];
|
|
1227
|
+
if (!trail || !step) return;
|
|
1228
|
+
const stepKey = stepClaimKey(step);
|
|
1229
|
+
const guidance = activeGuideStep.guidance;
|
|
1230
|
+
setState((prev) => {
|
|
1231
|
+
if (
|
|
1232
|
+
prev.records.some(
|
|
1233
|
+
(r) => r.trailId === trail.id && r.stepKey === stepKey,
|
|
1234
|
+
)
|
|
1235
|
+
) {
|
|
1236
|
+
return prev;
|
|
1237
|
+
}
|
|
1238
|
+
return {
|
|
1239
|
+
...prev,
|
|
1240
|
+
records: [
|
|
1241
|
+
...prev.records,
|
|
1242
|
+
{
|
|
1243
|
+
trailId: trail.id,
|
|
1244
|
+
stepKey,
|
|
1245
|
+
guidance,
|
|
1246
|
+
provenance: {
|
|
1247
|
+
source: "agent",
|
|
1248
|
+
author: "opencode",
|
|
1249
|
+
at: new Date().toISOString(),
|
|
1250
|
+
},
|
|
1251
|
+
},
|
|
1252
|
+
],
|
|
1253
|
+
};
|
|
1254
|
+
});
|
|
1255
|
+
}, [activeGuideStep, visibleTrails]);
|
|
1256
|
+
|
|
1257
|
+
const focusedTrailStep = useMemo(() => {
|
|
1258
|
+
if (!state.walkthrough) return undefined;
|
|
1259
|
+
if (!activeGuideStep) return null;
|
|
1260
|
+
return {
|
|
1261
|
+
trailId: activeGuideStep.trailId,
|
|
1262
|
+
stepIndex: activeGuideStep.stepIndex,
|
|
1263
|
+
showFile:
|
|
1264
|
+
activeGuideStep.stepIndex == null
|
|
1265
|
+
? false
|
|
1266
|
+
: (activeGuideStep.showFile ?? false),
|
|
1267
|
+
};
|
|
1268
|
+
}, [activeGuideStep, state.walkthrough]);
|
|
1269
|
+
|
|
1270
|
+
const removeGuidance = useCallback(
|
|
1271
|
+
(trail: SubsystemTrail, stepIndex: number) => {
|
|
1272
|
+
const target = trail.steps[stepIndex];
|
|
1273
|
+
if (!target) return;
|
|
1274
|
+
const key = stepClaimKey(target);
|
|
1275
|
+
setState((prev) => ({
|
|
1276
|
+
...prev,
|
|
1277
|
+
records: prev.records.filter(
|
|
1278
|
+
(r) => !(r.trailId === trail.id && r.stepKey === key),
|
|
1279
|
+
),
|
|
1280
|
+
}));
|
|
1281
|
+
},
|
|
1282
|
+
[],
|
|
1283
|
+
);
|
|
1284
|
+
|
|
1285
|
+
const togglePreviousStep = useCallback(() => {
|
|
1286
|
+
setState((prev) => ({
|
|
1287
|
+
...prev,
|
|
1288
|
+
showPreviousStep: !prev.showPreviousStep,
|
|
1289
|
+
}));
|
|
1290
|
+
}, []);
|
|
1291
|
+
|
|
1292
|
+
const moveWalkthroughStep = useCallback((delta: number) => {
|
|
1293
|
+
setState((prev) => {
|
|
1294
|
+
const walkthrough = prev.walkthrough;
|
|
1295
|
+
if (!walkthrough) return prev;
|
|
1296
|
+
const index = walkthrough.steps.findIndex(
|
|
1297
|
+
(s) => s.id === walkthrough.activeStepId,
|
|
1298
|
+
);
|
|
1299
|
+
const nextIndex = index + delta;
|
|
1300
|
+
if (nextIndex < 0 || nextIndex >= walkthrough.steps.length) return prev;
|
|
1301
|
+
const target = walkthrough.steps[nextIndex]!;
|
|
1302
|
+
return {
|
|
1303
|
+
...prev,
|
|
1304
|
+
walkRun: null,
|
|
1305
|
+
walkthrough: { ...walkthrough, activeStepId: target.id },
|
|
1306
|
+
};
|
|
1307
|
+
});
|
|
1308
|
+
}, []);
|
|
1309
|
+
|
|
1310
|
+
// A `walk-steps` call advances the host focus on its own clock. Manual
|
|
1311
|
+
// navigation cancels the run by clearing `walkRun`.
|
|
1312
|
+
useEffect(() => {
|
|
1313
|
+
const run = state.walkRun;
|
|
1314
|
+
if (!run) return;
|
|
1315
|
+
if (run.index >= run.stepIds.length - 1) {
|
|
1316
|
+
setState((prev) =>
|
|
1317
|
+
prev.walkRun === run ? { ...prev, walkRun: null } : prev,
|
|
1318
|
+
);
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
const timer = window.setTimeout(() => {
|
|
1322
|
+
const nextIndex = run.index + 1;
|
|
1323
|
+
const nextStepId = run.stepIds[nextIndex];
|
|
1324
|
+
if (!nextStepId) return;
|
|
1325
|
+
setState((prev) => {
|
|
1326
|
+
if (prev.walkRun !== run) return prev;
|
|
1327
|
+
return {
|
|
1328
|
+
...prev,
|
|
1329
|
+
walkRun: { ...run, index: nextIndex },
|
|
1330
|
+
walkthrough: prev.walkthrough
|
|
1331
|
+
? { ...prev.walkthrough, activeStepId: nextStepId }
|
|
1332
|
+
: prev.walkthrough,
|
|
1333
|
+
};
|
|
1334
|
+
});
|
|
1335
|
+
}, run.pauseMs);
|
|
1336
|
+
return () => window.clearTimeout(timer);
|
|
1337
|
+
}, [state.walkRun]);
|
|
1338
|
+
|
|
1339
|
+
const proposalKind = activeGuideStep?.proposal;
|
|
1340
|
+
const proposalPending =
|
|
1341
|
+
(proposalKind === "trail" && !!state.pendingTrail) ||
|
|
1342
|
+
(proposalKind === "step" && !!state.pendingStep) ||
|
|
1343
|
+
(proposalKind === "component" && !!state.pendingComponent) ||
|
|
1344
|
+
(proposalKind === "removal" && !!state.pendingRemoval);
|
|
1345
|
+
const appliedLabel =
|
|
1346
|
+
proposalKind === "step"
|
|
1347
|
+
? "Change applied"
|
|
1348
|
+
: proposalKind === "removal"
|
|
1349
|
+
? "Removed from model"
|
|
1350
|
+
: "Added to model";
|
|
1351
|
+
const proposalStatus = state.lastDecision
|
|
1352
|
+
? state.lastDecision === "accepted"
|
|
1353
|
+
? appliedLabel
|
|
1354
|
+
: "Kept model as is"
|
|
1355
|
+
: "Awaiting agent decision";
|
|
1356
|
+
|
|
1357
|
+
const guidePanel =
|
|
1358
|
+
state.walkthrough && activeGuideStep ? (
|
|
1359
|
+
<div
|
|
1360
|
+
style={{
|
|
1361
|
+
fontFamily: mono,
|
|
1362
|
+
color: theme.colors.text,
|
|
1363
|
+
}}
|
|
1364
|
+
>
|
|
1365
|
+
<div
|
|
1366
|
+
style={{
|
|
1367
|
+
display: "flex",
|
|
1368
|
+
justifyContent: "space-between",
|
|
1369
|
+
alignItems: "center",
|
|
1370
|
+
}}
|
|
1371
|
+
>
|
|
1372
|
+
{hasProposalStep ? (
|
|
1373
|
+
<span
|
|
1374
|
+
style={{
|
|
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
|
|
1415
|
+
style={{
|
|
1416
|
+
display: "flex",
|
|
1417
|
+
alignItems: "center",
|
|
1418
|
+
gap: 8,
|
|
1419
|
+
marginTop: 12,
|
|
1420
|
+
}}
|
|
1421
|
+
>
|
|
1422
|
+
<button
|
|
1423
|
+
type="button"
|
|
1424
|
+
onClick={() => moveWalkthroughStep(-1)}
|
|
1425
|
+
disabled={activeGuideIndex === 0}
|
|
1426
|
+
style={{
|
|
1427
|
+
padding: "4px 10px",
|
|
1428
|
+
borderRadius: 4,
|
|
1429
|
+
border: `1px solid ${border}`,
|
|
1430
|
+
background: "transparent",
|
|
1431
|
+
color: muted,
|
|
1432
|
+
fontFamily: mono,
|
|
1433
|
+
fontSize: small,
|
|
1434
|
+
cursor: activeGuideIndex === 0 ? "default" : "pointer",
|
|
1435
|
+
opacity: activeGuideIndex === 0 ? 0.5 : 1,
|
|
1436
|
+
}}
|
|
1437
|
+
>
|
|
1438
|
+
Previous
|
|
1439
|
+
</button>
|
|
1440
|
+
<span
|
|
1441
|
+
style={{
|
|
1442
|
+
flex: 1,
|
|
1443
|
+
textAlign: "center",
|
|
1444
|
+
fontSize: small,
|
|
1445
|
+
color: muted,
|
|
1446
|
+
whiteSpace: "nowrap",
|
|
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>
|
|
1477
|
+
</div>
|
|
1478
|
+
) : null;
|
|
1479
|
+
|
|
1480
|
+
// The active step sits above the map so the instruction is read where the
|
|
1481
|
+
// camera is moving. The question and step navigation stay in the left rail.
|
|
1482
|
+
const guideStepCard =
|
|
1483
|
+
state.walkthrough && activeGuideStep ? (
|
|
1484
|
+
<div
|
|
1485
|
+
style={{
|
|
1486
|
+
width: 380,
|
|
1487
|
+
maxWidth: "100%",
|
|
1488
|
+
padding: 12,
|
|
1489
|
+
borderRadius: 6,
|
|
1490
|
+
border: `1px solid ${accent}55`,
|
|
1491
|
+
background:
|
|
1492
|
+
theme.colors.backgroundSecondary ?? theme.colors.background,
|
|
1493
|
+
boxShadow: "0 8px 28px rgba(0,0,0,0.32)",
|
|
1494
|
+
fontFamily: mono,
|
|
1495
|
+
color: theme.colors.text,
|
|
1496
|
+
}}
|
|
1497
|
+
>
|
|
1498
|
+
<div
|
|
1499
|
+
style={{
|
|
1500
|
+
fontSize: body,
|
|
1501
|
+
fontWeight: 600,
|
|
1502
|
+
color: theme.colors.text,
|
|
1503
|
+
}}
|
|
1504
|
+
>
|
|
1505
|
+
{activeGuideStep.title}
|
|
1506
|
+
</div>
|
|
1507
|
+
<p
|
|
1508
|
+
style={{
|
|
1509
|
+
margin: "6px 0 0",
|
|
1510
|
+
fontSize: small,
|
|
1511
|
+
lineHeight: 1.5,
|
|
1512
|
+
color: theme.colors.text,
|
|
1513
|
+
}}
|
|
1514
|
+
>
|
|
1515
|
+
{activeGuideStep.body}
|
|
1516
|
+
</p>
|
|
1517
|
+
{proposalPending ? (
|
|
1518
|
+
<div
|
|
1519
|
+
aria-live="polite"
|
|
1520
|
+
style={{ marginTop: 10, fontSize: small, color: warning }}
|
|
1521
|
+
>
|
|
1522
|
+
{proposalStatus}
|
|
1523
|
+
</div>
|
|
1524
|
+
) : null}
|
|
1525
|
+
</div>
|
|
1526
|
+
) : null;
|
|
1527
|
+
|
|
1528
|
+
// The agent status lives on the graph itself, not in the left guide column.
|
|
1529
|
+
// No pill is shown until the agent starts working or resolves a proposal.
|
|
1530
|
+
const agentStatusOverlay =
|
|
1531
|
+
state.agentWorkingOn || state.lastDecision ? (
|
|
1532
|
+
<div
|
|
1533
|
+
aria-live="polite"
|
|
1534
|
+
style={{
|
|
1535
|
+
display: "flex",
|
|
1536
|
+
alignItems: "center",
|
|
1537
|
+
gap: 8,
|
|
1538
|
+
padding: "6px 12px",
|
|
1539
|
+
borderRadius: 999,
|
|
1540
|
+
border: `1px solid ${state.agentWorkingOn ? accent : warning}`,
|
|
1541
|
+
background:
|
|
1542
|
+
theme.colors.backgroundSecondary ?? theme.colors.background,
|
|
1543
|
+
boxShadow: "0 6px 20px rgba(0,0,0,0.35)",
|
|
1544
|
+
fontFamily: mono,
|
|
1545
|
+
fontSize: small,
|
|
1546
|
+
whiteSpace: "nowrap",
|
|
1547
|
+
}}
|
|
1548
|
+
>
|
|
1549
|
+
{state.agentWorkingOn ? (
|
|
1550
|
+
<>
|
|
1551
|
+
<span
|
|
1552
|
+
className="agent-working-dot"
|
|
1553
|
+
style={{
|
|
1554
|
+
width: 6,
|
|
1555
|
+
height: 6,
|
|
1556
|
+
borderRadius: "50%",
|
|
1557
|
+
background: accent,
|
|
1558
|
+
flexShrink: 0,
|
|
1559
|
+
}}
|
|
1560
|
+
/>
|
|
1561
|
+
<span style={{ color: accent, fontWeight: 600 }}>
|
|
1562
|
+
AGENT WORKING ON
|
|
1563
|
+
</span>
|
|
1564
|
+
<span style={{ color: theme.colors.text }}>
|
|
1565
|
+
{state.agentWorkingOn}
|
|
1566
|
+
</span>
|
|
1567
|
+
</>
|
|
1568
|
+
) : (
|
|
1569
|
+
<span style={{ color: warning, fontWeight: 600 }}>
|
|
1570
|
+
{state.lastDecision === "accepted"
|
|
1571
|
+
? "AGENT COMMITTED PROPOSAL"
|
|
1572
|
+
: "AGENT DECLINED PROPOSAL"}
|
|
1573
|
+
</span>
|
|
1574
|
+
)}
|
|
1575
|
+
</div>
|
|
1576
|
+
) : null;
|
|
1577
|
+
|
|
1578
|
+
// The step card and agent status float as one stack over the map, so the
|
|
1579
|
+
// status lands directly beneath the card instead of above it.
|
|
1580
|
+
const graphCardStack =
|
|
1581
|
+
guideStepCard || agentStatusOverlay ? (
|
|
1582
|
+
<div
|
|
1583
|
+
style={{
|
|
1584
|
+
position: "absolute",
|
|
1585
|
+
top: 56,
|
|
1586
|
+
left: "50%",
|
|
1587
|
+
transform: "translateX(-50%)",
|
|
1588
|
+
zIndex: 20,
|
|
1589
|
+
pointerEvents: "none",
|
|
1590
|
+
display: "flex",
|
|
1591
|
+
flexDirection: "column",
|
|
1592
|
+
alignItems: "center",
|
|
1593
|
+
gap: 8,
|
|
1594
|
+
width: "max-content",
|
|
1595
|
+
maxWidth: "calc(100% - 32px)",
|
|
1596
|
+
}}
|
|
1597
|
+
>
|
|
1598
|
+
{guideStepCard}
|
|
1599
|
+
{agentStatusOverlay}
|
|
1600
|
+
</div>
|
|
1601
|
+
) : null;
|
|
1602
|
+
|
|
1603
|
+
// The swap lives in whichever header is currently visible. In driven mode it
|
|
1604
|
+
// sits beside the question; in standard mode it rides in the old header's
|
|
1605
|
+
// actions, whose sidebar-view switch stays part of that header only.
|
|
1606
|
+
const swapHeaderButton = (
|
|
1607
|
+
<button
|
|
1608
|
+
type="button"
|
|
1609
|
+
onClick={() => setDrivenHeaderMode((prev) => !prev)}
|
|
1610
|
+
aria-label="Swap header"
|
|
1611
|
+
style={{
|
|
1612
|
+
padding: "4px 10px",
|
|
1613
|
+
borderRadius: 4,
|
|
1614
|
+
border: `1px solid ${border}`,
|
|
1615
|
+
background: "transparent",
|
|
1616
|
+
color: muted,
|
|
1617
|
+
fontFamily: mono,
|
|
1618
|
+
fontSize: small,
|
|
1619
|
+
cursor: "pointer",
|
|
1620
|
+
whiteSpace: "nowrap",
|
|
1621
|
+
}}
|
|
1622
|
+
>
|
|
1623
|
+
Swap header
|
|
1624
|
+
</button>
|
|
1625
|
+
);
|
|
1626
|
+
|
|
1627
|
+
const drivenHeader = drivenHeaderMode ? (
|
|
1628
|
+
<header
|
|
1629
|
+
style={{
|
|
1630
|
+
position: "relative",
|
|
1631
|
+
flexShrink: 0,
|
|
1632
|
+
display: "flex",
|
|
1633
|
+
alignItems: "center",
|
|
1634
|
+
gap: 12,
|
|
1635
|
+
padding: "12px 16px",
|
|
1636
|
+
background: theme.colors.background,
|
|
1637
|
+
borderBottom: `1px solid ${border}`,
|
|
1638
|
+
fontFamily: mono,
|
|
1639
|
+
}}
|
|
1640
|
+
>
|
|
1641
|
+
<span
|
|
1642
|
+
style={{
|
|
1643
|
+
fontSize: small,
|
|
1644
|
+
letterSpacing: "0.08em",
|
|
1645
|
+
fontWeight: 600,
|
|
1646
|
+
color: accent,
|
|
1647
|
+
whiteSpace: "nowrap",
|
|
1648
|
+
}}
|
|
1649
|
+
>
|
|
1650
|
+
AGENT-DRIVEN
|
|
1651
|
+
</span>
|
|
1652
|
+
<span
|
|
1653
|
+
style={{
|
|
1654
|
+
position: "absolute",
|
|
1655
|
+
left: "50%",
|
|
1656
|
+
transform: "translateX(-50%)",
|
|
1657
|
+
maxWidth: "calc(100% - 320px)",
|
|
1658
|
+
fontSize: theme.fontSizes[2],
|
|
1659
|
+
color: theme.colors.text,
|
|
1660
|
+
whiteSpace: "nowrap",
|
|
1661
|
+
overflow: "hidden",
|
|
1662
|
+
textOverflow: "ellipsis",
|
|
1663
|
+
textAlign: "center",
|
|
1664
|
+
pointerEvents: "none",
|
|
1665
|
+
}}
|
|
1666
|
+
>
|
|
1667
|
+
{state.walkthrough?.question ?? title}
|
|
1668
|
+
</span>
|
|
1669
|
+
<span style={{ marginLeft: "auto" }}>{swapHeaderButton}</span>
|
|
1670
|
+
</header>
|
|
1671
|
+
) : null;
|
|
1672
|
+
|
|
1673
|
+
return (
|
|
1674
|
+
<div
|
|
1675
|
+
style={{
|
|
1676
|
+
display: "flex",
|
|
1677
|
+
height: "100vh",
|
|
1678
|
+
background: theme.colors.background,
|
|
1679
|
+
}}
|
|
1680
|
+
>
|
|
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>
|
|
1729
|
+
{state.modelOpen ? (
|
|
1730
|
+
<div
|
|
1731
|
+
key={openingKey}
|
|
1732
|
+
className="agent-model-opening"
|
|
1733
|
+
style={{
|
|
1734
|
+
flex: 1,
|
|
1735
|
+
minWidth: 0,
|
|
1736
|
+
display: "flex",
|
|
1737
|
+
flexDirection: "column",
|
|
1738
|
+
}}
|
|
1739
|
+
>
|
|
1740
|
+
{drivenHeader}
|
|
1741
|
+
<div style={{ flex: 1, minHeight: 0, position: "relative" }}>
|
|
1742
|
+
<SubsystemComponentGraph
|
|
1743
|
+
components={visibleComponents}
|
|
1744
|
+
trails={visibleTrails}
|
|
1745
|
+
focusedTrailStep={focusedTrailStep}
|
|
1746
|
+
proposedTrailIds={
|
|
1747
|
+
state.pendingTrail && !state.lastDecision
|
|
1748
|
+
? new Set([state.pendingTrail.id])
|
|
1749
|
+
: undefined
|
|
1750
|
+
}
|
|
1751
|
+
proposedStepKeys={
|
|
1752
|
+
state.pendingStep && !state.lastDecision
|
|
1753
|
+
? new Set([
|
|
1754
|
+
emphasisKey(
|
|
1755
|
+
state.pendingStep.trailId,
|
|
1756
|
+
state.pendingStep.step,
|
|
1757
|
+
),
|
|
1758
|
+
])
|
|
1759
|
+
: undefined
|
|
1760
|
+
}
|
|
1761
|
+
stepChange={state.stepChange}
|
|
1762
|
+
showPreviousStep={state.showPreviousStep}
|
|
1763
|
+
onTogglePreviousStep={togglePreviousStep}
|
|
1764
|
+
proposedComponentAliases={
|
|
1765
|
+
state.pendingComponent && !state.lastDecision
|
|
1766
|
+
? new Set([state.pendingComponent.alias])
|
|
1767
|
+
: undefined
|
|
1768
|
+
}
|
|
1769
|
+
workingComponentAliases={workingComponentAliases}
|
|
1770
|
+
removedComponentAliases={state.removedComponentAliases}
|
|
1771
|
+
canvasOverlay={graphCardStack}
|
|
1772
|
+
trailFocusDurationMs={600}
|
|
1773
|
+
focusVerticalBiasPx={96}
|
|
1774
|
+
persistKey={persistKey}
|
|
1775
|
+
stepEmphasis={emphasis}
|
|
1776
|
+
onRemoveStepEmphasis={removeGuidance}
|
|
1777
|
+
sidebarAfterDescription={guidePanel}
|
|
1778
|
+
hideHeader={drivenHeaderMode}
|
|
1779
|
+
headerActions={drivenHeaderMode ? undefined : swapHeaderButton}
|
|
1780
|
+
title={title}
|
|
1781
|
+
description={state.walkthrough ? undefined : description}
|
|
1782
|
+
notes={
|
|
1783
|
+
state.walkthrough
|
|
1784
|
+
? undefined
|
|
1785
|
+
: "**Prototype boundary:** this is Storybook-only. The same tool-call shapes can later be emitted by the MCP bridge; the portable model document is untouched."
|
|
1786
|
+
}
|
|
1787
|
+
/>
|
|
1788
|
+
</div>
|
|
1789
|
+
</div>
|
|
1790
|
+
) : (
|
|
1791
|
+
<div
|
|
1792
|
+
style={{
|
|
1793
|
+
flex: 1,
|
|
1794
|
+
minWidth: 0,
|
|
1795
|
+
background: theme.colors.background,
|
|
1796
|
+
}}
|
|
1797
|
+
/>
|
|
1798
|
+
)}
|
|
1799
|
+
|
|
1800
|
+
<aside
|
|
1801
|
+
style={{
|
|
1802
|
+
width: 390,
|
|
1803
|
+
flexShrink: 0,
|
|
1804
|
+
display: "flex",
|
|
1805
|
+
flexDirection: "column",
|
|
1806
|
+
borderLeft: `1px solid ${border}`,
|
|
1807
|
+
background: theme.colors.background,
|
|
1808
|
+
overflow: "hidden",
|
|
1809
|
+
}}
|
|
1810
|
+
>
|
|
1811
|
+
<header
|
|
1812
|
+
style={{
|
|
1813
|
+
padding: "14px 16px 10px",
|
|
1814
|
+
borderBottom: `1px solid ${border}`,
|
|
1815
|
+
}}
|
|
1816
|
+
>
|
|
1817
|
+
<div
|
|
1818
|
+
style={{
|
|
1819
|
+
fontFamily: mono,
|
|
1820
|
+
fontSize: body,
|
|
1821
|
+
color: theme.colors.text,
|
|
1822
|
+
}}
|
|
1823
|
+
>
|
|
1824
|
+
Agent tool stream
|
|
1825
|
+
</div>
|
|
1826
|
+
<p
|
|
1827
|
+
style={{
|
|
1828
|
+
margin: "6px 0 0",
|
|
1829
|
+
fontSize: small,
|
|
1830
|
+
lineHeight: 1.5,
|
|
1831
|
+
color: muted,
|
|
1832
|
+
}}
|
|
1833
|
+
>
|
|
1834
|
+
Step through the fake calls or play them like a live session.
|
|
1835
|
+
</p>
|
|
1836
|
+
<div style={{ display: "flex", gap: 6, marginTop: 10 }}>
|
|
1837
|
+
<button
|
|
1838
|
+
type="button"
|
|
1839
|
+
onClick={step}
|
|
1840
|
+
disabled={cursor >= events.length}
|
|
1841
|
+
style={{
|
|
1842
|
+
padding: "4px 10px",
|
|
1843
|
+
borderRadius: 4,
|
|
1844
|
+
border: `1px solid ${border}`,
|
|
1845
|
+
background:
|
|
1846
|
+
theme.colors.backgroundSecondary ?? theme.colors.background,
|
|
1847
|
+
color: theme.colors.text,
|
|
1848
|
+
fontFamily: mono,
|
|
1849
|
+
fontSize: small,
|
|
1850
|
+
cursor: cursor >= events.length ? "default" : "pointer",
|
|
1851
|
+
opacity: cursor >= events.length ? 0.5 : 1,
|
|
1852
|
+
}}
|
|
1853
|
+
>
|
|
1854
|
+
Next tool call
|
|
1855
|
+
</button>
|
|
1856
|
+
<button
|
|
1857
|
+
type="button"
|
|
1858
|
+
onClick={() => setPlaying((prev) => !prev)}
|
|
1859
|
+
disabled={cursor >= events.length && !playing}
|
|
1860
|
+
style={{
|
|
1861
|
+
padding: "4px 10px",
|
|
1862
|
+
borderRadius: 4,
|
|
1863
|
+
border: `1px solid ${accent}`,
|
|
1864
|
+
background: `${accent}18`,
|
|
1865
|
+
color: accent,
|
|
1866
|
+
fontFamily: mono,
|
|
1867
|
+
fontSize: small,
|
|
1868
|
+
fontWeight: 600,
|
|
1869
|
+
cursor: "pointer",
|
|
1870
|
+
}}
|
|
1871
|
+
>
|
|
1872
|
+
{playing ? "Pause" : "Play"}
|
|
1873
|
+
</button>
|
|
1874
|
+
<button
|
|
1875
|
+
type="button"
|
|
1876
|
+
onClick={reset}
|
|
1877
|
+
style={{
|
|
1878
|
+
padding: "4px 10px",
|
|
1879
|
+
borderRadius: 4,
|
|
1880
|
+
border: `1px solid ${border}`,
|
|
1881
|
+
background: "transparent",
|
|
1882
|
+
color: muted,
|
|
1883
|
+
fontFamily: mono,
|
|
1884
|
+
fontSize: small,
|
|
1885
|
+
cursor: "pointer",
|
|
1886
|
+
}}
|
|
1887
|
+
>
|
|
1888
|
+
Reset
|
|
1889
|
+
</button>
|
|
1890
|
+
<button
|
|
1891
|
+
type="button"
|
|
1892
|
+
onClick={animateOpening}
|
|
1893
|
+
style={{
|
|
1894
|
+
padding: "4px 10px",
|
|
1895
|
+
borderRadius: 4,
|
|
1896
|
+
border: `1px solid ${border}`,
|
|
1897
|
+
background: "transparent",
|
|
1898
|
+
color: muted,
|
|
1899
|
+
fontFamily: mono,
|
|
1900
|
+
fontSize: small,
|
|
1901
|
+
cursor: "pointer",
|
|
1902
|
+
}}
|
|
1903
|
+
>
|
|
1904
|
+
Animate opening
|
|
1905
|
+
</button>
|
|
1906
|
+
</div>
|
|
1907
|
+
<div style={{ marginTop: 8, fontSize: small, color: muted }}>
|
|
1908
|
+
{cursor} / {events.length} calls replayed
|
|
1909
|
+
</div>
|
|
1910
|
+
</header>
|
|
1911
|
+
|
|
1912
|
+
<div
|
|
1913
|
+
style={{
|
|
1914
|
+
flex: 1,
|
|
1915
|
+
minHeight: 0,
|
|
1916
|
+
overflow: "auto",
|
|
1917
|
+
padding: "12px 16px",
|
|
1918
|
+
display: "grid",
|
|
1919
|
+
gap: 8,
|
|
1920
|
+
alignContent: "start",
|
|
1921
|
+
}}
|
|
1922
|
+
>
|
|
1923
|
+
{events.slice(0, cursor).map((event) => (
|
|
1924
|
+
<ToolRow key={event.id} event={event} />
|
|
1925
|
+
))}
|
|
1926
|
+
</div>
|
|
1927
|
+
</aside>
|
|
1928
|
+
</div>
|
|
1929
|
+
);
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
export const Walkthrough: Story = {
|
|
1933
|
+
render: () => (
|
|
1934
|
+
<Prototype
|
|
1935
|
+
events={trailProposalEvents}
|
|
1936
|
+
title="Agent-driven walkthrough · prototype"
|
|
1937
|
+
persistKey="agent-driven-walkthrough-prototype"
|
|
1938
|
+
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."
|
|
1939
|
+
/>
|
|
1940
|
+
),
|
|
1941
|
+
};
|
|
1942
|
+
|
|
1943
|
+
export const StepChangeProposal: Story = {
|
|
1944
|
+
render: () => (
|
|
1945
|
+
<Prototype
|
|
1946
|
+
events={stepProposalEvents}
|
|
1947
|
+
title="Agent-driven step change · prototype"
|
|
1948
|
+
persistKey="agent-driven-step-change-prototype"
|
|
1949
|
+
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."
|
|
1950
|
+
/>
|
|
1951
|
+
),
|
|
1952
|
+
};
|
|
1953
|
+
|
|
1954
|
+
export const ComponentProposal: Story = {
|
|
1955
|
+
render: () => (
|
|
1956
|
+
<Prototype
|
|
1957
|
+
events={componentProposalEvents}
|
|
1958
|
+
title="Agent-driven component proposal · prototype"
|
|
1959
|
+
persistKey="agent-driven-component-proposal-prototype"
|
|
1960
|
+
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."
|
|
1961
|
+
/>
|
|
1962
|
+
),
|
|
1963
|
+
};
|
|
1964
|
+
|
|
1965
|
+
export const ComponentRemoval: Story = {
|
|
1966
|
+
render: () => (
|
|
1967
|
+
<Prototype
|
|
1968
|
+
events={componentRemovalEvents}
|
|
1969
|
+
title="Agent-driven component removal · prototype"
|
|
1970
|
+
persistKey="agent-driven-component-removal-prototype"
|
|
1971
|
+
description="A simulated agent retires the confirmation mailer. Its steps leave the trails, while its box stays in place as a dim REMOVED ghost."
|
|
1972
|
+
/>
|
|
1973
|
+
),
|
|
1974
|
+
};
|
|
1975
|
+
|
|
1976
|
+
export const TrailProposalDeclined: Story = {
|
|
1977
|
+
render: () => (
|
|
1978
|
+
<Prototype
|
|
1979
|
+
events={trailDeclinedEvents}
|
|
1980
|
+
title="Agent-driven walkthrough · declined"
|
|
1981
|
+
persistKey="agent-driven-walkthrough-declined-prototype"
|
|
1982
|
+
description="The same narrated trail proposal, but the agent declines it in conversation and the visible model stays unchanged."
|
|
1983
|
+
/>
|
|
1984
|
+
),
|
|
1985
|
+
};
|
|
1986
|
+
|
|
1987
|
+
export const StepProposalDeclined: Story = {
|
|
1988
|
+
render: () => (
|
|
1989
|
+
<Prototype
|
|
1990
|
+
events={stepDeclinedEvents}
|
|
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
|
+
};
|
|
1997
|
+
|
|
1998
|
+
export const ComponentProposalDeclined: Story = {
|
|
1999
|
+
render: () => (
|
|
2000
|
+
<Prototype
|
|
2001
|
+
events={componentDeclinedEvents}
|
|
2002
|
+
title="Agent-driven component proposal · declined"
|
|
2003
|
+
persistKey="agent-driven-component-proposal-declined-prototype"
|
|
2004
|
+
description="The agent reviews the staged component and trail, declines them, and no new box appears in the model."
|
|
2005
|
+
/>
|
|
2006
|
+
),
|
|
2007
|
+
};
|