@blackbelt-technology/pi-dashboard-flows-plugin 0.11.0 → 0.12.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 (71) hide show
  1. package/README.md +5 -1
  2. package/package.json +23 -4
  3. package/src/bridge/flow-catalog-publisher.ts +138 -0
  4. package/src/bridge/flow-event-forward.ts +132 -0
  5. package/src/bridge/flow-files-reporter.ts +16 -14
  6. package/src/bridge/flow-open-tool.ts +124 -0
  7. package/src/bridge/flow-probe.ts +20 -0
  8. package/src/bridge/flow-tool-registry.ts +298 -0
  9. package/src/bridge/flow-tools-guideline.ts +52 -0
  10. package/src/bridge/index.ts +67 -10
  11. package/src/bridge/run-snapshot-reporter.ts +146 -0
  12. package/src/catalog-timings.ts +70 -0
  13. package/src/client/AskSession.tsx +82 -0
  14. package/src/client/FlowActionDialogs.tsx +143 -0
  15. package/src/client/FlowActivityBadge.tsx +42 -4
  16. package/src/client/FlowAgentCard.tsx +63 -8
  17. package/src/client/FlowAgentDetail.tsx +3 -5
  18. package/src/client/FlowDashboard.tsx +381 -273
  19. package/src/client/FlowEditMenu.tsx +69 -0
  20. package/src/client/FlowEditPopover.tsx +130 -0
  21. package/src/client/FlowGraph.tsx +127 -44
  22. package/src/client/FlowHeaderActions.tsx +83 -0
  23. package/src/client/FlowInputWiring.tsx +1 -1
  24. package/src/client/FlowOpenListener.tsx +82 -0
  25. package/src/client/FlowQuestionBlock.tsx +226 -0
  26. package/src/client/FlowStepCards.tsx +189 -0
  27. package/src/client/FlowSummary.tsx +72 -240
  28. package/src/client/FlowWriteToolRenderer.tsx +46 -17
  29. package/src/client/FlowYamlPopoverButton.tsx +2 -2
  30. package/src/client/FlowsContextGroup.tsx +156 -0
  31. package/src/client/FlowsSessionStateContext.tsx +202 -54
  32. package/src/client/FlowsSettings.tsx +145 -17
  33. package/src/client/SessionFlowActions.tsx +65 -10
  34. package/src/client/SessionFlowMenuClaim.tsx +48 -241
  35. package/src/client/ask-session-store.ts +243 -0
  36. package/src/client/flow-attach-store.ts +2 -0
  37. package/src/client/flow-card-grid.ts +2 -2
  38. package/src/client/flow-collapse-storage.ts +36 -6
  39. package/src/client/flow-edges.ts +91 -35
  40. package/src/client/flow-files.ts +16 -4
  41. package/src/client/flow-idle-state.ts +93 -37
  42. package/src/client/flowsActionsGate.ts +1 -1
  43. package/src/client/flowsAvailability.ts +8 -2
  44. package/src/client/index.tsx +13 -11
  45. package/src/client/shouldRender.ts +1 -1
  46. package/src/client/useEditModeState.ts +78 -0
  47. package/src/client/useFlowActions.tsx +191 -0
  48. package/src/client/useFlowCatalog.ts +69 -0
  49. package/src/client/useMinuteClock.ts +21 -0
  50. package/src/client/useRunReattach.ts +50 -0
  51. package/src/configSchema.json +37 -2
  52. package/src/flow-catalog-contract.ts +65 -0
  53. package/src/flow-questions.ts +138 -0
  54. package/src/flow-reducer.ts +434 -13
  55. package/src/flow-state-serialize.ts +132 -0
  56. package/src/i18n.ts +144 -6
  57. package/src/server/automation-actions.ts +4 -3
  58. package/src/server/edit-mode.ts +307 -0
  59. package/src/server/flow-catalog.ts +127 -0
  60. package/src/server/flow-control.ts +263 -0
  61. package/src/server/flow-files.ts +140 -14
  62. package/src/server/flow-open.ts +385 -0
  63. package/src/server/index.ts +112 -34
  64. package/src/server/render-actions.ts +3 -2
  65. package/src/server/state-store.ts +11 -5
  66. package/src/types.ts +180 -0
  67. package/src/bridge/flow-question-adapter.ts +0 -93
  68. package/src/client/FlowQuestionCard.tsx +0 -218
  69. package/src/client/FlowQuestionTranscriptPill.tsx +0 -58
  70. package/src/client/FlowsCommandRoutes.tsx +0 -245
  71. package/src/client/flow-yaml-parse.ts +0 -140
package/src/types.ts ADDED
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Flow types — owned by the flows plugin (moved out of
3
+ * `packages/shared/src/types.ts`; core holds no flow type). The plugin keeps its
4
+ * per-session slice through its registered session-event reducer and the
5
+ * server `state-store.ts`.
6
+ *
7
+ * pi-flows 0.10 additions (design D6): `skipped` status (untaken / unchosen
8
+ * branch), fan-out item cards keyed `<stepId>[<i>]` grouped under
9
+ * `FlowState.groups`, and a decision's chosen routes on its card.
10
+ * See change: update-flows-plugin (D5, D6).
11
+ */
12
+ import type { FlowDetailEntry, FlowRecentTool } from "@blackbelt-technology/pi-dashboard-shared/types.js";
13
+
14
+ // Shared with the core architect state (not flow-run specific); re-exported.
15
+ export type { FlowDetailEntry, FlowRecentTool };
16
+
17
+ /** Status of a flow agent card */
18
+ export type FlowAgentStatus = "pending" | "running" | "complete" | "error" | "blocked" | "skipped";
19
+
20
+ /** Agent card config from pi-flows AgentConfig (minimal subset) */
21
+ export interface FlowAgentCardConfig {
22
+ name: string;
23
+ description?: string;
24
+ model?: string;
25
+ card?: { label?: string; metric?: string; role?: string };
26
+ sourcePath?: string;
27
+ }
28
+
29
+ /** First-class node-kind discriminator emitted by every pi-flows executor.
30
+ * Decided once at the node's started event; carried on the event payload so it
31
+ * persists + replays. Distinct from FlowDetailEntry.kind (text|thinking|tool|error).
32
+ * See change: rework-flows-plugin-for-new-pi-flows (consumes pi-flows surface-node-kind). */
33
+ export type NodeKind =
34
+ | "agent"
35
+ | "agent-decision"
36
+ | "code"
37
+ | "code-decision"
38
+ | "fork";
39
+
40
+ /** Per-agent (per-step) state tracked in flow state */
41
+ export interface FlowAgentState {
42
+ agentName: string;
43
+ stepId: string;
44
+ /** Step type from the flow config (agent, fork, agent-decision, etc.) */
45
+ stepType?: string;
46
+ /** Node-kind from the lifecycle started event; selects the card renderer. */
47
+ nodeKind?: NodeKind;
48
+ /** Failure outcome from the completion event: routed-soft vs flow-halting-hard. */
49
+ outcome?: "success" | "soft" | "hard";
50
+ /** Typed outputs from the completion event (code/agent contract). */
51
+ typedOutputs?: Record<string, string>;
52
+ /** Chosen branch label for code-decision / agent-decision nodes. */
53
+ branch?: string;
54
+ /** Resolved handler target path for code / code-decision nodes (from started). */
55
+ codeTarget?: string;
56
+ status: FlowAgentStatus;
57
+ label?: string;
58
+ model?: string;
59
+ resolvedModel?: string;
60
+ cardRole?: string;
61
+ blockedBy: string[];
62
+ tokens?: { input: number; output: number };
63
+ /** Accumulated per-agent USD cost from `flow_agent_complete` (`result.cost`).
64
+ * Sibling of `tokens`; `undefined` when the session predates cost surfacing. */
65
+ cost?: number;
66
+ duration?: number;
67
+ summary?: string;
68
+ files?: string[];
69
+ recentTools: FlowRecentTool[];
70
+ detailHistory: FlowDetailEntry[];
71
+ loopIteration?: number;
72
+ loopMax?: number;
73
+ sourcePath?: string;
74
+ runCount?: number;
75
+ /** Fan-out item card: 0-based item index and its key `<stepId>[<i>]`. */
76
+ itemIndex?: number;
77
+ itemKey?: string;
78
+ /** Fan-out group parent: item count and ok / failed rollup (derived). */
79
+ itemCount?: number;
80
+ rollup?: { ok: number; failed: number };
81
+ /** Multi-route decision (pi-flows 0.10 `flow_decision`): chosen labels,
82
+ * chosen routes (with fan-out item counts) and a post-routing error. */
83
+ decision?: FlowDecisionInfo;
84
+ }
85
+
86
+ /** What a `flow_decision` stored for one decision step. */
87
+ export interface FlowDecisionInfo {
88
+ labels?: string[];
89
+ routes?: Array<{ branch: string; itemCount?: number }>;
90
+ routeError?: string;
91
+ /** Resolved chosen target step ids (route branch → `branches` target). */
92
+ chosenTargets: string[];
93
+ /** Branch targets of this decision that were not chosen. */
94
+ notTaken: string[];
95
+ }
96
+
97
+ /** How a parent-mailbox question closed (pi-flows `flow:answer.via`). */
98
+ export type FlowQuestionVia = "reply" | "timeout" | "cancel";
99
+
100
+ /** The question's own context block (pi-flows `flow:question.context`). */
101
+ export interface FlowQuestionContext {
102
+ values?: Record<string, unknown>;
103
+ changes?: Array<{ path?: string; added?: number; removed?: number; [k: string]: unknown }>;
104
+ upstream?: Record<string, unknown> | unknown[];
105
+ payload?: unknown;
106
+ text?: string;
107
+ }
108
+
109
+ /** One question a flow step asked its parent session (pi-flows 0.11+ parent
110
+ * mailbox). Folded from `flow_question` / `flow_answer`; holds no receive time,
111
+ * so live and replayed runs fold identically. See change: adopt-flow-parent-mailbox (D1). */
112
+ export interface FlowQuestionState {
113
+ id: string;
114
+ runId?: string;
115
+ stepId?: string;
116
+ agent?: string;
117
+ /** Fan-out item that asked (`item.index` maps onto the item card). */
118
+ item?: { index: number; count?: number };
119
+ kind?: string;
120
+ question: string;
121
+ options?: string[];
122
+ multiSelect?: boolean;
123
+ allowCustom?: boolean;
124
+ canDecide?: boolean;
125
+ /** Effective timeout in seconds (pi-flows 0.14+; `0` disables). */
126
+ timeoutS?: number;
127
+ /** Expiry as epoch ms on the pi host (pi-flows 0.14+). */
128
+ expiresAt?: number;
129
+ default?: string | string[];
130
+ context?: FlowQuestionContext;
131
+ /** Set once by the first `flow_answer` (or `cancel` at run end). */
132
+ closed?: { via: FlowQuestionVia; answer?: string | string[]; notes?: string; decide?: boolean };
133
+ }
134
+
135
+ /** Overall flow execution status. `interrupted` = orphaned run reconciled on resume
136
+ * (pi-flows clear-orphaned synthesized terminal). */
137
+ export type FlowStatus = "running" | "success" | "error" | "aborted" | "interrupted";
138
+
139
+ /** Flow execution state tracked client-side by the event reducer */
140
+ export interface FlowState {
141
+ flowName: string;
142
+ task: string;
143
+ status: FlowStatus;
144
+ /** Parent-mailbox questions keyed by `question_id` (empty at run start).
145
+ * See change: adopt-flow-parent-mailbox (D1). */
146
+ questions?: Record<string, FlowQuestionState>;
147
+ /** Path to the flow YAML file (for YAML viewer) */
148
+ flowSource?: string;
149
+ /** pi-flows run id from `flow_started` (dismiss names the run by it).
150
+ * See change: persist-flow-run-close (D3). */
151
+ runId?: string;
152
+ /** Ordered map — insertion order matches step order from flow config */
153
+ agents: Map<string, FlowAgentState>;
154
+ /** All steps from the flow configuration — used for DAG graph rendering.
155
+ * Includes non-agent steps (fork, agent-decision, code-decision). `branches`
156
+ * carries decision routing (label → target) emitted by `flow:flow-started`. */
157
+ dagSteps?: Array<{ id: string; stepType: string; agent?: string; blockedBy: string[]; branches?: Record<string, string>; onComplete?: string; onError?: string }>;
158
+ /** Set after flow_complete event */
159
+ flowResult?: Record<string, unknown>;
160
+ /** Fan-out groups: step id → item cards in item order (`<stepId>[<i>]`).
161
+ * The pre-listed step card is the group parent. pi-flows ≥ 0.10. */
162
+ groups?: Record<string, FlowAgentState[]>;
163
+ /** Decision step id → its last `flow_decision`. pi-flows ≥ 0.10. */
164
+ decisions?: Record<string, FlowDecisionInfo>;
165
+ /** Steps marked skipped that have no card (non-agent targets). */
166
+ skippedSteps?: string[];
167
+ /** Set when a run snapshot dropped detail history to fit its byte budget.
168
+ * No UI. See change: fix-flow-reattach-per-run-state (D4). */
169
+ historyTrimmed?: boolean;
170
+
171
+ /** Next flow to run (workflow stage resolution) */
172
+ nextStep?: string | null;
173
+ /** Pre-computed summary stats */
174
+ summaryStats?: {
175
+ agentCount: number;
176
+ duration: string;
177
+ fileCount: number;
178
+ perAgent: Array<{ name: string; status: string; fileCount: number }>;
179
+ };
180
+ }
@@ -1,93 +0,0 @@
1
- /**
2
- * FlowQuestionAdapter — PromptBus adapter that claims prompts originating
3
- * inside a running flow step (carrying `metadata.flowId`) so they render
4
- * in the FlowDashboard's upper slot instead of the chat stream.
5
- *
6
- * Lives in the flows-plugin bridge entry. Auto-loaded by pi when the
7
- * dashboard server registers the plugin's bridge path into pi's
8
- * `settings.json#dashboardPluginBridges` + `packages[]` via the standard
9
- * `discoverPlugins → registerAllPluginBridges` pipeline.
10
- *
11
- * Registration: the bridge entry (`./index.ts`) emits
12
- * `pi.events.emit("prompt:register-adapter", new FlowQuestionAdapter())`.
13
- * The main dashboard bridge listens for that event and calls
14
- * `promptBus.registerAdapter(adapter)` (see `packages/extension/src/bridge.ts`
15
- * around the `prompt:register-adapter` handler). PromptBus sorts adapters by
16
- * `priority` (lower first); we use 100 so this adapter beats
17
- * `DashboardDefaultAdapter` (priority 9999).
18
- *
19
- * See change: route-flow-asks-to-upper-slot.
20
- */
21
-
22
- // Structural typing — avoid a hard dep on the main bridge package. The shape
23
- // matches `PromptAdapter` / `PromptRequest` / `PromptClaim` /
24
- // `PromptResponse` in `packages/extension/src/prompt-bus.ts` byte-for-byte.
25
-
26
- interface PromptRequest {
27
- id: string;
28
- pipeline: string;
29
- type: "select" | "input" | "confirm" | "editor" | "multiselect";
30
- question: string;
31
- options?: string[];
32
- defaultValue?: string;
33
- metadata?: Record<string, unknown>;
34
- }
35
-
36
- interface PromptResponse {
37
- id: string;
38
- answer?: string;
39
- cancelled?: boolean;
40
- source: string;
41
- }
42
-
43
- interface PromptComponent {
44
- type: string;
45
- props: Record<string, unknown>;
46
- }
47
-
48
- interface PromptClaim {
49
- component?: PromptComponent;
50
- placement?: "widget-bar" | "inline" | "overlay";
51
- }
52
-
53
- interface PromptAdapter {
54
- name: string;
55
- priority?: number;
56
- onRequest(prompt: PromptRequest): PromptClaim | null | undefined | void;
57
- onResponse(response: PromptResponse): void;
58
- onCancel(id: string): void;
59
- }
60
-
61
- export class FlowQuestionAdapter implements PromptAdapter {
62
- readonly name = "flow-question";
63
- readonly priority = 100;
64
-
65
- onRequest(prompt: PromptRequest): PromptClaim | null {
66
- const flowId = prompt.metadata?.flowId;
67
- if (typeof flowId !== "string" || flowId.length === 0) return null;
68
- const stepId = typeof prompt.metadata?.stepId === "string" ? prompt.metadata.stepId : "";
69
- return {
70
- component: {
71
- type: "flow-question",
72
- props: {
73
- flowId,
74
- stepId,
75
- question: prompt.question,
76
- type: prompt.type,
77
- options: prompt.options,
78
- defaultValue: prompt.defaultValue,
79
- },
80
- },
81
- placement: "widget-bar",
82
- };
83
- }
84
-
85
- onResponse(_response: PromptResponse): void {
86
- // No adapter-owned UI to dismiss — the client tears down the card on
87
- // submit; the bus broadcasts `prompt_dismiss` for all listeners.
88
- }
89
-
90
- onCancel(_id: string): void {
91
- // No adapter-owned UI to dismiss.
92
- }
93
- }
@@ -1,218 +0,0 @@
1
- /**
2
- * FlowQuestionCard — renders a pending `flow-question` prompt inside
3
- * FlowDashboard's upper slot, above the agent grid.
4
- *
5
- * Routes to the appropriate input affordance based on the prompt's
6
- * `type` (`confirm` / `select` / `multiselect` / `input`). On submit,
7
- * dispatches `prompt_response` via the plugin's send fn. On dismiss,
8
- * dispatches `prompt_cancel`.
9
- *
10
- * V1 inlines minimal renderers for the 4 prompt types. Extracting these
11
- * into shared UI primitives is tracked as follow-up tech debt — for now
12
- * each renderer is ~10 LOC and the duplication is contained.
13
- *
14
- * See change: route-flow-asks-to-upper-slot.
15
- */
16
-
17
- import { useT } from "@blackbelt-technology/dashboard-plugin-runtime";
18
- import { mdiClose, mdiHelpCircleOutline } from "@mdi/js";
19
- import { Icon } from "@mdi/react";
20
- import React, { useState } from "react";
21
-
22
- export interface FlowQuestionCardProps {
23
- sessionId: string;
24
- promptId: string;
25
- flowId: string;
26
- stepId: string;
27
- question: string;
28
- type: "select" | "input" | "confirm" | "editor" | "multiselect";
29
- options?: string[];
30
- defaultValue?: string;
31
- /** Number of queued questions for this flow (head + queue). 0 or 1 hides the badge. */
32
- queueDepth: number;
33
- /** Dispatch `prompt_response`. */
34
- onSubmit: (answer: string) => void;
35
- /** Dispatch `prompt_cancel`. */
36
- onDismiss: () => void;
37
- }
38
-
39
- export function FlowQuestionCard({
40
- question,
41
- type,
42
- options,
43
- defaultValue,
44
- queueDepth,
45
- onSubmit,
46
- onDismiss,
47
- }: FlowQuestionCardProps) {
48
- const t = useT();
49
- return (
50
- <div
51
- data-testid="flow-question-card"
52
- data-widget-bar-slot=""
53
- tabIndex={-1}
54
- className="mt-2 mb-2 p-3 border border-purple-500/40 bg-purple-500/5 rounded"
55
- >
56
- <div className="flex items-start gap-2 mb-2">
57
- <Icon path={mdiHelpCircleOutline} size={0.7} className="text-purple-400 flex-shrink-0 mt-0.5" />
58
- <div className="flex-1 min-w-0">
59
- <div className="text-sm text-[var(--text-primary)] font-medium">{question}</div>
60
- </div>
61
- {queueDepth > 1 && (
62
- <span className="text-[10px] text-purple-300 bg-purple-500/20 px-1.5 py-0.5 rounded flex-shrink-0">
63
- +{queueDepth - 1} more queued
64
- </span>
65
- )}
66
- <button
67
- onClick={onDismiss}
68
- className="text-[var(--text-tertiary)] hover:text-[var(--text-primary)] flex-shrink-0"
69
- title={t("dismiss", undefined, "Dismiss")}
70
- >
71
- <Icon path={mdiClose} size={0.6} />
72
- </button>
73
- </div>
74
- <FlowQuestionInput
75
- type={type}
76
- options={options}
77
- defaultValue={defaultValue}
78
- onSubmit={onSubmit}
79
- />
80
- </div>
81
- );
82
- }
83
-
84
- function FlowQuestionInput({
85
- type,
86
- options,
87
- defaultValue,
88
- onSubmit,
89
- }: {
90
- type: FlowQuestionCardProps["type"];
91
- options?: string[];
92
- defaultValue?: string;
93
- onSubmit: (answer: string) => void;
94
- }) {
95
- if (type === "confirm") return <ConfirmRow onSubmit={onSubmit} />;
96
- if (type === "select") return <SelectRow options={options ?? []} onSubmit={onSubmit} />;
97
- if (type === "multiselect") return <MultiselectRow options={options ?? []} onSubmit={onSubmit} />;
98
- return <InputRow defaultValue={defaultValue} onSubmit={onSubmit} />;
99
- }
100
-
101
- function ConfirmRow({ onSubmit }: { onSubmit: (answer: string) => void }) {
102
- return (
103
- <div className="flex gap-2 justify-end">
104
- <button
105
- onClick={() => onSubmit("no")}
106
- className="px-3 py-1 text-xs rounded border border-[var(--border-primary)] hover:bg-[var(--bg-surface)]"
107
- >
108
- No
109
- </button>
110
- <button
111
- onClick={() => onSubmit("yes")}
112
- className="px-3 py-1 text-xs rounded bg-purple-500 text-white hover:bg-purple-600"
113
- >
114
- Yes
115
- </button>
116
- </div>
117
- );
118
- }
119
-
120
- function SelectRow({
121
- options,
122
- onSubmit,
123
- }: {
124
- options: string[];
125
- onSubmit: (answer: string) => void;
126
- }) {
127
- return (
128
- <div className="flex flex-wrap gap-1.5">
129
- {options.map((opt) => (
130
- <button
131
- key={opt}
132
- onClick={() => onSubmit(opt)}
133
- className="px-2.5 py-1 text-xs rounded border border-[var(--border-primary)] hover:bg-purple-500/10 hover:border-purple-500/40"
134
- >
135
- {opt}
136
- </button>
137
- ))}
138
- </div>
139
- );
140
- }
141
-
142
- function MultiselectRow({
143
- options,
144
- onSubmit,
145
- }: {
146
- options: string[];
147
- onSubmit: (answer: string) => void;
148
- }) {
149
- const [picked, setPicked] = useState<Set<string>>(new Set());
150
- const toggle = (opt: string) =>
151
- setPicked((prev) => {
152
- const next = new Set(prev);
153
- if (next.has(opt)) next.delete(opt);
154
- else next.add(opt);
155
- return next;
156
- });
157
- return (
158
- <div className="space-y-2">
159
- <div className="flex flex-wrap gap-1.5">
160
- {options.map((opt) => (
161
- <button
162
- key={opt}
163
- onClick={() => toggle(opt)}
164
- className={`px-2.5 py-1 text-xs rounded border ${
165
- picked.has(opt)
166
- ? "bg-purple-500/20 border-purple-500"
167
- : "border-[var(--border-primary)] hover:bg-purple-500/10 hover:border-purple-500/40"
168
- }`}
169
- >
170
- {opt}
171
- </button>
172
- ))}
173
- </div>
174
- <div className="flex justify-end">
175
- <button
176
- onClick={() => onSubmit(JSON.stringify(Array.from(picked)))}
177
- disabled={picked.size === 0}
178
- className="px-3 py-1 text-xs rounded bg-purple-500 text-white hover:bg-purple-600 disabled:opacity-50 disabled:cursor-not-allowed"
179
- >
180
- Submit ({picked.size})
181
- </button>
182
- </div>
183
- </div>
184
- );
185
- }
186
-
187
- function InputRow({
188
- defaultValue,
189
- onSubmit,
190
- }: {
191
- defaultValue?: string;
192
- onSubmit: (answer: string) => void;
193
- }) {
194
- const [val, setVal] = useState(defaultValue ?? "");
195
- return (
196
- <form
197
- onSubmit={(e) => {
198
- e.preventDefault();
199
- onSubmit(val);
200
- }}
201
- className="flex gap-2"
202
- >
203
- <input
204
- autoFocus
205
- type="text"
206
- value={val}
207
- onChange={(e) => setVal(e.target.value)}
208
- className="flex-1 px-2 py-1 text-xs bg-[var(--bg-surface)] border border-[var(--border-primary)] rounded focus:outline-none focus:border-purple-500"
209
- />
210
- <button
211
- type="submit"
212
- className="px-3 py-1 text-xs rounded bg-purple-500 text-white hover:bg-purple-600"
213
- >
214
- Submit
215
- </button>
216
- </form>
217
- );
218
- }
@@ -1,58 +0,0 @@
1
- /**
2
- * FlowQuestionTranscriptPill — collapsed pill rendering an answered or
3
- * cancelled flow-question prompt in the FlowDashboard upper-slot
4
- * transcript. The pending head is rendered by FlowQuestionCard; this
5
- * pill covers everything else (resolved / cancelled / dismissed).
6
- *
7
- * See change: fix-flows-plugin-polish (C3).
8
- */
9
- import React from "react";
10
- import { Icon } from "@mdi/react";
11
- import { mdiCheckCircle, mdiCloseCircle, mdiHelpCircleOutline } from "@mdi/js";
12
-
13
- export interface FlowQuestionTranscriptPillProps {
14
- question: string;
15
- /** Resolved answer (string for non-multiselect, JSON array for multiselect). */
16
- answer?: string;
17
- status: "resolved" | "cancelled" | "dismissed" | "pending";
18
- }
19
-
20
- export function FlowQuestionTranscriptPill({
21
- question,
22
- answer,
23
- status,
24
- }: FlowQuestionTranscriptPillProps) {
25
- const { iconPath, color } =
26
- status === "resolved"
27
- ? { iconPath: mdiCheckCircle, color: "text-green-400" }
28
- : status === "cancelled" || status === "dismissed"
29
- ? { iconPath: mdiCloseCircle, color: "text-[var(--text-muted)]" }
30
- : { iconPath: mdiHelpCircleOutline, color: "text-purple-400" };
31
-
32
- const displayAnswer = (() => {
33
- if (typeof answer !== "string") return null;
34
- // For multiselect answers stored as JSON array, render compactly.
35
- try {
36
- const parsed = JSON.parse(answer);
37
- if (Array.isArray(parsed)) return parsed.join(", ");
38
- } catch {
39
- // fall through
40
- }
41
- return answer;
42
- })();
43
-
44
- return (
45
- <div
46
- data-testid="flow-question-transcript-pill"
47
- className="mt-1 px-2 py-1 border border-[var(--border-subtle)] bg-[var(--bg-tertiary)] rounded text-[11px] flex items-center gap-2"
48
- >
49
- <Icon path={iconPath} size={0.45} className={`${color} flex-shrink-0`} />
50
- <span className="text-[var(--text-secondary)] truncate flex-1 min-w-0">{question}</span>
51
- {displayAnswer && (
52
- <span className={`${color} font-medium truncate flex-shrink-0 max-w-[40%]`}>
53
- → {displayAnswer}
54
- </span>
55
- )}
56
- </div>
57
- );
58
- }