@blackbelt-technology/pi-dashboard-flows-plugin 0.7.0 → 0.9.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 +18 -7
- package/src/bridge/flow-files-reporter.ts +113 -0
- package/src/bridge/index.ts +5 -1
- package/src/client/FlowAgentCard.tsx +82 -213
- package/src/client/FlowAgentDetail.tsx +1 -1
- package/src/client/FlowDashboard.tsx +428 -66
- package/src/client/FlowInputWiring.tsx +2 -2
- package/src/client/FlowSummary.tsx +22 -16
- package/src/client/FlowYamlPopoverButton.tsx +27 -92
- package/src/client/FlowsCommandRoutes.tsx +13 -5
- package/src/client/FlowsSessionStateContext.tsx +40 -4
- package/src/client/FlowsSettings.tsx +4 -4
- package/src/client/SessionFlowActions.tsx +80 -6
- package/src/client/flow-attach-store.ts +140 -0
- package/src/client/flow-card-grid.ts +36 -0
- package/src/client/flow-files.ts +152 -0
- package/src/client/flow-idle-state.ts +230 -0
- package/src/client/format-cost.ts +21 -0
- package/src/client/send-safe.ts +19 -0
- package/src/flow-files-contract.ts +21 -0
- package/src/flow-reducer.ts +4 -0
- package/src/i18n.ts +28 -0
- package/src/server/automation-actions.ts +3 -0
- package/src/server/flow-files.ts +264 -0
- package/src/server/index.ts +15 -0
- package/src/AGENTS.md +0 -8
- package/src/__tests__/FlowGraph.test.ts +0 -305
- package/src/__tests__/FlowInputWiring.test.tsx +0 -97
- package/src/__tests__/FlowSummary.test.tsx +0 -331
- package/src/__tests__/FlowYamlPreview.test.tsx +0 -75
- package/src/__tests__/FlowsSessionStateContext.test.tsx +0 -223
- package/src/__tests__/FlowsUiStateContext.test.tsx +0 -140
- package/src/__tests__/authoring-renderers.test.tsx +0 -190
- package/src/__tests__/automation-actions.test.ts +0 -117
- package/src/__tests__/flow-agent-card-code-source.test.tsx +0 -190
- package/src/__tests__/flow-agent-cost.test.tsx +0 -160
- package/src/__tests__/flow-agent-error.test.ts +0 -60
- package/src/__tests__/flow-collapse-storage.test.ts +0 -90
- package/src/__tests__/flow-edges.test.ts +0 -195
- package/src/__tests__/flow-inputs.test.ts +0 -69
- package/src/__tests__/flow-reducer-bridge-contract.test.ts +0 -108
- package/src/__tests__/flow-reducer-seed-on-start.test.ts +0 -61
- package/src/__tests__/flow-yaml-parse.test.ts +0 -124
- package/src/__tests__/flows-for-cwd.test.ts +0 -51
- package/src/__tests__/flowsAvailability.test.ts +0 -79
- package/src/__tests__/manifest-discoverability.test.ts +0 -97
- package/src/__tests__/node-kind-reducer.test.ts +0 -135
- package/src/__tests__/plugin-action-handler.test.ts +0 -54
- package/src/__tests__/reducer-parity.test.ts +0 -106
- package/src/__tests__/render-actions.test.ts +0 -63
- package/src/__tests__/session-flow-actions-edit.test.tsx +0 -98
- package/src/bridge/AGENTS.md +0 -8
- package/src/client/AGENTS.md +0 -32
- package/src/server/AGENTS.md +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blackbelt-technology/pi-dashboard-flows-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Flow rendering plugin for pi-dashboard — pi-flows event reaction (FlowDashboard, FlowAgentCard, FlowArchitect, etc.)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -27,7 +27,12 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
|
-
"src/"
|
|
30
|
+
"src/",
|
|
31
|
+
"!**/AGENTS.md",
|
|
32
|
+
"!**/*.AGENTS.md",
|
|
33
|
+
"!**/__tests__",
|
|
34
|
+
"!**/*.test.ts",
|
|
35
|
+
"!**/*.test.tsx"
|
|
31
36
|
],
|
|
32
37
|
"pi-dashboard-plugin": {
|
|
33
38
|
"id": "flows",
|
|
@@ -79,19 +84,25 @@
|
|
|
79
84
|
},
|
|
80
85
|
"peerDependencies": {
|
|
81
86
|
"react": ">=18.0.0",
|
|
82
|
-
"react-dom": ">=18.0.0"
|
|
87
|
+
"react-dom": ">=18.0.0",
|
|
88
|
+
"wouter": ">=3.0.0"
|
|
83
89
|
},
|
|
84
90
|
"//deps-rationale": "client-utils retained for hooks (useMobile, useZoomPan) and Phase-2 extension-ui slot consumers (AgentMetricSlot, BreadcrumbSlot, GateSlot, aggregateGateState helper). All UI primitive components (AgentCardShell, MarkdownContent, ConfirmDialog, DialogPortal, SearchableSelectDialog, ZoomControls, format-tokens, format-duration) flow through the UI primitive registry per add-plugin-ui-primitive-registry.",
|
|
85
91
|
"dependencies": {
|
|
86
|
-
"@blackbelt-technology/dashboard-plugin-runtime": "^0.
|
|
87
|
-
"@blackbelt-technology/pi-dashboard-client-utils": "^0.
|
|
88
|
-
"@blackbelt-technology/pi-dashboard-shared": "^0.
|
|
92
|
+
"@blackbelt-technology/dashboard-plugin-runtime": "^0.9.0",
|
|
93
|
+
"@blackbelt-technology/pi-dashboard-client-utils": "^0.9.0",
|
|
94
|
+
"@blackbelt-technology/pi-dashboard-shared": "^0.9.0",
|
|
95
|
+
"@fastify/rate-limit": "^11.2.0",
|
|
96
|
+
"@mdi/js": "^7.4.47",
|
|
97
|
+
"@mdi/react": "^1.6.1",
|
|
98
|
+
"dagre-d3-es": "^7.0.14",
|
|
89
99
|
"yaml": "^2.9.0"
|
|
90
100
|
},
|
|
91
101
|
"devDependencies": {
|
|
92
102
|
"@types/react": "^19.0.0",
|
|
93
103
|
"@types/react-dom": "^19.0.0",
|
|
94
104
|
"react": "^19.0.0",
|
|
95
|
-
"react-dom": "^19.0.0"
|
|
105
|
+
"react-dom": "^19.0.0",
|
|
106
|
+
"wouter": "^3.9.0"
|
|
96
107
|
}
|
|
97
108
|
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reports the files this session's pi-flows engine uses — flow sources from
|
|
3
|
+
* `flow:list-flows`, agent sources from `flow:get-agents` — to the flows-plugin
|
|
4
|
+
* server over the private plugin request lane (`requestPluginServer`), so the
|
|
5
|
+
* UI can open YAML / agent / handler files in runtime-registered flow dirs.
|
|
6
|
+
*
|
|
7
|
+
* Triggers (debounced): `session_start`, `flow:(un)register-(flows|agents)-dir`,
|
|
8
|
+
* `flow:rediscover`, and the server's `dashboard-flows:report-files` ask (sent
|
|
9
|
+
* when it has no report, e.g. after a dashboard restart). Retries while the
|
|
10
|
+
* dashboard lane is unavailable. Best-effort: never throws into pi.
|
|
11
|
+
* See change: attach-flow-before-run.
|
|
12
|
+
*/
|
|
13
|
+
import { requestPluginServer } from "@blackbelt-technology/dashboard-plugin-runtime/bridge";
|
|
14
|
+
import { FLOW_FILES_REPORT, FLOW_FILES_REQUEST_EVENT, type FlowFilesReport, type ReportedFile } from "../flow-files-contract.js";
|
|
15
|
+
|
|
16
|
+
interface PiEvents {
|
|
17
|
+
on(name: string, fn: (data: unknown) => void): unknown;
|
|
18
|
+
emit(name: string, data: unknown): unknown;
|
|
19
|
+
}
|
|
20
|
+
interface PiLike {
|
|
21
|
+
events?: PiEvents;
|
|
22
|
+
on?: (name: string, fn: () => void) => unknown;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const TRIGGERS = [
|
|
26
|
+
"flow:register-flows-dir",
|
|
27
|
+
"flow:register-agents-dir",
|
|
28
|
+
"flow:unregister-flows-dir",
|
|
29
|
+
"flow:unregister-agents-dir",
|
|
30
|
+
"flow:rediscover",
|
|
31
|
+
FLOW_FILES_REQUEST_EVENT,
|
|
32
|
+
];
|
|
33
|
+
const DEBOUNCE_MS = 300;
|
|
34
|
+
const RETRY_MS = 2_000;
|
|
35
|
+
const MAX_RETRIES = 5;
|
|
36
|
+
|
|
37
|
+
function toFile(name: unknown, source: unknown): ReportedFile | null {
|
|
38
|
+
return typeof name === "string" && typeof source === "string" && source ? { name, source } : null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Synchronously probe pi-flows for its flow + agent sources. */
|
|
42
|
+
export function collectFlowFiles(events: PiEvents): FlowFilesReport {
|
|
43
|
+
const flows: ReportedFile[] = [];
|
|
44
|
+
const agents: ReportedFile[] = [];
|
|
45
|
+
try {
|
|
46
|
+
const probe: { flows?: unknown } = {};
|
|
47
|
+
events.emit("flow:list-flows", probe);
|
|
48
|
+
if (Array.isArray(probe.flows)) {
|
|
49
|
+
for (const f of probe.flows) {
|
|
50
|
+
const r = toFile((f as ReportedFile)?.name, (f as ReportedFile)?.source);
|
|
51
|
+
if (r) flows.push(r);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} catch {
|
|
55
|
+
/* pi-flows absent */
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const probe: { agents?: unknown } = {};
|
|
59
|
+
events.emit("flow:get-agents", probe);
|
|
60
|
+
const entries: Iterable<[unknown, unknown]> =
|
|
61
|
+
probe.agents instanceof Map
|
|
62
|
+
? probe.agents.entries()
|
|
63
|
+
: probe.agents && typeof probe.agents === "object"
|
|
64
|
+
? Object.entries(probe.agents)
|
|
65
|
+
: [];
|
|
66
|
+
for (const [key, cfg] of entries) {
|
|
67
|
+
const c = cfg as { name?: unknown; source?: unknown } | null;
|
|
68
|
+
const r = toFile(typeof c?.name === "string" ? c.name : key, c?.source);
|
|
69
|
+
if (r) agents.push(r);
|
|
70
|
+
}
|
|
71
|
+
} catch {
|
|
72
|
+
/* pi-flows absent */
|
|
73
|
+
}
|
|
74
|
+
return { flows, agents };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function startFlowFilesReporter(pi: PiLike): void {
|
|
78
|
+
const events = pi.events;
|
|
79
|
+
if (!events || typeof events.emit !== "function" || typeof events.on !== "function") return;
|
|
80
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
81
|
+
let retries = 0;
|
|
82
|
+
|
|
83
|
+
const send = async () => {
|
|
84
|
+
timer = undefined;
|
|
85
|
+
const reply = await requestPluginServer("flows", FLOW_FILES_REPORT, collectFlowFiles(events));
|
|
86
|
+
if (reply.ok) {
|
|
87
|
+
retries = 0;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if ((reply.error === "unavailable" || reply.error === "disconnected" || reply.error === "timeout") && retries < MAX_RETRIES) {
|
|
91
|
+
retries++;
|
|
92
|
+
timer = setTimeout(() => void send(), RETRY_MS);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const schedule = () => {
|
|
96
|
+
if (timer) clearTimeout(timer);
|
|
97
|
+
retries = 0;
|
|
98
|
+
timer = setTimeout(() => void send(), DEBOUNCE_MS);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
for (const name of TRIGGERS) {
|
|
102
|
+
try {
|
|
103
|
+
events.on(name, schedule);
|
|
104
|
+
} catch {
|
|
105
|
+
/* noop */
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
pi.on?.("session_start", schedule);
|
|
110
|
+
} catch {
|
|
111
|
+
/* noop */
|
|
112
|
+
}
|
|
113
|
+
}
|
package/src/bridge/index.ts
CHANGED
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
* therefore claims flow-tagged prompts before `DashboardDefaultAdapter`
|
|
16
16
|
* (priority 9999).
|
|
17
17
|
*
|
|
18
|
-
*
|
|
18
|
+
* Also starts the flow-files reporter (see `flow-files-reporter.ts`).
|
|
19
19
|
*
|
|
20
20
|
* See change: route-flow-asks-to-upper-slot.
|
|
21
21
|
*/
|
|
22
|
+
import { startFlowFilesReporter } from "./flow-files-reporter.js";
|
|
22
23
|
import { FlowQuestionAdapter } from "./flow-question-adapter.js";
|
|
23
24
|
|
|
24
25
|
export default function activate(ctx: unknown): void {
|
|
@@ -27,4 +28,7 @@ export default function activate(ctx: unknown): void {
|
|
|
27
28
|
const events = (pi as { events?: { emit: (name: string, payload: unknown) => void } })?.events;
|
|
28
29
|
if (!events || typeof events.emit !== "function") return;
|
|
29
30
|
events.emit("prompt:register-adapter", new FlowQuestionAdapter());
|
|
31
|
+
// Report this session's flow / agent / handler files to the plugin server so
|
|
32
|
+
// the UI can open them. See change: attach-flow-before-run.
|
|
33
|
+
startFlowFilesReporter(pi as Parameters<typeof startFlowFilesReporter>[0]);
|
|
30
34
|
}
|
|
@@ -6,34 +6,17 @@ import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/das
|
|
|
6
6
|
import type { DashboardSession, FlowAgentState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
7
7
|
import { mdiCallSplit, mdiCodeBraces, mdiCodeTags, mdiEyeOffOutline, mdiEyeOutline, mdiFileDocumentOutline, mdiRefresh, mdiSourceBranch } from "@mdi/js";
|
|
8
8
|
import { Icon } from "@mdi/react";
|
|
9
|
-
import React, {
|
|
9
|
+
import React, { useState } from "react";
|
|
10
10
|
import { FlowAgentDetail } from "./FlowAgentDetail.js";
|
|
11
|
+
import { useOpenFileInEditor } from "./flow-files.js";
|
|
12
|
+
import { formatCost } from "./format-cost.js";
|
|
11
13
|
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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)}`;
|
|
14
|
+
/** Last path segment — the card's basename line. Mirrors the editor-pane copies. */
|
|
15
|
+
function basenameOf(p: string): string {
|
|
16
|
+
const parts = p.split("/");
|
|
17
|
+
return parts[parts.length - 1] || p;
|
|
29
18
|
}
|
|
30
19
|
|
|
31
|
-
type AgentSourceState =
|
|
32
|
-
| { kind: "idle" }
|
|
33
|
-
| { kind: "loading" }
|
|
34
|
-
| { kind: "loaded"; content: string }
|
|
35
|
-
| { kind: "error"; error: string };
|
|
36
|
-
|
|
37
20
|
export function FlowAgentCard({
|
|
38
21
|
agent,
|
|
39
22
|
selected,
|
|
@@ -54,96 +37,20 @@ export function FlowAgentCard({
|
|
|
54
37
|
const t = useT();
|
|
55
38
|
const AgentCardShell = useUiPrimitive(UI_PRIMITIVE_KEYS.agentCard);
|
|
56
39
|
// Soft lookup: production registers `logBlock` (main.tsx); when absent the
|
|
57
|
-
// code-node preview falls back to the
|
|
40
|
+
// code-node preview falls back to the reserved two-line body slot.
|
|
58
41
|
const LogBlock = useUiPrimitiveOrNull(UI_PRIMITIVE_KEYS.logBlock);
|
|
59
42
|
const formatTokens = useUiPrimitive(UI_PRIMITIVE_KEYS.formatTokens);
|
|
60
43
|
const formatDuration = useUiPrimitive(UI_PRIMITIVE_KEYS.formatDuration);
|
|
61
44
|
const Dialog = useUiPrimitive(UI_PRIMITIVE_KEYS.dialog);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
const [sourceState, setSourceState] = useState<AgentSourceState>({ kind: "idle" });
|
|
66
|
-
|
|
67
|
-
// Code-handler source popover state. Mirrors the agent-source pair above but
|
|
68
|
-
// keyed on `codeTarget` (the resolved .ts handler path for code /
|
|
69
|
-
// code-decision nodes). The fetched .ts is rendered as a fenced ```ts block
|
|
70
|
-
// so the markdown primitive syntax-highlights it instead of mangling it.
|
|
71
|
-
// See change: open-code-handler-from-flow-card.
|
|
72
|
-
const [codeSourceOpen, setCodeSourceOpen] = useState(false);
|
|
73
|
-
const [codeSourceState, setCodeSourceState] = useState<AgentSourceState>({ kind: "idle" });
|
|
45
|
+
// File buttons open the file in the host editor (Split view).
|
|
46
|
+
// See change: attach-flow-before-run.
|
|
47
|
+
const openInEditor = useOpenFileInEditor(sessionId);
|
|
74
48
|
|
|
75
49
|
// Eye-button detail state: opens the FlowAgentDetail run-history view in a
|
|
76
50
|
// ui:dialog (replaces the prior anchored popover). See change:
|
|
77
51
|
// improve-flow-graph-dialog-and-card-interaction.
|
|
78
52
|
const [detailOpen, setDetailOpen] = useState(false);
|
|
79
53
|
|
|
80
|
-
// Fetch the agent's .md when the popover opens. Mirrors the pattern of
|
|
81
|
-
// `usePiResourceFileFetch` in the dashboard client: deps include only
|
|
82
|
-
// open + path. Including state in deps causes the cleanup to fire on
|
|
83
|
-
// the idle→loading transition and self-cancel the fetch.
|
|
84
|
-
// See change: add-ui-popover-primitive.
|
|
85
|
-
useEffect(() => {
|
|
86
|
-
if (!sourceOpen) return;
|
|
87
|
-
if (!agent.sourcePath) {
|
|
88
|
-
setSourceState({ kind: "error", error: "No source path recorded for this agent." });
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
let cancelled = false;
|
|
92
|
-
setSourceState({ kind: "loading" });
|
|
93
|
-
fetch(`/api/pi-resource-file?path=${encodeURIComponent(agent.sourcePath)}`)
|
|
94
|
-
.then(async (r) => {
|
|
95
|
-
const json = await r.json();
|
|
96
|
-
if (cancelled) return;
|
|
97
|
-
if (json?.success && typeof json?.data?.content === "string") {
|
|
98
|
-
setSourceState({ kind: "loaded", content: json.data.content });
|
|
99
|
-
} else {
|
|
100
|
-
setSourceState({
|
|
101
|
-
kind: "error",
|
|
102
|
-
error: typeof json?.error === "string" ? json.error : "Failed to read source",
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
})
|
|
106
|
-
.catch((err) => {
|
|
107
|
-
if (!cancelled) setSourceState({ kind: "error", error: String(err) });
|
|
108
|
-
});
|
|
109
|
-
return () => {
|
|
110
|
-
cancelled = true;
|
|
111
|
-
};
|
|
112
|
-
}, [sourceOpen, agent.sourcePath]);
|
|
113
|
-
|
|
114
|
-
// Fetch the code node's handler .ts when its popover opens. `codeTarget` is
|
|
115
|
-
// emitted absolute by the upstream flow runtime, so it is passed verbatim to
|
|
116
|
-
// the resource-file endpoint (allow-list accepts `<cwd>/.pi/...`).
|
|
117
|
-
// See change: open-code-handler-from-flow-card.
|
|
118
|
-
useEffect(() => {
|
|
119
|
-
if (!codeSourceOpen) return;
|
|
120
|
-
if (!agent.codeTarget) {
|
|
121
|
-
setCodeSourceState({ kind: "error", error: "No handler target recorded for this node." });
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
let cancelled = false;
|
|
125
|
-
setCodeSourceState({ kind: "loading" });
|
|
126
|
-
fetch(`/api/pi-resource-file?path=${encodeURIComponent(agent.codeTarget)}`)
|
|
127
|
-
.then(async (r) => {
|
|
128
|
-
const json = await r.json();
|
|
129
|
-
if (cancelled) return;
|
|
130
|
-
if (json?.success && typeof json?.data?.content === "string") {
|
|
131
|
-
setCodeSourceState({ kind: "loaded", content: json.data.content });
|
|
132
|
-
} else {
|
|
133
|
-
setCodeSourceState({
|
|
134
|
-
kind: "error",
|
|
135
|
-
error: typeof json?.error === "string" ? json.error : "Failed to read handler",
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
.catch((err) => {
|
|
140
|
-
if (!cancelled) setCodeSourceState({ kind: "error", error: String(err) });
|
|
141
|
-
});
|
|
142
|
-
return () => {
|
|
143
|
-
cancelled = true;
|
|
144
|
-
};
|
|
145
|
-
}, [codeSourceOpen, agent.codeTarget]);
|
|
146
|
-
|
|
147
54
|
const displayName = agent.label || agent.stepId || agent.agentName;
|
|
148
55
|
const displayRole = agent.cardRole || agent.model || "";
|
|
149
56
|
const isComplete = agent.status === "complete" || agent.status === "error" || agent.status === "blocked";
|
|
@@ -185,7 +92,16 @@ export function FlowAgentCard({
|
|
|
185
92
|
</span>
|
|
186
93
|
) : kindBadge;
|
|
187
94
|
|
|
188
|
-
|
|
95
|
+
// The stats line is the single carrier for secondary values (D7): a pending
|
|
96
|
+
// blocked card shows `waiting: <deps>` there, else the complete/model/role
|
|
97
|
+
// chain with cost preserved between tokens and duration.
|
|
98
|
+
const waiting =
|
|
99
|
+
agent.status === "pending" && agent.blockedBy.length > 0
|
|
100
|
+
? `waiting: ${agent.blockedBy.join(", ")}`
|
|
101
|
+
: null;
|
|
102
|
+
const stats = waiting ? (
|
|
103
|
+
<span>{waiting}</span>
|
|
104
|
+
) : isComplete && agent.tokens ? (
|
|
189
105
|
<span>↑{formatTokens(agent.tokens.input)} ↓{formatTokens(agent.tokens.output)}{agent.cost != null && agent.cost > 0 ? ` · ${formatCost(agent.cost)}` : ""} · {formatDuration(agent.duration ?? 0)}</span>
|
|
190
106
|
) : displayModel ? (
|
|
191
107
|
<span>{displayModel}</span>
|
|
@@ -193,8 +109,22 @@ export function FlowAgentCard({
|
|
|
193
109
|
<span>{displayRole}</span>
|
|
194
110
|
) : null;
|
|
195
111
|
|
|
112
|
+
// One monospace basename line: handler target → agent .md source → @alias.
|
|
113
|
+
// The full path/alias is the line's tooltip (D4).
|
|
114
|
+
const basenameLine =
|
|
115
|
+
isCodeKind && agent.codeTarget
|
|
116
|
+
? { text: basenameOf(agent.codeTarget), title: agent.codeTarget }
|
|
117
|
+
: agent.sourcePath
|
|
118
|
+
? { text: basenameOf(agent.sourcePath), title: agent.sourcePath }
|
|
119
|
+
: hasAlias
|
|
120
|
+
? { text: rawModel, title: rawModel }
|
|
121
|
+
: null;
|
|
122
|
+
|
|
123
|
+
// Display-only truncation to the LAST 2 tool calls, newest first (D3).
|
|
124
|
+
const recentTools = agent.recentTools.slice(-2).reverse();
|
|
125
|
+
|
|
196
126
|
return (
|
|
197
|
-
<div data-step={stepId}>
|
|
127
|
+
<div data-step={stepId} className="h-full [&>*]:h-full">
|
|
198
128
|
<AgentCardShell
|
|
199
129
|
name={displayName}
|
|
200
130
|
status={agent.status}
|
|
@@ -204,58 +134,56 @@ export function FlowAgentCard({
|
|
|
204
134
|
onClick={onSelect ? () => onSelect(stepId) : undefined}
|
|
205
135
|
>
|
|
206
136
|
<div className="flex flex-col flex-1">
|
|
207
|
-
{/*
|
|
208
|
-
{
|
|
209
|
-
<div
|
|
137
|
+
{/* One monospace basename line; the full path/alias is the tooltip. */}
|
|
138
|
+
{basenameLine && (
|
|
139
|
+
<div
|
|
140
|
+
data-testid="flow-card-basename"
|
|
141
|
+
className="text-[10px] leading-[15px] text-[var(--text-tertiary)] font-mono truncate @max-[480px]:hidden"
|
|
142
|
+
title={basenameLine.title}
|
|
143
|
+
>
|
|
144
|
+
{basenameLine.text}
|
|
145
|
+
</div>
|
|
210
146
|
)}
|
|
211
147
|
|
|
212
|
-
{/* Metric / waiting line */}
|
|
213
|
-
<div className="text-[11px] text-[var(--text-muted)] mt-0.5 truncate">
|
|
214
|
-
{agent.status === "pending" && agent.blockedBy.length > 0 ? (
|
|
215
|
-
<span>waiting: {agent.blockedBy.join(", ")}</span>
|
|
216
|
-
) : null}
|
|
217
|
-
</div>
|
|
218
|
-
|
|
219
148
|
{/* Phase-2 agent-metric decorator slot. See change: add-extension-ui-decorations. */}
|
|
220
149
|
<AgentMetricSlot session={session} agentId={agent.agentName} />
|
|
221
150
|
|
|
222
|
-
{/* Body: code nodes show
|
|
223
|
-
|
|
151
|
+
{/* Body: code nodes with logs show the LogBlock preview (it defines the
|
|
152
|
+
height and the row grows with it); agent nodes and logless code
|
|
153
|
+
nodes reserve two lines via an explicit line box, never pad rows. */}
|
|
224
154
|
{isCodeKind ? (
|
|
225
155
|
logLines.length > 0 && LogBlock ? (
|
|
226
|
-
<div className="mt-1">
|
|
156
|
+
<div data-testid="flow-card-body" className="mt-1 @max-[480px]:hidden">
|
|
227
157
|
<LogBlock
|
|
228
158
|
label={t("programLog", undefined, "Program log")}
|
|
229
159
|
text={logLines.join("\n")}
|
|
230
160
|
preview
|
|
231
|
-
previewLines={
|
|
161
|
+
previewLines={2}
|
|
232
162
|
/>
|
|
233
163
|
</div>
|
|
234
164
|
) : (
|
|
235
|
-
<div
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
</div>
|
|
165
|
+
<div
|
|
166
|
+
data-testid="flow-card-body"
|
|
167
|
+
className="mt-1 text-[10px] leading-[15px] min-h-[30px] text-[var(--text-tertiary)] @max-[480px]:hidden"
|
|
168
|
+
/>
|
|
240
169
|
)
|
|
241
170
|
) : (
|
|
242
|
-
<div
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
171
|
+
<div
|
|
172
|
+
data-testid="flow-card-body"
|
|
173
|
+
className="mt-1 text-[10px] leading-[15px] min-h-[30px] text-[var(--text-tertiary)] @max-[480px]:hidden"
|
|
174
|
+
>
|
|
175
|
+
{recentTools.map((tool, i) => (
|
|
176
|
+
<div key={i} className="truncate">
|
|
177
|
+
{i === 0 ? "▸" : "·"} {tool.toolName} {tool.inputPreview}
|
|
246
178
|
</div>
|
|
247
179
|
))}
|
|
248
|
-
{/* Pad to 3 lines for consistent height */}
|
|
249
|
-
{Array.from({ length: Math.max(0, 3 - agent.recentTools.length) }).map((_, i) => (
|
|
250
|
-
<div key={`pad-${i}`} className="text-[10px]"> </div>
|
|
251
|
-
))}
|
|
252
180
|
</div>
|
|
253
181
|
)}
|
|
254
182
|
|
|
255
183
|
{/* Chosen branch (code-decision / agent-decision) */}
|
|
256
184
|
{agent.branch && (
|
|
257
185
|
<div className="mt-1 text-[10px] font-mono">
|
|
258
|
-
<span className="text-[var(--text-
|
|
186
|
+
<span className="text-[var(--text-tertiary)]">branch </span>
|
|
259
187
|
<span className="text-cyan-400 font-semibold">{agent.branch}</span>
|
|
260
188
|
</div>
|
|
261
189
|
)}
|
|
@@ -279,91 +207,29 @@ export function FlowAgentCard({
|
|
|
279
207
|
<div className="mt-1 text-[10px] text-red-400">✕ hard-failed — halted flow</div>
|
|
280
208
|
)}
|
|
281
209
|
|
|
282
|
-
{/* Resolved handler target for code nodes */}
|
|
283
|
-
{isCodeKind && agent.codeTarget && (
|
|
284
|
-
<div className="mt-1 text-[10px] text-[var(--text-muted)] font-mono truncate" title={agent.codeTarget}>‹› {agent.codeTarget}</div>
|
|
285
|
-
)}
|
|
286
|
-
|
|
287
210
|
{/* View source / detail icons — bottom-right of card */}
|
|
288
211
|
<div className="flex justify-end mt-auto pt-1 gap-1">
|
|
289
|
-
{isCodeKind && agent.codeTarget && (
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}`}
|
|
298
|
-
title={codeSourceOpen ? "Close handler source" : "View handler source"}
|
|
299
|
-
>
|
|
300
|
-
<Icon path={mdiCodeBraces} size={0.45} />
|
|
301
|
-
</button>
|
|
302
|
-
<Dialog
|
|
303
|
-
open={codeSourceOpen}
|
|
304
|
-
onClose={() => setCodeSourceOpen(false)}
|
|
305
|
-
title={agent.codeTarget.split("/").pop() || "Handler"}
|
|
306
|
-
size="lg"
|
|
307
|
-
>
|
|
308
|
-
<div className="text-[11px] text-[var(--text-tertiary)] font-mono break-all" title={agent.codeTarget}>
|
|
309
|
-
{agent.codeTarget}
|
|
310
|
-
</div>
|
|
311
|
-
<div className="h-[60vh] overflow-y-auto">
|
|
312
|
-
{codeSourceState.kind === "loading" && (
|
|
313
|
-
<div className="text-xs text-[var(--text-muted)]">Loading…</div>
|
|
314
|
-
)}
|
|
315
|
-
{codeSourceState.kind === "error" && (
|
|
316
|
-
<div className="text-xs text-red-400">⚠ {codeSourceState.error}</div>
|
|
317
|
-
)}
|
|
318
|
-
{codeSourceState.kind === "loaded" && (
|
|
319
|
-
<MarkdownContent content={"```ts\n" + codeSourceState.content + "\n```"} />
|
|
320
|
-
)}
|
|
321
|
-
</div>
|
|
322
|
-
</Dialog>
|
|
323
|
-
</>
|
|
212
|
+
{openInEditor && isCodeKind && agent.codeTarget && (
|
|
213
|
+
<button
|
|
214
|
+
onClick={(e) => { e.stopPropagation(); openInEditor(agent.codeTarget as string); }}
|
|
215
|
+
className="transition-colors h-6 w-6 rounded inline-flex items-center justify-center text-[var(--text-tertiary)] hover:text-cyan-400 hover:bg-[var(--bg-surface)]"
|
|
216
|
+
title={t("openHandlerInEditor", undefined, "Open handler in editor")}
|
|
217
|
+
>
|
|
218
|
+
<Icon path={mdiCodeBraces} size={0.45} />
|
|
219
|
+
</button>
|
|
324
220
|
)}
|
|
325
|
-
{agent.sourcePath && (
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}`}
|
|
334
|
-
title={sourceOpen ? `Close ${displayName} source` : `View ${displayName} source`}
|
|
335
|
-
>
|
|
336
|
-
<Icon path={mdiFileDocumentOutline} size={0.45} />
|
|
337
|
-
</button>
|
|
338
|
-
<Dialog
|
|
339
|
-
open={sourceOpen}
|
|
340
|
-
onClose={() => setSourceOpen(false)}
|
|
341
|
-
title={agent.sourcePath.split("/").pop() || "Source"}
|
|
342
|
-
size="lg"
|
|
343
|
-
>
|
|
344
|
-
{/* Pinned path header; body scrolls inside a fixed-height
|
|
345
|
-
region so the dialog stays a fixed size. See change:
|
|
346
|
-
improve-flow-graph-dialog-and-card-interaction. */}
|
|
347
|
-
<div className="text-[11px] text-[var(--text-tertiary)] font-mono break-all" title={agent.sourcePath}>
|
|
348
|
-
{agent.sourcePath}
|
|
349
|
-
</div>
|
|
350
|
-
<div className="h-[60vh] overflow-y-auto">
|
|
351
|
-
{sourceState.kind === "loading" && (
|
|
352
|
-
<div className="text-xs text-[var(--text-muted)]">Loading…</div>
|
|
353
|
-
)}
|
|
354
|
-
{sourceState.kind === "error" && (
|
|
355
|
-
<div className="text-xs text-red-400">⚠ {sourceState.error}</div>
|
|
356
|
-
)}
|
|
357
|
-
{sourceState.kind === "loaded" && (
|
|
358
|
-
<MarkdownContent content={sourceState.content} />
|
|
359
|
-
)}
|
|
360
|
-
</div>
|
|
361
|
-
</Dialog>
|
|
362
|
-
</>
|
|
221
|
+
{openInEditor && agent.sourcePath && (
|
|
222
|
+
<button
|
|
223
|
+
onClick={(e) => { e.stopPropagation(); openInEditor(agent.sourcePath as string); }}
|
|
224
|
+
className="transition-colors h-6 w-6 rounded inline-flex items-center justify-center text-[var(--text-tertiary)] hover:text-blue-400 hover:bg-[var(--bg-surface)]"
|
|
225
|
+
title={t("openSourceInEditor", { name: displayName }, `Open ${displayName} source in editor`)}
|
|
226
|
+
>
|
|
227
|
+
<Icon path={mdiFileDocumentOutline} size={0.45} />
|
|
228
|
+
</button>
|
|
363
229
|
)}
|
|
364
230
|
<button
|
|
365
231
|
onClick={(e) => { e.stopPropagation(); setDetailOpen((prev) => !prev); }}
|
|
366
|
-
className={`transition-colors px-1.5 py-0.5 rounded text-[11px] inline-flex items-center gap-1 border ${
|
|
232
|
+
className={`transition-colors min-h-6 px-1.5 py-0.5 rounded text-[11px] inline-flex items-center gap-1 border ${
|
|
367
233
|
detailOpen
|
|
368
234
|
? "text-blue-400 bg-blue-400/10 border-blue-400/40"
|
|
369
235
|
: "border-[var(--border-subtle)] text-[var(--text-tertiary)] hover:text-blue-400 hover:border-blue-400/40 hover:bg-blue-400/10"
|
|
@@ -388,6 +254,9 @@ export function FlowAgentCard({
|
|
|
388
254
|
size="lg"
|
|
389
255
|
flush
|
|
390
256
|
>
|
|
257
|
+
{/* STAYS: a DEFINITE height pin, not a duplicated flex context —
|
|
258
|
+
the popout keeps a stable height as the transcript grows.
|
|
259
|
+
See change: fix-flush-dialog-scroll-and-close-collision. */}
|
|
391
260
|
<div className="h-[70vh] overflow-hidden flex flex-col">
|
|
392
261
|
<FlowAgentDetail
|
|
393
262
|
agent={agent}
|
|
@@ -21,7 +21,7 @@ import type {
|
|
|
21
21
|
FlowDetailEntry,
|
|
22
22
|
} from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
23
23
|
import React from "react";
|
|
24
|
-
import { formatCost } from "./
|
|
24
|
+
import { formatCost } from "./format-cost.js";
|
|
25
25
|
|
|
26
26
|
function mapFlowStatus(status: FlowAgentStatus): MinimalChatStatus {
|
|
27
27
|
switch (status) {
|