@blackbelt-technology/pi-dashboard-flows-plugin 0.0.0-test-darwin-x64.1
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/README.md +18 -0
- package/package.json +62 -0
- package/src/__tests__/ArchitectInputPrompt.test.tsx +81 -0
- package/src/__tests__/FlowGraph.test.ts +159 -0
- package/src/__tests__/architect-reducer.test.ts +307 -0
- package/src/__tests__/reducer-parity.test.ts +106 -0
- package/src/architect-reducer.ts +386 -0
- package/src/client/FlowActivityBadge.tsx +41 -0
- package/src/client/FlowAgentCard.tsx +133 -0
- package/src/client/FlowAgentDetail.tsx +173 -0
- package/src/client/FlowArchitect.tsx +622 -0
- package/src/client/FlowDashboard.tsx +230 -0
- package/src/client/FlowGraph.tsx +563 -0
- package/src/client/FlowLaunchDialog.tsx +87 -0
- package/src/client/FlowSummary.tsx +137 -0
- package/src/client/FlowTabBar.tsx +52 -0
- package/src/client/SessionFlowActions.tsx +178 -0
- package/src/client/index.tsx +29 -0
- package/src/flow-reducer.ts +323 -0
- package/src/reducer.ts +10 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import React, { useState, useMemo, useEffect, useRef } from "react";
|
|
2
|
+
import { Icon } from "@mdi/react";
|
|
3
|
+
import { mdiRobotOutline, mdiStop, mdiChevronUp, mdiChevronRight, mdiChevronDown, mdiFileDocumentOutline, mdiLoading } from "@mdi/js";
|
|
4
|
+
import type { DashboardSession, FlowState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
5
|
+
import { FlowAgentCard } from "./FlowAgentCard.js";
|
|
6
|
+
import { FlowGraph, flowStateToGraphSteps } from "./FlowGraph.js";
|
|
7
|
+
import { FlowSummary } from "./FlowSummary.js";
|
|
8
|
+
import { FlowTabBar, type FlowTab } from "./FlowTabBar.js";
|
|
9
|
+
import { useMobile } from "../../../client/src/hooks/useMobile.js";
|
|
10
|
+
import { BreadcrumbSlot } from "../../../client/src/components/extension-ui/BreadcrumbSlot.js";
|
|
11
|
+
|
|
12
|
+
export function FlowDashboard({
|
|
13
|
+
flowState,
|
|
14
|
+
flowStates,
|
|
15
|
+
onAgentClick,
|
|
16
|
+
selectedAgent,
|
|
17
|
+
onAbort,
|
|
18
|
+
onToggleAutonomous,
|
|
19
|
+
onDismiss,
|
|
20
|
+
onSendPrompt,
|
|
21
|
+
onViewYaml,
|
|
22
|
+
onViewAgentSource,
|
|
23
|
+
sourceOpenAgent,
|
|
24
|
+
session,
|
|
25
|
+
}: {
|
|
26
|
+
flowState: FlowState;
|
|
27
|
+
/** All flow states (main + subflows) for tab navigation */
|
|
28
|
+
flowStates?: Map<string, FlowState>;
|
|
29
|
+
onAgentClick: (agentName: string | null) => void;
|
|
30
|
+
selectedAgent?: string | null;
|
|
31
|
+
onAbort: () => void;
|
|
32
|
+
onToggleAutonomous: () => void;
|
|
33
|
+
onDismiss: () => void;
|
|
34
|
+
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
|
+
/** Phase-2 decorator host — carries breadcrumb + agent-metric descriptors. */
|
|
39
|
+
session?: Pick<DashboardSession, "uiDecorators">;
|
|
40
|
+
}) {
|
|
41
|
+
const isMobile = useMobile();
|
|
42
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
43
|
+
const [mobileExpanded, setMobileExpanded] = useState(false);
|
|
44
|
+
const [activeTabId, setActiveTabId] = useState<string>(flowState.flowName);
|
|
45
|
+
const [followMode, setFollowMode] = useState(true);
|
|
46
|
+
const prevFlowNameRef = useRef(flowState.flowName);
|
|
47
|
+
|
|
48
|
+
// Build tab list from flowStates
|
|
49
|
+
const tabs: FlowTab[] = useMemo(() => {
|
|
50
|
+
if (!flowStates || flowStates.size <= 1) return [];
|
|
51
|
+
return Array.from(flowStates.keys()).map(name => ({
|
|
52
|
+
id: name,
|
|
53
|
+
label: name,
|
|
54
|
+
isActive: name === flowState.flowName,
|
|
55
|
+
}));
|
|
56
|
+
}, [flowStates, flowState.flowName]);
|
|
57
|
+
|
|
58
|
+
// Follow mode: auto-switch to latest active flow
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (followMode && flowState.flowName !== prevFlowNameRef.current) {
|
|
61
|
+
setActiveTabId(flowState.flowName);
|
|
62
|
+
}
|
|
63
|
+
prevFlowNameRef.current = flowState.flowName;
|
|
64
|
+
}, [followMode, flowState.flowName]);
|
|
65
|
+
|
|
66
|
+
// Determine which flow state to display based on active tab
|
|
67
|
+
const displayState = useMemo(() => {
|
|
68
|
+
if (flowStates && activeTabId !== flowState.flowName) {
|
|
69
|
+
return flowStates.get(activeTabId) || flowState;
|
|
70
|
+
}
|
|
71
|
+
return flowState;
|
|
72
|
+
}, [flowStates, activeTabId, flowState]);
|
|
73
|
+
|
|
74
|
+
const agents = Array.from(displayState.agents.values());
|
|
75
|
+
const allAgents = Array.from(flowState.agents.values());
|
|
76
|
+
const doneCount = allAgents.filter(a => a.status === "complete" || a.status === "error" || a.status === "blocked").length;
|
|
77
|
+
const totalCount = allAgents.length;
|
|
78
|
+
const isRunning = flowState.status === "running";
|
|
79
|
+
const isComplete = !isRunning;
|
|
80
|
+
|
|
81
|
+
// After completion, show summary
|
|
82
|
+
if (isComplete) {
|
|
83
|
+
return (
|
|
84
|
+
<FlowSummary
|
|
85
|
+
flowState={flowState}
|
|
86
|
+
onAgentClick={onAgentClick}
|
|
87
|
+
onDismiss={onDismiss}
|
|
88
|
+
onSendPrompt={onSendPrompt}
|
|
89
|
+
onViewYaml={onViewYaml}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const handleTabClick = (tabId: string) => {
|
|
95
|
+
setActiveTabId(tabId);
|
|
96
|
+
setFollowMode(false); // Manual click disables follow
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const handleToggleFollow = () => {
|
|
100
|
+
const newFollow = !followMode;
|
|
101
|
+
setFollowMode(newFollow);
|
|
102
|
+
if (newFollow) {
|
|
103
|
+
// Re-enable: jump to latest active flow
|
|
104
|
+
setActiveTabId(flowState.flowName);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// Mobile collapsed bar
|
|
109
|
+
if (isMobile && !mobileExpanded) {
|
|
110
|
+
return (
|
|
111
|
+
<div
|
|
112
|
+
onClick={() => setMobileExpanded(true)}
|
|
113
|
+
className="px-3 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-subtle)] cursor-pointer flex items-center gap-2"
|
|
114
|
+
>
|
|
115
|
+
<span className="text-blue-400 text-sm">π</span>
|
|
116
|
+
<span className="text-sm text-[var(--text-primary)] truncate flex-1">
|
|
117
|
+
{flowState.flowName} · {doneCount}/{totalCount} steps
|
|
118
|
+
</span>
|
|
119
|
+
<span className="text-[10px] text-[var(--text-tertiary)]">tap to expand</span>
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<div className="bg-[var(--bg-secondary)] border-b border-[var(--border-subtle)] px-3 py-2">
|
|
126
|
+
{/* Header */}
|
|
127
|
+
<div className="flex items-center gap-2 mb-2">
|
|
128
|
+
<span
|
|
129
|
+
className="inline-flex text-[var(--text-tertiary)] cursor-pointer"
|
|
130
|
+
onClick={() => setCollapsed(!collapsed)}
|
|
131
|
+
>
|
|
132
|
+
<Icon path={collapsed ? mdiChevronRight : mdiChevronDown} size={0.6} />
|
|
133
|
+
</span>
|
|
134
|
+
{isRunning ? (
|
|
135
|
+
<Icon path={mdiLoading} size={0.55} className="text-blue-400 animate-spin shrink-0" />
|
|
136
|
+
) : (
|
|
137
|
+
<span className="text-blue-400 text-sm font-medium">π</span>
|
|
138
|
+
)}
|
|
139
|
+
<span className="text-sm text-[var(--text-primary)] truncate flex-1">
|
|
140
|
+
{flowState.flowName}
|
|
141
|
+
<span className="text-[var(--text-tertiary)] ml-1.5">{doneCount}/{totalCount} steps</span>
|
|
142
|
+
</span>
|
|
143
|
+
|
|
144
|
+
{/* Controls */}
|
|
145
|
+
<button
|
|
146
|
+
onClick={(e) => { e.stopPropagation(); onToggleAutonomous(); }}
|
|
147
|
+
className={`text-[10px] px-1.5 py-0.5 rounded border ${
|
|
148
|
+
flowState.autonomousMode
|
|
149
|
+
? "border-green-500/40 text-green-400 bg-green-500/10"
|
|
150
|
+
: "border-[var(--border-subtle)] text-[var(--text-tertiary)]"
|
|
151
|
+
}`}
|
|
152
|
+
title="Toggle autonomous mode"
|
|
153
|
+
>
|
|
154
|
+
<Icon path={mdiRobotOutline} size={0.4} className="inline mr-0.5" />AUTO
|
|
155
|
+
</button>
|
|
156
|
+
{isRunning && (
|
|
157
|
+
<button
|
|
158
|
+
onClick={(e) => { e.stopPropagation(); onAbort(); }}
|
|
159
|
+
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"
|
|
161
|
+
>
|
|
162
|
+
<Icon path={mdiStop} size={0.4} className="inline mr-0.5" />Abort
|
|
163
|
+
</button>
|
|
164
|
+
)}
|
|
165
|
+
{isMobile && (
|
|
166
|
+
<button
|
|
167
|
+
onClick={() => setMobileExpanded(false)}
|
|
168
|
+
className="text-[10px] text-[var(--text-tertiary)]"
|
|
169
|
+
>
|
|
170
|
+
<Icon path={mdiChevronUp} size={0.4} className="inline mr-0.5" />collapse
|
|
171
|
+
</button>
|
|
172
|
+
)}
|
|
173
|
+
</div>
|
|
174
|
+
|
|
175
|
+
{/* DAG graph — structural minimap */}
|
|
176
|
+
<div className={`group-collapse ${collapsed ? "collapsed" : "expanded"}`}>
|
|
177
|
+
<div>
|
|
178
|
+
{/* Tab bar for multi-flow navigation */}
|
|
179
|
+
<FlowTabBar
|
|
180
|
+
tabs={tabs}
|
|
181
|
+
activeTabId={activeTabId}
|
|
182
|
+
followMode={followMode}
|
|
183
|
+
onTabClick={handleTabClick}
|
|
184
|
+
onToggleFollow={handleToggleFollow}
|
|
185
|
+
/>
|
|
186
|
+
|
|
187
|
+
{/* Phase-2 breadcrumb decorator slot. See change: add-extension-ui-decorations. */}
|
|
188
|
+
<BreadcrumbSlot session={session} />
|
|
189
|
+
|
|
190
|
+
<FlowGraph
|
|
191
|
+
steps={flowStateToGraphSteps(displayState)}
|
|
192
|
+
/>
|
|
193
|
+
{onViewYaml && (
|
|
194
|
+
<div className="mt-1">
|
|
195
|
+
<button
|
|
196
|
+
onClick={onViewYaml}
|
|
197
|
+
className="text-[var(--text-tertiary)] hover:text-blue-400 transition-colors p-0.5 rounded hover:bg-[var(--bg-surface)] inline-flex items-center"
|
|
198
|
+
title="View flow YAML"
|
|
199
|
+
>
|
|
200
|
+
<Icon path={mdiFileDocumentOutline} size={0.5} />
|
|
201
|
+
</button>
|
|
202
|
+
</div>
|
|
203
|
+
)}
|
|
204
|
+
|
|
205
|
+
{/* Agent card grid — detailed per-agent info */}
|
|
206
|
+
<div
|
|
207
|
+
className="grid gap-2 mt-2"
|
|
208
|
+
style={{ gridTemplateColumns: `repeat(auto-fill, minmax(200px, 1fr))` }}
|
|
209
|
+
>
|
|
210
|
+
{agents.map(agent => (
|
|
211
|
+
<FlowAgentCard
|
|
212
|
+
key={agent.stepId || agent.agentName}
|
|
213
|
+
agent={agent}
|
|
214
|
+
session={session}
|
|
215
|
+
onClick={() => {
|
|
216
|
+
const key = agent.stepId || agent.agentName;
|
|
217
|
+
onAgentClick(selectedAgent === key ? null : key);
|
|
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}
|
|
223
|
+
/>
|
|
224
|
+
))}
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
);
|
|
230
|
+
}
|