@blackbelt-technology/pi-dashboard-flows-plugin 0.8.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blackbelt-technology/pi-dashboard-flows-plugin",
3
- "version": "0.8.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": {
@@ -84,13 +84,15 @@
84
84
  },
85
85
  "peerDependencies": {
86
86
  "react": ">=18.0.0",
87
- "react-dom": ">=18.0.0"
87
+ "react-dom": ">=18.0.0",
88
+ "wouter": ">=3.0.0"
88
89
  },
89
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.",
90
91
  "dependencies": {
91
- "@blackbelt-technology/dashboard-plugin-runtime": "^0.8.0",
92
- "@blackbelt-technology/pi-dashboard-client-utils": "^0.8.0",
93
- "@blackbelt-technology/pi-dashboard-shared": "^0.8.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",
94
96
  "@mdi/js": "^7.4.47",
95
97
  "@mdi/react": "^1.6.1",
96
98
  "dagre-d3-es": "^7.0.14",
@@ -100,6 +102,7 @@
100
102
  "@types/react": "^19.0.0",
101
103
  "@types/react-dom": "^19.0.0",
102
104
  "react": "^19.0.0",
103
- "react-dom": "^19.0.0"
105
+ "react-dom": "^19.0.0",
106
+ "wouter": "^3.9.0"
104
107
  }
105
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
+ }
@@ -15,10 +15,11 @@
15
15
  * therefore claims flow-tagged prompts before `DashboardDefaultAdapter`
16
16
  * (priority 9999).
17
17
  *
18
- * No other behavior here — this entry is intentionally narrow.
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,26 +6,16 @@ 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, { useEffect, useState } from "react";
9
+ import React, { useState } from "react";
10
10
  import { FlowAgentDetail } from "./FlowAgentDetail.js";
11
+ import { useOpenFileInEditor } from "./flow-files.js";
11
12
  import { formatCost } from "./format-cost.js";
12
13
 
13
- /**
14
- * State of the agent-source fetch for the document-icon popover.
15
- *
16
- * Self-contained inside FlowAgentCard: when the user clicks the doc icon,
17
- * we open a popover anchored to that button and fetch the agent's .md
18
- * via `GET /api/pi-resource-file?path=<sourcePath>`. The bytes are then
19
- * rendered with the `ui:markdown-content` primitive.
20
- *
21
- * See change: add-ui-popover-primitive.
22
- */
23
-
24
- type AgentSourceState =
25
- | { kind: "idle" }
26
- | { kind: "loading" }
27
- | { kind: "loaded"; content: string }
28
- | { kind: "error"; error: string };
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;
18
+ }
29
19
 
30
20
  export function FlowAgentCard({
31
21
  agent,
@@ -47,96 +37,20 @@ export function FlowAgentCard({
47
37
  const t = useT();
48
38
  const AgentCardShell = useUiPrimitive(UI_PRIMITIVE_KEYS.agentCard);
49
39
  // Soft lookup: production registers `logBlock` (main.tsx); when absent the
50
- // code-node preview falls back to the padded placeholder below.
40
+ // code-node preview falls back to the reserved two-line body slot.
51
41
  const LogBlock = useUiPrimitiveOrNull(UI_PRIMITIVE_KEYS.logBlock);
52
42
  const formatTokens = useUiPrimitive(UI_PRIMITIVE_KEYS.formatTokens);
53
43
  const formatDuration = useUiPrimitive(UI_PRIMITIVE_KEYS.formatDuration);
54
44
  const Dialog = useUiPrimitive(UI_PRIMITIVE_KEYS.dialog);
55
- const MarkdownContent = useUiPrimitive(UI_PRIMITIVE_KEYS.markdownContent);
56
-
57
- const [sourceOpen, setSourceOpen] = useState(false);
58
- const [sourceState, setSourceState] = useState<AgentSourceState>({ kind: "idle" });
59
-
60
- // Code-handler source popover state. Mirrors the agent-source pair above but
61
- // keyed on `codeTarget` (the resolved .ts handler path for code /
62
- // code-decision nodes). The fetched .ts is rendered as a fenced ```ts block
63
- // so the markdown primitive syntax-highlights it instead of mangling it.
64
- // See change: open-code-handler-from-flow-card.
65
- const [codeSourceOpen, setCodeSourceOpen] = useState(false);
66
- 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);
67
48
 
68
49
  // Eye-button detail state: opens the FlowAgentDetail run-history view in a
69
50
  // ui:dialog (replaces the prior anchored popover). See change:
70
51
  // improve-flow-graph-dialog-and-card-interaction.
71
52
  const [detailOpen, setDetailOpen] = useState(false);
72
53
 
73
- // Fetch the agent's .md when the popover opens. Mirrors the pattern of
74
- // `usePiResourceFileFetch` in the dashboard client: deps include only
75
- // open + path. Including state in deps causes the cleanup to fire on
76
- // the idle→loading transition and self-cancel the fetch.
77
- // See change: add-ui-popover-primitive.
78
- useEffect(() => {
79
- if (!sourceOpen) return;
80
- if (!agent.sourcePath) {
81
- setSourceState({ kind: "error", error: "No source path recorded for this agent." });
82
- return;
83
- }
84
- let cancelled = false;
85
- setSourceState({ kind: "loading" });
86
- fetch(`/api/pi-resource-file?path=${encodeURIComponent(agent.sourcePath)}`)
87
- .then(async (r) => {
88
- const json = await r.json();
89
- if (cancelled) return;
90
- if (json?.success && typeof json?.data?.content === "string") {
91
- setSourceState({ kind: "loaded", content: json.data.content });
92
- } else {
93
- setSourceState({
94
- kind: "error",
95
- error: typeof json?.error === "string" ? json.error : "Failed to read source",
96
- });
97
- }
98
- })
99
- .catch((err) => {
100
- if (!cancelled) setSourceState({ kind: "error", error: String(err) });
101
- });
102
- return () => {
103
- cancelled = true;
104
- };
105
- }, [sourceOpen, agent.sourcePath]);
106
-
107
- // Fetch the code node's handler .ts when its popover opens. `codeTarget` is
108
- // emitted absolute by the upstream flow runtime, so it is passed verbatim to
109
- // the resource-file endpoint (allow-list accepts `<cwd>/.pi/...`).
110
- // See change: open-code-handler-from-flow-card.
111
- useEffect(() => {
112
- if (!codeSourceOpen) return;
113
- if (!agent.codeTarget) {
114
- setCodeSourceState({ kind: "error", error: "No handler target recorded for this node." });
115
- return;
116
- }
117
- let cancelled = false;
118
- setCodeSourceState({ kind: "loading" });
119
- fetch(`/api/pi-resource-file?path=${encodeURIComponent(agent.codeTarget)}`)
120
- .then(async (r) => {
121
- const json = await r.json();
122
- if (cancelled) return;
123
- if (json?.success && typeof json?.data?.content === "string") {
124
- setCodeSourceState({ kind: "loaded", content: json.data.content });
125
- } else {
126
- setCodeSourceState({
127
- kind: "error",
128
- error: typeof json?.error === "string" ? json.error : "Failed to read handler",
129
- });
130
- }
131
- })
132
- .catch((err) => {
133
- if (!cancelled) setCodeSourceState({ kind: "error", error: String(err) });
134
- });
135
- return () => {
136
- cancelled = true;
137
- };
138
- }, [codeSourceOpen, agent.codeTarget]);
139
-
140
54
  const displayName = agent.label || agent.stepId || agent.agentName;
141
55
  const displayRole = agent.cardRole || agent.model || "";
142
56
  const isComplete = agent.status === "complete" || agent.status === "error" || agent.status === "blocked";
@@ -178,7 +92,16 @@ export function FlowAgentCard({
178
92
  </span>
179
93
  ) : kindBadge;
180
94
 
181
- const stats = isComplete && agent.tokens ? (
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 ? (
182
105
  <span>↑{formatTokens(agent.tokens.input)} ↓{formatTokens(agent.tokens.output)}{agent.cost != null && agent.cost > 0 ? ` · ${formatCost(agent.cost)}` : ""} · {formatDuration(agent.duration ?? 0)}</span>
183
106
  ) : displayModel ? (
184
107
  <span>{displayModel}</span>
@@ -186,8 +109,22 @@ export function FlowAgentCard({
186
109
  <span>{displayRole}</span>
187
110
  ) : null;
188
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
+
189
126
  return (
190
- <div data-step={stepId}>
127
+ <div data-step={stepId} className="h-full [&>*]:h-full">
191
128
  <AgentCardShell
192
129
  name={displayName}
193
130
  status={agent.status}
@@ -197,58 +134,56 @@ export function FlowAgentCard({
197
134
  onClick={onSelect ? () => onSelect(stepId) : undefined}
198
135
  >
199
136
  <div className="flex flex-col flex-1">
200
- {/* Model alias line (when model uses @role alias) */}
201
- {hasAlias && (
202
- <div className="text-[10px] text-[var(--text-tertiary)] truncate">{rawModel}</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>
203
146
  )}
204
147
 
205
- {/* Metric / waiting line */}
206
- <div className="text-[11px] text-[var(--text-muted)] mt-0.5 truncate">
207
- {agent.status === "pending" && agent.blockedBy.length > 0 ? (
208
- <span>waiting: {agent.blockedBy.join(", ")}</span>
209
- ) : null}
210
- </div>
211
-
212
148
  {/* Phase-2 agent-metric decorator slot. See change: add-extension-ui-decorations. */}
213
149
  <AgentMetricSlot session={session} agentId={agent.agentName} />
214
150
 
215
- {/* Body: code nodes show a Log preview (program logs); agent nodes
216
- show their recent tool calls. */}
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. */}
217
154
  {isCodeKind ? (
218
155
  logLines.length > 0 && LogBlock ? (
219
- <div className="mt-1">
156
+ <div data-testid="flow-card-body" className="mt-1 @max-[480px]:hidden">
220
157
  <LogBlock
221
158
  label={t("programLog", undefined, "Program log")}
222
159
  text={logLines.join("\n")}
223
160
  preview
224
- previewLines={3}
161
+ previewLines={2}
225
162
  />
226
163
  </div>
227
164
  ) : (
228
- <div className="mt-1 space-y-0">
229
- {Array.from({ length: 3 }).map((_, i) => (
230
- <div key={`pad-${i}`} className="text-[10px]">&nbsp;</div>
231
- ))}
232
- </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
+ />
233
169
  )
234
170
  ) : (
235
- <div className="mt-1 space-y-0">
236
- {agent.recentTools.map((tool, i) => (
237
- <div key={i} className="text-[10px] text-[var(--text-tertiary)] truncate">
238
- {i === agent.recentTools.length - 1 ? "▸" : "·"} {tool.toolName} {tool.inputPreview}
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}
239
178
  </div>
240
179
  ))}
241
- {/* Pad to 3 lines for consistent height */}
242
- {Array.from({ length: Math.max(0, 3 - agent.recentTools.length) }).map((_, i) => (
243
- <div key={`pad-${i}`} className="text-[10px]">&nbsp;</div>
244
- ))}
245
180
  </div>
246
181
  )}
247
182
 
248
183
  {/* Chosen branch (code-decision / agent-decision) */}
249
184
  {agent.branch && (
250
185
  <div className="mt-1 text-[10px] font-mono">
251
- <span className="text-[var(--text-muted)]">branch </span>
186
+ <span className="text-[var(--text-tertiary)]">branch </span>
252
187
  <span className="text-cyan-400 font-semibold">{agent.branch}</span>
253
188
  </div>
254
189
  )}
@@ -272,91 +207,29 @@ export function FlowAgentCard({
272
207
  <div className="mt-1 text-[10px] text-red-400">✕ hard-failed — halted flow</div>
273
208
  )}
274
209
 
275
- {/* Resolved handler target for code nodes */}
276
- {isCodeKind && agent.codeTarget && (
277
- <div className="mt-1 text-[10px] text-[var(--text-muted)] font-mono truncate" title={agent.codeTarget}>‹› {agent.codeTarget}</div>
278
- )}
279
-
280
210
  {/* View source / detail icons — bottom-right of card */}
281
211
  <div className="flex justify-end mt-auto pt-1 gap-1">
282
- {isCodeKind && agent.codeTarget && (
283
- <>
284
- <button
285
- onClick={(e) => { e.stopPropagation(); setCodeSourceOpen((prev) => !prev); }}
286
- className={`transition-colors p-0.5 rounded inline-flex items-center ${
287
- codeSourceOpen
288
- ? "text-cyan-400 bg-cyan-400/10"
289
- : "text-[var(--text-tertiary)] hover:text-cyan-400 hover:bg-[var(--bg-surface)]"
290
- }`}
291
- title={codeSourceOpen ? "Close handler source" : "View handler source"}
292
- >
293
- <Icon path={mdiCodeBraces} size={0.45} />
294
- </button>
295
- <Dialog
296
- open={codeSourceOpen}
297
- onClose={() => setCodeSourceOpen(false)}
298
- title={agent.codeTarget.split("/").pop() || "Handler"}
299
- size="lg"
300
- >
301
- <div className="text-[11px] text-[var(--text-tertiary)] font-mono break-all" title={agent.codeTarget}>
302
- {agent.codeTarget}
303
- </div>
304
- <div className="h-[60vh] overflow-y-auto">
305
- {codeSourceState.kind === "loading" && (
306
- <div className="text-xs text-[var(--text-muted)]">Loading…</div>
307
- )}
308
- {codeSourceState.kind === "error" && (
309
- <div className="text-xs text-red-400">⚠ {codeSourceState.error}</div>
310
- )}
311
- {codeSourceState.kind === "loaded" && (
312
- <MarkdownContent content={"```ts\n" + codeSourceState.content + "\n```"} />
313
- )}
314
- </div>
315
- </Dialog>
316
- </>
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>
317
220
  )}
318
- {agent.sourcePath && (
319
- <>
320
- <button
321
- onClick={(e) => { e.stopPropagation(); setSourceOpen((prev) => !prev); }}
322
- className={`transition-colors p-0.5 rounded inline-flex items-center ${
323
- sourceOpen
324
- ? "text-blue-400 bg-blue-400/10"
325
- : "text-[var(--text-tertiary)] hover:text-blue-400 hover:bg-[var(--bg-surface)]"
326
- }`}
327
- title={sourceOpen ? `Close ${displayName} source` : `View ${displayName} source`}
328
- >
329
- <Icon path={mdiFileDocumentOutline} size={0.45} />
330
- </button>
331
- <Dialog
332
- open={sourceOpen}
333
- onClose={() => setSourceOpen(false)}
334
- title={agent.sourcePath.split("/").pop() || "Source"}
335
- size="lg"
336
- >
337
- {/* Pinned path header; body scrolls inside a fixed-height
338
- region so the dialog stays a fixed size. See change:
339
- improve-flow-graph-dialog-and-card-interaction. */}
340
- <div className="text-[11px] text-[var(--text-tertiary)] font-mono break-all" title={agent.sourcePath}>
341
- {agent.sourcePath}
342
- </div>
343
- <div className="h-[60vh] overflow-y-auto">
344
- {sourceState.kind === "loading" && (
345
- <div className="text-xs text-[var(--text-muted)]">Loading…</div>
346
- )}
347
- {sourceState.kind === "error" && (
348
- <div className="text-xs text-red-400">⚠ {sourceState.error}</div>
349
- )}
350
- {sourceState.kind === "loaded" && (
351
- <MarkdownContent content={sourceState.content} />
352
- )}
353
- </div>
354
- </Dialog>
355
- </>
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>
356
229
  )}
357
230
  <button
358
231
  onClick={(e) => { e.stopPropagation(); setDetailOpen((prev) => !prev); }}
359
- 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 ${
360
233
  detailOpen
361
234
  ? "text-blue-400 bg-blue-400/10 border-blue-400/40"
362
235
  : "border-[var(--border-subtle)] text-[var(--text-tertiary)] hover:text-blue-400 hover:border-blue-400/40 hover:bg-blue-400/10"