@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,14 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Icon } from "@mdi/react";
|
|
3
|
-
import { mdiRefresh, mdiEyeOutline, mdiEyeOffOutline, mdiFileDocumentOutline, mdiOpenInNew } from "@mdi/js";
|
|
4
|
-
import type { DashboardSession, FlowAgentState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
5
|
-
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
6
|
-
import { useUiPrimitive } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
1
|
+
import { useT, useUiPrimitive } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
7
2
|
// AgentMetricSlot is a slot CONSUMER (Phase-2 decorator slot), not a primitive
|
|
8
3
|
// — it stays as a direct import. See add-plugin-ui-primitive-registry Decision 4.
|
|
9
4
|
import { AgentMetricSlot } from "@blackbelt-technology/pi-dashboard-client-utils/extension-ui/AgentMetricSlot";
|
|
5
|
+
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
6
|
+
import type { DashboardSession, FlowAgentState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
7
|
+
import { mdiCallSplit, mdiCodeBraces, mdiCodeTags, mdiEyeOffOutline, mdiEyeOutline, mdiFileDocumentOutline, mdiRefresh, mdiSourceBranch } from "@mdi/js";
|
|
8
|
+
import { Icon } from "@mdi/react";
|
|
9
|
+
import React, { useEffect, useState } from "react";
|
|
10
10
|
import { FlowAgentDetail } from "./FlowAgentDetail.js";
|
|
11
|
-
import { buildFlowAgentPopoutUrl } from "./popout-url.js";
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* State of the agent-source fetch for the document-icon popover.
|
|
@@ -20,6 +19,15 @@ import { buildFlowAgentPopoutUrl } from "./popout-url.js";
|
|
|
20
19
|
*
|
|
21
20
|
* See change: add-ui-popover-primitive.
|
|
22
21
|
*/
|
|
22
|
+
/**
|
|
23
|
+
* Format an accumulated USD cost, matching the pi-flows TUI precision
|
|
24
|
+
* (`agent-card.ts`): two decimals at or above $1, four decimals sub-dollar.
|
|
25
|
+
* Exported so `FlowAgentDetail` renders identical values (DRY, D4).
|
|
26
|
+
*/
|
|
27
|
+
export function formatCost(n: number): string {
|
|
28
|
+
return `$${n >= 1 ? n.toFixed(2) : n.toFixed(4)}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
23
31
|
type AgentSourceState =
|
|
24
32
|
| { kind: "idle" }
|
|
25
33
|
| { kind: "loading" }
|
|
@@ -31,41 +39,39 @@ export function FlowAgentCard({
|
|
|
31
39
|
selected,
|
|
32
40
|
session,
|
|
33
41
|
sessionId,
|
|
34
|
-
|
|
42
|
+
onSelect,
|
|
35
43
|
}: {
|
|
36
44
|
agent: FlowAgentState;
|
|
37
45
|
selected?: boolean;
|
|
38
46
|
/** Phase-2 decorator host — used for `agent-metric` filtering by agentId. */
|
|
39
47
|
session?: Pick<DashboardSession, "uiDecorators">;
|
|
40
|
-
/** Session id of the parent flow —
|
|
48
|
+
/** Session id of the parent flow — threaded to FlowAgentDetail. */
|
|
41
49
|
sessionId?: string;
|
|
42
|
-
/**
|
|
43
|
-
|
|
50
|
+
/** Toggle shared graph⇄card selection. See change: improve-flow-graph-dialog-and-card-interaction. */
|
|
51
|
+
onSelect?: (stepId: string) => void;
|
|
44
52
|
}) {
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const handlePopout = React.useCallback(
|
|
48
|
-
(e: React.MouseEvent) => {
|
|
49
|
-
e.stopPropagation();
|
|
50
|
-
if (popoutUrl) window.open(popoutUrl, "_blank", "noopener");
|
|
51
|
-
},
|
|
52
|
-
[popoutUrl],
|
|
53
|
-
);
|
|
53
|
+
const stepId = agent.stepId || agent.agentName;
|
|
54
|
+
const t = useT();
|
|
54
55
|
const AgentCardShell = useUiPrimitive(UI_PRIMITIVE_KEYS.agentCard);
|
|
55
56
|
const formatTokens = useUiPrimitive(UI_PRIMITIVE_KEYS.formatTokens);
|
|
56
57
|
const formatDuration = useUiPrimitive(UI_PRIMITIVE_KEYS.formatDuration);
|
|
57
|
-
const
|
|
58
|
+
const Dialog = useUiPrimitive(UI_PRIMITIVE_KEYS.dialog);
|
|
58
59
|
const MarkdownContent = useUiPrimitive(UI_PRIMITIVE_KEYS.markdownContent);
|
|
59
60
|
|
|
60
|
-
const sourceButtonRef = useRef<HTMLButtonElement | null>(null);
|
|
61
61
|
const [sourceOpen, setSourceOpen] = useState(false);
|
|
62
62
|
const [sourceState, setSourceState] = useState<AgentSourceState>({ kind: "idle" });
|
|
63
63
|
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
|
|
64
|
+
// Code-handler source popover state. Mirrors the agent-source pair above but
|
|
65
|
+
// keyed on `codeTarget` (the resolved .ts handler path for code /
|
|
66
|
+
// code-decision nodes). The fetched .ts is rendered as a fenced ```ts block
|
|
67
|
+
// so the markdown primitive syntax-highlights it instead of mangling it.
|
|
68
|
+
// See change: open-code-handler-from-flow-card.
|
|
69
|
+
const [codeSourceOpen, setCodeSourceOpen] = useState(false);
|
|
70
|
+
const [codeSourceState, setCodeSourceState] = useState<AgentSourceState>({ kind: "idle" });
|
|
71
|
+
|
|
72
|
+
// Eye-button detail state: opens the FlowAgentDetail run-history view in a
|
|
73
|
+
// ui:dialog (replaces the prior anchored popover). See change:
|
|
74
|
+
// improve-flow-graph-dialog-and-card-interaction.
|
|
69
75
|
const [detailOpen, setDetailOpen] = useState(false);
|
|
70
76
|
|
|
71
77
|
// Fetch the agent's .md when the popover opens. Mirrors the pattern of
|
|
@@ -102,6 +108,39 @@ export function FlowAgentCard({
|
|
|
102
108
|
};
|
|
103
109
|
}, [sourceOpen, agent.sourcePath]);
|
|
104
110
|
|
|
111
|
+
// Fetch the code node's handler .ts when its popover opens. `codeTarget` is
|
|
112
|
+
// emitted absolute by the upstream flow runtime, so it is passed verbatim to
|
|
113
|
+
// the resource-file endpoint (allow-list accepts `<cwd>/.pi/...`).
|
|
114
|
+
// See change: open-code-handler-from-flow-card.
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
if (!codeSourceOpen) return;
|
|
117
|
+
if (!agent.codeTarget) {
|
|
118
|
+
setCodeSourceState({ kind: "error", error: "No handler target recorded for this node." });
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
let cancelled = false;
|
|
122
|
+
setCodeSourceState({ kind: "loading" });
|
|
123
|
+
fetch(`/api/pi-resource-file?path=${encodeURIComponent(agent.codeTarget)}`)
|
|
124
|
+
.then(async (r) => {
|
|
125
|
+
const json = await r.json();
|
|
126
|
+
if (cancelled) return;
|
|
127
|
+
if (json?.success && typeof json?.data?.content === "string") {
|
|
128
|
+
setCodeSourceState({ kind: "loaded", content: json.data.content });
|
|
129
|
+
} else {
|
|
130
|
+
setCodeSourceState({
|
|
131
|
+
kind: "error",
|
|
132
|
+
error: typeof json?.error === "string" ? json.error : "Failed to read handler",
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
.catch((err) => {
|
|
137
|
+
if (!cancelled) setCodeSourceState({ kind: "error", error: String(err) });
|
|
138
|
+
});
|
|
139
|
+
return () => {
|
|
140
|
+
cancelled = true;
|
|
141
|
+
};
|
|
142
|
+
}, [codeSourceOpen, agent.codeTarget]);
|
|
143
|
+
|
|
105
144
|
const displayName = agent.label || agent.stepId || agent.agentName;
|
|
106
145
|
const displayRole = agent.cardRole || agent.model || "";
|
|
107
146
|
const isComplete = agent.status === "complete" || agent.status === "error" || agent.status === "blocked";
|
|
@@ -112,13 +151,27 @@ export function FlowAgentCard({
|
|
|
112
151
|
const rawModel = agent.model || "";
|
|
113
152
|
const hasAlias = rawModel.startsWith("@");
|
|
114
153
|
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
154
|
+
// Node-kind badge. Card type is decided by `nodeKind` (surface-node-kind
|
|
155
|
+
// contract); falls back to `stepType` for runs persisted before the
|
|
156
|
+
// contract. See change: rework-flows-plugin-for-new-pi-flows.
|
|
157
|
+
const kind = agent.nodeKind ?? agent.stepType;
|
|
158
|
+
const isCodeKind = kind === "code" || kind === "code-decision";
|
|
159
|
+
const kindBadge =
|
|
160
|
+
kind === "code"
|
|
161
|
+
? <span className="text-[9px] text-cyan-400/80 bg-cyan-400/10 px-1 rounded flex-shrink-0 inline-flex items-center gap-0.5"><Icon path={mdiCodeTags} size={0.4} /> code</span>
|
|
162
|
+
: kind === "code-decision"
|
|
163
|
+
? <span className="text-[9px] text-cyan-400/80 bg-cyan-400/10 px-1 rounded flex-shrink-0 inline-flex items-center gap-0.5"><Icon path={mdiCallSplit} size={0.4} /> decision</span>
|
|
164
|
+
: kind === "fork" || kind === "agent-decision"
|
|
165
|
+
? <span className="text-[9px] text-amber-400/70 bg-amber-400/10 px-1 rounded flex-shrink-0 inline-flex items-center gap-0.5"><Icon path={mdiSourceBranch} size={0.4} /> fork</span>
|
|
120
166
|
: null;
|
|
121
167
|
|
|
168
|
+
// Code-node program logs ride the assistant-text channel; the card's
|
|
169
|
+
// nodeKind makes them "logs". (surface-node-kind D1.)
|
|
170
|
+
const logLines = isCodeKind
|
|
171
|
+
? agent.detailHistory.flatMap((e) => (e.kind === "text" ? [e.text] : []))
|
|
172
|
+
: [];
|
|
173
|
+
const outputs = agent.typedOutputs ? Object.entries(agent.typedOutputs).filter(([k]) => k !== "branch") : [];
|
|
174
|
+
|
|
122
175
|
const headerRight = agent.loopIteration != null && agent.loopIteration > 0 ? (
|
|
123
176
|
<span className="text-[10px] text-blue-400 flex-shrink-0 inline-flex items-center gap-0.5">
|
|
124
177
|
<Icon path={mdiRefresh} size={0.4} />{agent.loopIteration}/{agent.loopMax}
|
|
@@ -127,10 +180,10 @@ export function FlowAgentCard({
|
|
|
127
180
|
<span className="text-[10px] text-blue-400 flex-shrink-0 inline-flex items-center gap-0.5">
|
|
128
181
|
<Icon path={mdiRefresh} size={0.4} />{agent.runCount}
|
|
129
182
|
</span>
|
|
130
|
-
) :
|
|
183
|
+
) : kindBadge;
|
|
131
184
|
|
|
132
185
|
const stats = isComplete && agent.tokens ? (
|
|
133
|
-
<span>↑{formatTokens(agent.tokens.input)} ↓{formatTokens(agent.tokens.output)} · {formatDuration(agent.duration ?? 0)}</span>
|
|
186
|
+
<span>↑{formatTokens(agent.tokens.input)} ↓{formatTokens(agent.tokens.output)}{agent.cost != null && agent.cost > 0 ? ` · ${formatCost(agent.cost)}` : ""} · {formatDuration(agent.duration ?? 0)}</span>
|
|
134
187
|
) : displayModel ? (
|
|
135
188
|
<span>{displayModel}</span>
|
|
136
189
|
) : displayRole ? (
|
|
@@ -138,12 +191,14 @@ export function FlowAgentCard({
|
|
|
138
191
|
) : null;
|
|
139
192
|
|
|
140
193
|
return (
|
|
194
|
+
<div data-step={stepId}>
|
|
141
195
|
<AgentCardShell
|
|
142
196
|
name={displayName}
|
|
143
197
|
status={agent.status}
|
|
144
198
|
headerRight={headerRight}
|
|
145
199
|
stats={stats}
|
|
146
200
|
selected={selected}
|
|
201
|
+
onClick={onSelect ? () => onSelect(stepId) : undefined}
|
|
147
202
|
>
|
|
148
203
|
<div className="flex flex-col flex-1">
|
|
149
204
|
{/* Model alias line (when model uses @role alias) */}
|
|
@@ -161,25 +216,104 @@ export function FlowAgentCard({
|
|
|
161
216
|
{/* Phase-2 agent-metric decorator slot. See change: add-extension-ui-decorations. */}
|
|
162
217
|
<AgentMetricSlot session={session} agentId={agent.agentName} />
|
|
163
218
|
|
|
164
|
-
{/*
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
219
|
+
{/* Body: code nodes show a Log preview (program logs); agent nodes
|
|
220
|
+
show their recent tool calls. */}
|
|
221
|
+
{isCodeKind ? (
|
|
222
|
+
<div className="mt-1 space-y-0">
|
|
223
|
+
{logLines.slice(-3).map((line, i) => (
|
|
224
|
+
<div key={i} className="text-[10px] text-[var(--text-tertiary)] truncate font-mono" title={line}>{line}</div>
|
|
225
|
+
))}
|
|
226
|
+
{Array.from({ length: Math.max(0, 3 - Math.min(3, logLines.length)) }).map((_, i) => (
|
|
227
|
+
<div key={`pad-${i}`} className="text-[10px]"> </div>
|
|
228
|
+
))}
|
|
229
|
+
</div>
|
|
230
|
+
) : (
|
|
231
|
+
<div className="mt-1 space-y-0">
|
|
232
|
+
{agent.recentTools.map((tool, i) => (
|
|
233
|
+
<div key={i} className="text-[10px] text-[var(--text-tertiary)] truncate">
|
|
234
|
+
{i === agent.recentTools.length - 1 ? "▸" : "·"} {tool.toolName} {tool.inputPreview}
|
|
235
|
+
</div>
|
|
236
|
+
))}
|
|
237
|
+
{/* Pad to 3 lines for consistent height */}
|
|
238
|
+
{Array.from({ length: Math.max(0, 3 - agent.recentTools.length) }).map((_, i) => (
|
|
239
|
+
<div key={`pad-${i}`} className="text-[10px]"> </div>
|
|
240
|
+
))}
|
|
241
|
+
</div>
|
|
242
|
+
)}
|
|
243
|
+
|
|
244
|
+
{/* Chosen branch (code-decision / agent-decision) */}
|
|
245
|
+
{agent.branch && (
|
|
246
|
+
<div className="mt-1 text-[10px] font-mono">
|
|
247
|
+
<span className="text-[var(--text-muted)]">branch </span>
|
|
248
|
+
<span className="text-cyan-400 font-semibold">{agent.branch}</span>
|
|
249
|
+
</div>
|
|
250
|
+
)}
|
|
251
|
+
|
|
252
|
+
{/* Typed outputs (agent + code contract) */}
|
|
253
|
+
{outputs.length > 0 && (
|
|
254
|
+
<div className="mt-1 flex flex-wrap gap-1">
|
|
255
|
+
{outputs.map(([k, v]) => (
|
|
256
|
+
<span key={k} className="text-[10px] font-mono bg-[var(--bg-surface)] border border-[var(--border-subtle)] rounded px-1 py-0.5 truncate max-w-[160px]" title={`${k}: ${v}`}>
|
|
257
|
+
<span className="text-cyan-400">{k}</span>: {v}
|
|
258
|
+
</span>
|
|
259
|
+
))}
|
|
260
|
+
</div>
|
|
261
|
+
)}
|
|
262
|
+
|
|
263
|
+
{/* Soft (routed) vs hard (halted) failure outcome */}
|
|
264
|
+
{agent.status === "error" && agent.outcome === "soft" && (
|
|
265
|
+
<div className="mt-1 text-[10px] text-amber-400">⚠ soft-failed — routed to on_error</div>
|
|
266
|
+
)}
|
|
267
|
+
{agent.status === "error" && agent.outcome === "hard" && (
|
|
268
|
+
<div className="mt-1 text-[10px] text-red-400">✕ hard-failed — halted flow</div>
|
|
269
|
+
)}
|
|
270
|
+
|
|
271
|
+
{/* Resolved handler target for code nodes */}
|
|
272
|
+
{isCodeKind && agent.codeTarget && (
|
|
273
|
+
<div className="mt-1 text-[10px] text-[var(--text-muted)] font-mono truncate" title={agent.codeTarget}>‹› {agent.codeTarget}</div>
|
|
274
|
+
)}
|
|
176
275
|
|
|
177
276
|
{/* View source / detail icons — bottom-right of card */}
|
|
178
277
|
<div className="flex justify-end mt-auto pt-1 gap-1">
|
|
278
|
+
{isCodeKind && agent.codeTarget && (
|
|
279
|
+
<>
|
|
280
|
+
<button
|
|
281
|
+
onClick={(e) => { e.stopPropagation(); setCodeSourceOpen((prev) => !prev); }}
|
|
282
|
+
className={`transition-colors p-0.5 rounded inline-flex items-center ${
|
|
283
|
+
codeSourceOpen
|
|
284
|
+
? "text-cyan-400 bg-cyan-400/10"
|
|
285
|
+
: "text-[var(--text-tertiary)] hover:text-cyan-400 hover:bg-[var(--bg-surface)]"
|
|
286
|
+
}`}
|
|
287
|
+
title={codeSourceOpen ? "Close handler source" : "View handler source"}
|
|
288
|
+
>
|
|
289
|
+
<Icon path={mdiCodeBraces} size={0.45} />
|
|
290
|
+
</button>
|
|
291
|
+
<Dialog
|
|
292
|
+
open={codeSourceOpen}
|
|
293
|
+
onClose={() => setCodeSourceOpen(false)}
|
|
294
|
+
title={agent.codeTarget.split("/").pop() || "Handler"}
|
|
295
|
+
size="lg"
|
|
296
|
+
>
|
|
297
|
+
<div className="text-[11px] text-[var(--text-tertiary)] font-mono break-all" title={agent.codeTarget}>
|
|
298
|
+
{agent.codeTarget}
|
|
299
|
+
</div>
|
|
300
|
+
<div className="h-[60vh] overflow-y-auto">
|
|
301
|
+
{codeSourceState.kind === "loading" && (
|
|
302
|
+
<div className="text-xs text-[var(--text-muted)]">Loading…</div>
|
|
303
|
+
)}
|
|
304
|
+
{codeSourceState.kind === "error" && (
|
|
305
|
+
<div className="text-xs text-red-400">⚠ {codeSourceState.error}</div>
|
|
306
|
+
)}
|
|
307
|
+
{codeSourceState.kind === "loaded" && (
|
|
308
|
+
<MarkdownContent content={"```ts\n" + codeSourceState.content + "\n```"} />
|
|
309
|
+
)}
|
|
310
|
+
</div>
|
|
311
|
+
</Dialog>
|
|
312
|
+
</>
|
|
313
|
+
)}
|
|
179
314
|
{agent.sourcePath && (
|
|
180
315
|
<>
|
|
181
316
|
<button
|
|
182
|
-
ref={sourceButtonRef}
|
|
183
317
|
onClick={(e) => { e.stopPropagation(); setSourceOpen((prev) => !prev); }}
|
|
184
318
|
className={`transition-colors p-0.5 rounded inline-flex items-center ${
|
|
185
319
|
sourceOpen
|
|
@@ -190,83 +324,70 @@ export function FlowAgentCard({
|
|
|
190
324
|
>
|
|
191
325
|
<Icon path={mdiFileDocumentOutline} size={0.45} />
|
|
192
326
|
</button>
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
</
|
|
216
|
-
|
|
327
|
+
<Dialog
|
|
328
|
+
open={sourceOpen}
|
|
329
|
+
onClose={() => setSourceOpen(false)}
|
|
330
|
+
title={agent.sourcePath.split("/").pop() || "Source"}
|
|
331
|
+
size="lg"
|
|
332
|
+
>
|
|
333
|
+
{/* Pinned path header; body scrolls inside a fixed-height
|
|
334
|
+
region so the dialog stays a fixed size. See change:
|
|
335
|
+
improve-flow-graph-dialog-and-card-interaction. */}
|
|
336
|
+
<div className="text-[11px] text-[var(--text-tertiary)] font-mono break-all" title={agent.sourcePath}>
|
|
337
|
+
{agent.sourcePath}
|
|
338
|
+
</div>
|
|
339
|
+
<div className="h-[60vh] overflow-y-auto">
|
|
340
|
+
{sourceState.kind === "loading" && (
|
|
341
|
+
<div className="text-xs text-[var(--text-muted)]">Loading…</div>
|
|
342
|
+
)}
|
|
343
|
+
{sourceState.kind === "error" && (
|
|
344
|
+
<div className="text-xs text-red-400">⚠ {sourceState.error}</div>
|
|
345
|
+
)}
|
|
346
|
+
{sourceState.kind === "loaded" && (
|
|
347
|
+
<MarkdownContent content={sourceState.content} />
|
|
348
|
+
)}
|
|
349
|
+
</div>
|
|
350
|
+
</Dialog>
|
|
217
351
|
</>
|
|
218
352
|
)}
|
|
219
353
|
<button
|
|
220
|
-
type="button"
|
|
221
|
-
onClick={handlePopout}
|
|
222
|
-
disabled={!popoutEnabled}
|
|
223
|
-
data-testid="flow-agent-popout-button"
|
|
224
|
-
className={`transition-colors px-1.5 py-0.5 rounded text-[11px] inline-flex items-center gap-1 border ${
|
|
225
|
-
popoutEnabled
|
|
226
|
-
? "border-[var(--border-subtle)] text-[var(--text-tertiary)] hover:text-blue-400 hover:border-blue-400/40 hover:bg-blue-400/10"
|
|
227
|
-
: "border-[var(--border-subtle)] text-[var(--text-muted)] opacity-50 cursor-not-allowed"
|
|
228
|
-
}`}
|
|
229
|
-
title={popoutEnabled ? `Open ${displayName} in new tab` : "Popout unavailable (no session context)"}
|
|
230
|
-
>
|
|
231
|
-
<Icon path={mdiOpenInNew} size={0.55} />
|
|
232
|
-
<span className="text-[10px]">Popout</span>
|
|
233
|
-
</button>
|
|
234
|
-
<button
|
|
235
|
-
ref={detailButtonRef}
|
|
236
354
|
onClick={(e) => { e.stopPropagation(); setDetailOpen((prev) => !prev); }}
|
|
237
355
|
className={`transition-colors px-1.5 py-0.5 rounded text-[11px] inline-flex items-center gap-1 border ${
|
|
238
356
|
detailOpen
|
|
239
357
|
? "text-blue-400 bg-blue-400/10 border-blue-400/40"
|
|
240
358
|
: "border-[var(--border-subtle)] text-[var(--text-tertiary)] hover:text-blue-400 hover:border-blue-400/40 hover:bg-blue-400/10"
|
|
241
359
|
}`}
|
|
242
|
-
title={
|
|
360
|
+
title={
|
|
361
|
+
detailOpen
|
|
362
|
+
? t("closeAgentDetail", { name: displayName }, `Close ${displayName} detail`)
|
|
363
|
+
: t("viewAgentDetail", { name: displayName }, `View ${displayName} detail`)
|
|
364
|
+
}
|
|
243
365
|
>
|
|
244
366
|
<Icon path={detailOpen ? mdiEyeOffOutline : mdiEyeOutline} size={0.55} />
|
|
245
|
-
<span className="text-[10px]">Details</span>
|
|
367
|
+
<span className="text-[10px]">{t("details", undefined, "Details")}</span>
|
|
246
368
|
</button>
|
|
247
|
-
{
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
</Popover>
|
|
267
|
-
)}
|
|
369
|
+
{/* Agent detail opens in the ui:dialog (the dialog title carries the
|
|
370
|
+
agent name; FlowAgentDetail's onBack maps to onClose). `h-[70vh]
|
|
371
|
+
flex flex-col` gives MinimalChatView's `h-full` mode a concrete
|
|
372
|
+
height + flex parent so the body scrolls instead of overflowing.
|
|
373
|
+
See change: improve-flow-graph-dialog-and-card-interaction. */}
|
|
374
|
+
<Dialog
|
|
375
|
+
open={detailOpen}
|
|
376
|
+
onClose={() => setDetailOpen(false)}
|
|
377
|
+
size="lg"
|
|
378
|
+
flush
|
|
379
|
+
>
|
|
380
|
+
<div className="h-[70vh] overflow-hidden flex flex-col">
|
|
381
|
+
<FlowAgentDetail
|
|
382
|
+
agent={agent}
|
|
383
|
+
onBack={() => setDetailOpen(false)}
|
|
384
|
+
sessionId={sessionId}
|
|
385
|
+
/>
|
|
386
|
+
</div>
|
|
387
|
+
</Dialog>
|
|
268
388
|
</div>
|
|
269
389
|
</div>
|
|
270
390
|
</AgentCardShell>
|
|
391
|
+
</div>
|
|
271
392
|
);
|
|
272
393
|
}
|
|
@@ -2,24 +2,26 @@
|
|
|
2
2
|
* FlowAgentDetail — thin adapter shim over `MinimalChatView`.
|
|
3
3
|
*
|
|
4
4
|
* Maps `FlowAgentState` → `MinimalChatViewProps`. Preserves the existing
|
|
5
|
-
* public API (`agent`, `onBack`) so `FlowAgentCard`'s eye-button
|
|
6
|
-
*
|
|
5
|
+
* public API (`agent`, `onBack`) so `FlowAgentCard`'s eye-button detail
|
|
6
|
+
* dialog keeps working without change.
|
|
7
7
|
*
|
|
8
8
|
* See change: extract-minimal-chat-view.
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
import { useT, useUiPrimitive } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
12
|
+
import {
|
|
13
|
+
type MinimalChatEntry,
|
|
14
|
+
type MinimalChatStatus,
|
|
15
|
+
MinimalChatView,
|
|
16
|
+
} from "@blackbelt-technology/pi-dashboard-client-utils/minimal-chat";
|
|
17
|
+
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
11
18
|
import type {
|
|
12
19
|
FlowAgentState,
|
|
13
20
|
FlowAgentStatus,
|
|
14
21
|
FlowDetailEntry,
|
|
15
22
|
} from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
MinimalChatView,
|
|
20
|
-
type MinimalChatEntry,
|
|
21
|
-
type MinimalChatStatus,
|
|
22
|
-
} from "@blackbelt-technology/pi-dashboard-client-utils/minimal-chat";
|
|
23
|
+
import React from "react";
|
|
24
|
+
import { formatCost } from "./FlowAgentCard.js";
|
|
23
25
|
|
|
24
26
|
function mapFlowStatus(status: FlowAgentStatus): MinimalChatStatus {
|
|
25
27
|
switch (status) {
|
|
@@ -77,6 +79,7 @@ export function FlowAgentDetail({
|
|
|
77
79
|
/** Forwarded to MinimalChatView so per-tool renderers can build session-scoped links. */
|
|
78
80
|
sessionId?: string;
|
|
79
81
|
}) {
|
|
82
|
+
const t = useT();
|
|
80
83
|
const MarkdownContent = useUiPrimitive(UI_PRIMITIVE_KEYS.markdownContent);
|
|
81
84
|
const title = agent.label || agent.agentName;
|
|
82
85
|
const status = mapFlowStatus(agent.status);
|
|
@@ -87,12 +90,15 @@ export function FlowAgentDetail({
|
|
|
87
90
|
|
|
88
91
|
const footer = agent.summary ? (
|
|
89
92
|
<div className="mt-3 pt-2 border-t border-[var(--border-subtle)]">
|
|
90
|
-
<div className="text-[11px] text-[var(--text-muted)] mb-1">Summary</div>
|
|
93
|
+
<div className="text-[11px] text-[var(--text-muted)] mb-1">{t("summary", undefined, "Summary")}</div>
|
|
91
94
|
<MarkdownContent content={agent.summary} />
|
|
92
95
|
</div>
|
|
93
96
|
) : undefined;
|
|
94
97
|
|
|
95
|
-
const emptyMessage =
|
|
98
|
+
const emptyMessage =
|
|
99
|
+
agent.status === "pending"
|
|
100
|
+
? t("waitingToStart", undefined, "Waiting to start...")
|
|
101
|
+
: t("noActivityYet", undefined, "No activity yet");
|
|
96
102
|
|
|
97
103
|
return (
|
|
98
104
|
<MinimalChatView
|
|
@@ -102,9 +108,11 @@ export function FlowAgentDetail({
|
|
|
102
108
|
mode="popout"
|
|
103
109
|
onBack={onBack}
|
|
104
110
|
sessionId={sessionId}
|
|
111
|
+
hideToolStatusIcon
|
|
105
112
|
meta={{
|
|
106
113
|
modelName: agent.model,
|
|
107
114
|
tokens: agent.tokens,
|
|
115
|
+
cost: agent.cost != null && agent.cost > 0 ? formatCost(agent.cost) : undefined,
|
|
108
116
|
durationMs: isComplete ? agent.duration : undefined,
|
|
109
117
|
}}
|
|
110
118
|
emptyMessage={emptyMessage}
|