@blackbelt-technology/pi-dashboard-flows-plugin 0.0.0-test-darwin-x64.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.
@@ -0,0 +1,137 @@
1
+ import React, { useState, type ReactNode } from "react";
2
+ import { Icon } from "@mdi/react";
3
+ import { mdiCloseCircleOutline, mdiCheckCircle, mdiAlertCircle, mdiStopCircle, mdiCloseCircle, mdiCircleOutline, mdiChevronRight, mdiChevronDown, mdiFileDocumentOutline } from "@mdi/js";
4
+ import type { FlowState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
5
+ import { FlowGraph, flowStateToGraphSteps } from "./FlowGraph.js";
6
+
7
+ function formatDuration(ms: number): string {
8
+ const sec = Math.floor(ms / 1000);
9
+ const min = Math.floor(sec / 60);
10
+ return min > 0 ? `${min}m ${sec % 60}s` : `${sec}s`;
11
+ }
12
+
13
+ const statusConfig: Record<string, { icon: ReactNode; label: string; color: string }> = {
14
+ success: { icon: <Icon path={mdiCheckCircle} size={0.55} />, label: "complete", color: "text-green-400" },
15
+ error: { icon: <Icon path={mdiAlertCircle} size={0.55} />, label: "failed", color: "text-red-400" },
16
+ aborted: { icon: <Icon path={mdiStopCircle} size={0.55} />, label: "aborted", color: "text-orange-400" },
17
+ };
18
+
19
+ export function FlowSummary({
20
+ flowState,
21
+ onAgentClick,
22
+ onDismiss,
23
+ onSendPrompt,
24
+ onViewYaml,
25
+ }: {
26
+ flowState: FlowState;
27
+ onAgentClick: (agentName: string) => void;
28
+ onDismiss: () => void;
29
+ onSendPrompt?: (text: string) => void;
30
+ onViewYaml?: () => void;
31
+ }) {
32
+ const [collapsed, setCollapsed] = useState(false);
33
+ const agents = Array.from(flowState.agents.values());
34
+ const { icon, label, color } = statusConfig[flowState.status] ?? statusConfig.success;
35
+ const totalDuration = flowState.flowResult?.totalDuration as number | undefined;
36
+ const totalFiles = agents.reduce((sum, a) => sum + (a.files?.length ?? 0), 0);
37
+
38
+ return (
39
+ <div className="bg-[var(--bg-secondary)] border-b border-[var(--border-subtle)] px-3 py-2">
40
+ {/* Header */}
41
+ <div className="flex items-center gap-2 mb-1.5">
42
+ <span
43
+ className="inline-flex text-[var(--text-tertiary)] cursor-pointer"
44
+ onClick={() => setCollapsed(!collapsed)}
45
+ >
46
+ <Icon path={collapsed ? mdiChevronRight : mdiChevronDown} size={0.6} />
47
+ </span>
48
+ <span className={`${color} inline-flex`}>{icon}</span>
49
+ <span className="text-sm text-[var(--text-primary)] flex-1">
50
+ {flowState.flowName} {label}
51
+ <span className="text-[var(--text-tertiary)] ml-1.5">
52
+ · {agents.length} steps
53
+ {totalDuration ? ` · ${formatDuration(totalDuration)}` : ""}
54
+ {totalFiles > 0 ? ` · ${totalFiles} files` : ""}
55
+ </span>
56
+ </span>
57
+ <button
58
+ onClick={onDismiss}
59
+ className="text-[10px] px-1.5 py-0.5 rounded border border-[var(--border-subtle)] text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"
60
+ >
61
+ <Icon path={mdiCloseCircleOutline} size={0.4} className="inline mr-0.5" />Dismiss
62
+ </button>
63
+ </div>
64
+
65
+ {/* DAG graph + Agent list -- collapsible */}
66
+ <div className={`group-collapse ${collapsed ? "collapsed" : "expanded"}`}>
67
+ <div>
68
+ {/* DAG graph showing final state */}
69
+ <FlowGraph
70
+ steps={flowStateToGraphSteps(flowState)}
71
+ />
72
+ {onViewYaml && (
73
+ <div className="mt-1">
74
+ <button
75
+ onClick={onViewYaml}
76
+ className="text-[var(--text-tertiary)] hover:text-blue-400 transition-colors p-0.5 rounded hover:bg-[var(--bg-surface)] inline-flex items-center"
77
+ title="View flow YAML"
78
+ >
79
+ <Icon path={mdiFileDocumentOutline} size={0.5} />
80
+ </button>
81
+ </div>
82
+ )}
83
+
84
+ {/* Per-agent status list */}
85
+ <div className="space-y-0.5">
86
+ {agents.map(agent => {
87
+ const agentIconPath = agent.status === "complete" ? mdiCheckCircle
88
+ : agent.status === "error" ? mdiCloseCircle
89
+ : agent.status === "blocked" ? mdiAlertCircle
90
+ : mdiCircleOutline;
91
+ const agentColor = agent.status === "complete" ? "text-green-400"
92
+ : agent.status === "error" ? "text-red-400"
93
+ : agent.status === "blocked" ? "text-orange-400"
94
+ : "text-[var(--text-tertiary)]";
95
+ const fileCount = agent.files?.length ?? 0;
96
+
97
+ return (
98
+ <div
99
+ key={agent.stepId || agent.agentName}
100
+ onClick={() => onAgentClick(agent.stepId || agent.agentName)}
101
+ className="flex items-center gap-1.5 text-[11px] cursor-pointer hover:bg-[var(--bg-tertiary)] rounded px-1 py-0.5"
102
+ >
103
+ <span className={`${agentColor} inline-flex`}><Icon path={agentIconPath} size={0.45} /></span>
104
+ <span className="text-[var(--text-primary)]">{agent.label || agent.stepId || agent.agentName}</span>
105
+ {(agent.stepType === "fork" || agent.stepType === "agent-decision") && (
106
+ <span className="text-[9px] text-amber-400/60">◇</span>
107
+ )}
108
+ {agent.stepType === "agent-loop-decision" && (
109
+ <span className="text-[9px] text-purple-400/60">↻</span>
110
+ )}
111
+ {fileCount > 0 && (
112
+ <span className="text-[var(--text-muted)]">({fileCount} files)</span>
113
+ )}
114
+ {agent.summary && (
115
+ <span className="text-[var(--text-tertiary)] truncate flex-1">{agent.summary}</span>
116
+ )}
117
+ </div>
118
+ );
119
+ })}
120
+ </div>
121
+ </div>
122
+ </div>
123
+
124
+ {/* Next step suggestion */}
125
+ {flowState.nextStep && onSendPrompt && (
126
+ <div className="mt-1.5 pt-1.5 border-t border-[var(--border-subtle)]">
127
+ <button
128
+ onClick={() => onSendPrompt(`/${flowState.nextStep}`)}
129
+ className="text-[11px] px-2 py-1 rounded border border-blue-500/30 text-blue-400 hover:bg-blue-500/10"
130
+ >
131
+ Next: /{flowState.nextStep}
132
+ </button>
133
+ </div>
134
+ )}
135
+ </div>
136
+ );
137
+ }
@@ -0,0 +1,52 @@
1
+ import React from "react";
2
+
3
+ export interface FlowTab {
4
+ id: string;
5
+ label: string;
6
+ isActive: boolean;
7
+ }
8
+
9
+ export function FlowTabBar({
10
+ tabs,
11
+ activeTabId,
12
+ followMode,
13
+ onTabClick,
14
+ onToggleFollow,
15
+ }: {
16
+ tabs: FlowTab[];
17
+ activeTabId: string;
18
+ followMode: boolean;
19
+ onTabClick: (tabId: string) => void;
20
+ onToggleFollow: () => void;
21
+ }) {
22
+ if (tabs.length <= 1) return null; // No tab bar for single flow
23
+
24
+ return (
25
+ <div className="flex items-center gap-1 mb-1.5 overflow-x-auto text-[11px]">
26
+ {tabs.map((tab) => (
27
+ <button
28
+ key={tab.id}
29
+ onClick={() => onTabClick(tab.id)}
30
+ className={`px-2 py-0.5 rounded border whitespace-nowrap ${
31
+ tab.id === activeTabId
32
+ ? "border-blue-500/40 text-blue-400 bg-blue-500/10"
33
+ : "border-[var(--border-subtle)] text-[var(--text-tertiary)] hover:text-[var(--text-secondary)]"
34
+ }`}
35
+ >
36
+ {tab.label}
37
+ </button>
38
+ ))}
39
+ <button
40
+ onClick={onToggleFollow}
41
+ className={`ml-auto px-1.5 py-0.5 rounded border text-[10px] whitespace-nowrap ${
42
+ followMode
43
+ ? "border-green-500/40 text-green-400 bg-green-500/10"
44
+ : "border-[var(--border-subtle)] text-[var(--text-tertiary)]"
45
+ }`}
46
+ title={followMode ? "Following latest active flow" : "Click to follow latest active flow"}
47
+ >
48
+ FOLLOW
49
+ </button>
50
+ </div>
51
+ );
52
+ }
@@ -0,0 +1,178 @@
1
+ import React, { useState } from "react";
2
+ import { Icon } from "@mdi/react";
3
+ import { mdiPlay, mdiPlus } from "@mdi/js";
4
+ import type { FlowInfo } from "@blackbelt-technology/pi-dashboard-shared/types.js";
5
+ import { FlowLaunchDialog } from "./FlowLaunchDialog.js";
6
+ import { ConfirmDialog } from "../../../client/src/components/ConfirmDialog.js";
7
+ import { SearchableSelectDialog, type SelectOption } from "../../../client/src/components/SearchableSelectDialog.js";
8
+
9
+ export function SessionFlowActions({
10
+ flows,
11
+ hasFlowsNew,
12
+ hasFlowsEdit,
13
+ hasFlowsDelete,
14
+ onFlowAction,
15
+ }: {
16
+ flows: FlowInfo[];
17
+ hasFlowsNew: boolean;
18
+ hasFlowsEdit?: boolean;
19
+ hasFlowsDelete?: boolean;
20
+ onFlowAction: (action: string, opts?: { flowName?: string; task?: string; description?: string }) => void;
21
+ }) {
22
+ const [pickerOpen, setPickerOpen] = useState(false);
23
+ const [editPickerOpen, setEditPickerOpen] = useState(false);
24
+ const [editFlowName, setEditFlowName] = useState<string | null>(null);
25
+ const [deletePickerOpen, setDeletePickerOpen] = useState(false);
26
+ const [deleteFlowName, setDeleteFlowName] = useState<string | null>(null);
27
+ const [selectedFlow, setSelectedFlow] = useState<FlowInfo | null>(null);
28
+ const [newFlowOpen, setNewFlowOpen] = useState(false);
29
+
30
+ if (flows.length === 0 && !hasFlowsNew) return null;
31
+
32
+ const flowOptions: SelectOption[] = flows.map((f) => ({
33
+ value: f.name,
34
+ label: f.name,
35
+ description: f.description,
36
+ }));
37
+
38
+ return (
39
+ <>
40
+ <div className="mt-1.5 pt-1.5 border-t border-[var(--border-subtle)]">
41
+ <div className="flex items-center gap-1.5 flex-wrap">
42
+ <span className="text-[10px] text-[var(--text-muted)]">Flows:</span>
43
+ {flows.length > 0 && (
44
+ <button
45
+ onClick={(e) => { e.stopPropagation(); setPickerOpen(true); }}
46
+ className="text-[10px] px-1.5 py-0.5 rounded border border-blue-500/30 text-blue-400 hover:bg-blue-500/10"
47
+ >
48
+ <Icon path={mdiPlay} size={0.4} className="inline mr-0.5" />Run Flow...
49
+ </button>
50
+ )}
51
+ {hasFlowsNew && (
52
+ <button
53
+ onClick={(e) => { e.stopPropagation(); setNewFlowOpen(true); }}
54
+ className="text-[10px] px-1.5 py-0.5 rounded border border-purple-500/30 text-purple-400 hover:bg-purple-500/10"
55
+ >
56
+ <Icon path={mdiPlus} size={0.4} className="inline mr-0.5" />New Flow
57
+ </button>
58
+ )}
59
+ {hasFlowsEdit && flows.length > 0 && (
60
+ <button
61
+ onClick={(e) => { e.stopPropagation(); setEditPickerOpen(true); }}
62
+ className="text-[10px] px-1.5 py-0.5 rounded border border-[var(--border-subtle)] text-[var(--text-tertiary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"
63
+ >
64
+ &#x270E;&#xFE0E; Edit
65
+ </button>
66
+ )}
67
+ {hasFlowsDelete && flows.length > 0 && (
68
+ <button
69
+ onClick={(e) => { e.stopPropagation(); setDeletePickerOpen(true); }}
70
+ className="text-[10px] px-1.5 py-0.5 rounded border border-[var(--border-subtle)] text-[var(--text-tertiary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"
71
+ >
72
+ &#215; Delete
73
+ </button>
74
+ )}
75
+ </div>
76
+ </div>
77
+
78
+ {/* Run: pick flow → task dialog */}
79
+ {pickerOpen && (
80
+ <SearchableSelectDialog
81
+ title="Run Flow"
82
+ options={flowOptions}
83
+ placeholder="Search flows..."
84
+ emptyMessage="No flows available"
85
+ onSelect={(value) => {
86
+ const flow = flows.find(f => f.name === value);
87
+ if (flow) setSelectedFlow(flow);
88
+ setPickerOpen(false);
89
+ }}
90
+ onCancel={() => setPickerOpen(false)}
91
+ />
92
+ )}
93
+
94
+ {selectedFlow && (
95
+ <FlowLaunchDialog
96
+ flowName={selectedFlow.name}
97
+ description={selectedFlow.description}
98
+ onSubmit={(task) => {
99
+ onFlowAction("run", { flowName: selectedFlow.name, task: task || undefined });
100
+ setSelectedFlow(null);
101
+ }}
102
+ onCancel={() => setSelectedFlow(null)}
103
+ />
104
+ )}
105
+
106
+ {/* Edit: pick flow → modification input dialog */}
107
+ {editPickerOpen && (
108
+ <SearchableSelectDialog
109
+ title="Edit Flow"
110
+ options={flowOptions}
111
+ placeholder="Search flows..."
112
+ emptyMessage="No flows available"
113
+ onSelect={(value) => {
114
+ setEditFlowName(value);
115
+ setEditPickerOpen(false);
116
+ }}
117
+ onCancel={() => setEditPickerOpen(false)}
118
+ />
119
+ )}
120
+
121
+ {editFlowName && (
122
+ <FlowLaunchDialog
123
+ flowName={editFlowName}
124
+ description="Describe how this flow should be updated"
125
+ onSubmit={(desc) => {
126
+ if (desc.trim()) {
127
+ onFlowAction("edit", { flowName: editFlowName, description: desc.trim() });
128
+ }
129
+ setEditFlowName(null);
130
+ }}
131
+ onCancel={() => setEditFlowName(null)}
132
+ />
133
+ )}
134
+
135
+ {/* Delete: pick flow → confirm dialog */}
136
+ {deletePickerOpen && (
137
+ <SearchableSelectDialog
138
+ title="Delete Flow"
139
+ options={flowOptions}
140
+ placeholder="Search flows..."
141
+ emptyMessage="No flows available"
142
+ onSelect={(value) => {
143
+ setDeleteFlowName(value);
144
+ setDeletePickerOpen(false);
145
+ }}
146
+ onCancel={() => setDeletePickerOpen(false)}
147
+ />
148
+ )}
149
+
150
+ {deleteFlowName && (
151
+ <ConfirmDialog
152
+ message={`Delete flow "${deleteFlowName}"? This will remove the flow file and any associated agents.`}
153
+ confirmLabel="Delete"
154
+ onConfirm={() => {
155
+ onFlowAction("delete", { flowName: deleteFlowName });
156
+ setDeleteFlowName(null);
157
+ }}
158
+ onCancel={() => setDeleteFlowName(null)}
159
+ />
160
+ )}
161
+
162
+ {/* New: description dialog */}
163
+ {newFlowOpen && (
164
+ <FlowLaunchDialog
165
+ flowName="flows:new"
166
+ description="Design a new flow with the Flow Architect"
167
+ onSubmit={(task) => {
168
+ if (task.trim()) {
169
+ onFlowAction("new", { description: task.trim() });
170
+ }
171
+ setNewFlowOpen(false);
172
+ }}
173
+ onCancel={() => setNewFlowOpen(false)}
174
+ />
175
+ )}
176
+ </>
177
+ );
178
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Client entry barrel for the flows plugin.
3
+ *
4
+ * Re-exports every flow-related React component so the dashboard shell
5
+ * can import them via `@blackbelt-technology/pi-dashboard-flows-plugin/client`.
6
+ *
7
+ * Also exports the `hasActiveFlow` predicate consumed by the
8
+ * `pi-dashboard-plugin` manifest's `session-card-badge` claim.
9
+ */
10
+ import type { DashboardSession } from "@blackbelt-technology/pi-dashboard-shared/types.js";
11
+
12
+ export { FlowDashboard } from "./FlowDashboard.js";
13
+ export { FlowAgentCard } from "./FlowAgentCard.js";
14
+ export { FlowAgentDetail } from "./FlowAgentDetail.js";
15
+ export { FlowSummary } from "./FlowSummary.js";
16
+ export { FlowGraph, flowStateToGraphSteps, architectStepsToGraphSteps, computeLayout } from "./FlowGraph.js";
17
+ export { FlowArchitect, FlowArchitectDetail, ArchitectInputPrompt } from "./FlowArchitect.js";
18
+ export { FlowActivityBadge } from "./FlowActivityBadge.js";
19
+ export { FlowLaunchDialog } from "./FlowLaunchDialog.js";
20
+ export { FlowTabBar } from "./FlowTabBar.js";
21
+ export { SessionFlowActions } from "./SessionFlowActions.js";
22
+
23
+ /**
24
+ * Predicate for the `session-card-badge` slot claim.
25
+ * The slot consumer skips claims whose predicate returns false.
26
+ */
27
+ export function hasActiveFlow(session: DashboardSession): boolean {
28
+ return Boolean(session.activeFlowName);
29
+ }