@blackbelt-technology/pi-dashboard-flows-plugin 0.5.4 → 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 +25 -16
- 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 +2 -39
- 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 +51 -64
- package/src/__tests__/node-kind-reducer.test.ts +135 -0
- package/src/__tests__/plugin-action-handler.test.ts +54 -0
- package/src/__tests__/session-flow-actions-edit.test.tsx +98 -0
- package/src/bridge/AGENTS.md +8 -0
- package/src/client/AGENTS.md +32 -0
- package/src/client/FlowActivityBadge.tsx +8 -5
- package/src/client/FlowAgentCard.tsx +231 -110
- package/src/client/FlowAgentDetail.tsx +20 -12
- package/src/client/FlowAgentsToolRenderer.tsx +228 -0
- package/src/client/FlowAuthorPromptDialog.tsx +92 -0
- package/src/client/FlowDashboard.tsx +88 -23
- package/src/client/FlowGraph.tsx +420 -275
- package/src/client/FlowInputWiring.tsx +243 -0
- package/src/client/FlowLaunchDialog.tsx +48 -54
- package/src/client/FlowQuestionCard.tsx +6 -3
- package/src/client/FlowSummary.tsx +252 -69
- package/src/client/FlowWriteToolRenderer.tsx +127 -0
- package/src/client/FlowYamlPopoverButton.tsx +26 -25
- package/src/client/FlowYamlPreview.tsx +9 -7
- package/src/client/FlowsSessionStateContext.tsx +14 -33
- package/src/client/FlowsSettings.tsx +68 -0
- package/src/client/SessionFlowActions.tsx +92 -76
- 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 +28 -87
- package/src/client/index.tsx +27 -32
- package/src/client/shouldRender.ts +24 -12
- 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 +93 -9
- package/src/server/state-store.ts +3 -14
- 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/FlowAgentPopoutClaim.tsx +0 -66
- package/src/client/FlowAgentPopoutPage.tsx +0 -177
- package/src/client/FlowArchitect.tsx +0 -699
- package/src/client/FlowArchitectPopoutClaim.tsx +0 -52
- package/src/client/FlowArchitectPopoutPage.tsx +0 -133
- package/src/client/popout-url.ts +0 -59
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Icon } from "@mdi/react";
|
|
3
|
-
import { mdiCloseCircleOutline, mdiCheckCircle, mdiAlertCircle, mdiStopCircle, mdiCloseCircle, mdiCircleOutline, mdiChevronRight, mdiChevronDown } from "@mdi/js";
|
|
4
|
-
import type { DashboardSession, FlowState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
1
|
+
import { usePluginSend, useUiPrimitive, useUiPrimitiveOrNull } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
5
2
|
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
6
|
-
import {
|
|
3
|
+
import type { DashboardSession, FlowAgentState, FlowState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
4
|
+
import { mdiAlertCircle, mdiCheckCircle, mdiChevronDown, mdiChevronRight, mdiCircleOutline, mdiCloseCircle, mdiCloseCircleOutline, mdiStopCircle } from "@mdi/js";
|
|
5
|
+
import { Icon } from "@mdi/react";
|
|
6
|
+
import { type ReactNode, useCallback, useEffect, useRef, useState } from "react";
|
|
7
|
+
import { FlowAgentCard } from "./FlowAgentCard.js";
|
|
7
8
|
import { FlowGraph, flowStateToGraphSteps } from "./FlowGraph.js";
|
|
8
|
-
import { FlowYamlPopoverButton } from "./FlowYamlPopoverButton.js";
|
|
9
9
|
import { useFlowsSessionState } from "./FlowsSessionStateContext.js";
|
|
10
|
+
import { FlowYamlPopoverButton } from "./FlowYamlPopoverButton.js";
|
|
11
|
+
import { useFlowCollapsePersisted } from "./flow-collapse-storage.js";
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
// formatDuration moved to registry primitive lookup inside FlowSummary
|
|
@@ -23,28 +25,85 @@ export function FlowSummary({
|
|
|
23
25
|
flowState,
|
|
24
26
|
onDismiss,
|
|
25
27
|
onSendPrompt,
|
|
28
|
+
session,
|
|
29
|
+
sessionId,
|
|
26
30
|
}: {
|
|
27
31
|
flowState: FlowState;
|
|
28
32
|
onDismiss: () => void;
|
|
29
33
|
onSendPrompt?: (text: string) => void;
|
|
34
|
+
/** Parent session — threaded to the frozen cards for their detail/popout affordances. */
|
|
35
|
+
session?: DashboardSession;
|
|
36
|
+
sessionId?: string;
|
|
30
37
|
}) {
|
|
31
38
|
const formatDuration = useUiPrimitive(UI_PRIMITIVE_KEYS.formatDuration);
|
|
39
|
+
const Dialog = useUiPrimitiveOrNull(UI_PRIMITIVE_KEYS.dialog);
|
|
32
40
|
const [collapsed, setCollapsed] = useState(false);
|
|
41
|
+
// Whole-panel collapse (distinct from the footer `collapsed` above, which only
|
|
42
|
+
// hides the Summaries list). Shrinks the completed-flow summary to its header
|
|
43
|
+
// bar, mirroring FlowDashboard's collapse affordance. See change: improve-flow-graph-fidelity.
|
|
44
|
+
// Persisted per session so a collapsed panel stays collapsed across remounts.
|
|
45
|
+
// See change: fix-flow-ui-graph-zoom-summary.
|
|
46
|
+
const [panelCollapsed, togglePanelCollapsed] = useFlowCollapsePersisted(
|
|
47
|
+
sessionId ?? session?.id,
|
|
48
|
+
"summary",
|
|
49
|
+
);
|
|
50
|
+
const [graphOpen, setGraphOpen] = useState(false);
|
|
51
|
+
// Shared graph⇄card selection (ephemeral). See change:
|
|
52
|
+
// improve-flow-graph-dialog-and-card-interaction.
|
|
53
|
+
const [selectedStepId, setSelectedStepId] = useState<string | null>(null);
|
|
54
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
33
55
|
const agents = Array.from(flowState.agents.values());
|
|
56
|
+
// Only summary-bearing agents are listed in the Summaries subsection (others
|
|
57
|
+
// stay in the frozen cards + graph). See change: fix-flow-ui-graph-zoom-summary.
|
|
58
|
+
const summarised = agents.filter(a => a.summary);
|
|
34
59
|
const { icon, label, color } = statusConfig[flowState.status] ?? statusConfig.success;
|
|
35
60
|
const totalDuration = flowState.flowResult?.totalDuration as number | undefined;
|
|
36
61
|
const totalFiles = agents.reduce((sum, a) => sum + (a.files?.length ?? 0), 0);
|
|
37
62
|
|
|
63
|
+
const handleSelectStep = useCallback((stepId: string) => {
|
|
64
|
+
setSelectedStepId((prev) => (prev === stepId ? null : stepId));
|
|
65
|
+
}, []);
|
|
66
|
+
|
|
67
|
+
// Reset selection when the agent set changes (selection is ephemeral).
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
setSelectedStepId(null);
|
|
70
|
+
}, [flowState.agents]);
|
|
71
|
+
|
|
72
|
+
// Esc clears selection (the Dialog handles its own Esc independently).
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!selectedStepId) return;
|
|
75
|
+
const onKey = (e: KeyboardEvent) => {
|
|
76
|
+
if (e.key === "Escape") setSelectedStepId(null);
|
|
77
|
+
};
|
|
78
|
+
window.addEventListener("keydown", onKey);
|
|
79
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
80
|
+
}, [selectedStepId]);
|
|
81
|
+
|
|
82
|
+
// Scroll the matching node + card into view on selection (counterpart sync).
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (!selectedStepId || !rootRef.current) return;
|
|
85
|
+
const esc = selectedStepId.replace(/["\\]/g, "\\$&");
|
|
86
|
+
for (const attr of ["data-node", "data-step"]) {
|
|
87
|
+
rootRef.current
|
|
88
|
+
.querySelector(`[${attr}="${esc}"]`)
|
|
89
|
+
?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
90
|
+
}
|
|
91
|
+
}, [selectedStepId]);
|
|
92
|
+
|
|
38
93
|
return (
|
|
39
|
-
<div className="bg-[var(--bg-secondary)] border-b border-[var(--border-subtle)] px-3 py-2">
|
|
94
|
+
<div ref={rootRef} className="bg-[var(--bg-secondary)] border-b border-[var(--border-subtle)] px-3 py-2">
|
|
40
95
|
{/* Header */}
|
|
41
96
|
<div className="flex items-center gap-2 mb-1.5">
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
onClick={
|
|
97
|
+
{/* Minimal disclosure chevron, left of the flow name (not near Dismiss). */}
|
|
98
|
+
<button
|
|
99
|
+
onClick={togglePanelCollapsed}
|
|
100
|
+
data-testid="flow-summary-panel-toggle"
|
|
101
|
+
title={panelCollapsed ? "Expand summary" : "Collapse summary"}
|
|
102
|
+
aria-expanded={!panelCollapsed}
|
|
103
|
+
className="inline-flex -ml-0.5 text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"
|
|
45
104
|
>
|
|
46
|
-
<Icon path={
|
|
47
|
-
</
|
|
105
|
+
<Icon path={panelCollapsed ? mdiChevronRight : mdiChevronDown} size={0.6} />
|
|
106
|
+
</button>
|
|
48
107
|
<span className={`${color} inline-flex`}>{icon}</span>
|
|
49
108
|
<span className="text-sm text-[var(--text-primary)] flex-1">
|
|
50
109
|
{flowState.flowName} {label}
|
|
@@ -62,70 +121,192 @@ export function FlowSummary({
|
|
|
62
121
|
</button>
|
|
63
122
|
</div>
|
|
64
123
|
|
|
65
|
-
{
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
124
|
+
{!panelCollapsed && (<>
|
|
125
|
+
{/* Flow graph — bounded + fit-to-window; ⤢ expand opens the centered Dialog
|
|
126
|
+
with pan/zoom. Bounded so it cannot be dragged over the cards/summaries.
|
|
127
|
+
See change: show-flow-cards-in-summary. */}
|
|
128
|
+
<FlowGraph
|
|
129
|
+
steps={flowStateToGraphSteps(flowState)}
|
|
130
|
+
fit
|
|
131
|
+
selectedStepId={selectedStepId}
|
|
132
|
+
onSelectStep={handleSelectStep}
|
|
133
|
+
onExpand={Dialog ? () => setGraphOpen(true) : undefined}
|
|
134
|
+
/>
|
|
135
|
+
{flowState.flowSource && (
|
|
136
|
+
<div className="mt-1">
|
|
137
|
+
<FlowYamlPopoverButton
|
|
138
|
+
flowSource={flowState.flowSource}
|
|
139
|
+
flowName={flowState.flowName}
|
|
71
140
|
/>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
141
|
+
</div>
|
|
142
|
+
)}
|
|
143
|
+
|
|
144
|
+
{/* Everything UNDER the graph lives in ONE fixed-height scrollable box so
|
|
145
|
+
the whole panel always fits the viewport (no page scroll). The summaries
|
|
146
|
+
section and each agent row stay independently collapsible inside it. */}
|
|
147
|
+
<div className="mt-2 overflow-y-auto" style={{ maxHeight: "48vh" }} data-testid="flow-summary-scrollbox">
|
|
148
|
+
{/* Frozen agent cards — read-only. */}
|
|
149
|
+
{agents.length > 0 && (
|
|
150
|
+
<div
|
|
151
|
+
className="grid gap-2"
|
|
152
|
+
style={{ gridTemplateColumns: `repeat(auto-fill, minmax(200px, 1fr))` }}
|
|
153
|
+
>
|
|
154
|
+
{agents.map(agent => (
|
|
155
|
+
<FlowAgentCard
|
|
156
|
+
key={agent.stepId || agent.agentName}
|
|
157
|
+
agent={agent}
|
|
158
|
+
session={session}
|
|
159
|
+
sessionId={sessionId ?? session?.id}
|
|
160
|
+
selected={selectedStepId === (agent.stepId || agent.agentName)}
|
|
161
|
+
onSelect={handleSelectStep}
|
|
77
162
|
/>
|
|
163
|
+
))}
|
|
164
|
+
</div>
|
|
165
|
+
)}
|
|
166
|
+
|
|
167
|
+
{/* Summaries — collapsible; each row expands inline. Only agents with
|
|
168
|
+
summary text are listed; the subsection is hidden when none qualify
|
|
169
|
+
(summary-less steps remain visible in the frozen cards above + graph).
|
|
170
|
+
See change: fix-flow-ui-graph-zoom-summary. */}
|
|
171
|
+
{summarised.length > 0 && (
|
|
172
|
+
<div className="mt-2 pt-1.5 border-t border-[var(--border-subtle)]">
|
|
173
|
+
<div
|
|
174
|
+
data-testid="flow-summary-toggle"
|
|
175
|
+
className="flex items-center gap-1.5 text-[11px] text-[var(--text-tertiary)] cursor-pointer mb-1 hover:text-[var(--text-primary)]"
|
|
176
|
+
onClick={() => setCollapsed(!collapsed)}
|
|
177
|
+
>
|
|
178
|
+
<Icon path={collapsed ? mdiChevronRight : mdiChevronDown} size={0.5} />
|
|
179
|
+
<span>Summaries ({summarised.length})</span>
|
|
78
180
|
</div>
|
|
79
|
-
|
|
181
|
+
{!collapsed && (
|
|
182
|
+
<div className="space-y-0.5" data-testid="flow-summaries">
|
|
183
|
+
{summarised.map(agent => (
|
|
184
|
+
<FlowSummaryRow key={agent.stepId || agent.agentName} agent={agent} />
|
|
185
|
+
))}
|
|
186
|
+
</div>
|
|
187
|
+
)}
|
|
188
|
+
</div>
|
|
189
|
+
)}
|
|
80
190
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
: agent.status === "blocked" ? "text-orange-400"
|
|
91
|
-
: "text-[var(--text-tertiary)]";
|
|
92
|
-
const fileCount = agent.files?.length ?? 0;
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<div
|
|
96
|
-
key={agent.stepId || agent.agentName}
|
|
97
|
-
className="flex items-center gap-1.5 text-[11px] hover:bg-[var(--bg-tertiary)] rounded px-1 py-0.5"
|
|
98
|
-
>
|
|
99
|
-
<span className={`${agentColor} inline-flex`}><Icon path={agentIconPath} size={0.45} /></span>
|
|
100
|
-
<span className="text-[var(--text-primary)]">{agent.label || agent.stepId || agent.agentName}</span>
|
|
101
|
-
{(agent.stepType === "fork" || agent.stepType === "agent-decision") && (
|
|
102
|
-
<span className="text-[9px] text-amber-400/60">◇</span>
|
|
103
|
-
)}
|
|
104
|
-
{agent.stepType === "agent-loop-decision" && (
|
|
105
|
-
<span className="text-[9px] text-purple-400/60">↻</span>
|
|
106
|
-
)}
|
|
107
|
-
{fileCount > 0 && (
|
|
108
|
-
<span className="text-[var(--text-muted)]">({fileCount} files)</span>
|
|
109
|
-
)}
|
|
110
|
-
{agent.summary && (
|
|
111
|
-
<span className="text-[var(--text-tertiary)] truncate flex-1">{agent.summary}</span>
|
|
112
|
-
)}
|
|
113
|
-
</div>
|
|
114
|
-
);
|
|
115
|
-
})}
|
|
191
|
+
{/* Next step suggestion */}
|
|
192
|
+
{flowState.nextStep && onSendPrompt && (
|
|
193
|
+
<div className="mt-1.5 pt-1.5 border-t border-[var(--border-subtle)]">
|
|
194
|
+
<button
|
|
195
|
+
onClick={() => onSendPrompt(`/${flowState.nextStep}`)}
|
|
196
|
+
className="text-[11px] px-2 py-1 rounded border border-blue-500/30 text-blue-400 hover:bg-blue-500/10"
|
|
197
|
+
>
|
|
198
|
+
Next: /{flowState.nextStep}
|
|
199
|
+
</button>
|
|
116
200
|
</div>
|
|
117
|
-
|
|
201
|
+
)}
|
|
118
202
|
</div>
|
|
119
203
|
|
|
120
|
-
{/*
|
|
121
|
-
{
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
204
|
+
{/* Expanded graph — centered Dialog with pan/zoom (OUTSIDE the scroll box). */}
|
|
205
|
+
{Dialog && (
|
|
206
|
+
<Dialog
|
|
207
|
+
open={graphOpen}
|
|
208
|
+
onClose={() => setGraphOpen(false)}
|
|
209
|
+
title={`Flow graph · ${flowState.flowName}`}
|
|
210
|
+
size="full"
|
|
211
|
+
>
|
|
212
|
+
{/* Non-fit (pan/zoom) graph fills the full-size dialog; no inner
|
|
213
|
+
height cap so the horizontal DAG gets a wide stage. See change:
|
|
214
|
+
improve-flow-graph-dialog-and-card-interaction. */}
|
|
215
|
+
<div style={{ height: "82vh", overflow: "hidden" }}>
|
|
216
|
+
<FlowGraph
|
|
217
|
+
steps={flowStateToGraphSteps(flowState)}
|
|
218
|
+
selectedStepId={selectedStepId}
|
|
219
|
+
onSelectStep={handleSelectStep}
|
|
220
|
+
/>
|
|
221
|
+
</div>
|
|
222
|
+
</Dialog>
|
|
223
|
+
)}
|
|
224
|
+
</>)}
|
|
225
|
+
</div>
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* One expandable per-agent row. Collapsed: status icon + label + badges +
|
|
231
|
+
* file count + truncated summary peek (matches prior behaviour). Expanded:
|
|
232
|
+
* full summary (markdown), typed-output chips, file list, soft/hard outcome.
|
|
233
|
+
* Mirrors the ToolCallStep chevron idiom; failed steps auto-expand.
|
|
234
|
+
* See change: expandable-flow-summary-rows.
|
|
235
|
+
*/
|
|
236
|
+
function FlowSummaryRow({ agent }: { agent: FlowAgentState }) {
|
|
237
|
+
const MarkdownContent = useUiPrimitive(UI_PRIMITIVE_KEYS.markdownContent);
|
|
238
|
+
const fileCount = agent.files?.length ?? 0;
|
|
239
|
+
const outputs = agent.typedOutputs
|
|
240
|
+
? Object.entries(agent.typedOutputs).filter(([k]) => k !== "branch")
|
|
241
|
+
: [];
|
|
242
|
+
const hasDetail = !!agent.summary || fileCount > 0 || outputs.length > 0;
|
|
243
|
+
const [open, setOpen] = useState(agent.status === "error");
|
|
244
|
+
|
|
245
|
+
const agentIconPath = agent.status === "complete" ? mdiCheckCircle
|
|
246
|
+
: agent.status === "error" ? mdiCloseCircle
|
|
247
|
+
: agent.status === "blocked" ? mdiAlertCircle
|
|
248
|
+
: mdiCircleOutline;
|
|
249
|
+
const agentColor = agent.status === "complete" ? "text-green-400"
|
|
250
|
+
: agent.status === "error" ? "text-red-400"
|
|
251
|
+
: agent.status === "blocked" ? "text-orange-400"
|
|
252
|
+
: "text-[var(--text-tertiary)]";
|
|
253
|
+
|
|
254
|
+
return (
|
|
255
|
+
<div>
|
|
256
|
+
{/* Header row */}
|
|
257
|
+
<div
|
|
258
|
+
className={`flex items-center gap-1.5 text-[11px] hover:bg-[var(--bg-tertiary)] rounded px-1 py-0.5 ${hasDetail ? "cursor-pointer" : ""}`}
|
|
259
|
+
onClick={hasDetail ? () => setOpen(!open) : undefined}
|
|
260
|
+
>
|
|
261
|
+
<span className="inline-flex w-[11px] justify-center text-[var(--text-muted)]">
|
|
262
|
+
{hasDetail ? <Icon path={open ? mdiChevronDown : mdiChevronRight} size={0.45} /> : null}
|
|
263
|
+
</span>
|
|
264
|
+
<span className={`${agentColor} inline-flex`}><Icon path={agentIconPath} size={0.45} /></span>
|
|
265
|
+
<span className="text-[var(--text-primary)]">{agent.label || agent.stepId || agent.agentName}</span>
|
|
266
|
+
{(agent.stepType === "fork" || agent.stepType === "agent-decision") && (
|
|
267
|
+
<span className="text-[9px] text-amber-400/60">◇</span>
|
|
268
|
+
)}
|
|
269
|
+
{agent.stepType === "agent-loop-decision" && (
|
|
270
|
+
<span className="text-[9px] text-purple-400/60">↻</span>
|
|
271
|
+
)}
|
|
272
|
+
{fileCount > 0 && (
|
|
273
|
+
<span className="text-[var(--text-muted)]">({fileCount} files)</span>
|
|
274
|
+
)}
|
|
275
|
+
{!open && agent.summary && (
|
|
276
|
+
<span className="text-[var(--text-tertiary)] truncate flex-1">{agent.summary}</span>
|
|
277
|
+
)}
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
{/* Expanded body */}
|
|
281
|
+
{open && hasDetail && (
|
|
282
|
+
<div className="ml-[22px] mt-0.5 mb-1 pl-2.5 pr-2 py-1.5 border-l-2 border-[var(--border-primary)] bg-[var(--bg-surface)] rounded-r flex flex-col gap-1.5">
|
|
283
|
+
{agent.summary && (
|
|
284
|
+
<div className="text-[11px] text-[var(--text-secondary)]">
|
|
285
|
+
<MarkdownContent content={agent.summary} />
|
|
286
|
+
</div>
|
|
287
|
+
)}
|
|
288
|
+
{outputs.length > 0 && (
|
|
289
|
+
<div className="flex flex-wrap gap-1">
|
|
290
|
+
{outputs.map(([k, v]) => (
|
|
291
|
+
<span key={k} className="text-[10px] font-mono bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded px-1 py-0.5 truncate max-w-[160px]" title={`${k}: ${v}`}>
|
|
292
|
+
<span className="text-cyan-400">{k}</span>: {v}
|
|
293
|
+
</span>
|
|
294
|
+
))}
|
|
295
|
+
</div>
|
|
296
|
+
)}
|
|
297
|
+
{fileCount > 0 && (
|
|
298
|
+
<div className="flex flex-wrap gap-x-2 gap-y-0.5 text-[10px] font-mono text-[var(--text-tertiary)]">
|
|
299
|
+
{agent.files?.map((f) => (
|
|
300
|
+
<span key={f} title={f}>{f}</span>
|
|
301
|
+
))}
|
|
302
|
+
</div>
|
|
303
|
+
)}
|
|
304
|
+
{agent.status === "error" && agent.outcome === "soft" && (
|
|
305
|
+
<div className="text-[10px] text-amber-400">⚠ soft-failed — routed to on_error</div>
|
|
306
|
+
)}
|
|
307
|
+
{agent.status === "error" && agent.outcome === "hard" && (
|
|
308
|
+
<div className="text-[10px] text-red-400">✕ hard-failed — halted flow</div>
|
|
309
|
+
)}
|
|
129
310
|
</div>
|
|
130
311
|
)}
|
|
131
312
|
</div>
|
|
@@ -148,6 +329,8 @@ export function FlowSummaryClaim({ session }: { session: DashboardSession }) {
|
|
|
148
329
|
return (
|
|
149
330
|
<FlowSummary
|
|
150
331
|
flowState={flowState}
|
|
332
|
+
session={session}
|
|
333
|
+
sessionId={session.id}
|
|
151
334
|
onDismiss={() =>
|
|
152
335
|
send({ type: "flow_control", sessionId: session.id, action: "dismiss_summary" })
|
|
153
336
|
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool renderer for the `flow_write` authoring tool (main-session timeline).
|
|
3
|
+
*
|
|
4
|
+
* Renders from the real tool contract: result JSON is
|
|
5
|
+
* `{ written, name, namespace, command, path, diagnostics[] }` (success) or
|
|
6
|
+
* `{ written:false, diagnostics[] }` / `{ written:false, error }` (failure).
|
|
7
|
+
* The result carries no parsed steps, so the Mermaid snapshot + step/agent/code
|
|
8
|
+
* counts are parsed client-side from the tool ARGS (`toolInput.content`).
|
|
9
|
+
*
|
|
10
|
+
* See change: rework-flows-plugin-for-new-pi-flows.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { useT, useUiPrimitive } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
14
|
+
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
15
|
+
import React, { useMemo, useState } from "react";
|
|
16
|
+
import { flowToMermaid, parseFlowYaml } from "./flow-yaml-parse.js";
|
|
17
|
+
|
|
18
|
+
interface FlowWriteResult {
|
|
19
|
+
written?: boolean;
|
|
20
|
+
name?: string;
|
|
21
|
+
namespace?: string;
|
|
22
|
+
command?: string;
|
|
23
|
+
path?: string;
|
|
24
|
+
diagnostics?: Array<{ message?: string } | string>;
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function safeParse(result: string | undefined): FlowWriteResult | null {
|
|
29
|
+
if (!result) return null;
|
|
30
|
+
try { return JSON.parse(result) as FlowWriteResult; } catch { return null; }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function diagText(d: { message?: string } | string): string {
|
|
34
|
+
return typeof d === "string" ? d : (d.message ?? JSON.stringify(d));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function FlowWriteToolRenderer({
|
|
38
|
+
toolInput,
|
|
39
|
+
status,
|
|
40
|
+
result,
|
|
41
|
+
}: {
|
|
42
|
+
toolName: string;
|
|
43
|
+
toolInput: Record<string, unknown>;
|
|
44
|
+
sessionId: string;
|
|
45
|
+
status?: "running" | "complete" | "error";
|
|
46
|
+
result?: string;
|
|
47
|
+
}) {
|
|
48
|
+
const t = useT();
|
|
49
|
+
const MarkdownContent = useUiPrimitive(UI_PRIMITIVE_KEYS.markdownContent);
|
|
50
|
+
const [showYaml, setShowYaml] = useState(false);
|
|
51
|
+
|
|
52
|
+
const content = typeof toolInput.content === "string" ? toolInput.content : "";
|
|
53
|
+
const parsed = safeParse(result);
|
|
54
|
+
const flow = useMemo(() => (content ? parseFlowYaml(content) : null), [content]);
|
|
55
|
+
const mermaidMd = useMemo(
|
|
56
|
+
() => (flow ? "```mermaid\n" + flowToMermaid(flow) + "\n```" : null),
|
|
57
|
+
[flow],
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const diagnostics = (parsed?.diagnostics ?? []).map(diagText);
|
|
61
|
+
const written = parsed?.written === true;
|
|
62
|
+
const isError = status === "error" || parsed?.written === false;
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div className="border border-[var(--border-primary)] rounded-md bg-[var(--bg-secondary)] p-3 text-xs">
|
|
66
|
+
<div className="flex items-center gap-2">
|
|
67
|
+
<span className="text-[var(--accent-blue,#0969da)]">⇆</span>
|
|
68
|
+
<span className="font-semibold">flow_write</span>
|
|
69
|
+
{status === "running" && <span className="text-[var(--text-muted)]">writing…</span>}
|
|
70
|
+
{written && parsed?.command && (
|
|
71
|
+
<span className="font-mono text-green-400">/{parsed.command}</span>
|
|
72
|
+
)}
|
|
73
|
+
{written && <span className="text-[var(--text-muted)]">registered</span>}
|
|
74
|
+
{isError && <span className="text-red-400">not written — validation failed</span>}
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
{/* Counts parsed from args */}
|
|
78
|
+
{written && flow && (
|
|
79
|
+
<div className="mt-1 text-[var(--text-tertiary)]">
|
|
80
|
+
{flow.counts.total} steps · {flow.counts.agents} agents, {flow.counts.code} code
|
|
81
|
+
</div>
|
|
82
|
+
)}
|
|
83
|
+
|
|
84
|
+
{/* Mermaid snapshot from args */}
|
|
85
|
+
{written && mermaidMd && (
|
|
86
|
+
<div className="mt-2">
|
|
87
|
+
<div className="text-[10px] uppercase tracking-wide text-[var(--text-muted)] mb-1">{t("flowGraph", undefined, "Flow graph")}</div>
|
|
88
|
+
<MarkdownContent content={mermaidMd} />
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
|
|
92
|
+
{/* Validation failure — diagnostics verbatim */}
|
|
93
|
+
{isError && (
|
|
94
|
+
<div className="mt-2">
|
|
95
|
+
<div className="text-[10px] uppercase tracking-wide text-red-400 mb-1">{t("result", undefined, "Result")}</div>
|
|
96
|
+
<pre className="font-mono text-[11px] text-red-400 whitespace-pre-wrap">
|
|
97
|
+
{diagnostics.length > 0 ? diagnostics.join("\n") : (parsed?.error ?? "Unknown error")}
|
|
98
|
+
</pre>
|
|
99
|
+
</div>
|
|
100
|
+
)}
|
|
101
|
+
|
|
102
|
+
{/* Non-fatal diagnostics on success */}
|
|
103
|
+
{written && diagnostics.length > 0 && (
|
|
104
|
+
<div className="mt-2 text-[11px] text-amber-400">
|
|
105
|
+
{diagnostics.map((d, i) => <div key={i}>⚠ {d}</div>)}
|
|
106
|
+
</div>
|
|
107
|
+
)}
|
|
108
|
+
|
|
109
|
+
{/* View flow YAML (the submitted args) */}
|
|
110
|
+
{content && (
|
|
111
|
+
<div className="mt-2">
|
|
112
|
+
<button
|
|
113
|
+
onClick={() => setShowYaml((v) => !v)}
|
|
114
|
+
className="text-[11px] text-[var(--text-tertiary)] hover:text-blue-400 font-mono"
|
|
115
|
+
>
|
|
116
|
+
{showYaml ? "▾" : "▸"} View flow YAML {parsed?.path ? `· ${parsed.path.split("/").pop()}` : ""}
|
|
117
|
+
</button>
|
|
118
|
+
{showYaml && (
|
|
119
|
+
<pre className="mt-1 font-mono text-[11px] bg-[var(--bg-surface)] border border-[var(--border-subtle)] rounded p-2 overflow-auto max-h-[260px] whitespace-pre">
|
|
120
|
+
{content}
|
|
121
|
+
</pre>
|
|
122
|
+
)}
|
|
123
|
+
</div>
|
|
124
|
+
)}
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* See change: add-ui-popover-primitive.
|
|
15
15
|
*/
|
|
16
|
-
import React, { useEffect,
|
|
16
|
+
import React, { useEffect, useState } from "react";
|
|
17
17
|
import { Icon } from "@mdi/react";
|
|
18
18
|
import { mdiFileDocumentOutline } from "@mdi/js";
|
|
19
19
|
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
@@ -32,9 +32,8 @@ export function FlowYamlPopoverButton({
|
|
|
32
32
|
flowSource: string;
|
|
33
33
|
flowName: string;
|
|
34
34
|
}) {
|
|
35
|
-
const
|
|
35
|
+
const Dialog = useUiPrimitive(UI_PRIMITIVE_KEYS.dialog);
|
|
36
36
|
const MarkdownContent = useUiPrimitive(UI_PRIMITIVE_KEYS.markdownContent);
|
|
37
|
-
const ref = useRef<HTMLButtonElement | null>(null);
|
|
38
37
|
const [open, setOpen] = useState(false);
|
|
39
38
|
const [state, setState] = useState<YamlFetchState>({ kind: "idle" });
|
|
40
39
|
|
|
@@ -69,7 +68,6 @@ export function FlowYamlPopoverButton({
|
|
|
69
68
|
return (
|
|
70
69
|
<>
|
|
71
70
|
<button
|
|
72
|
-
ref={ref}
|
|
73
71
|
onClick={(e) => {
|
|
74
72
|
e.stopPropagation();
|
|
75
73
|
setOpen((prev) => !prev);
|
|
@@ -83,27 +81,30 @@ export function FlowYamlPopoverButton({
|
|
|
83
81
|
>
|
|
84
82
|
<Icon path={mdiFileDocumentOutline} size={0.5} />
|
|
85
83
|
</button>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
84
|
+
<Dialog
|
|
85
|
+
open={open}
|
|
86
|
+
onClose={() => setOpen(false)}
|
|
87
|
+
title={`${flowName} · YAML`}
|
|
88
|
+
size="lg"
|
|
89
|
+
>
|
|
90
|
+
{/* Pinned path header; YAML scrolls inside a fixed-height region so the
|
|
91
|
+
dialog stays a fixed size. See change:
|
|
92
|
+
improve-flow-graph-dialog-and-card-interaction. */}
|
|
93
|
+
<div className="text-[11px] text-[var(--text-tertiary)] font-mono break-all" title={flowSource}>
|
|
94
|
+
{flowSource}
|
|
95
|
+
</div>
|
|
96
|
+
<div className="h-[60vh] overflow-y-auto">
|
|
97
|
+
{state.kind === "loading" && (
|
|
98
|
+
<div className="text-xs text-[var(--text-muted)]">Loading…</div>
|
|
99
|
+
)}
|
|
100
|
+
{state.kind === "error" && (
|
|
101
|
+
<div className="text-xs text-red-400">⚠ {state.error}</div>
|
|
102
|
+
)}
|
|
103
|
+
{state.kind === "loaded" && (
|
|
104
|
+
<MarkdownContent content={"```yaml\n" + state.content + "\n```"} />
|
|
105
|
+
)}
|
|
106
|
+
</div>
|
|
107
|
+
</Dialog>
|
|
107
108
|
</>
|
|
108
109
|
);
|
|
109
110
|
}
|
|
@@ -10,13 +10,14 @@
|
|
|
10
10
|
* See change: pluginize-flows-via-registry (design.md Decision 3
|
|
11
11
|
* RECONSIDERED — predicates over routes).
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
import { mdiArrowLeft } from "@mdi/js";
|
|
16
|
-
import type { DashboardSession } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
13
|
+
|
|
14
|
+
import { useT, useUiPrimitive } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
17
15
|
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
16
|
+
import type { DashboardSession } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
17
|
+
import { mdiArrowLeft } from "@mdi/js";
|
|
18
|
+
import { Icon } from "@mdi/react";
|
|
19
|
+
import React from "react";
|
|
20
|
+
import { useFlowsUiActions, useFlowsUiState } from "./FlowsUiStateContext.js";
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Slot-consumer wrapper for the `content-view` claim. Reads the
|
|
@@ -33,6 +34,7 @@ export function FlowYamlPreviewClaim({
|
|
|
33
34
|
routeParams: Record<string, string>;
|
|
34
35
|
onClose: () => void;
|
|
35
36
|
}) {
|
|
37
|
+
const t = useT();
|
|
36
38
|
const MarkdownContent = useUiPrimitive(UI_PRIMITIVE_KEYS.markdownContent);
|
|
37
39
|
const { flowYamlPreview } = useFlowsUiState();
|
|
38
40
|
const actions = useFlowsUiActions();
|
|
@@ -51,7 +53,7 @@ export function FlowYamlPreviewClaim({
|
|
|
51
53
|
<button
|
|
52
54
|
onClick={handleBack}
|
|
53
55
|
className="text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors"
|
|
54
|
-
title="Back"
|
|
56
|
+
title={t("back", undefined, "Back")}
|
|
55
57
|
>
|
|
56
58
|
<Icon path={mdiArrowLeft} size={0.7} />
|
|
57
59
|
</button>
|