@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
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Tool renderer for the `flow_agents` authoring tool (main-session timeline).
3
+ *
4
+ * Renders from the real tool contract:
5
+ * op:"list" → result is a catalog array `[{ name, description, … }]`.
6
+ * op:"write" → result is `{ written, name, path, diagnostics[] }` /
7
+ * `{ written:false, error }`.
8
+ * The agent markdown body for the "view agent file" sub-row comes from the
9
+ * tool ARGS (`toolInput.content`), not the result.
10
+ *
11
+ * See change: rework-flows-plugin-for-new-pi-flows.
12
+ */
13
+ import React, { useState } from "react";
14
+
15
+ // A per-agent catalog entry. All fields optional/duck-typed: pi-flows may add
16
+ // or drop fields, and text-parsed entries nest `architect.use_when`. The
17
+ // renderer renders whatever is present. See change: flow-agents-readable-list.
18
+ interface AgentListEntry {
19
+ name?: string;
20
+ description?: string;
21
+ source_type?: string;
22
+ source_path?: string;
23
+ tools?: string[];
24
+ inputs?: string[];
25
+ outputs?: Array<string | { name?: string }>;
26
+ use_when?: string;
27
+ architect?: { use_when?: string };
28
+ }
29
+ interface AgentWriteResult {
30
+ written?: boolean;
31
+ name?: string;
32
+ path?: string;
33
+ diagnostics?: Array<{ message?: string } | string>;
34
+ error?: string;
35
+ }
36
+
37
+ function diagText(d: { message?: string } | string): string {
38
+ return typeof d === "string" ? d : (d.message ?? JSON.stringify(d));
39
+ }
40
+
41
+ // Display truncation marker prepended by the host when a tool result exceeds
42
+ // the line cap (see client event-reducer TRUNCATION_MARKER_PREFIX). Matched as
43
+ // the full header so a raw result that merely starts with "«" is not misread.
44
+ const TRUNCATION_MARKER_RE = /^«\d+ earlier lines hidden»\n/;
45
+
46
+ function normalizeEntry(e: AgentListEntry): AgentListEntry {
47
+ return { ...e, use_when: e.use_when ?? e.architect?.use_when ?? e.description };
48
+ }
49
+
50
+ function outputNames(outputs: AgentListEntry["outputs"]): string[] {
51
+ if (!Array.isArray(outputs)) return [];
52
+ return outputs
53
+ .map((o) => (typeof o === "string" ? o : o?.name))
54
+ .filter((n): n is string => typeof n === "string");
55
+ }
56
+
57
+ /**
58
+ * Derive the `op:"list"` catalog entries from the most authoritative
59
+ * non-truncated source. Fallback order (design Decision 2):
60
+ * 1. `toolDetails.agents` structured catalog (never line-truncated),
61
+ * 2. valid-JSON parse of the `result` text,
62
+ * 3. truncation-marker guard → entries empty, truncated:true (never report 0),
63
+ * 4. genuine empty array → 0 agents.
64
+ * `count` is carried through so a details count survives even when entries are
65
+ * not enumerable.
66
+ */
67
+ function deriveListCatalog(
68
+ result: string | undefined,
69
+ toolDetails: unknown,
70
+ ): { entries: AgentListEntry[]; truncated: boolean; count?: number } {
71
+ // 1. toolDetails.agents (duck-typed; pi-flows may not emit it on older builds)
72
+ const td = toolDetails as { agents?: unknown; count?: unknown } | AgentListEntry[] | undefined;
73
+ const detailsAgents = Array.isArray(td) ? td : (td && typeof td === "object" ? td.agents : undefined);
74
+ if (Array.isArray(detailsAgents) && detailsAgents.length > 0) {
75
+ const entries = (detailsAgents as AgentListEntry[]).map(normalizeEntry);
76
+ return { entries, truncated: false, count: entries.length };
77
+ }
78
+ const detailsCount =
79
+ td && typeof td === "object" && !Array.isArray(td) && typeof td.count === "number"
80
+ ? td.count
81
+ : undefined;
82
+
83
+ // 3. truncation-marker guard (before parse: the marker is never valid JSON)
84
+ if (typeof result === "string" && TRUNCATION_MARKER_RE.test(result)) {
85
+ return { entries: [], truncated: true, count: detailsCount };
86
+ }
87
+
88
+ // 2. valid-JSON parse of the (untruncated) result text
89
+ let parsed: unknown = null;
90
+ try { if (result) parsed = JSON.parse(result); } catch { parsed = null; }
91
+ const catalog = Array.isArray(parsed) ? (parsed as AgentListEntry[]) : [];
92
+ const entries = catalog
93
+ .filter((a) => typeof a?.name === "string")
94
+ .map(normalizeEntry);
95
+ return { entries, truncated: false, count: entries.length };
96
+ }
97
+
98
+ export function FlowAgentsToolRenderer({
99
+ toolInput,
100
+ status,
101
+ result,
102
+ toolDetails,
103
+ }: {
104
+ toolName: string;
105
+ toolInput: Record<string, unknown>;
106
+ sessionId: string;
107
+ status?: "running" | "complete" | "error";
108
+ result?: string;
109
+ toolDetails?: unknown;
110
+ }) {
111
+ const [showFile, setShowFile] = useState(false);
112
+ const [expanded, setExpanded] = useState<Set<string>>(() => new Set());
113
+ const op = toolInput.op === "write" ? "write" : "list";
114
+ const content = typeof toolInput.content === "string" ? toolInput.content : "";
115
+
116
+ let parsed: unknown = null;
117
+ try { if (result) parsed = JSON.parse(result); } catch { parsed = null; }
118
+
119
+ // ── list ──
120
+ if (op === "list") {
121
+ const { entries, truncated, count } = deriveListCatalog(result, toolDetails);
122
+ const shownCount = entries.length > 0 ? entries.length : (typeof count === "number" ? count : 0);
123
+ const toggle = (name: string) =>
124
+ setExpanded((prev) => {
125
+ const next = new Set(prev);
126
+ if (next.has(name)) next.delete(name); else next.add(name);
127
+ return next;
128
+ });
129
+ return (
130
+ <div className="border border-[var(--border-primary)] rounded-md bg-[var(--bg-secondary)] p-3 text-xs">
131
+ <div className="flex items-center gap-2">
132
+ <span className="text-purple-400">⊙</span>
133
+ <span className="font-semibold">flow_agents</span>
134
+ {truncated && entries.length === 0 ? (
135
+ <span className="text-[var(--text-muted)]">list · output truncated — expand</span>
136
+ ) : (
137
+ <span className="text-[var(--text-muted)]">list · {shownCount} agents</span>
138
+ )}
139
+ </div>
140
+ {entries.length > 0 && (
141
+ <div className="mt-2">
142
+ {entries.map((a) => {
143
+ const name = a.name ?? "";
144
+ const isOpen = expanded.has(name);
145
+ const detailRows: Array<[string, string]> = [];
146
+ if (a.tools && a.tools.length > 0) detailRows.push(["tools", a.tools.join(", ")]);
147
+ if (a.inputs && a.inputs.length > 0) detailRows.push(["inputs", a.inputs.join(", ")]);
148
+ const outs = outputNames(a.outputs);
149
+ if (outs.length > 0) detailRows.push(["outputs", outs.join(", ")]);
150
+ if (a.use_when) detailRows.push(["use_when", a.use_when]);
151
+ return (
152
+ <div key={name} className="border-t border-[var(--border-subtle)] first:border-t-0">
153
+ <button
154
+ type="button"
155
+ onClick={() => toggle(name)}
156
+ className="flex items-baseline gap-2 w-full text-left py-1 hover:text-[var(--text-primary)]"
157
+ >
158
+ <span className="text-[var(--text-muted)] w-3 shrink-0">{isOpen ? "▾" : "▸"}</span>
159
+ <span className="font-mono font-semibold text-[var(--text-primary)]">{name}</span>
160
+ {a.description && (
161
+ <span className="text-[var(--text-secondary)] flex-1">{a.description}</span>
162
+ )}
163
+ {a.source_type && (
164
+ <span className="ml-auto shrink-0 text-[10px] text-[var(--text-tertiary)] bg-[var(--bg-surface)] rounded px-1.5 py-0.5">
165
+ {a.source_type}
166
+ </span>
167
+ )}
168
+ </button>
169
+ {isOpen && detailRows.length > 0 && (
170
+ <div className="ml-5 mb-2 p-2 bg-[var(--bg-code)] border border-[var(--border-subtle)] rounded">
171
+ {detailRows.map(([k, v]) => (
172
+ <div key={k} className="flex gap-2">
173
+ <span className="text-[var(--text-tertiary)] w-16 shrink-0">{k}</span>
174
+ <span className="font-mono text-[var(--text-secondary)]">{v}</span>
175
+ </div>
176
+ ))}
177
+ </div>
178
+ )}
179
+ </div>
180
+ );
181
+ })}
182
+ </div>
183
+ )}
184
+ </div>
185
+ );
186
+ }
187
+
188
+ // ── write ──
189
+ const wr = (parsed && typeof parsed === "object" ? parsed : {}) as AgentWriteResult;
190
+ const written = wr.written === true;
191
+ const isError = status === "error" || wr.written === false;
192
+ const diagnostics = (wr.diagnostics ?? []).map(diagText);
193
+
194
+ return (
195
+ <div className="border border-[var(--border-primary)] rounded-md bg-[var(--bg-secondary)] p-3 text-xs">
196
+ <div className="flex items-center gap-2">
197
+ <span className="text-purple-400">⊙</span>
198
+ <span className="font-semibold">flow_agents</span>
199
+ <span className="text-[var(--text-muted)]">write</span>
200
+ {written && wr.name && <span className="font-mono text-green-400">{wr.name}</span>}
201
+ {written && <span className="text-[var(--text-muted)]">saved</span>}
202
+ {isError && <span className="text-red-400">not written</span>}
203
+ </div>
204
+
205
+ {isError && (
206
+ <pre className="mt-2 font-mono text-[11px] text-red-400 whitespace-pre-wrap">
207
+ {diagnostics.length > 0 ? diagnostics.join("\n") : (wr.error ?? "Unknown error")}
208
+ </pre>
209
+ )}
210
+
211
+ {content && (
212
+ <div className="mt-2">
213
+ <button
214
+ onClick={() => setShowFile((v) => !v)}
215
+ className="text-[11px] text-[var(--text-tertiary)] hover:text-blue-400 font-mono"
216
+ >
217
+ {showFile ? "▾" : "▸"} View agent file {wr.path ? `· ${wr.path.split("/").pop()}` : ""}
218
+ </button>
219
+ {showFile && (
220
+ <pre className="mt-1 font-mono text-[11px] bg-[var(--bg-surface)] border border-[var(--border-subtle)] rounded p-2 overflow-auto max-h-[260px] whitespace-pre">
221
+ {content}
222
+ </pre>
223
+ )}
224
+ </div>
225
+ )}
226
+ </div>
227
+ );
228
+ }
@@ -0,0 +1,92 @@
1
+ import React, { useState, useRef, useEffect } from "react";
2
+ import { Icon } from "@mdi/react";
3
+ import { mdiPencil } from "@mdi/js";
4
+ import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
5
+ import { useUiPrimitive } from "@blackbelt-technology/dashboard-plugin-runtime";
6
+
7
+ /**
8
+ * Intent-capture step for the manage-flows authoring launcher.
9
+ * Mirrors FlowLaunchDialog's two-step pattern: after the user picks "+ New flow"
10
+ * or an existing flow, this dialog asks what the flow should do (new) or what to
11
+ * change (edit) before the skill is launched. The text is forwarded to the
12
+ * `/skill:manage-flows` prompt so the agent starts with stated intent.
13
+ *
14
+ * New mode requires a description (the whole point is to seed intent); edit mode
15
+ * leaves the instruction optional.
16
+ */
17
+ export function FlowAuthorPromptDialog({
18
+ mode,
19
+ flowName,
20
+ onSubmit,
21
+ onCancel,
22
+ }: {
23
+ mode: "new" | "edit";
24
+ /** Present for edit mode; the flow being changed. */
25
+ flowName?: string;
26
+ onSubmit: (instruction: string) => void;
27
+ onCancel: () => void;
28
+ }) {
29
+ const Dialog = useUiPrimitive(UI_PRIMITIVE_KEYS.dialog);
30
+ const [instruction, setInstruction] = useState("");
31
+ const inputRef = useRef<HTMLTextAreaElement>(null);
32
+
33
+ useEffect(() => {
34
+ inputRef.current?.focus();
35
+ }, []);
36
+
37
+ const isNew = mode === "new";
38
+ const trimmed = instruction.trim();
39
+ const canSubmit = isNew ? trimmed.length > 0 : true;
40
+
41
+ const handleSubmit = (e: React.FormEvent) => {
42
+ e.preventDefault();
43
+ if (!canSubmit) return;
44
+ onSubmit(trimmed);
45
+ };
46
+
47
+ return (
48
+ <Dialog
49
+ open
50
+ onClose={onCancel}
51
+ title={isNew ? "New flow" : `Edit flow: ${flowName}`}
52
+ size="md"
53
+ testId="flow-author-prompt-dialog"
54
+ >
55
+ <p className="text-[11px] text-[var(--text-tertiary)]">
56
+ {isNew
57
+ ? "Describe what the flow should do. The agent uses this to author it."
58
+ : "Describe what to change. Leave blank to open the flow without a specific instruction."}
59
+ </p>
60
+ <form onSubmit={handleSubmit} className="space-y-3">
61
+ <textarea
62
+ ref={inputRef}
63
+ value={instruction}
64
+ onChange={(e) => setInstruction(e.target.value)}
65
+ rows={4}
66
+ placeholder={
67
+ isNew
68
+ ? "e.g. Research an invoice, extract line items, and draft a summary email…"
69
+ : "e.g. Add a review step after extraction…"
70
+ }
71
+ className="w-full px-3 py-2 text-sm bg-[var(--bg-tertiary)] border border-[var(--border-subtle)] rounded-lg text-[var(--text-primary)] placeholder:text-[var(--text-muted)] focus:outline-none focus:border-purple-500/50 resize-y"
72
+ />
73
+ <Dialog.Footer>
74
+ <Dialog.Cancel onClick={onCancel} />
75
+ <button
76
+ type="submit"
77
+ disabled={!canSubmit}
78
+ className={`text-xs px-3 py-1.5 rounded transition-colors ${
79
+ canSubmit
80
+ ? "bg-[var(--accent-primary)] text-white hover:opacity-90"
81
+ : "bg-[var(--bg-tertiary)] text-[var(--text-muted)] cursor-not-allowed"
82
+ }`}
83
+ data-testid="flow-author-submit"
84
+ >
85
+ <Icon path={mdiPencil} size={0.45} className="inline mr-0.5" />
86
+ {isNew ? "Create" : "Edit"}
87
+ </button>
88
+ </Dialog.Footer>
89
+ </form>
90
+ </Dialog>
91
+ );
92
+ }
@@ -1,22 +1,26 @@
1
- import React, { useState, useMemo, useEffect, useRef } from "react";
2
- import { Icon } from "@mdi/react";
3
- import { mdiRobotOutline, mdiStop, mdiChevronUp, mdiChevronRight, mdiChevronDown, mdiFileDocumentOutline, mdiLoading } from "@mdi/js";
4
- import type { DashboardSession, FlowState, ImageContent } from "@blackbelt-technology/pi-dashboard-shared/types.js";
5
1
  import {
2
+ type InteractiveUiRequestSnapshot,
6
3
  usePluginSend,
7
4
  useSessionInteractiveRequests,
8
- type InteractiveUiRequestSnapshot,
5
+ useT,
6
+ useUiPrimitiveOrNull,
9
7
  } from "@blackbelt-technology/dashboard-plugin-runtime";
8
+ import { BreadcrumbSlot } from "@blackbelt-technology/pi-dashboard-client-utils/extension-ui/BreadcrumbSlot";
9
+ import { useMobile } from "@blackbelt-technology/pi-dashboard-client-utils/useMobile";
10
+ import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
11
+ import type { DashboardSession, FlowState, ImageContent } from "@blackbelt-technology/pi-dashboard-shared/types.js";
12
+ import { mdiChevronDown, mdiChevronRight, mdiChevronUp, mdiFileDocumentOutline, mdiLoading, mdiRobotOutline, mdiStop } from "@mdi/js";
13
+ import { Icon } from "@mdi/react";
14
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
10
15
  import { FlowAgentCard } from "./FlowAgentCard.js";
16
+ import { FlowGraph, flowStateToGraphSteps } from "./FlowGraph.js";
11
17
  import { FlowQuestionCard } from "./FlowQuestionCard.js";
12
18
  import { FlowQuestionTranscriptPill } from "./FlowQuestionTranscriptPill.js";
13
- import { FlowGraph, flowStateToGraphSteps } from "./FlowGraph.js";
14
19
  import { FlowSummary } from "./FlowSummary.js";
15
- import { FlowYamlPopoverButton } from "./FlowYamlPopoverButton.js";
16
- import { FlowTabBar, type FlowTab } from "./FlowTabBar.js";
17
- import { useMobile } from "@blackbelt-technology/pi-dashboard-client-utils/useMobile";
18
- import { BreadcrumbSlot } from "@blackbelt-technology/pi-dashboard-client-utils/extension-ui/BreadcrumbSlot";
19
20
  import { useFlowsSessionState } from "./FlowsSessionStateContext.js";
21
+ import { type FlowTab, FlowTabBar } from "./FlowTabBar.js";
22
+ import { FlowYamlPopoverButton } from "./FlowYamlPopoverButton.js";
23
+ import { useFlowCollapsePersisted } from "./flow-collapse-storage.js";
20
24
 
21
25
 
22
26
 
@@ -32,7 +36,7 @@ export function FlowDashboard({
32
36
  sessionId,
33
37
  }: {
34
38
  flowState: FlowState;
35
- /** All flow states (main + subflows) for tab navigation */
39
+ /** All flow states (one per distinct flow run this session) for tab navigation */
36
40
  flowStates?: Map<string, FlowState>;
37
41
  onAbort: () => void;
38
42
  onToggleAutonomous: () => void;
@@ -45,7 +49,16 @@ export function FlowDashboard({
45
49
  sessionId?: string;
46
50
  }) {
47
51
  const isMobile = useMobile();
48
- const [collapsed, setCollapsed] = useState(false);
52
+ const t = useT();
53
+ const Dialog = useUiPrimitiveOrNull(UI_PRIMITIVE_KEYS.dialog);
54
+ const [graphOpen, setGraphOpen] = useState(false);
55
+ // Shared graph⇄card selection (live view parity with FlowSummary). See change:
56
+ // improve-flow-graph-dialog-and-card-interaction.
57
+ const [selectedStepId, setSelectedStepId] = useState<string | null>(null);
58
+ const rootRef = useRef<HTMLDivElement>(null);
59
+ // Persisted per session so a collapsed dashboard stays collapsed across
60
+ // remounts. See change: fix-flow-ui-graph-zoom-summary.
61
+ const [collapsed, toggleCollapsed] = useFlowCollapsePersisted(sessionId, "dashboard");
49
62
  const [mobileExpanded, setMobileExpanded] = useState(false);
50
63
  const [activeTabId, setActiveTabId] = useState<string>(flowState.flowName);
51
64
  const [followMode, setFollowMode] = useState(true);
@@ -79,18 +92,48 @@ export function FlowDashboard({
79
92
 
80
93
  const agents = Array.from(displayState.agents.values());
81
94
  const allAgents = Array.from(flowState.agents.values());
95
+
96
+ const handleSelectStep = useCallback((stepId: string) => {
97
+ setSelectedStepId((prev) => (prev === stepId ? null : stepId));
98
+ }, []);
99
+ // Selection is ephemeral; reset when the displayed agent set changes.
100
+ useEffect(() => {
101
+ setSelectedStepId(null);
102
+ }, [displayState.agents]);
103
+ // Esc clears selection (Dialog handles its own Esc independently).
104
+ useEffect(() => {
105
+ if (!selectedStepId) return;
106
+ const onKey = (e: KeyboardEvent) => {
107
+ if (e.key === "Escape") setSelectedStepId(null);
108
+ };
109
+ window.addEventListener("keydown", onKey);
110
+ return () => window.removeEventListener("keydown", onKey);
111
+ }, [selectedStepId]);
112
+ // Scroll the matching node + card into view on selection (counterpart sync).
113
+ useEffect(() => {
114
+ if (!selectedStepId || !rootRef.current) return;
115
+ const esc = selectedStepId.replace(/["\\]/g, "\\$&");
116
+ for (const attr of ["data-node", "data-step"]) {
117
+ rootRef.current
118
+ .querySelector(`[${attr}="${esc}"]`)
119
+ ?.scrollIntoView({ block: "nearest", inline: "nearest" });
120
+ }
121
+ }, [selectedStepId]);
82
122
  const doneCount = allAgents.filter(a => a.status === "complete" || a.status === "error" || a.status === "blocked").length;
83
123
  const totalCount = allAgents.length;
84
124
  const isRunning = flowState.status === "running";
85
125
  const isComplete = !isRunning;
86
126
 
87
- // After completion, show summary
127
+ // After completion, show summary. Forward sessionId so the summary's per-session
128
+ // collapse state persists (the hook no-ops without a session id).
129
+ // See change: fix-flow-ui-graph-zoom-summary.
88
130
  if (isComplete) {
89
131
  return (
90
132
  <FlowSummary
91
133
  flowState={flowState}
92
134
  onDismiss={onDismiss}
93
135
  onSendPrompt={onSendPrompt}
136
+ sessionId={sessionId}
94
137
  />
95
138
  );
96
139
  }
@@ -126,12 +169,12 @@ export function FlowDashboard({
126
169
  }
127
170
 
128
171
  return (
129
- <div className="bg-[var(--bg-secondary)] border-b border-[var(--border-subtle)] px-3 py-2">
172
+ <div ref={rootRef} className="bg-[var(--bg-secondary)] border-b border-[var(--border-subtle)] px-3 py-2">
130
173
  {/* Header */}
131
174
  <div className="flex items-center gap-2 mb-2">
132
175
  <span
133
176
  className="inline-flex text-[var(--text-tertiary)] cursor-pointer"
134
- onClick={() => setCollapsed(!collapsed)}
177
+ onClick={toggleCollapsed}
135
178
  >
136
179
  <Icon path={collapsed ? mdiChevronRight : mdiChevronDown} size={0.6} />
137
180
  </span>
@@ -142,7 +185,7 @@ export function FlowDashboard({
142
185
  )}
143
186
  <span className="text-sm text-[var(--text-primary)] truncate flex-1">
144
187
  {flowState.flowName}
145
- <span className="text-[var(--text-tertiary)] ml-1.5">{doneCount}/{totalCount} steps</span>
188
+ <span className="text-[var(--text-tertiary)] ml-1.5">{t("stepsCount", { done: doneCount, total: totalCount }, `${doneCount}/${totalCount} steps`)}</span>
146
189
  </span>
147
190
 
148
191
  {/* Controls */}
@@ -153,7 +196,7 @@ export function FlowDashboard({
153
196
  ? "border-green-500/40 text-green-400 bg-green-500/10"
154
197
  : "border-[var(--border-subtle)] text-[var(--text-tertiary)]"
155
198
  }`}
156
- title="Toggle autonomous mode"
199
+ title={t("toggleAutonomousMode", undefined, "Toggle autonomous mode")}
157
200
  >
158
201
  <Icon path={mdiRobotOutline} size={0.4} className="inline mr-0.5" />AUTO
159
202
  </button>
@@ -161,9 +204,9 @@ export function FlowDashboard({
161
204
  <button
162
205
  onClick={(e) => { e.stopPropagation(); onAbort(); }}
163
206
  className="text-[10px] px-1.5 py-0.5 rounded border border-red-500/30 text-red-400 hover:bg-red-500/10"
164
- title="Abort flow"
207
+ title={t("abortFlow", undefined, "Abort flow")}
165
208
  >
166
- <Icon path={mdiStop} size={0.4} className="inline mr-0.5" />Abort
209
+ <Icon path={mdiStop} size={0.4} className="inline mr-0.5" />{t("abort", undefined, "Abort")}
167
210
  </button>
168
211
  )}
169
212
  {isMobile && (
@@ -202,6 +245,10 @@ export function FlowDashboard({
202
245
 
203
246
  <FlowGraph
204
247
  steps={flowStateToGraphSteps(displayState)}
248
+ fit
249
+ selectedStepId={selectedStepId}
250
+ onSelectStep={handleSelectStep}
251
+ onExpand={Dialog ? () => setGraphOpen(true) : undefined}
205
252
  />
206
253
  {displayState.flowSource && (
207
254
  <div className="mt-1">
@@ -211,6 +258,25 @@ export function FlowDashboard({
211
258
  />
212
259
  </div>
213
260
  )}
261
+ {/* Expanded graph — centered Dialog with pan/zoom. See change: show-flow-cards-in-summary. */}
262
+ {Dialog && (
263
+ <Dialog
264
+ open={graphOpen}
265
+ onClose={() => setGraphOpen(false)}
266
+ title={`Flow graph · ${displayState.flowName}`}
267
+ size="full"
268
+ >
269
+ {/* Non-fit (pan/zoom) graph fills the full-size dialog. See change:
270
+ improve-flow-graph-dialog-and-card-interaction. */}
271
+ <div style={{ height: "82vh", overflow: "hidden" }}>
272
+ <FlowGraph
273
+ steps={flowStateToGraphSteps(displayState)}
274
+ selectedStepId={selectedStepId}
275
+ onSelectStep={handleSelectStep}
276
+ />
277
+ </div>
278
+ </Dialog>
279
+ )}
214
280
 
215
281
  {/* Agent card grid — detailed per-agent info */}
216
282
  <div
@@ -223,7 +289,8 @@ export function FlowDashboard({
223
289
  agent={agent}
224
290
  session={session}
225
291
  sessionId={sessionId}
226
- flowId={displayState.flowName}
292
+ selected={selectedStepId === (agent.stepId || agent.agentName)}
293
+ onSelect={handleSelectStep}
227
294
  />
228
295
  ))}
229
296
  </div>
@@ -350,7 +417,7 @@ type FlowQuestionCardType = "select" | "input" | "confirm" | "editor" | "multise
350
417
  * pluginize-flows-via-registry.
351
418
  */
352
419
  export function FlowDashboardClaim({ session }: { session: DashboardSession }) {
353
- const { flowState, flowStates, architectState } = useFlowsSessionState(session.id);
420
+ const { flowState, flowStates } = useFlowsSessionState(session.id);
354
421
  const send = usePluginSend();
355
422
 
356
423
  // Diagnostic logging — helps trace why the upper slot might be empty when
@@ -365,8 +432,6 @@ export function FlowDashboardClaim({ session }: { session: DashboardSession }) {
365
432
  flowName: flowState?.flowName,
366
433
  flowStatus: flowState?.status,
367
434
  flowsCount: flowStates.size,
368
- hasArchitect: !!architectState,
369
- architectPhase: architectState?.phase,
370
435
  },
371
436
  );
372
437
  }