@blackbelt-technology/pi-dashboard-flows-plugin 0.5.3 → 0.6.0
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/package.json +48 -4
- package/src/AGENTS.md +8 -0
- package/src/__tests__/FlowGraph.test.ts +151 -5
- package/src/__tests__/FlowInputWiring.test.tsx +97 -0
- package/src/__tests__/FlowSummary.test.tsx +331 -0
- package/src/__tests__/FlowYamlPreview.test.tsx +75 -0
- package/src/__tests__/FlowsSessionStateContext.test.tsx +223 -0
- package/src/__tests__/FlowsUiStateContext.test.tsx +140 -0
- package/src/__tests__/authoring-renderers.test.tsx +190 -0
- package/src/__tests__/automation-actions.test.ts +117 -0
- package/src/__tests__/flow-agent-card-code-source.test.tsx +154 -0
- package/src/__tests__/flow-agent-cost.test.tsx +160 -0
- package/src/__tests__/flow-agent-error.test.ts +60 -0
- package/src/__tests__/flow-collapse-storage.test.ts +90 -0
- package/src/__tests__/flow-edges.test.ts +195 -0
- package/src/__tests__/flow-inputs.test.ts +69 -0
- package/src/__tests__/flow-reducer-bridge-contract.test.ts +108 -0
- package/src/__tests__/flow-reducer-seed-on-start.test.ts +61 -0
- package/src/__tests__/flow-yaml-parse.test.ts +124 -0
- package/src/__tests__/flows-for-cwd.test.ts +51 -0
- package/src/__tests__/flowsAvailability.test.ts +79 -0
- package/src/__tests__/manifest-discoverability.test.ts +97 -0
- package/src/__tests__/node-kind-reducer.test.ts +135 -0
- package/src/__tests__/plugin-action-handler.test.ts +54 -0
- package/src/__tests__/render-actions.test.ts +63 -0
- package/src/__tests__/session-flow-actions-edit.test.tsx +98 -0
- package/src/bridge/AGENTS.md +8 -0
- package/src/bridge/flow-question-adapter.ts +93 -0
- package/src/bridge/index.ts +30 -0
- package/src/client/AGENTS.md +32 -0
- package/src/client/FlowActivityBadge.tsx +41 -11
- package/src/client/FlowAgentCard.tsx +321 -61
- package/src/client/FlowAgentDetail.tsx +103 -154
- package/src/client/FlowAgentsToolRenderer.tsx +228 -0
- package/src/client/FlowAuthorPromptDialog.tsx +92 -0
- package/src/client/FlowDashboard.tsx +271 -43
- package/src/client/FlowGraph.tsx +425 -276
- package/src/client/FlowInputWiring.tsx +243 -0
- package/src/client/FlowLaunchDialog.tsx +52 -52
- package/src/client/FlowQuestionCard.tsx +216 -0
- package/src/client/FlowQuestionTranscriptPill.tsx +58 -0
- package/src/client/FlowSummary.tsx +285 -80
- package/src/client/FlowWriteToolRenderer.tsx +127 -0
- package/src/client/FlowYamlPopoverButton.tsx +110 -0
- package/src/client/FlowYamlPreview.tsx +67 -0
- package/src/client/FlowsCommandRoutes.tsx +237 -0
- package/src/client/FlowsSessionStateContext.tsx +142 -0
- package/src/client/FlowsSettings.tsx +68 -0
- package/src/client/FlowsUiStateContext.tsx +169 -0
- package/src/client/SessionFlowActions.tsx +172 -65
- package/src/client/flow-collapse-storage.ts +79 -0
- package/src/client/flow-edges.ts +173 -0
- package/src/client/flow-yaml-parse.ts +140 -0
- package/src/client/flowsAvailability.ts +44 -0
- package/src/client/index.tsx +95 -13
- package/src/client/shouldRender.ts +38 -0
- package/src/configSchema.json +14 -0
- package/src/flow-reducer.ts +94 -13
- package/src/i18n.ts +90 -0
- package/src/reducer.ts +5 -5
- package/src/server/AGENTS.md +10 -0
- package/src/server/automation-actions.ts +162 -0
- package/src/server/flow-inputs.ts +58 -0
- package/src/server/index.ts +171 -0
- package/src/server/render-actions.ts +88 -0
- package/src/server/state-store.ts +74 -0
- package/src/__tests__/ArchitectInputPrompt.test.tsx +0 -81
- package/src/__tests__/architect-reducer.test.ts +0 -307
- package/src/architect-reducer.ts +0 -386
- package/src/client/FlowArchitect.tsx +0 -622
|
@@ -1,45 +1,64 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
type InteractiveUiRequestSnapshot,
|
|
3
|
+
usePluginSend,
|
|
4
|
+
useSessionInteractiveRequests,
|
|
5
|
+
useT,
|
|
6
|
+
useUiPrimitiveOrNull,
|
|
7
|
+
} from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
8
|
+
import { BreadcrumbSlot } from "@blackbelt-technology/pi-dashboard-client-utils/extension-ui/BreadcrumbSlot";
|
|
9
|
+
import { useMobile } from "@blackbelt-technology/pi-dashboard-client-utils/useMobile";
|
|
10
|
+
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
11
|
+
import type { DashboardSession, FlowState, ImageContent } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
12
|
+
import { mdiChevronDown, mdiChevronRight, mdiChevronUp, mdiFileDocumentOutline, mdiLoading, mdiRobotOutline, mdiStop } from "@mdi/js";
|
|
2
13
|
import { Icon } from "@mdi/react";
|
|
3
|
-
import
|
|
4
|
-
import type { DashboardSession, FlowState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
14
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
15
|
import { FlowAgentCard } from "./FlowAgentCard.js";
|
|
6
16
|
import { FlowGraph, flowStateToGraphSteps } from "./FlowGraph.js";
|
|
17
|
+
import { FlowQuestionCard } from "./FlowQuestionCard.js";
|
|
18
|
+
import { FlowQuestionTranscriptPill } from "./FlowQuestionTranscriptPill.js";
|
|
7
19
|
import { FlowSummary } from "./FlowSummary.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
20
|
+
import { useFlowsSessionState } from "./FlowsSessionStateContext.js";
|
|
21
|
+
import { type FlowTab, FlowTabBar } from "./FlowTabBar.js";
|
|
22
|
+
import { FlowYamlPopoverButton } from "./FlowYamlPopoverButton.js";
|
|
23
|
+
import { useFlowCollapsePersisted } from "./flow-collapse-storage.js";
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
11
27
|
|
|
12
28
|
export function FlowDashboard({
|
|
13
29
|
flowState,
|
|
14
30
|
flowStates,
|
|
15
|
-
onAgentClick,
|
|
16
|
-
selectedAgent,
|
|
17
31
|
onAbort,
|
|
18
32
|
onToggleAutonomous,
|
|
19
33
|
onDismiss,
|
|
20
34
|
onSendPrompt,
|
|
21
|
-
onViewYaml,
|
|
22
|
-
onViewAgentSource,
|
|
23
|
-
sourceOpenAgent,
|
|
24
35
|
session,
|
|
36
|
+
sessionId,
|
|
25
37
|
}: {
|
|
26
38
|
flowState: FlowState;
|
|
27
|
-
/** All flow states (
|
|
39
|
+
/** All flow states (one per distinct flow run this session) for tab navigation */
|
|
28
40
|
flowStates?: Map<string, FlowState>;
|
|
29
|
-
onAgentClick: (agentName: string | null) => void;
|
|
30
|
-
selectedAgent?: string | null;
|
|
31
41
|
onAbort: () => void;
|
|
32
42
|
onToggleAutonomous: () => void;
|
|
33
43
|
onDismiss: () => void;
|
|
34
44
|
onSendPrompt?: (text: string, images?: import("@blackbelt-technology/pi-dashboard-shared/types.js").ImageContent[]) => void;
|
|
35
|
-
onViewYaml?: () => void;
|
|
36
|
-
onViewAgentSource?: (sourcePath: string, agentName: string) => void;
|
|
37
|
-
sourceOpenAgent?: string | null;
|
|
38
45
|
/** Phase-2 decorator host — carries breadcrumb + agent-metric descriptors. */
|
|
39
46
|
session?: Pick<DashboardSession, "uiDecorators">;
|
|
47
|
+
/** Session id — threaded so child cards can render popout URLs and the
|
|
48
|
+
upper-slot question card can submit responses. See change: add-flow-agent-popout. */
|
|
49
|
+
sessionId?: string;
|
|
40
50
|
}) {
|
|
41
51
|
const isMobile = useMobile();
|
|
42
|
-
const
|
|
52
|
+
const t = useT();
|
|
53
|
+
const Dialog = useUiPrimitiveOrNull(UI_PRIMITIVE_KEYS.dialog);
|
|
54
|
+
const [graphOpen, setGraphOpen] = useState(false);
|
|
55
|
+
// Shared graph⇄card selection (live view parity with FlowSummary). See change:
|
|
56
|
+
// improve-flow-graph-dialog-and-card-interaction.
|
|
57
|
+
const [selectedStepId, setSelectedStepId] = useState<string | null>(null);
|
|
58
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
59
|
+
// Persisted per session so a collapsed dashboard stays collapsed across
|
|
60
|
+
// remounts. See change: fix-flow-ui-graph-zoom-summary.
|
|
61
|
+
const [collapsed, toggleCollapsed] = useFlowCollapsePersisted(sessionId, "dashboard");
|
|
43
62
|
const [mobileExpanded, setMobileExpanded] = useState(false);
|
|
44
63
|
const [activeTabId, setActiveTabId] = useState<string>(flowState.flowName);
|
|
45
64
|
const [followMode, setFollowMode] = useState(true);
|
|
@@ -73,20 +92,48 @@ export function FlowDashboard({
|
|
|
73
92
|
|
|
74
93
|
const agents = Array.from(displayState.agents.values());
|
|
75
94
|
const allAgents = Array.from(flowState.agents.values());
|
|
95
|
+
|
|
96
|
+
const handleSelectStep = useCallback((stepId: string) => {
|
|
97
|
+
setSelectedStepId((prev) => (prev === stepId ? null : stepId));
|
|
98
|
+
}, []);
|
|
99
|
+
// Selection is ephemeral; reset when the displayed agent set changes.
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
setSelectedStepId(null);
|
|
102
|
+
}, [displayState.agents]);
|
|
103
|
+
// Esc clears selection (Dialog handles its own Esc independently).
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (!selectedStepId) return;
|
|
106
|
+
const onKey = (e: KeyboardEvent) => {
|
|
107
|
+
if (e.key === "Escape") setSelectedStepId(null);
|
|
108
|
+
};
|
|
109
|
+
window.addEventListener("keydown", onKey);
|
|
110
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
111
|
+
}, [selectedStepId]);
|
|
112
|
+
// Scroll the matching node + card into view on selection (counterpart sync).
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (!selectedStepId || !rootRef.current) return;
|
|
115
|
+
const esc = selectedStepId.replace(/["\\]/g, "\\$&");
|
|
116
|
+
for (const attr of ["data-node", "data-step"]) {
|
|
117
|
+
rootRef.current
|
|
118
|
+
.querySelector(`[${attr}="${esc}"]`)
|
|
119
|
+
?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
120
|
+
}
|
|
121
|
+
}, [selectedStepId]);
|
|
76
122
|
const doneCount = allAgents.filter(a => a.status === "complete" || a.status === "error" || a.status === "blocked").length;
|
|
77
123
|
const totalCount = allAgents.length;
|
|
78
124
|
const isRunning = flowState.status === "running";
|
|
79
125
|
const isComplete = !isRunning;
|
|
80
126
|
|
|
81
|
-
// After completion, show summary
|
|
127
|
+
// After completion, show summary. Forward sessionId so the summary's per-session
|
|
128
|
+
// collapse state persists (the hook no-ops without a session id).
|
|
129
|
+
// See change: fix-flow-ui-graph-zoom-summary.
|
|
82
130
|
if (isComplete) {
|
|
83
131
|
return (
|
|
84
132
|
<FlowSummary
|
|
85
133
|
flowState={flowState}
|
|
86
|
-
onAgentClick={onAgentClick}
|
|
87
134
|
onDismiss={onDismiss}
|
|
88
135
|
onSendPrompt={onSendPrompt}
|
|
89
|
-
|
|
136
|
+
sessionId={sessionId}
|
|
90
137
|
/>
|
|
91
138
|
);
|
|
92
139
|
}
|
|
@@ -122,12 +169,12 @@ export function FlowDashboard({
|
|
|
122
169
|
}
|
|
123
170
|
|
|
124
171
|
return (
|
|
125
|
-
<div className="bg-[var(--bg-secondary)] border-b border-[var(--border-subtle)] px-3 py-2">
|
|
172
|
+
<div ref={rootRef} className="bg-[var(--bg-secondary)] border-b border-[var(--border-subtle)] px-3 py-2">
|
|
126
173
|
{/* Header */}
|
|
127
174
|
<div className="flex items-center gap-2 mb-2">
|
|
128
175
|
<span
|
|
129
176
|
className="inline-flex text-[var(--text-tertiary)] cursor-pointer"
|
|
130
|
-
onClick={
|
|
177
|
+
onClick={toggleCollapsed}
|
|
131
178
|
>
|
|
132
179
|
<Icon path={collapsed ? mdiChevronRight : mdiChevronDown} size={0.6} />
|
|
133
180
|
</span>
|
|
@@ -138,7 +185,7 @@ export function FlowDashboard({
|
|
|
138
185
|
)}
|
|
139
186
|
<span className="text-sm text-[var(--text-primary)] truncate flex-1">
|
|
140
187
|
{flowState.flowName}
|
|
141
|
-
<span className="text-[var(--text-tertiary)] ml-1.5">{doneCount}
|
|
188
|
+
<span className="text-[var(--text-tertiary)] ml-1.5">{t("stepsCount", { done: doneCount, total: totalCount }, `${doneCount}/${totalCount} steps`)}</span>
|
|
142
189
|
</span>
|
|
143
190
|
|
|
144
191
|
{/* Controls */}
|
|
@@ -149,7 +196,7 @@ export function FlowDashboard({
|
|
|
149
196
|
? "border-green-500/40 text-green-400 bg-green-500/10"
|
|
150
197
|
: "border-[var(--border-subtle)] text-[var(--text-tertiary)]"
|
|
151
198
|
}`}
|
|
152
|
-
title="Toggle autonomous mode"
|
|
199
|
+
title={t("toggleAutonomousMode", undefined, "Toggle autonomous mode")}
|
|
153
200
|
>
|
|
154
201
|
<Icon path={mdiRobotOutline} size={0.4} className="inline mr-0.5" />AUTO
|
|
155
202
|
</button>
|
|
@@ -157,9 +204,9 @@ export function FlowDashboard({
|
|
|
157
204
|
<button
|
|
158
205
|
onClick={(e) => { e.stopPropagation(); onAbort(); }}
|
|
159
206
|
className="text-[10px] px-1.5 py-0.5 rounded border border-red-500/30 text-red-400 hover:bg-red-500/10"
|
|
160
|
-
title="Abort flow"
|
|
207
|
+
title={t("abortFlow", undefined, "Abort flow")}
|
|
161
208
|
>
|
|
162
|
-
<Icon path={mdiStop} size={0.4} className="inline mr-0.5" />Abort
|
|
209
|
+
<Icon path={mdiStop} size={0.4} className="inline mr-0.5" />{t("abort", undefined, "Abort")}
|
|
163
210
|
</button>
|
|
164
211
|
)}
|
|
165
212
|
{isMobile && (
|
|
@@ -187,20 +234,49 @@ export function FlowDashboard({
|
|
|
187
234
|
{/* Phase-2 breadcrumb decorator slot. See change: add-extension-ui-decorations. */}
|
|
188
235
|
<BreadcrumbSlot session={session} />
|
|
189
236
|
|
|
237
|
+
{/* Pending flow-question card — head of the per-flow FIFO queue.
|
|
238
|
+
See change: route-flow-asks-to-upper-slot. */}
|
|
239
|
+
{sessionId && (
|
|
240
|
+
<FlowQuestionsSection
|
|
241
|
+
sessionId={sessionId}
|
|
242
|
+
flowId={displayState.flowName}
|
|
243
|
+
/>
|
|
244
|
+
)}
|
|
245
|
+
|
|
190
246
|
<FlowGraph
|
|
191
247
|
steps={flowStateToGraphSteps(displayState)}
|
|
248
|
+
fit
|
|
249
|
+
selectedStepId={selectedStepId}
|
|
250
|
+
onSelectStep={handleSelectStep}
|
|
251
|
+
onExpand={Dialog ? () => setGraphOpen(true) : undefined}
|
|
192
252
|
/>
|
|
193
|
-
{
|
|
253
|
+
{displayState.flowSource && (
|
|
194
254
|
<div className="mt-1">
|
|
195
|
-
<
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
>
|
|
200
|
-
<Icon path={mdiFileDocumentOutline} size={0.5} />
|
|
201
|
-
</button>
|
|
255
|
+
<FlowYamlPopoverButton
|
|
256
|
+
flowSource={displayState.flowSource}
|
|
257
|
+
flowName={displayState.flowName}
|
|
258
|
+
/>
|
|
202
259
|
</div>
|
|
203
260
|
)}
|
|
261
|
+
{/* Expanded graph — centered Dialog with pan/zoom. See change: show-flow-cards-in-summary. */}
|
|
262
|
+
{Dialog && (
|
|
263
|
+
<Dialog
|
|
264
|
+
open={graphOpen}
|
|
265
|
+
onClose={() => setGraphOpen(false)}
|
|
266
|
+
title={`Flow graph · ${displayState.flowName}`}
|
|
267
|
+
size="full"
|
|
268
|
+
>
|
|
269
|
+
{/* Non-fit (pan/zoom) graph fills the full-size dialog. See change:
|
|
270
|
+
improve-flow-graph-dialog-and-card-interaction. */}
|
|
271
|
+
<div style={{ height: "82vh", overflow: "hidden" }}>
|
|
272
|
+
<FlowGraph
|
|
273
|
+
steps={flowStateToGraphSteps(displayState)}
|
|
274
|
+
selectedStepId={selectedStepId}
|
|
275
|
+
onSelectStep={handleSelectStep}
|
|
276
|
+
/>
|
|
277
|
+
</div>
|
|
278
|
+
</Dialog>
|
|
279
|
+
)}
|
|
204
280
|
|
|
205
281
|
{/* Agent card grid — detailed per-agent info */}
|
|
206
282
|
<div
|
|
@@ -212,14 +288,9 @@ export function FlowDashboard({
|
|
|
212
288
|
key={agent.stepId || agent.agentName}
|
|
213
289
|
agent={agent}
|
|
214
290
|
session={session}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}}
|
|
219
|
-
selected={selectedAgent === (agent.stepId || agent.agentName)}
|
|
220
|
-
isDetailOpen={selectedAgent === (agent.stepId || agent.agentName)}
|
|
221
|
-
isSourceOpen={sourceOpenAgent === (agent.label || agent.stepId || agent.agentName)}
|
|
222
|
-
onViewSource={agent.sourcePath && onViewAgentSource ? () => onViewAgentSource(agent.sourcePath!, agent.label || agent.stepId || agent.agentName) : undefined}
|
|
291
|
+
sessionId={sessionId}
|
|
292
|
+
selected={selectedStepId === (agent.stepId || agent.agentName)}
|
|
293
|
+
onSelect={handleSelectStep}
|
|
223
294
|
/>
|
|
224
295
|
))}
|
|
225
296
|
</div>
|
|
@@ -228,3 +299,160 @@ export function FlowDashboard({
|
|
|
228
299
|
</div>
|
|
229
300
|
);
|
|
230
301
|
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Renders the head of the per-flow `flow-question` queue. Derived from
|
|
305
|
+
* the shell's active interactive UI requests, filtered by component
|
|
306
|
+
* type `flow-question` and grouped by `flowId`. The first matching
|
|
307
|
+
* request is the head; queue depth shown as a "+N more queued" badge
|
|
308
|
+
* on the rendered card.
|
|
309
|
+
*
|
|
310
|
+
* Returns null when no flow-question is pending for `flowId`.
|
|
311
|
+
*
|
|
312
|
+
* See change: route-flow-asks-to-upper-slot.
|
|
313
|
+
*/
|
|
314
|
+
/** Most recent N transcript entries kept visible. See change: fix-flows-plugin-polish (C3). */
|
|
315
|
+
const FLOW_QUESTION_TRANSCRIPT_CAP = 10;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Renders the per-flow flow-question transcript above the agent grid.
|
|
319
|
+
*
|
|
320
|
+
* Includes ALL flow-question prompts for `flowId` — pending AND answered —
|
|
321
|
+
* in insertion order (oldest first), capped at {@link FLOW_QUESTION_TRANSCRIPT_CAP}.
|
|
322
|
+
* Pending entries render as the interactive `FlowQuestionCard`;
|
|
323
|
+
* answered/cancelled/dismissed entries render as a collapsed
|
|
324
|
+
* `FlowQuestionTranscriptPill`.
|
|
325
|
+
*
|
|
326
|
+
* Chat suppresses widget-bar prompts (B2) so the slot is the single visible
|
|
327
|
+
* site — no double-render.
|
|
328
|
+
*
|
|
329
|
+
* See change: fix-flows-plugin-polish (C3).
|
|
330
|
+
*/
|
|
331
|
+
function FlowQuestionsSection({
|
|
332
|
+
sessionId,
|
|
333
|
+
flowId,
|
|
334
|
+
}: {
|
|
335
|
+
sessionId: string;
|
|
336
|
+
flowId: string;
|
|
337
|
+
}) {
|
|
338
|
+
const requests = useSessionInteractiveRequests(sessionId);
|
|
339
|
+
const send = usePluginSend();
|
|
340
|
+
|
|
341
|
+
const queue = useMemo<InteractiveUiRequestSnapshot[]>(() => {
|
|
342
|
+
const out: InteractiveUiRequestSnapshot[] = [];
|
|
343
|
+
for (const req of requests) {
|
|
344
|
+
const cmp = req.params._promptBusComponent as
|
|
345
|
+
| { type?: string; props?: { flowId?: unknown } }
|
|
346
|
+
| undefined;
|
|
347
|
+
if (cmp?.type !== "flow-question") continue;
|
|
348
|
+
if (cmp?.props?.flowId !== flowId) continue;
|
|
349
|
+
out.push(req);
|
|
350
|
+
}
|
|
351
|
+
return out.slice(-FLOW_QUESTION_TRANSCRIPT_CAP);
|
|
352
|
+
}, [requests, flowId]);
|
|
353
|
+
|
|
354
|
+
if (queue.length === 0) return null;
|
|
355
|
+
|
|
356
|
+
const pendingCount = queue.filter((r) => r.status === "pending").length;
|
|
357
|
+
|
|
358
|
+
return (
|
|
359
|
+
<div data-testid="flow-questions-transcript" className="flex flex-col gap-1">
|
|
360
|
+
{queue.map((req) => {
|
|
361
|
+
const props =
|
|
362
|
+
(req.params._promptBusComponent as { props?: Record<string, unknown> }).props ?? {};
|
|
363
|
+
const question = typeof props.question === "string" ? props.question : "";
|
|
364
|
+
if (req.status === "pending") {
|
|
365
|
+
const submit = (answer: string) => {
|
|
366
|
+
send({
|
|
367
|
+
type: "prompt_response",
|
|
368
|
+
sessionId,
|
|
369
|
+
promptId: req.requestId,
|
|
370
|
+
answer,
|
|
371
|
+
source: "dashboard-flow-question",
|
|
372
|
+
});
|
|
373
|
+
};
|
|
374
|
+
const dismiss = () => {
|
|
375
|
+
send({ type: "prompt_cancel", sessionId, promptId: req.requestId });
|
|
376
|
+
};
|
|
377
|
+
return (
|
|
378
|
+
<FlowQuestionCard
|
|
379
|
+
key={req.requestId}
|
|
380
|
+
sessionId={sessionId}
|
|
381
|
+
promptId={req.requestId}
|
|
382
|
+
flowId={typeof props.flowId === "string" ? props.flowId : flowId}
|
|
383
|
+
stepId={typeof props.stepId === "string" ? props.stepId : ""}
|
|
384
|
+
question={question}
|
|
385
|
+
type={(props.type as FlowQuestionCardType) ?? "input"}
|
|
386
|
+
options={Array.isArray(props.options) ? (props.options as string[]) : undefined}
|
|
387
|
+
defaultValue={
|
|
388
|
+
typeof props.defaultValue === "string" ? props.defaultValue : undefined
|
|
389
|
+
}
|
|
390
|
+
queueDepth={pendingCount}
|
|
391
|
+
onSubmit={submit}
|
|
392
|
+
onDismiss={dismiss}
|
|
393
|
+
/>
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
const answer = typeof req.result === "string" ? req.result : undefined;
|
|
397
|
+
return (
|
|
398
|
+
<FlowQuestionTranscriptPill
|
|
399
|
+
key={req.requestId}
|
|
400
|
+
question={question}
|
|
401
|
+
answer={answer}
|
|
402
|
+
status={req.status}
|
|
403
|
+
/>
|
|
404
|
+
);
|
|
405
|
+
})}
|
|
406
|
+
</div>
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
type FlowQuestionCardType = "select" | "input" | "confirm" | "editor" | "multiselect";
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Slot-consumer wrapper for the `content-header-sticky` claim.
|
|
414
|
+
* Self-derives flow state from useFlowsSessionState; selection state
|
|
415
|
+
* and callbacks come from useFlowsUiState / pluginContext.send.
|
|
416
|
+
* Returns null when no flow is active. See change:
|
|
417
|
+
* pluginize-flows-via-registry.
|
|
418
|
+
*/
|
|
419
|
+
export function FlowDashboardClaim({ session }: { session: DashboardSession }) {
|
|
420
|
+
const { flowState, flowStates } = useFlowsSessionState(session.id);
|
|
421
|
+
const send = usePluginSend();
|
|
422
|
+
|
|
423
|
+
// Diagnostic logging — helps trace why the upper slot might be empty when
|
|
424
|
+
// a flow is running. Gated to dev builds. See change: fix-flows-plugin-polish (C1).
|
|
425
|
+
if (typeof import.meta !== "undefined" && (import.meta as { env?: { DEV?: boolean } }).env?.DEV) {
|
|
426
|
+
// eslint-disable-next-line no-console
|
|
427
|
+
console.debug(
|
|
428
|
+
"[flows] FlowDashboardClaim render",
|
|
429
|
+
{
|
|
430
|
+
sessionId: session.id,
|
|
431
|
+
hasFlowState: !!flowState,
|
|
432
|
+
flowName: flowState?.flowName,
|
|
433
|
+
flowStatus: flowState?.status,
|
|
434
|
+
flowsCount: flowStates.size,
|
|
435
|
+
},
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
if (!flowState) return null;
|
|
440
|
+
|
|
441
|
+
const flowControl = (action: string) =>
|
|
442
|
+
send({ type: "flow_control", sessionId: session.id, action });
|
|
443
|
+
|
|
444
|
+
return (
|
|
445
|
+
<FlowDashboard
|
|
446
|
+
flowState={flowState}
|
|
447
|
+
flowStates={flowStates as Map<string, FlowState>}
|
|
448
|
+
session={session}
|
|
449
|
+
sessionId={session.id}
|
|
450
|
+
onAbort={() => flowControl("abort")}
|
|
451
|
+
onToggleAutonomous={() => flowControl("toggle_autonomous")}
|
|
452
|
+
onDismiss={() => flowControl("dismiss_summary")}
|
|
453
|
+
onSendPrompt={(text: string, images?: ImageContent[]) =>
|
|
454
|
+
send({ type: "send_prompt", sessionId: session.id, text, images })
|
|
455
|
+
}
|
|
456
|
+
/>
|
|
457
|
+
);
|
|
458
|
+
}
|