@blackbelt-technology/pi-dashboard-flows-plugin 0.5.3 → 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 +48 -4
- 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 +223 -0
- package/src/__tests__/FlowsUiStateContext.test.tsx +140 -0
- 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 +79 -0
- package/src/__tests__/manifest-discoverability.test.ts +97 -0
- package/src/__tests__/node-kind-reducer.test.ts +135 -0
- package/src/__tests__/plugin-action-handler.test.ts +54 -0
- package/src/__tests__/render-actions.test.ts +63 -0
- package/src/__tests__/session-flow-actions-edit.test.tsx +98 -0
- package/src/bridge/AGENTS.md +8 -0
- package/src/bridge/flow-question-adapter.ts +93 -0
- package/src/bridge/index.ts +30 -0
- package/src/client/AGENTS.md +32 -0
- package/src/client/FlowActivityBadge.tsx +41 -11
- package/src/client/FlowAgentCard.tsx +321 -61
- package/src/client/FlowAgentDetail.tsx +103 -154
- package/src/client/FlowAgentsToolRenderer.tsx +228 -0
- package/src/client/FlowAuthorPromptDialog.tsx +92 -0
- package/src/client/FlowDashboard.tsx +271 -43
- package/src/client/FlowGraph.tsx +425 -276
- package/src/client/FlowInputWiring.tsx +243 -0
- package/src/client/FlowLaunchDialog.tsx +52 -52
- package/src/client/FlowQuestionCard.tsx +216 -0
- package/src/client/FlowQuestionTranscriptPill.tsx +58 -0
- package/src/client/FlowSummary.tsx +285 -80
- package/src/client/FlowWriteToolRenderer.tsx +127 -0
- package/src/client/FlowYamlPopoverButton.tsx +110 -0
- package/src/client/FlowYamlPreview.tsx +67 -0
- package/src/client/FlowsCommandRoutes.tsx +237 -0
- package/src/client/FlowsSessionStateContext.tsx +142 -0
- package/src/client/FlowsSettings.tsx +68 -0
- package/src/client/FlowsUiStateContext.tsx +169 -0
- package/src/client/SessionFlowActions.tsx +172 -65
- 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 +44 -0
- package/src/client/index.tsx +95 -13
- package/src/client/shouldRender.ts +38 -0
- 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 +171 -0
- package/src/server/render-actions.ts +88 -0
- package/src/server/state-store.ts +74 -0
- 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/FlowArchitect.tsx +0 -622
|
@@ -1,29 +1,146 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { useT, useUiPrimitive } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
2
|
+
// AgentMetricSlot is a slot CONSUMER (Phase-2 decorator slot), not a primitive
|
|
3
|
+
// — it stays as a direct import. See add-plugin-ui-primitive-registry Decision 4.
|
|
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";
|
|
4
6
|
import type { DashboardSession, FlowAgentState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
|
+
import { FlowAgentDetail } from "./FlowAgentDetail.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* State of the agent-source fetch for the document-icon popover.
|
|
14
|
+
*
|
|
15
|
+
* Self-contained inside FlowAgentCard: when the user clicks the doc icon,
|
|
16
|
+
* we open a popover anchored to that button and fetch the agent's .md
|
|
17
|
+
* via `GET /api/pi-resource-file?path=<sourcePath>`. The bytes are then
|
|
18
|
+
* rendered with the `ui:markdown-content` primitive.
|
|
19
|
+
*
|
|
20
|
+
* See change: add-ui-popover-primitive.
|
|
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
|
+
|
|
31
|
+
type AgentSourceState =
|
|
32
|
+
| { kind: "idle" }
|
|
33
|
+
| { kind: "loading" }
|
|
34
|
+
| { kind: "loaded"; content: string }
|
|
35
|
+
| { kind: "error"; error: string };
|
|
8
36
|
|
|
9
37
|
export function FlowAgentCard({
|
|
10
38
|
agent,
|
|
11
|
-
onClick,
|
|
12
|
-
onViewSource,
|
|
13
39
|
selected,
|
|
14
|
-
isDetailOpen,
|
|
15
|
-
isSourceOpen,
|
|
16
40
|
session,
|
|
41
|
+
sessionId,
|
|
42
|
+
onSelect,
|
|
17
43
|
}: {
|
|
18
44
|
agent: FlowAgentState;
|
|
19
|
-
onClick?: () => void;
|
|
20
|
-
onViewSource?: () => void;
|
|
21
45
|
selected?: boolean;
|
|
22
|
-
isDetailOpen?: boolean;
|
|
23
|
-
isSourceOpen?: boolean;
|
|
24
46
|
/** Phase-2 decorator host — used for `agent-metric` filtering by agentId. */
|
|
25
47
|
session?: Pick<DashboardSession, "uiDecorators">;
|
|
48
|
+
/** Session id of the parent flow — threaded to FlowAgentDetail. */
|
|
49
|
+
sessionId?: string;
|
|
50
|
+
/** Toggle shared graph⇄card selection. See change: improve-flow-graph-dialog-and-card-interaction. */
|
|
51
|
+
onSelect?: (stepId: string) => void;
|
|
26
52
|
}) {
|
|
53
|
+
const stepId = agent.stepId || agent.agentName;
|
|
54
|
+
const t = useT();
|
|
55
|
+
const AgentCardShell = useUiPrimitive(UI_PRIMITIVE_KEYS.agentCard);
|
|
56
|
+
const formatTokens = useUiPrimitive(UI_PRIMITIVE_KEYS.formatTokens);
|
|
57
|
+
const formatDuration = useUiPrimitive(UI_PRIMITIVE_KEYS.formatDuration);
|
|
58
|
+
const Dialog = useUiPrimitive(UI_PRIMITIVE_KEYS.dialog);
|
|
59
|
+
const MarkdownContent = useUiPrimitive(UI_PRIMITIVE_KEYS.markdownContent);
|
|
60
|
+
|
|
61
|
+
const [sourceOpen, setSourceOpen] = useState(false);
|
|
62
|
+
const [sourceState, setSourceState] = useState<AgentSourceState>({ kind: "idle" });
|
|
63
|
+
|
|
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.
|
|
75
|
+
const [detailOpen, setDetailOpen] = useState(false);
|
|
76
|
+
|
|
77
|
+
// Fetch the agent's .md when the popover opens. Mirrors the pattern of
|
|
78
|
+
// `usePiResourceFileFetch` in the dashboard client: deps include only
|
|
79
|
+
// open + path. Including state in deps causes the cleanup to fire on
|
|
80
|
+
// the idle→loading transition and self-cancel the fetch.
|
|
81
|
+
// See change: add-ui-popover-primitive.
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (!sourceOpen) return;
|
|
84
|
+
if (!agent.sourcePath) {
|
|
85
|
+
setSourceState({ kind: "error", error: "No source path recorded for this agent." });
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
let cancelled = false;
|
|
89
|
+
setSourceState({ kind: "loading" });
|
|
90
|
+
fetch(`/api/pi-resource-file?path=${encodeURIComponent(agent.sourcePath)}`)
|
|
91
|
+
.then(async (r) => {
|
|
92
|
+
const json = await r.json();
|
|
93
|
+
if (cancelled) return;
|
|
94
|
+
if (json?.success && typeof json?.data?.content === "string") {
|
|
95
|
+
setSourceState({ kind: "loaded", content: json.data.content });
|
|
96
|
+
} else {
|
|
97
|
+
setSourceState({
|
|
98
|
+
kind: "error",
|
|
99
|
+
error: typeof json?.error === "string" ? json.error : "Failed to read source",
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
.catch((err) => {
|
|
104
|
+
if (!cancelled) setSourceState({ kind: "error", error: String(err) });
|
|
105
|
+
});
|
|
106
|
+
return () => {
|
|
107
|
+
cancelled = true;
|
|
108
|
+
};
|
|
109
|
+
}, [sourceOpen, agent.sourcePath]);
|
|
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
|
+
|
|
27
144
|
const displayName = agent.label || agent.stepId || agent.agentName;
|
|
28
145
|
const displayRole = agent.cardRole || agent.model || "";
|
|
29
146
|
const isComplete = agent.status === "complete" || agent.status === "error" || agent.status === "blocked";
|
|
@@ -34,13 +151,27 @@ export function FlowAgentCard({
|
|
|
34
151
|
const rawModel = agent.model || "";
|
|
35
152
|
const hasAlias = rawModel.startsWith("@");
|
|
36
153
|
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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>
|
|
42
166
|
: null;
|
|
43
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
|
+
|
|
44
175
|
const headerRight = agent.loopIteration != null && agent.loopIteration > 0 ? (
|
|
45
176
|
<span className="text-[10px] text-blue-400 flex-shrink-0 inline-flex items-center gap-0.5">
|
|
46
177
|
<Icon path={mdiRefresh} size={0.4} />{agent.loopIteration}/{agent.loopMax}
|
|
@@ -49,10 +180,10 @@ export function FlowAgentCard({
|
|
|
49
180
|
<span className="text-[10px] text-blue-400 flex-shrink-0 inline-flex items-center gap-0.5">
|
|
50
181
|
<Icon path={mdiRefresh} size={0.4} />{agent.runCount}
|
|
51
182
|
</span>
|
|
52
|
-
) :
|
|
183
|
+
) : kindBadge;
|
|
53
184
|
|
|
54
185
|
const stats = isComplete && agent.tokens ? (
|
|
55
|
-
<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>
|
|
56
187
|
) : displayModel ? (
|
|
57
188
|
<span>{displayModel}</span>
|
|
58
189
|
) : displayRole ? (
|
|
@@ -60,12 +191,14 @@ export function FlowAgentCard({
|
|
|
60
191
|
) : null;
|
|
61
192
|
|
|
62
193
|
return (
|
|
194
|
+
<div data-step={stepId}>
|
|
63
195
|
<AgentCardShell
|
|
64
196
|
name={displayName}
|
|
65
197
|
status={agent.status}
|
|
66
198
|
headerRight={headerRight}
|
|
67
199
|
stats={stats}
|
|
68
200
|
selected={selected}
|
|
201
|
+
onClick={onSelect ? () => onSelect(stepId) : undefined}
|
|
69
202
|
>
|
|
70
203
|
<div className="flex flex-col flex-1">
|
|
71
204
|
{/* Model alias line (when model uses @role alias) */}
|
|
@@ -83,51 +216,178 @@ export function FlowAgentCard({
|
|
|
83
216
|
{/* Phase-2 agent-metric decorator slot. See change: add-extension-ui-decorations. */}
|
|
84
217
|
<AgentMetricSlot session={session} agentId={agent.agentName} />
|
|
85
218
|
|
|
86
|
-
{/*
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
+
)}
|
|
98
275
|
|
|
99
276
|
{/* View source / detail icons — bottom-right of card */}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
+
</>
|
|
114
313
|
)}
|
|
115
|
-
{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
314
|
+
{agent.sourcePath && (
|
|
315
|
+
<>
|
|
316
|
+
<button
|
|
317
|
+
onClick={(e) => { e.stopPropagation(); setSourceOpen((prev) => !prev); }}
|
|
318
|
+
className={`transition-colors p-0.5 rounded inline-flex items-center ${
|
|
319
|
+
sourceOpen
|
|
320
|
+
? "text-blue-400 bg-blue-400/10"
|
|
321
|
+
: "text-[var(--text-tertiary)] hover:text-blue-400 hover:bg-[var(--bg-surface)]"
|
|
322
|
+
}`}
|
|
323
|
+
title={sourceOpen ? `Close ${displayName} source` : `View ${displayName} source`}
|
|
324
|
+
>
|
|
325
|
+
<Icon path={mdiFileDocumentOutline} size={0.45} />
|
|
326
|
+
</button>
|
|
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>
|
|
351
|
+
</>
|
|
127
352
|
)}
|
|
128
|
-
|
|
129
|
-
|
|
353
|
+
<button
|
|
354
|
+
onClick={(e) => { e.stopPropagation(); setDetailOpen((prev) => !prev); }}
|
|
355
|
+
className={`transition-colors px-1.5 py-0.5 rounded text-[11px] inline-flex items-center gap-1 border ${
|
|
356
|
+
detailOpen
|
|
357
|
+
? "text-blue-400 bg-blue-400/10 border-blue-400/40"
|
|
358
|
+
: "border-[var(--border-subtle)] text-[var(--text-tertiary)] hover:text-blue-400 hover:border-blue-400/40 hover:bg-blue-400/10"
|
|
359
|
+
}`}
|
|
360
|
+
title={
|
|
361
|
+
detailOpen
|
|
362
|
+
? t("closeAgentDetail", { name: displayName }, `Close ${displayName} detail`)
|
|
363
|
+
: t("viewAgentDetail", { name: displayName }, `View ${displayName} detail`)
|
|
364
|
+
}
|
|
365
|
+
>
|
|
366
|
+
<Icon path={detailOpen ? mdiEyeOffOutline : mdiEyeOutline} size={0.55} />
|
|
367
|
+
<span className="text-[10px]">{t("details", undefined, "Details")}</span>
|
|
368
|
+
</button>
|
|
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>
|
|
388
|
+
</div>
|
|
130
389
|
</div>
|
|
131
390
|
</AgentCardShell>
|
|
391
|
+
</div>
|
|
132
392
|
);
|
|
133
393
|
}
|