@blackbelt-technology/pi-dashboard-flows-plugin 0.5.4 → 0.6.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/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,699 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState } from "react";
|
|
2
|
-
import { Icon } from "@mdi/react";
|
|
3
|
-
import {
|
|
4
|
-
mdiChevronRight,
|
|
5
|
-
mdiChevronDown,
|
|
6
|
-
mdiLoading,
|
|
7
|
-
mdiFileDocumentOutline,
|
|
8
|
-
mdiEyeOutline,
|
|
9
|
-
mdiEyeOffOutline,
|
|
10
|
-
mdiOpenInNew,
|
|
11
|
-
} from "@mdi/js";
|
|
12
|
-
import type {
|
|
13
|
-
ArchitectState,
|
|
14
|
-
ArchitectPhase,
|
|
15
|
-
ArchitectPrompt,
|
|
16
|
-
ArchitectAgentEntry,
|
|
17
|
-
DashboardSession,
|
|
18
|
-
FlowDetailEntry,
|
|
19
|
-
} from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
20
|
-
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
21
|
-
import { useUiPrimitive, usePluginSend } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
22
|
-
import {
|
|
23
|
-
MinimalChatView,
|
|
24
|
-
type MinimalChatEntry,
|
|
25
|
-
type MinimalChatStatus,
|
|
26
|
-
} from "@blackbelt-technology/pi-dashboard-client-utils/minimal-chat";
|
|
27
|
-
import { FlowGraph, architectStepsToGraphSteps } from "./FlowGraph.js";
|
|
28
|
-
import { useFlowsSessionState } from "./FlowsSessionStateContext.js";
|
|
29
|
-
import { buildFlowArchitectPopoutUrl } from "./popout-url.js";
|
|
30
|
-
import {
|
|
31
|
-
useFlowsUiState,
|
|
32
|
-
useFlowsUiActions,
|
|
33
|
-
} from "./FlowsUiStateContext.js";
|
|
34
|
-
|
|
35
|
-
// ── Architect detail view ─────────────────────────────────────────────────
|
|
36
|
-
//
|
|
37
|
-
// Shim over `MinimalChatView`. Inline `ToolCallEntry` / `TextEntry` /
|
|
38
|
-
// `ThinkingEntry` / `extractInputPreview` were removed in
|
|
39
|
-
// `fix-flows-plugin-polish` (A1) — the architect now uses the same
|
|
40
|
-
// timeline renderer as `FlowAgentDetail` and `SubagentDetailView`.
|
|
41
|
-
//
|
|
42
|
-
// See change: fix-flows-plugin-polish (A1).
|
|
43
|
-
|
|
44
|
-
function mapArchitectPhase(phase: ArchitectPhase): MinimalChatStatus {
|
|
45
|
-
switch (phase) {
|
|
46
|
-
case "context":
|
|
47
|
-
case "designing":
|
|
48
|
-
return "running";
|
|
49
|
-
case "preview":
|
|
50
|
-
return "running";
|
|
51
|
-
case "complete":
|
|
52
|
-
return "complete";
|
|
53
|
-
case "cancelled":
|
|
54
|
-
return "error";
|
|
55
|
-
default: {
|
|
56
|
-
const _exhaustive: never = phase;
|
|
57
|
-
void _exhaustive;
|
|
58
|
-
return "pending";
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function mapArchitectEntries(detailHistory: FlowDetailEntry[]): MinimalChatEntry[] {
|
|
64
|
-
return detailHistory.map((e) => {
|
|
65
|
-
switch (e.kind) {
|
|
66
|
-
case "tool":
|
|
67
|
-
return {
|
|
68
|
-
kind: "tool",
|
|
69
|
-
toolName: e.toolName,
|
|
70
|
-
input: e.input,
|
|
71
|
-
output: e.output,
|
|
72
|
-
isError: e.isError,
|
|
73
|
-
};
|
|
74
|
-
case "text":
|
|
75
|
-
return { kind: "text", text: e.text };
|
|
76
|
-
case "thinking":
|
|
77
|
-
return { kind: "thinking", text: e.text };
|
|
78
|
-
case "error":
|
|
79
|
-
return { kind: "error", text: e.text };
|
|
80
|
-
default: {
|
|
81
|
-
const _exhaustive: never = e;
|
|
82
|
-
void _exhaustive;
|
|
83
|
-
return { kind: "error", text: "(unknown entry)" };
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function FlowArchitectDetail({
|
|
90
|
-
state,
|
|
91
|
-
onBack,
|
|
92
|
-
sessionId,
|
|
93
|
-
}: {
|
|
94
|
-
state: ArchitectState;
|
|
95
|
-
onBack?: () => void;
|
|
96
|
-
/** Forwarded to MinimalChatView so per-tool renderers can build session-scoped links. */
|
|
97
|
-
sessionId?: string;
|
|
98
|
-
}) {
|
|
99
|
-
const status = mapArchitectPhase(state.phase);
|
|
100
|
-
const entries = mapArchitectEntries(state.detailHistory);
|
|
101
|
-
const modeLabel = state.architectMode === "edit" ? "Edit" : "New";
|
|
102
|
-
const iterationSuffix = state.iteration > 1 ? ` · Iter ${state.iteration}` : "";
|
|
103
|
-
|
|
104
|
-
return (
|
|
105
|
-
<MinimalChatView
|
|
106
|
-
title="Flow Architect"
|
|
107
|
-
subtitle={state.flowName || undefined}
|
|
108
|
-
status={status}
|
|
109
|
-
entries={entries}
|
|
110
|
-
mode="popout"
|
|
111
|
-
onBack={onBack}
|
|
112
|
-
sessionId={sessionId}
|
|
113
|
-
meta={{ modelName: `${modeLabel}${iterationSuffix}` }}
|
|
114
|
-
emptyMessage={
|
|
115
|
-
state.phase === "context" || state.phase === "designing"
|
|
116
|
-
? "Working…"
|
|
117
|
-
: "No activity yet"
|
|
118
|
-
}
|
|
119
|
-
/>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// ── Inline prompt renderers ───────────────────────────────────────
|
|
124
|
-
|
|
125
|
-
function ArchitectSelectPrompt({
|
|
126
|
-
prompt,
|
|
127
|
-
onRespond,
|
|
128
|
-
}: {
|
|
129
|
-
prompt: ArchitectPrompt;
|
|
130
|
-
onRespond: (answer: string) => void;
|
|
131
|
-
}) {
|
|
132
|
-
return (
|
|
133
|
-
<div className="mt-2 pt-2 border-t border-[var(--border-subtle)]">
|
|
134
|
-
<div className="text-[11px] text-[var(--text-secondary)] mb-1.5">
|
|
135
|
-
{prompt.question}
|
|
136
|
-
</div>
|
|
137
|
-
<div className="flex flex-wrap gap-1.5">
|
|
138
|
-
{prompt.options?.map((opt) => (
|
|
139
|
-
<button
|
|
140
|
-
key={opt}
|
|
141
|
-
onClick={() => onRespond(opt)}
|
|
142
|
-
className={`text-[11px] px-2.5 py-1 rounded border transition-colors ${
|
|
143
|
-
opt === "Cancel" || opt === "Don't save"
|
|
144
|
-
? "border-red-500/30 text-red-400 hover:bg-red-500/10"
|
|
145
|
-
: opt === "Save"
|
|
146
|
-
? "border-green-500/30 text-green-400 hover:bg-green-500/10"
|
|
147
|
-
: "border-purple-500/30 text-purple-400 hover:bg-purple-500/10"
|
|
148
|
-
}`}
|
|
149
|
-
>
|
|
150
|
-
{opt}
|
|
151
|
-
</button>
|
|
152
|
-
))}
|
|
153
|
-
</div>
|
|
154
|
-
</div>
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/** @internal — exported for testing */
|
|
159
|
-
export function ArchitectInputPrompt({
|
|
160
|
-
prompt,
|
|
161
|
-
onRespond,
|
|
162
|
-
}: {
|
|
163
|
-
prompt: ArchitectPrompt;
|
|
164
|
-
onRespond: (answer: string) => void;
|
|
165
|
-
}) {
|
|
166
|
-
const [value, setValue] = React.useState(prompt.defaultValue || "");
|
|
167
|
-
const handleSubmit = () => {
|
|
168
|
-
onRespond(value.trim());
|
|
169
|
-
};
|
|
170
|
-
return (
|
|
171
|
-
<div className="mt-2 pt-2 border-t border-[var(--border-subtle)]">
|
|
172
|
-
<div className="text-[11px] text-[var(--text-secondary)] mb-1.5">
|
|
173
|
-
{prompt.question}
|
|
174
|
-
</div>
|
|
175
|
-
<div className="flex gap-1.5">
|
|
176
|
-
<input
|
|
177
|
-
type="text"
|
|
178
|
-
value={value}
|
|
179
|
-
onChange={(e) => setValue(e.target.value)}
|
|
180
|
-
onKeyDown={(e) => e.key === "Enter" && handleSubmit()}
|
|
181
|
-
className="flex-1 text-[11px] px-2 py-1 rounded border border-[var(--border-subtle)] bg-[var(--bg-primary)] text-[var(--text-primary)] outline-none focus:border-purple-500/50"
|
|
182
|
-
placeholder="Enter a value..."
|
|
183
|
-
autoFocus
|
|
184
|
-
/>
|
|
185
|
-
<button
|
|
186
|
-
onClick={handleSubmit}
|
|
187
|
-
className="text-[11px] px-2.5 py-1 rounded border border-purple-500/30 text-purple-400 hover:bg-purple-500/10"
|
|
188
|
-
>
|
|
189
|
-
Submit
|
|
190
|
-
</button>
|
|
191
|
-
</div>
|
|
192
|
-
</div>
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function ArchitectConfirmPrompt({
|
|
197
|
-
prompt,
|
|
198
|
-
onRespond,
|
|
199
|
-
}: {
|
|
200
|
-
prompt: ArchitectPrompt;
|
|
201
|
-
onRespond: (answer: string) => void;
|
|
202
|
-
}) {
|
|
203
|
-
return (
|
|
204
|
-
<div className="mt-2 pt-2 border-t border-[var(--border-subtle)]">
|
|
205
|
-
<div className="text-[11px] text-[var(--text-secondary)] mb-1.5">
|
|
206
|
-
{prompt.question}
|
|
207
|
-
</div>
|
|
208
|
-
<div className="flex gap-1.5">
|
|
209
|
-
<button
|
|
210
|
-
onClick={() => onRespond("true")}
|
|
211
|
-
className="text-[11px] px-2.5 py-1 rounded border border-green-500/30 text-green-400 hover:bg-green-500/10"
|
|
212
|
-
>
|
|
213
|
-
Yes
|
|
214
|
-
</button>
|
|
215
|
-
<button
|
|
216
|
-
onClick={() => onRespond("false")}
|
|
217
|
-
className="text-[11px] px-2.5 py-1 rounded border border-red-500/30 text-red-400 hover:bg-red-500/10"
|
|
218
|
-
>
|
|
219
|
-
No
|
|
220
|
-
</button>
|
|
221
|
-
</div>
|
|
222
|
-
</div>
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function ArchitectPromptInline({
|
|
227
|
-
prompt,
|
|
228
|
-
onRespond,
|
|
229
|
-
}: {
|
|
230
|
-
prompt: ArchitectPrompt;
|
|
231
|
-
onRespond: (answer: string) => void;
|
|
232
|
-
}) {
|
|
233
|
-
switch (prompt.type) {
|
|
234
|
-
case "select":
|
|
235
|
-
return <ArchitectSelectPrompt prompt={prompt} onRespond={onRespond} />;
|
|
236
|
-
case "input":
|
|
237
|
-
return <ArchitectInputPrompt prompt={prompt} onRespond={onRespond} />;
|
|
238
|
-
case "confirm":
|
|
239
|
-
return <ArchitectConfirmPrompt prompt={prompt} onRespond={onRespond} />;
|
|
240
|
-
default:
|
|
241
|
-
return null;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// ── Agent card for architect (similar to FlowAgentCard) ──────────
|
|
246
|
-
|
|
247
|
-
const AGENT_STATUS_MAP: Record<
|
|
248
|
-
string,
|
|
249
|
-
"pending" | "running" | "complete" | "error"
|
|
250
|
-
> = {
|
|
251
|
-
pending: "pending",
|
|
252
|
-
creating: "running",
|
|
253
|
-
done: "complete",
|
|
254
|
-
error: "error",
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
function ArchitectAgentCard({
|
|
258
|
-
agent,
|
|
259
|
-
}: {
|
|
260
|
-
agent: ArchitectAgentEntry;
|
|
261
|
-
}) {
|
|
262
|
-
const AgentCardShell = useUiPrimitive(UI_PRIMITIVE_KEYS.agentCard);
|
|
263
|
-
const Popover = useUiPrimitive(UI_PRIMITIVE_KEYS.popover);
|
|
264
|
-
const MarkdownContent = useUiPrimitive(UI_PRIMITIVE_KEYS.markdownContent);
|
|
265
|
-
const sourceButtonRef = useRef<HTMLButtonElement | null>(null);
|
|
266
|
-
const [sourceOpen, setSourceOpen] = useState(false);
|
|
267
|
-
|
|
268
|
-
// Architect's custom agents carry their raw markdown inline on the
|
|
269
|
-
// ArchitectAgentEntry (set by the architect-reducer when capturing
|
|
270
|
-
// `agent_write` events). No REST fetch needed — just render in a
|
|
271
|
-
// popover anchored to the doc button.
|
|
272
|
-
const hasSource = Boolean(agent.source);
|
|
273
|
-
|
|
274
|
-
return (
|
|
275
|
-
<AgentCardShell
|
|
276
|
-
name={agent.name}
|
|
277
|
-
status={AGENT_STATUS_MAP[agent.status] || "pending"}
|
|
278
|
-
>
|
|
279
|
-
<div className="flex items-center justify-between">
|
|
280
|
-
<span className="text-[10px] text-[var(--text-muted)] truncate">
|
|
281
|
-
{agent.type === "custom" ? "custom agent" : agent.type}
|
|
282
|
-
</span>
|
|
283
|
-
{hasSource && (
|
|
284
|
-
<>
|
|
285
|
-
<button
|
|
286
|
-
ref={sourceButtonRef}
|
|
287
|
-
onClick={(e) => {
|
|
288
|
-
e.stopPropagation();
|
|
289
|
-
setSourceOpen((prev) => !prev);
|
|
290
|
-
}}
|
|
291
|
-
className={`transition-colors p-0.5 rounded ${
|
|
292
|
-
sourceOpen
|
|
293
|
-
? "text-purple-400 bg-purple-400/10"
|
|
294
|
-
: "text-[var(--text-tertiary)] hover:text-purple-400 hover:bg-[var(--bg-surface)]"
|
|
295
|
-
}`}
|
|
296
|
-
title={sourceOpen ? `Close ${agent.name} source` : `View ${agent.name} source`}
|
|
297
|
-
>
|
|
298
|
-
<Icon path={mdiFileDocumentOutline} size={0.5} />
|
|
299
|
-
</button>
|
|
300
|
-
{sourceOpen && sourceButtonRef.current && (
|
|
301
|
-
<Popover
|
|
302
|
-
anchorEl={sourceButtonRef.current}
|
|
303
|
-
onDismiss={() => setSourceOpen(false)}
|
|
304
|
-
>
|
|
305
|
-
<div
|
|
306
|
-
className="w-[640px] max-w-[90vw] max-h-[70vh] overflow-auto bg-[var(--bg-secondary)] border border-[var(--border-primary)] rounded-md shadow-xl p-3"
|
|
307
|
-
onClick={(e) => e.stopPropagation()}
|
|
308
|
-
>
|
|
309
|
-
<div className="text-[11px] text-[var(--text-tertiary)] mb-2 font-mono">
|
|
310
|
-
{agent.name}
|
|
311
|
-
</div>
|
|
312
|
-
<MarkdownContent content={agent.source!} />
|
|
313
|
-
</div>
|
|
314
|
-
</Popover>
|
|
315
|
-
)}
|
|
316
|
-
</>
|
|
317
|
-
)}
|
|
318
|
-
</div>
|
|
319
|
-
</AgentCardShell>
|
|
320
|
-
);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Small icon button that opens a popover anchored to itself, showing the
|
|
325
|
-
* given markdown/YAML `content`. Replaces the previous callback-based
|
|
326
|
-
* ViewFileButton that routed via the dormant FlowYamlPreview slot.
|
|
327
|
-
*
|
|
328
|
-
* See change: add-ui-popover-primitive.
|
|
329
|
-
*/
|
|
330
|
-
function ViewFilePopoverButton({
|
|
331
|
-
title,
|
|
332
|
-
content,
|
|
333
|
-
filename,
|
|
334
|
-
language,
|
|
335
|
-
}: {
|
|
336
|
-
title: string;
|
|
337
|
-
content: string;
|
|
338
|
-
/** Path/filename shown as a small caption above the content. */
|
|
339
|
-
filename?: string;
|
|
340
|
-
/** Hint for code fence (e.g. "yaml", "markdown"). When omitted we render raw. */
|
|
341
|
-
language?: string;
|
|
342
|
-
}) {
|
|
343
|
-
const Popover = useUiPrimitive(UI_PRIMITIVE_KEYS.popover);
|
|
344
|
-
const MarkdownContent = useUiPrimitive(UI_PRIMITIVE_KEYS.markdownContent);
|
|
345
|
-
const ref = useRef<HTMLButtonElement | null>(null);
|
|
346
|
-
const [open, setOpen] = useState(false);
|
|
347
|
-
|
|
348
|
-
// Wrap raw YAML/text in a code fence so MarkdownContent renders it as a
|
|
349
|
-
// syntax-highlighted block. Already-markdown content is shown verbatim.
|
|
350
|
-
const rendered = language
|
|
351
|
-
? "```" + language + "\n" + content + "\n```"
|
|
352
|
-
: content;
|
|
353
|
-
|
|
354
|
-
return (
|
|
355
|
-
<>
|
|
356
|
-
<button
|
|
357
|
-
ref={ref}
|
|
358
|
-
onClick={(e) => {
|
|
359
|
-
e.stopPropagation();
|
|
360
|
-
setOpen((prev) => !prev);
|
|
361
|
-
}}
|
|
362
|
-
className={`transition-colors p-0.5 rounded inline-flex items-center ${
|
|
363
|
-
open
|
|
364
|
-
? "text-purple-400 bg-purple-400/10"
|
|
365
|
-
: "text-[var(--text-tertiary)] hover:text-purple-400 hover:bg-[var(--bg-surface)]"
|
|
366
|
-
}`}
|
|
367
|
-
title={title}
|
|
368
|
-
>
|
|
369
|
-
<Icon path={mdiFileDocumentOutline} size={0.5} />
|
|
370
|
-
</button>
|
|
371
|
-
{open && ref.current && (
|
|
372
|
-
<Popover anchorEl={ref.current} onDismiss={() => setOpen(false)}>
|
|
373
|
-
<div
|
|
374
|
-
className="w-[640px] max-w-[90vw] max-h-[70vh] overflow-auto bg-[var(--bg-secondary)] border border-[var(--border-primary)] rounded-md shadow-xl p-3"
|
|
375
|
-
onClick={(e) => e.stopPropagation()}
|
|
376
|
-
>
|
|
377
|
-
{filename && (
|
|
378
|
-
<div className="text-[11px] text-[var(--text-tertiary)] mb-2 font-mono truncate" title={filename}>
|
|
379
|
-
{filename}
|
|
380
|
-
</div>
|
|
381
|
-
)}
|
|
382
|
-
<MarkdownContent content={rendered} />
|
|
383
|
-
</div>
|
|
384
|
-
</Popover>
|
|
385
|
-
)}
|
|
386
|
-
</>
|
|
387
|
-
);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
// ── Card (shown in the sticky header bar) ─────────────────────────
|
|
391
|
-
|
|
392
|
-
export function FlowArchitect({
|
|
393
|
-
state,
|
|
394
|
-
onAbort,
|
|
395
|
-
onPromptRespond,
|
|
396
|
-
sessionId,
|
|
397
|
-
}: {
|
|
398
|
-
state: ArchitectState;
|
|
399
|
-
onAbort: () => void;
|
|
400
|
-
onPromptRespond?: (promptId: string, answer: string) => void;
|
|
401
|
-
/** Session id — threaded so the popout button can build a URL.
|
|
402
|
-
See change: fix-flows-plugin-polish (A4). */
|
|
403
|
-
sessionId?: string;
|
|
404
|
-
}) {
|
|
405
|
-
const popoutUrl = buildFlowArchitectPopoutUrl(sessionId);
|
|
406
|
-
const popoutEnabled = popoutUrl !== null;
|
|
407
|
-
const handlePopout = React.useCallback(
|
|
408
|
-
(e: React.MouseEvent) => {
|
|
409
|
-
e.stopPropagation();
|
|
410
|
-
if (popoutUrl) window.open(popoutUrl, "_blank", "noopener");
|
|
411
|
-
},
|
|
412
|
-
[popoutUrl],
|
|
413
|
-
);
|
|
414
|
-
const [collapsed, setCollapsed] = useState(false);
|
|
415
|
-
// Popover state for the architect-detail view. Lives in this component
|
|
416
|
-
// so the eye button (the anchor) and the Popover share the same scope.
|
|
417
|
-
// Replaces the old `content-view` slot claim + global UI-state flag.
|
|
418
|
-
// See change: add-ui-popover-primitive.
|
|
419
|
-
const [detailOpen, setDetailOpen] = useState(false);
|
|
420
|
-
const detailButtonRef = useRef<HTMLButtonElement | null>(null);
|
|
421
|
-
const Popover = useUiPrimitive(UI_PRIMITIVE_KEYS.popover);
|
|
422
|
-
const isActive = state.phase === "context" || state.phase === "designing";
|
|
423
|
-
const isPreview = state.phase === "preview";
|
|
424
|
-
const customAgents = state.agents.filter((a) => a.type === "custom");
|
|
425
|
-
const firstFlow = state.parsedFlows[0];
|
|
426
|
-
|
|
427
|
-
return (
|
|
428
|
-
<div className="bg-[var(--bg-secondary)] border-b border-[var(--border-subtle)] px-3 py-2">
|
|
429
|
-
{/* Header */}
|
|
430
|
-
<div className="flex items-center gap-2 mb-1.5">
|
|
431
|
-
<span
|
|
432
|
-
className="inline-flex text-[var(--text-tertiary)] cursor-pointer"
|
|
433
|
-
onClick={() => setCollapsed(!collapsed)}
|
|
434
|
-
>
|
|
435
|
-
<Icon
|
|
436
|
-
path={collapsed ? mdiChevronRight : mdiChevronDown}
|
|
437
|
-
size={0.6}
|
|
438
|
-
/>
|
|
439
|
-
</span>
|
|
440
|
-
{isActive ? (
|
|
441
|
-
<Icon path={mdiLoading} size={0.55} className="text-purple-400 animate-spin shrink-0" />
|
|
442
|
-
) : (
|
|
443
|
-
<span className="text-purple-400 text-sm font-medium">π</span>
|
|
444
|
-
)}
|
|
445
|
-
<span className="text-sm text-[var(--text-primary)] truncate flex-1">
|
|
446
|
-
Flow Architect{" "}
|
|
447
|
-
<span className="text-[var(--text-tertiary)] ml-1.5">
|
|
448
|
-
{state.phase === "context"
|
|
449
|
-
? "Analyzing conversation..."
|
|
450
|
-
: state.phase === "designing"
|
|
451
|
-
? state.flowName
|
|
452
|
-
? `Designing: ${state.flowName}`
|
|
453
|
-
: "Designing..."
|
|
454
|
-
: state.phase === "preview"
|
|
455
|
-
? state.flowName
|
|
456
|
-
? `Preview: ${state.flowName}`
|
|
457
|
-
: "Preview"
|
|
458
|
-
: ""}
|
|
459
|
-
</span>
|
|
460
|
-
</span>
|
|
461
|
-
|
|
462
|
-
{/* Model + alias */}
|
|
463
|
-
{state.resolvedModel && (
|
|
464
|
-
<span className="text-[10px] text-[var(--text-muted)] shrink-0">
|
|
465
|
-
{state.resolvedModel.split("/").pop()}
|
|
466
|
-
{state.modelAlias?.startsWith("@") && (
|
|
467
|
-
<span className="text-[var(--text-tertiary)] ml-0.5">
|
|
468
|
-
{state.modelAlias}
|
|
469
|
-
</span>
|
|
470
|
-
)}
|
|
471
|
-
</span>
|
|
472
|
-
)}
|
|
473
|
-
|
|
474
|
-
{/* Iteration badge */}
|
|
475
|
-
{state.iteration > 1 && (
|
|
476
|
-
<span className="text-[10px] px-1.5 py-0.5 rounded border border-purple-500/30 text-purple-400">
|
|
477
|
-
Iteration {state.iteration}
|
|
478
|
-
</span>
|
|
479
|
-
)}
|
|
480
|
-
|
|
481
|
-
{/* Mode badge */}
|
|
482
|
-
<span
|
|
483
|
-
className={`text-[10px] px-1.5 py-0.5 rounded border ${
|
|
484
|
-
state.architectMode === "edit"
|
|
485
|
-
? "border-yellow-500/30 text-yellow-400"
|
|
486
|
-
: "border-purple-500/30 text-purple-400"
|
|
487
|
-
}`}
|
|
488
|
-
>
|
|
489
|
-
{state.architectMode === "edit" ? "Edit" : "New"}
|
|
490
|
-
</span>
|
|
491
|
-
|
|
492
|
-
{/* Abort button */}
|
|
493
|
-
{(isActive || isPreview || state.pendingPrompt) && (
|
|
494
|
-
<button
|
|
495
|
-
onClick={(e) => {
|
|
496
|
-
e.stopPropagation();
|
|
497
|
-
onAbort();
|
|
498
|
-
}}
|
|
499
|
-
className="text-[10px] px-1.5 py-0.5 rounded border border-red-500/30 text-red-400 hover:bg-red-500/10"
|
|
500
|
-
title="Abort architect"
|
|
501
|
-
>
|
|
502
|
-
Abort
|
|
503
|
-
</button>
|
|
504
|
-
)}
|
|
505
|
-
</div>
|
|
506
|
-
|
|
507
|
-
{/* Content — always shown, flat layout */}
|
|
508
|
-
<div className={`group-collapse ${collapsed ? "collapsed" : "expanded"}`}>
|
|
509
|
-
<div>
|
|
510
|
-
{/* Loading indicator when active but no content yet */}
|
|
511
|
-
{isActive &&
|
|
512
|
-
state.dagSteps.length === 0 &&
|
|
513
|
-
customAgents.length === 0 &&
|
|
514
|
-
state.recentTools.length === 0 && (
|
|
515
|
-
<div className="flex items-center gap-2 py-3 text-[var(--text-muted)]">
|
|
516
|
-
<Icon
|
|
517
|
-
path={mdiLoading}
|
|
518
|
-
size={0.55}
|
|
519
|
-
className="text-purple-400 animate-spin"
|
|
520
|
-
/>
|
|
521
|
-
<span className="text-[11px]">
|
|
522
|
-
{state.phase === "context"
|
|
523
|
-
? "Generating session summary..."
|
|
524
|
-
: "Initializing architect agent..."}
|
|
525
|
-
</span>
|
|
526
|
-
</div>
|
|
527
|
-
)}
|
|
528
|
-
|
|
529
|
-
{/* Flow graph + view YAML icon (only when file exists) */}
|
|
530
|
-
{state.dagSteps.length > 0 && (
|
|
531
|
-
<div>
|
|
532
|
-
<FlowGraph steps={architectStepsToGraphSteps(state.dagSteps)} />
|
|
533
|
-
<div className="flex items-center gap-2 mt-1">
|
|
534
|
-
{firstFlow && (
|
|
535
|
-
<span className="text-[10px] text-[var(--text-muted)]">
|
|
536
|
-
{firstFlow.steps.length} steps · max{" "}
|
|
537
|
-
{firstFlow.maxConcurrent}
|
|
538
|
-
</span>
|
|
539
|
-
)}
|
|
540
|
-
{state.flowWriteStatus && (
|
|
541
|
-
<span
|
|
542
|
-
className={`text-[11px] ${state.flowWriteStatus === "validation-error" ? "text-red-400" : "text-green-400"}`}
|
|
543
|
-
title={
|
|
544
|
-
state.flowWriteStatus === "validation-error"
|
|
545
|
-
? "Flow has validation errors"
|
|
546
|
-
: "Flow is valid"
|
|
547
|
-
}
|
|
548
|
-
>
|
|
549
|
-
Flow:{" "}
|
|
550
|
-
{state.flowWriteStatus === "validation-error" ? "✗" : "✓"}
|
|
551
|
-
</span>
|
|
552
|
-
)}
|
|
553
|
-
{state.flowYamlContent && (
|
|
554
|
-
<ViewFilePopoverButton
|
|
555
|
-
title="View flow YAML"
|
|
556
|
-
content={state.flowYamlContent}
|
|
557
|
-
filename={state.flowName ? `${state.flowName}.yaml` : "flow.yaml"}
|
|
558
|
-
language="yaml"
|
|
559
|
-
/>
|
|
560
|
-
)}
|
|
561
|
-
</div>
|
|
562
|
-
</div>
|
|
563
|
-
)}
|
|
564
|
-
|
|
565
|
-
{/* Agent cards grid with view-source icon per card */}
|
|
566
|
-
{customAgents.length > 0 && (
|
|
567
|
-
<div className="mt-2">
|
|
568
|
-
<div className="text-[10px] text-[var(--text-muted)] mb-1">
|
|
569
|
-
Created Agents · new:{" "}
|
|
570
|
-
{customAgents.filter((a) => a.status === "done").length}
|
|
571
|
-
</div>
|
|
572
|
-
<div
|
|
573
|
-
className="grid gap-2"
|
|
574
|
-
style={{
|
|
575
|
-
gridTemplateColumns: `repeat(auto-fill, minmax(180px, 1fr))`,
|
|
576
|
-
}}
|
|
577
|
-
>
|
|
578
|
-
{customAgents.map((agent) => (
|
|
579
|
-
<ArchitectAgentCard key={agent.name} agent={agent} />
|
|
580
|
-
))}
|
|
581
|
-
</div>
|
|
582
|
-
</div>
|
|
583
|
-
)}
|
|
584
|
-
|
|
585
|
-
{/* Process status + view detail icon */}
|
|
586
|
-
<div className="mt-2">
|
|
587
|
-
{state.catalogSummary && (
|
|
588
|
-
<div className="text-[10px] text-[var(--text-muted)]">
|
|
589
|
-
{state.catalogSummary}
|
|
590
|
-
</div>
|
|
591
|
-
)}
|
|
592
|
-
<div className="space-y-0 mt-0.5">
|
|
593
|
-
{state.recentTools.map((tool, i) => (
|
|
594
|
-
<div
|
|
595
|
-
key={i}
|
|
596
|
-
className="text-[10px] text-[var(--text-tertiary)] truncate"
|
|
597
|
-
>
|
|
598
|
-
{i === state.recentTools.length - 1 ? "▸" : "·"}{" "}
|
|
599
|
-
{tool.toolName} {tool.inputPreview}
|
|
600
|
-
</div>
|
|
601
|
-
))}
|
|
602
|
-
</div>
|
|
603
|
-
<div className="flex items-center gap-1.5 mt-1">
|
|
604
|
-
<button
|
|
605
|
-
type="button"
|
|
606
|
-
onClick={handlePopout}
|
|
607
|
-
disabled={!popoutEnabled}
|
|
608
|
-
data-testid="flow-architect-popout-button"
|
|
609
|
-
className={`transition-colors px-1.5 py-0.5 rounded text-[11px] inline-flex items-center gap-1 border ${
|
|
610
|
-
popoutEnabled
|
|
611
|
-
? "border-[var(--border-subtle)] text-[var(--text-tertiary)] hover:text-purple-400 hover:border-purple-400/40 hover:bg-purple-400/10"
|
|
612
|
-
: "border-[var(--border-subtle)] text-[var(--text-muted)] opacity-50 cursor-not-allowed"
|
|
613
|
-
}`}
|
|
614
|
-
title={popoutEnabled ? "Open Flow Architect in new tab" : "Popout unavailable (no session context)"}
|
|
615
|
-
>
|
|
616
|
-
<Icon path={mdiOpenInNew} size={0.55} />
|
|
617
|
-
<span className="text-[10px]">Popout</span>
|
|
618
|
-
</button>
|
|
619
|
-
<button
|
|
620
|
-
ref={detailButtonRef}
|
|
621
|
-
type="button"
|
|
622
|
-
onClick={() => setDetailOpen((prev) => !prev)}
|
|
623
|
-
className={`transition-colors px-1.5 py-0.5 rounded text-[11px] inline-flex items-center gap-1 border ${
|
|
624
|
-
detailOpen
|
|
625
|
-
? "text-purple-400 bg-purple-400/10 border-purple-400/40"
|
|
626
|
-
: "border-[var(--border-subtle)] text-[var(--text-tertiary)] hover:text-purple-400 hover:border-purple-400/40 hover:bg-purple-400/10"
|
|
627
|
-
}`}
|
|
628
|
-
title={detailOpen ? "Close architect detail" : "View full architect detail"}
|
|
629
|
-
>
|
|
630
|
-
<Icon path={detailOpen ? mdiEyeOffOutline : mdiEyeOutline} size={0.55} />
|
|
631
|
-
<span className="text-[10px]">Details</span>
|
|
632
|
-
</button>
|
|
633
|
-
</div>
|
|
634
|
-
{detailOpen && detailButtonRef.current && (
|
|
635
|
-
<Popover
|
|
636
|
-
anchorEl={detailButtonRef.current}
|
|
637
|
-
onDismiss={() => setDetailOpen(false)}
|
|
638
|
-
>
|
|
639
|
-
{/* `overflow-hidden` on the wrapper + the inner MinimalChatView's
|
|
640
|
-
`overflow-y-auto` body produces an inner scrollbar (not an
|
|
641
|
-
outer one). See change: fix-flows-plugin-polish (scrollbar fix). */}
|
|
642
|
-
<div className="w-[640px] max-w-[90vw] h-[70vh] overflow-hidden bg-[var(--bg-secondary)] border border-[var(--border-primary)] rounded-md shadow-xl">
|
|
643
|
-
<FlowArchitectDetail
|
|
644
|
-
state={state}
|
|
645
|
-
onBack={() => setDetailOpen(false)}
|
|
646
|
-
sessionId={sessionId}
|
|
647
|
-
/>
|
|
648
|
-
</div>
|
|
649
|
-
</Popover>
|
|
650
|
-
)}
|
|
651
|
-
</div>
|
|
652
|
-
</div>
|
|
653
|
-
</div>
|
|
654
|
-
|
|
655
|
-
{/* Inline prompt (Save/Replan/Cancel etc.) */}
|
|
656
|
-
{state.pendingPrompt && onPromptRespond && (
|
|
657
|
-
<ArchitectPromptInline
|
|
658
|
-
prompt={state.pendingPrompt}
|
|
659
|
-
onRespond={(answer) =>
|
|
660
|
-
onPromptRespond(state.pendingPrompt!.id, answer)
|
|
661
|
-
}
|
|
662
|
-
/>
|
|
663
|
-
)}
|
|
664
|
-
|
|
665
|
-
{/* Error display */}
|
|
666
|
-
{state.error && (
|
|
667
|
-
<div className="text-[11px] text-red-400 mt-1.5 px-1">
|
|
668
|
-
⚠ {state.error}
|
|
669
|
-
</div>
|
|
670
|
-
)}
|
|
671
|
-
</div>
|
|
672
|
-
);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
/**
|
|
676
|
-
* Slot-consumer wrapper for the `content-header-sticky` claim.
|
|
677
|
-
* Self-derives architect state and dispatches via pluginContext.send.
|
|
678
|
-
* Returns null when no architect is active. See change:
|
|
679
|
-
* pluginize-flows-via-registry.
|
|
680
|
-
*/
|
|
681
|
-
export function FlowArchitectClaim({ session }: { session: DashboardSession }) {
|
|
682
|
-
const { architectState } = useFlowsSessionState(session.id);
|
|
683
|
-
const send = usePluginSend();
|
|
684
|
-
|
|
685
|
-
if (!architectState) return null;
|
|
686
|
-
|
|
687
|
-
return (
|
|
688
|
-
<FlowArchitect
|
|
689
|
-
state={architectState}
|
|
690
|
-
sessionId={session.id}
|
|
691
|
-
onAbort={() =>
|
|
692
|
-
send({ type: "flow_control", sessionId: session.id, action: "abort" })
|
|
693
|
-
}
|
|
694
|
-
onPromptRespond={(promptId, answer) =>
|
|
695
|
-
send({ type: "architect_prompt_response", sessionId: session.id, promptId, answer })
|
|
696
|
-
}
|
|
697
|
-
/>
|
|
698
|
-
);
|
|
699
|
-
}
|