@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.
Files changed (66) hide show
  1. package/package.json +25 -16
  2. package/src/AGENTS.md +8 -0
  3. package/src/__tests__/FlowGraph.test.ts +151 -5
  4. package/src/__tests__/FlowInputWiring.test.tsx +97 -0
  5. package/src/__tests__/FlowSummary.test.tsx +331 -0
  6. package/src/__tests__/FlowYamlPreview.test.tsx +75 -0
  7. package/src/__tests__/FlowsSessionStateContext.test.tsx +2 -39
  8. package/src/__tests__/authoring-renderers.test.tsx +190 -0
  9. package/src/__tests__/automation-actions.test.ts +117 -0
  10. package/src/__tests__/flow-agent-card-code-source.test.tsx +154 -0
  11. package/src/__tests__/flow-agent-cost.test.tsx +160 -0
  12. package/src/__tests__/flow-agent-error.test.ts +60 -0
  13. package/src/__tests__/flow-collapse-storage.test.ts +90 -0
  14. package/src/__tests__/flow-edges.test.ts +195 -0
  15. package/src/__tests__/flow-inputs.test.ts +69 -0
  16. package/src/__tests__/flow-reducer-bridge-contract.test.ts +108 -0
  17. package/src/__tests__/flow-reducer-seed-on-start.test.ts +61 -0
  18. package/src/__tests__/flow-yaml-parse.test.ts +124 -0
  19. package/src/__tests__/flows-for-cwd.test.ts +51 -0
  20. package/src/__tests__/flowsAvailability.test.ts +51 -64
  21. package/src/__tests__/node-kind-reducer.test.ts +135 -0
  22. package/src/__tests__/plugin-action-handler.test.ts +54 -0
  23. package/src/__tests__/session-flow-actions-edit.test.tsx +98 -0
  24. package/src/bridge/AGENTS.md +8 -0
  25. package/src/client/AGENTS.md +32 -0
  26. package/src/client/FlowActivityBadge.tsx +8 -5
  27. package/src/client/FlowAgentCard.tsx +231 -110
  28. package/src/client/FlowAgentDetail.tsx +20 -12
  29. package/src/client/FlowAgentsToolRenderer.tsx +228 -0
  30. package/src/client/FlowAuthorPromptDialog.tsx +92 -0
  31. package/src/client/FlowDashboard.tsx +88 -23
  32. package/src/client/FlowGraph.tsx +420 -275
  33. package/src/client/FlowInputWiring.tsx +243 -0
  34. package/src/client/FlowLaunchDialog.tsx +48 -54
  35. package/src/client/FlowQuestionCard.tsx +6 -3
  36. package/src/client/FlowSummary.tsx +252 -69
  37. package/src/client/FlowWriteToolRenderer.tsx +127 -0
  38. package/src/client/FlowYamlPopoverButton.tsx +26 -25
  39. package/src/client/FlowYamlPreview.tsx +9 -7
  40. package/src/client/FlowsSessionStateContext.tsx +14 -33
  41. package/src/client/FlowsSettings.tsx +68 -0
  42. package/src/client/SessionFlowActions.tsx +92 -76
  43. package/src/client/flow-collapse-storage.ts +79 -0
  44. package/src/client/flow-edges.ts +173 -0
  45. package/src/client/flow-yaml-parse.ts +140 -0
  46. package/src/client/flowsAvailability.ts +28 -87
  47. package/src/client/index.tsx +27 -32
  48. package/src/client/shouldRender.ts +24 -12
  49. package/src/configSchema.json +14 -0
  50. package/src/flow-reducer.ts +94 -13
  51. package/src/i18n.ts +90 -0
  52. package/src/reducer.ts +5 -5
  53. package/src/server/AGENTS.md +10 -0
  54. package/src/server/automation-actions.ts +162 -0
  55. package/src/server/flow-inputs.ts +58 -0
  56. package/src/server/index.ts +93 -9
  57. package/src/server/state-store.ts +3 -14
  58. package/src/__tests__/ArchitectInputPrompt.test.tsx +0 -81
  59. package/src/__tests__/architect-reducer.test.ts +0 -307
  60. package/src/architect-reducer.ts +0 -386
  61. package/src/client/FlowAgentPopoutClaim.tsx +0 -66
  62. package/src/client/FlowAgentPopoutPage.tsx +0 -177
  63. package/src/client/FlowArchitect.tsx +0 -699
  64. package/src/client/FlowArchitectPopoutClaim.tsx +0 -52
  65. package/src/client/FlowArchitectPopoutPage.tsx +0 -133
  66. package/src/client/popout-url.ts +0 -59
@@ -1,14 +1,13 @@
1
- import React, { useEffect, useRef, useState } from "react";
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
- flowId,
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 — required for the popout button. */
48
+ /** Session id of the parent flow — threaded to FlowAgentDetail. */
41
49
  sessionId?: string;
42
- /** Flow name (acts as flow id in the URL) — required for the popout button. */
43
- flowId?: string;
50
+ /** Toggle shared graph⇄card selection. See change: improve-flow-graph-dialog-and-card-interaction. */
51
+ onSelect?: (stepId: string) => void;
44
52
  }) {
45
- const popoutUrl = buildFlowAgentPopoutUrl(sessionId, flowId, agent.stepId);
46
- const popoutEnabled = popoutUrl !== null;
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 Popover = useUiPrimitive(UI_PRIMITIVE_KEYS.popover);
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
- // Eye-button popover state: shows the FlowAgentDetail run-history view
65
- // anchored to the eye button. Replaces the dormant content-view slot
66
- // claim (FlowAgentDetailClaim) which took over the full chat pane.
67
- // See change: add-ui-popover-primitive.
68
- const detailButtonRef = useRef<HTMLButtonElement | null>(null);
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
- // Step type badge for non-agent steps
116
- const stepTypeBadge = agent.stepType === "fork" || agent.stepType === "agent-decision"
117
- ? <span className="text-[9px] text-amber-400/70 bg-amber-400/10 px-1 rounded flex-shrink-0">◇ fork</span>
118
- : agent.stepType === "agent-loop-decision"
119
- ? <span className="text-[9px] text-purple-400/70 bg-purple-400/10 px-1 rounded flex-shrink-0">↻ loop</span>
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
- ) : stepTypeBadge;
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
- {/* Recent tools */}
165
- <div className="mt-1 space-y-0">
166
- {agent.recentTools.map((tool, i) => (
167
- <div key={i} className="text-[10px] text-[var(--text-tertiary)] truncate">
168
- {i === agent.recentTools.length - 1 ? "▸" : "·"} {tool.toolName} {tool.inputPreview}
169
- </div>
170
- ))}
171
- {/* Pad to 3 lines for consistent height */}
172
- {Array.from({ length: Math.max(0, 3 - agent.recentTools.length) }).map((_, i) => (
173
- <div key={`pad-${i}`} className="text-[10px]">&nbsp;</div>
174
- ))}
175
- </div>
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]">&nbsp;</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]">&nbsp;</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
- {sourceOpen && sourceButtonRef.current && (
194
- <Popover
195
- anchorEl={sourceButtonRef.current}
196
- onDismiss={() => setSourceOpen(false)}
197
- >
198
- <div
199
- 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"
200
- onClick={(e) => e.stopPropagation()}
201
- >
202
- <div className="text-[11px] text-[var(--text-tertiary)] mb-2 font-mono truncate" title={agent.sourcePath}>
203
- {agent.sourcePath}
204
- </div>
205
- {sourceState.kind === "loading" && (
206
- <div className="text-xs text-[var(--text-muted)]">Loading…</div>
207
- )}
208
- {sourceState.kind === "error" && (
209
- <div className="text-xs text-red-400">⚠ {sourceState.error}</div>
210
- )}
211
- {sourceState.kind === "loaded" && (
212
- <MarkdownContent content={sourceState.content} />
213
- )}
214
- </div>
215
- </Popover>
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={detailOpen ? `Close ${displayName} detail` : `View ${displayName} detail`}
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
- {detailOpen && detailButtonRef.current && (
248
- <Popover
249
- anchorEl={detailButtonRef.current}
250
- onDismiss={() => setDetailOpen(false)}
251
- >
252
- <div
253
- // `h-[70vh]` (not max-h) gives MinimalChatView's `h-full`
254
- // popout mode a concrete height to fill, so its inner body
255
- // scrolls instead of overflowing the popover.
256
- // See change: fix-flows-plugin-polish (scrollbar fix).
257
- className="w-[640px] max-w-[90vw] h-[70vh] overflow-hidden bg-[var(--bg-secondary)] border border-[var(--border-primary)] rounded-md shadow-xl"
258
- onClick={(e) => e.stopPropagation()}
259
- >
260
- <FlowAgentDetail
261
- agent={agent}
262
- onBack={() => setDetailOpen(false)}
263
- sessionId={sessionId}
264
- />
265
- </div>
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 popover
6
- * (and the future `FlowAgentPopoutPage` route) keep working without change.
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
- import React from "react";
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 { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
17
- import { useUiPrimitive } from "@blackbelt-technology/dashboard-plugin-runtime";
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 = agent.status === "pending" ? "Waiting to start..." : "No activity yet";
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}