@blackbelt-technology/pi-dashboard-flows-plugin 0.9.0 → 0.10.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 +14 -5
- package/src/client/FlowAuthorPromptDialog.tsx +5 -4
- package/src/client/FlowQuestionCard.tsx +2 -0
- package/src/client/FlowsSettings.tsx +18 -21
- package/src/client/SessionFlowActions.tsx +27 -330
- package/src/client/SessionFlowMenuClaim.tsx +265 -0
- package/src/client/flowsActionsGate.ts +35 -0
- package/src/client/index.tsx +8 -7
- package/src/client/shouldRender.ts +7 -22
- package/src/i18n.ts +6 -0
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.10.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": {
|
|
@@ -49,18 +49,25 @@
|
|
|
49
49
|
"component": "SessionFlowActionsClaim",
|
|
50
50
|
"shouldRender": "shouldRenderFlowsSubcard"
|
|
51
51
|
},
|
|
52
|
+
{
|
|
53
|
+
"slot": "session-card-action-bar",
|
|
54
|
+
"component": "SessionFlowMenuClaim"
|
|
55
|
+
},
|
|
52
56
|
{
|
|
53
57
|
"slot": "content-header-sticky",
|
|
54
|
-
"component": "FlowDashboardClaim"
|
|
58
|
+
"component": "FlowDashboardClaim",
|
|
59
|
+
"module": "./src/client/FlowDashboard.tsx"
|
|
55
60
|
},
|
|
56
61
|
{
|
|
57
62
|
"slot": "content-view",
|
|
58
63
|
"component": "FlowYamlPreviewClaim",
|
|
64
|
+
"module": "./src/client/FlowYamlPreview.tsx",
|
|
59
65
|
"predicate": "isFlowYamlPreviewActive"
|
|
60
66
|
},
|
|
61
67
|
{
|
|
62
68
|
"slot": "tool-renderer",
|
|
63
69
|
"component": "FlowWriteToolRenderer",
|
|
70
|
+
"module": "./src/client/FlowWriteToolRenderer.tsx",
|
|
64
71
|
"toolName": "flow_write"
|
|
65
72
|
},
|
|
66
73
|
{
|
|
@@ -71,11 +78,13 @@
|
|
|
71
78
|
{
|
|
72
79
|
"slot": "settings-section",
|
|
73
80
|
"component": "FlowsSettings",
|
|
81
|
+
"module": "./src/client/FlowsSettings.tsx",
|
|
74
82
|
"tab": "general"
|
|
75
83
|
},
|
|
76
84
|
{
|
|
77
85
|
"slot": "automation-action-editor",
|
|
78
86
|
"component": "FlowInputWiringClaim",
|
|
87
|
+
"module": "./src/client/FlowInputWiring.tsx",
|
|
79
88
|
"config": {
|
|
80
89
|
"actionId": "flows.run"
|
|
81
90
|
}
|
|
@@ -89,9 +98,9 @@
|
|
|
89
98
|
},
|
|
90
99
|
"//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.",
|
|
91
100
|
"dependencies": {
|
|
92
|
-
"@blackbelt-technology/dashboard-plugin-runtime": "^0.
|
|
93
|
-
"@blackbelt-technology/pi-dashboard-client-utils": "^0.
|
|
94
|
-
"@blackbelt-technology/pi-dashboard-shared": "^0.
|
|
101
|
+
"@blackbelt-technology/dashboard-plugin-runtime": "^0.10.0",
|
|
102
|
+
"@blackbelt-technology/pi-dashboard-client-utils": "^0.10.0",
|
|
103
|
+
"@blackbelt-technology/pi-dashboard-shared": "^0.10.0",
|
|
95
104
|
"@fastify/rate-limit": "^11.2.0",
|
|
96
105
|
"@mdi/js": "^7.4.47",
|
|
97
106
|
"@mdi/react": "^1.6.1",
|
|
@@ -1,8 +1,9 @@
|
|
|
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
1
|
import { useUiPrimitive } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
2
|
+
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
3
|
+
import { mdiPencil } from "@mdi/js";
|
|
4
|
+
import { Icon } from "@mdi/react";
|
|
5
|
+
import type React from "react";
|
|
6
|
+
import { useEffect, useRef, useState } from "react";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Intent-capture step for the manage-flows authoring launcher.
|
|
@@ -49,6 +49,8 @@ export function FlowQuestionCard({
|
|
|
49
49
|
return (
|
|
50
50
|
<div
|
|
51
51
|
data-testid="flow-question-card"
|
|
52
|
+
data-widget-bar-slot=""
|
|
53
|
+
tabIndex={-1}
|
|
52
54
|
className="mt-2 mb-2 p-3 border border-purple-500/40 bg-purple-500/5 rounded"
|
|
53
55
|
>
|
|
54
56
|
<div className="flex items-start gap-2 mb-2">
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* panel's Save). See change: rework-flows-plugin-for-new-pi-flows.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { useSettingsDraftSource, useT } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
13
|
+
import { ToggleField, useSettingsDraftSource, useT } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
14
14
|
import { usePluginConfig, usePluginSend } from "@blackbelt-technology/dashboard-plugin-runtime/context";
|
|
15
15
|
import type React from "react";
|
|
16
16
|
import { useCallback, useRef, useState } from "react";
|
|
@@ -40,29 +40,26 @@ export function FlowsSettings(): React.ReactElement {
|
|
|
40
40
|
const reset = useCallback(() => setEditFlow(baseRef.current), []);
|
|
41
41
|
useSettingsDraftSource({ id: "plugin:flows", isDirty, commit, reset });
|
|
42
42
|
|
|
43
|
+
const codeCls = "font-mono text-[12px] text-[var(--text-primary)]";
|
|
43
44
|
return (
|
|
44
45
|
// No self-header: the host owns identity + status chrome (design D1).
|
|
45
|
-
<div>
|
|
46
|
-
<p className="text-xs text-[var(--text-
|
|
47
|
-
Multi-agent
|
|
46
|
+
<div className="space-y-3">
|
|
47
|
+
<p className="text-xs text-[var(--text-secondary)]">
|
|
48
|
+
{t("settingsIntro", undefined, "Multi-agent workflows. This is the default for every session.")}
|
|
48
49
|
</p>
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
edit-flow skill model-visible. Off by default.
|
|
63
|
-
</span>
|
|
64
|
-
</span>
|
|
65
|
-
</label>
|
|
50
|
+
<ToggleField
|
|
51
|
+
label={t("editModeLabel", undefined, "Edit mode")}
|
|
52
|
+
hint={
|
|
53
|
+
<>
|
|
54
|
+
{t("editModeHintPre", undefined, "Lets the main session create and change flows and agents. Turns on")}{" "}
|
|
55
|
+
<code className={codeCls}>flow_agents</code> / <code className={codeCls}>flow_write</code>{" "}
|
|
56
|
+
{t("editModeHintPost", undefined, "and the edit-flow skill. Off by default.")}
|
|
57
|
+
</>
|
|
58
|
+
}
|
|
59
|
+
value={editFlow}
|
|
60
|
+
onChange={setEditFlow}
|
|
61
|
+
testIds={{ control: "flows-edit-mode-toggle" }}
|
|
62
|
+
/>
|
|
66
63
|
</div>
|
|
67
64
|
);
|
|
68
65
|
}
|
|
@@ -1,358 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
useSessionEvents,
|
|
5
|
-
useT,
|
|
6
|
-
useUiPrimitive,
|
|
7
|
-
} from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
8
|
-
import { usePluginConfig } from "@blackbelt-technology/dashboard-plugin-runtime/context";
|
|
9
|
-
import type { UiSelectOption as SelectOption } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
10
|
-
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
11
|
-
import type {
|
|
12
|
-
CommandInfo,
|
|
13
|
-
DashboardSession,
|
|
14
|
-
FlowInfo,
|
|
15
|
-
FlowState,
|
|
16
|
-
} from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
17
|
-
import { mdiEyeOutline, mdiPencil, mdiPlay } from "@mdi/js";
|
|
18
|
-
import { Icon } from "@mdi/react";
|
|
19
|
-
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
1
|
+
import { usePluginSend } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
2
|
+
import type { DashboardSession, FlowState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
3
|
+
import React from "react";
|
|
20
4
|
import { FlowActivityBadge } from "./FlowActivityBadge.js";
|
|
21
|
-
import { FlowAuthorPromptDialog } from "./FlowAuthorPromptDialog.js";
|
|
22
|
-
import { FlowLaunchDialog } from "./FlowLaunchDialog.js";
|
|
23
5
|
import { useFlowsSessionState } from "./FlowsSessionStateContext.js";
|
|
24
|
-
import type { FlowsPluginConfig } from "./FlowsSettings.js";
|
|
25
|
-
import { newAttachmentId, setAttachment } from "./flow-attach-store.js";
|
|
26
|
-
import { makeSafeSend } from "./send-safe.js";
|
|
27
|
-
|
|
28
|
-
/** Open flow… — disabled (with tooltip) while any flow runs. See change:
|
|
29
|
-
* attach-flow-before-run (D7). */
|
|
30
|
-
function OpenFlowButton({ disabled, onClick }: { disabled: boolean; onClick: () => void }) {
|
|
31
|
-
const t = useT();
|
|
32
|
-
return (
|
|
33
|
-
<button
|
|
34
|
-
onClick={(e) => { e.stopPropagation(); onClick(); }}
|
|
35
|
-
disabled={disabled}
|
|
36
|
-
title={disabled ? t("openFlowDisabledRunning", undefined, "A flow is running") : undefined}
|
|
37
|
-
className="text-[10px] px-1.5 py-0.5 rounded border border-[var(--border-subtle)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] disabled:opacity-50 disabled:cursor-not-allowed"
|
|
38
|
-
data-testid="flows-open-button"
|
|
39
|
-
>
|
|
40
|
-
<Icon path={mdiEyeOutline} size={0.4} className="inline mr-0.5" />{t("openFlowButton", undefined, "Open flow…")}
|
|
41
|
-
</button>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function isAnyFlowRunning(
|
|
46
|
-
flowState: FlowState | null | undefined,
|
|
47
|
-
flowStates: ReadonlyMap<string, FlowState> | undefined,
|
|
48
|
-
): boolean {
|
|
49
|
-
if (flowState?.status === "running") return true;
|
|
50
|
-
return flowStates ? Array.from(flowStates.values()).some((s) => s.status === "running") : false;
|
|
51
|
-
}
|
|
52
6
|
|
|
7
|
+
/**
|
|
8
|
+
* FLOWS-subcard body: flow STATUS only — `FlowActivityBadge` (with Abort while
|
|
9
|
+
* running) when the session has a flow state, else null. The flow actions
|
|
10
|
+
* (Run / Open / New-Edit / Delete), their dialogs and the edit-mode reconcile
|
|
11
|
+
* live in `SessionFlowMenuClaim`. See change: add-session-actions-flyout (D12).
|
|
12
|
+
*/
|
|
53
13
|
export function SessionFlowActions({
|
|
54
|
-
flows,
|
|
55
|
-
editMode,
|
|
56
|
-
hasFlowsDelete,
|
|
57
|
-
onFlowAction,
|
|
58
|
-
onEditFlow,
|
|
59
14
|
flowState,
|
|
60
|
-
flowStates,
|
|
61
15
|
onAbortFlow,
|
|
62
|
-
onOpenFlow,
|
|
63
16
|
}: {
|
|
64
|
-
|
|
65
|
-
/** Edit-mode on → show the New / Edit launcher (authoring via the skill). */
|
|
66
|
-
editMode: boolean;
|
|
67
|
-
hasFlowsDelete?: boolean;
|
|
68
|
-
onFlowAction: (action: string, opts?: { flowName?: string; task?: string; description?: string }) => void;
|
|
69
|
-
/**
|
|
70
|
-
* Launch the manage-flows skill for an existing flow (name) or a new flow
|
|
71
|
-
* (undefined), carrying the user's stated intent (description for new, change
|
|
72
|
-
* instruction for edit; empty string when none given).
|
|
73
|
-
*/
|
|
74
|
-
onEditFlow: (flowName: string | undefined, instruction: string) => void;
|
|
75
|
-
/** Current flow state for this session. Drives the status pill rendered above the action buttons. */
|
|
17
|
+
/** Current flow state for this session. Drives the status pill. */
|
|
76
18
|
flowState?: FlowState | null;
|
|
77
19
|
/** Dispatch flow_control abort. Called by the running-flow pill's Abort button. */
|
|
78
20
|
onAbortFlow?: () => void;
|
|
79
|
-
/** All flow states this session — Open is disabled while any is running. */
|
|
80
|
-
flowStates?: ReadonlyMap<string, FlowState>;
|
|
81
|
-
/** Attach a flow to the session flow slot before it runs. See change:
|
|
82
|
-
* attach-flow-before-run (D7). */
|
|
83
|
-
onOpenFlow?: (flow: FlowInfo) => void;
|
|
84
21
|
}) {
|
|
85
|
-
const t = useT();
|
|
86
|
-
const ConfirmDialog = useUiPrimitive(UI_PRIMITIVE_KEYS.confirmDialog);
|
|
87
|
-
const SearchableSelectDialog = useUiPrimitive(UI_PRIMITIVE_KEYS.searchableSelectDialog);
|
|
88
|
-
const [pickerOpen, setPickerOpen] = useState(false);
|
|
89
|
-
const [openPickerOpen, setOpenPickerOpen] = useState(false);
|
|
90
|
-
const [editPickerOpen, setEditPickerOpen] = useState(false);
|
|
91
|
-
// After picking from the edit launcher, capture intent before launching the skill.
|
|
92
|
-
const [authorTarget, setAuthorTarget] = useState<{ mode: "new" | "edit"; flowName?: string } | null>(null);
|
|
93
|
-
const [deletePickerOpen, setDeletePickerOpen] = useState(false);
|
|
94
|
-
const [deleteFlowName, setDeleteFlowName] = useState<string | null>(null);
|
|
95
|
-
const [selectedFlow, setSelectedFlow] = useState<FlowInfo | null>(null);
|
|
96
|
-
|
|
97
22
|
// Compute running-flow badge inputs from flowState (when present).
|
|
98
23
|
// See change: fix-flows-plugin-polish (A5 + A6).
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
(a) => a.status === "complete" || a.status === "error" || a.status === "blocked",
|
|
105
|
-
).length;
|
|
106
|
-
return {
|
|
107
|
-
flowName: flowState.flowName,
|
|
108
|
-
agentsDone: done,
|
|
109
|
-
agentsTotal: total,
|
|
110
|
-
status: flowState.status,
|
|
111
|
-
};
|
|
112
|
-
})()
|
|
113
|
-
: null;
|
|
114
|
-
|
|
115
|
-
if (flows.length === 0 && !editMode && !badgeProps) return null;
|
|
116
|
-
|
|
117
|
-
const anyRunning = isAnyFlowRunning(flowState, flowStates);
|
|
118
|
-
|
|
119
|
-
const flowOptions: SelectOption[] = flows.map((f) => ({
|
|
120
|
-
value: f.name,
|
|
121
|
-
label: f.name,
|
|
122
|
-
description: f.description,
|
|
123
|
-
}));
|
|
124
|
-
// Edit launcher options: existing flows + a "new flow" sentinel.
|
|
125
|
-
const editOptions: SelectOption[] = [
|
|
126
|
-
{ value: "__new__", label: t("newFlowOption", undefined, "+ New flow"), description: t("newFlowOptionDesc", undefined, "Author a new flow with the edit-flow skill") },
|
|
127
|
-
...flowOptions,
|
|
128
|
-
];
|
|
129
|
-
|
|
24
|
+
if (!flowState) return null;
|
|
25
|
+
const agents = flowState.agents;
|
|
26
|
+
const done = Array.from(agents.values()).filter(
|
|
27
|
+
(a) => a.status === "complete" || a.status === "error" || a.status === "blocked",
|
|
28
|
+
).length;
|
|
130
29
|
return (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
)}
|
|
139
|
-
<div className="flex items-center gap-1.5 flex-wrap">
|
|
140
|
-
{flows.length > 0 && (
|
|
141
|
-
<button
|
|
142
|
-
onClick={(e) => { e.stopPropagation(); setPickerOpen(true); }}
|
|
143
|
-
className="text-[10px] px-1.5 py-0.5 rounded border border-blue-500/30 text-blue-400 hover:bg-blue-500/10"
|
|
144
|
-
>
|
|
145
|
-
<Icon path={mdiPlay} size={0.4} className="inline mr-0.5" />{t("runFlowButton", undefined, "Run Flow...")}
|
|
146
|
-
</button>
|
|
147
|
-
)}
|
|
148
|
-
{onOpenFlow && flows.length > 0 && (
|
|
149
|
-
<OpenFlowButton disabled={anyRunning} onClick={() => setOpenPickerOpen(true)} />
|
|
150
|
-
)}
|
|
151
|
-
{editMode && (
|
|
152
|
-
<button
|
|
153
|
-
onClick={(e) => { e.stopPropagation(); setEditPickerOpen(true); }}
|
|
154
|
-
className="text-[10px] px-1.5 py-0.5 rounded border border-purple-500/30 text-purple-400 hover:bg-purple-500/10"
|
|
155
|
-
data-testid="flows-new-edit-button"
|
|
156
|
-
>
|
|
157
|
-
<Icon path={mdiPencil} size={0.4} className="inline mr-0.5" />{t("newEditButton", undefined, "New / Edit…")}
|
|
158
|
-
</button>
|
|
159
|
-
)}
|
|
160
|
-
{hasFlowsDelete && flows.length > 0 && (
|
|
161
|
-
<button
|
|
162
|
-
onClick={(e) => { e.stopPropagation(); setDeletePickerOpen(true); }}
|
|
163
|
-
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)]"
|
|
164
|
-
>
|
|
165
|
-
× {t("delete", undefined, "Delete")}
|
|
166
|
-
</button>
|
|
167
|
-
)}
|
|
168
|
-
</div>
|
|
169
|
-
</div>
|
|
170
|
-
|
|
171
|
-
{/* Run: pick flow → task dialog */}
|
|
172
|
-
{pickerOpen && (
|
|
173
|
-
<SearchableSelectDialog
|
|
174
|
-
title={t("runFlowDialogTitle", undefined, "Run Flow")}
|
|
175
|
-
options={flowOptions}
|
|
176
|
-
placeholder={t("searchFlows", undefined, "Search flows...")}
|
|
177
|
-
emptyMessage={t("noFlowsAvailable", undefined, "No flows available")}
|
|
178
|
-
onSelect={(value) => {
|
|
179
|
-
const flow = flows.find(f => f.name === value);
|
|
180
|
-
if (flow) setSelectedFlow(flow);
|
|
181
|
-
setPickerOpen(false);
|
|
182
|
-
}}
|
|
183
|
-
onCancel={() => setPickerOpen(false)}
|
|
184
|
-
/>
|
|
185
|
-
)}
|
|
186
|
-
|
|
187
|
-
{selectedFlow && (
|
|
188
|
-
<FlowLaunchDialog
|
|
189
|
-
flowName={selectedFlow.name}
|
|
190
|
-
description={selectedFlow.description}
|
|
191
|
-
onSubmit={(task) => {
|
|
192
|
-
onFlowAction("run", { flowName: selectedFlow.name, task: task || undefined });
|
|
193
|
-
setSelectedFlow(null);
|
|
194
|
-
}}
|
|
195
|
-
onCancel={() => setSelectedFlow(null)}
|
|
196
|
-
/>
|
|
197
|
-
)}
|
|
198
|
-
|
|
199
|
-
{/* Open: pick flow → attach it to the flow slot (not started). */}
|
|
200
|
-
{openPickerOpen && onOpenFlow && (
|
|
201
|
-
<SearchableSelectDialog
|
|
202
|
-
title={t("openFlowDialogTitle", undefined, "Open flow")}
|
|
203
|
-
options={flowOptions}
|
|
204
|
-
placeholder={t("searchFlows", undefined, "Search flows...")}
|
|
205
|
-
emptyMessage={t("noFlowsAvailable", undefined, "No flows available")}
|
|
206
|
-
onSelect={(value) => {
|
|
207
|
-
const flow = flows.find((f) => f.name === value);
|
|
208
|
-
if (flow) onOpenFlow(flow);
|
|
209
|
-
setOpenPickerOpen(false);
|
|
210
|
-
}}
|
|
211
|
-
onCancel={() => setOpenPickerOpen(false)}
|
|
212
|
-
/>
|
|
213
|
-
)}
|
|
214
|
-
|
|
215
|
-
{/* New / Edit: pick an existing flow or "new" → launch the edit-flow skill */}
|
|
216
|
-
{editPickerOpen && (
|
|
217
|
-
<SearchableSelectDialog
|
|
218
|
-
title={t("newEditFlowTitle", undefined, "New / Edit flow")}
|
|
219
|
-
options={editOptions}
|
|
220
|
-
placeholder={t("pickFlowToEdit", undefined, "Pick a flow to edit, or + New flow…")}
|
|
221
|
-
emptyMessage={t("noFlowsYet", undefined, "No flows yet — pick + New flow")}
|
|
222
|
-
onSelect={(value) => {
|
|
223
|
-
setAuthorTarget(
|
|
224
|
-
value === "__new__" ? { mode: "new" } : { mode: "edit", flowName: value },
|
|
225
|
-
);
|
|
226
|
-
setEditPickerOpen(false);
|
|
227
|
-
}}
|
|
228
|
-
onCancel={() => setEditPickerOpen(false)}
|
|
229
|
-
/>
|
|
230
|
-
)}
|
|
231
|
-
|
|
232
|
-
{/* New / Edit: capture intent → launch the manage-flows skill */}
|
|
233
|
-
{authorTarget && (
|
|
234
|
-
<FlowAuthorPromptDialog
|
|
235
|
-
mode={authorTarget.mode}
|
|
236
|
-
flowName={authorTarget.flowName}
|
|
237
|
-
onSubmit={(instruction) => {
|
|
238
|
-
onEditFlow(authorTarget.flowName, instruction);
|
|
239
|
-
setAuthorTarget(null);
|
|
240
|
-
}}
|
|
241
|
-
onCancel={() => setAuthorTarget(null)}
|
|
242
|
-
/>
|
|
243
|
-
)}
|
|
244
|
-
|
|
245
|
-
{/* Delete: pick flow → confirm dialog */}
|
|
246
|
-
{deletePickerOpen && (
|
|
247
|
-
<SearchableSelectDialog
|
|
248
|
-
title={t("deleteFlowTitle", undefined, "Delete Flow")}
|
|
249
|
-
options={flowOptions}
|
|
250
|
-
placeholder={t("searchFlows", undefined, "Search flows...")}
|
|
251
|
-
emptyMessage={t("noFlowsAvailable", undefined, "No flows available")}
|
|
252
|
-
onSelect={(value) => {
|
|
253
|
-
setDeleteFlowName(value);
|
|
254
|
-
setDeletePickerOpen(false);
|
|
255
|
-
}}
|
|
256
|
-
onCancel={() => setDeletePickerOpen(false)}
|
|
257
|
-
/>
|
|
258
|
-
)}
|
|
259
|
-
|
|
260
|
-
{deleteFlowName && (
|
|
261
|
-
<ConfirmDialog
|
|
262
|
-
message={t("deleteFlowConfirm", { name: deleteFlowName }, `Delete flow "${deleteFlowName}"? This will remove the flow file and any associated agents.`)}
|
|
263
|
-
confirmLabel={t("delete", undefined, "Delete")}
|
|
264
|
-
onConfirm={() => {
|
|
265
|
-
onFlowAction("delete", { flowName: deleteFlowName });
|
|
266
|
-
setDeleteFlowName(null);
|
|
267
|
-
}}
|
|
268
|
-
onCancel={() => setDeleteFlowName(null)}
|
|
269
|
-
/>
|
|
270
|
-
)}
|
|
271
|
-
</>
|
|
30
|
+
<FlowActivityBadge
|
|
31
|
+
flowName={flowState.flowName}
|
|
32
|
+
agentsDone={done}
|
|
33
|
+
agentsTotal={agents.size}
|
|
34
|
+
status={flowState.status}
|
|
35
|
+
onAbort={flowState.status === "running" ? onAbortFlow : undefined}
|
|
36
|
+
/>
|
|
272
37
|
);
|
|
273
38
|
}
|
|
274
39
|
|
|
275
40
|
/**
|
|
276
|
-
* Slot-consumer wrapper for the `session-card-
|
|
277
|
-
* Reads per-session
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
* via pluginContext.send. See change: pluginize-flows-via-registry.
|
|
281
|
-
*
|
|
282
|
-
* Returns null when the session has no flows AND no `flows:new`
|
|
283
|
-
* command — this matches the shell's previous gate at
|
|
284
|
-
* SessionCard.tsx:651 (`flows && onFlowAction && ...`).
|
|
41
|
+
* Slot-consumer wrapper for the `session-card-flows` claim (FLOWS subcard).
|
|
42
|
+
* Reads the per-session flow state and dispatches abort via pluginContext.send.
|
|
43
|
+
* Visibility is gated by `shouldRenderFlowsSubcard` (any flow event). See change:
|
|
44
|
+
* pluginize-flows-via-registry, add-session-actions-flyout.
|
|
285
45
|
*/
|
|
286
46
|
export function SessionFlowActionsClaim({ session }: { session: DashboardSession }) {
|
|
287
|
-
const
|
|
288
|
-
const commands = useSessionData<CommandInfo[]>(session.id, "commandsList") ?? [];
|
|
289
|
-
const { flowState, flowStates, lastFlowStartedAt } = useFlowsSessionState(session.id);
|
|
290
|
-
const events = useSessionEvents(session.id);
|
|
47
|
+
const { flowState } = useFlowsSessionState(session.id);
|
|
291
48
|
const send = usePluginSend();
|
|
292
|
-
// The edit-mode reconcile effect and the author-prompt handler cannot own the
|
|
293
|
-
// send promise — discard it explicitly.
|
|
294
|
-
// See change: cleanup-client-plugin-promises.
|
|
295
|
-
const dispatch = useMemo(() => makeSafeSend(send), [send]);
|
|
296
|
-
const config = usePluginConfig<FlowsPluginConfig>();
|
|
297
|
-
const editMode = config.editFlow ?? false;
|
|
298
|
-
|
|
299
|
-
const hasFlowsDelete = commands.some((c) => c.name === "flows:delete");
|
|
300
|
-
|
|
301
|
-
// Reconcile the GLOBAL edit-mode default down to this session once its flows
|
|
302
|
-
// plugin is available (flowsList observed). pi-flows persists it to the
|
|
303
|
-
// project .pi/settings.json. Idempotent — re-emits only when the default
|
|
304
|
-
// changes. See change: rework-flows-plugin-for-new-pi-flows (D4).
|
|
305
|
-
const reconciledRef = useRef<boolean | null>(null);
|
|
306
|
-
useEffect(() => {
|
|
307
|
-
if (flows.length === 0) return; // wait until flows-plugin is available
|
|
308
|
-
if (reconciledRef.current === editMode) return;
|
|
309
|
-
reconciledRef.current = editMode;
|
|
310
|
-
dispatch({ type: "flow_management", sessionId: session.id, action: "set-edit-mode", enabled: editMode });
|
|
311
|
-
}, [flows.length, editMode, session.id, dispatch]);
|
|
312
|
-
|
|
313
|
-
// Render when there's a flow active OR action buttons are available.
|
|
314
|
-
if (flows.length === 0 && !editMode && !flowState) return null;
|
|
315
|
-
|
|
316
49
|
return (
|
|
317
50
|
<SessionFlowActions
|
|
318
|
-
flows={flows}
|
|
319
|
-
editMode={editMode}
|
|
320
|
-
hasFlowsDelete={hasFlowsDelete}
|
|
321
51
|
flowState={flowState}
|
|
322
|
-
flowStates={flowStates}
|
|
323
|
-
onOpenFlow={(flow) =>
|
|
324
|
-
// Baseline = newest flow_started seen now; null on an empty (not yet
|
|
325
|
-
// replayed) stream — the flow slot resolves it from the first batch.
|
|
326
|
-
// See change: attach-flow-before-run (D4).
|
|
327
|
-
setAttachment(session.id, {
|
|
328
|
-
id: newAttachmentId(),
|
|
329
|
-
name: flow.name,
|
|
330
|
-
source: flow.source,
|
|
331
|
-
baselineStartedAt: events.length > 0 ? (lastFlowStartedAt ?? 0) : null,
|
|
332
|
-
})
|
|
333
|
-
}
|
|
334
52
|
onAbortFlow={() => send({ type: "flow_control", sessionId: session.id, action: "abort" })}
|
|
335
|
-
onEditFlow={(flowName, instruction) => {
|
|
336
|
-
const intent = instruction.trim();
|
|
337
|
-
// New flow: instruction describes what to build. Edit: flow name is
|
|
338
|
-
// token-1 (the skill reads that file), instruction follows on a new line.
|
|
339
|
-
const text = flowName
|
|
340
|
-
? intent
|
|
341
|
-
? `/skill:manage-flows ${flowName}\n\n${intent}`
|
|
342
|
-
: `/skill:manage-flows ${flowName}`
|
|
343
|
-
: `/skill:manage-flows ${intent}`;
|
|
344
|
-
dispatch({ type: "send_prompt", sessionId: session.id, text });
|
|
345
|
-
}}
|
|
346
|
-
onFlowAction={(action, opts) =>
|
|
347
|
-
send({
|
|
348
|
-
type: "flow_management",
|
|
349
|
-
sessionId: session.id,
|
|
350
|
-
action,
|
|
351
|
-
flowName: opts?.flowName,
|
|
352
|
-
task: opts?.task,
|
|
353
|
-
description: opts?.description,
|
|
354
|
-
})
|
|
355
|
-
}
|
|
356
53
|
/>
|
|
357
54
|
);
|
|
358
55
|
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import {
|
|
2
|
+
usePluginSend,
|
|
3
|
+
useSessionData,
|
|
4
|
+
useSessionEvents,
|
|
5
|
+
useT,
|
|
6
|
+
useUiPrimitive,
|
|
7
|
+
} from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
8
|
+
import { usePluginConfig } from "@blackbelt-technology/dashboard-plugin-runtime/context";
|
|
9
|
+
import { ActionList } from "@blackbelt-technology/pi-dashboard-client-utils/ActionList";
|
|
10
|
+
import type { UiSelectOption as SelectOption } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
11
|
+
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
12
|
+
import type {
|
|
13
|
+
CommandInfo,
|
|
14
|
+
DashboardSession,
|
|
15
|
+
FlowInfo,
|
|
16
|
+
FlowState,
|
|
17
|
+
} from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
18
|
+
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
19
|
+
import { FlowAuthorPromptDialog } from "./FlowAuthorPromptDialog.js";
|
|
20
|
+
import { FlowLaunchDialog } from "./FlowLaunchDialog.js";
|
|
21
|
+
import { useFlowsSessionState } from "./FlowsSessionStateContext.js";
|
|
22
|
+
import type { FlowsPluginConfig } from "./FlowsSettings.js";
|
|
23
|
+
import { newAttachmentId, setAttachment } from "./flow-attach-store.js";
|
|
24
|
+
import { hasFlowsCommand } from "./flowsActionsGate.js";
|
|
25
|
+
import { sessionHasFlowEvents } from "./flowsAvailability.js";
|
|
26
|
+
import { makeSafeSend } from "./send-safe.js";
|
|
27
|
+
|
|
28
|
+
function isAnyFlowRunning(
|
|
29
|
+
flowState: FlowState | null | undefined,
|
|
30
|
+
flowStates: ReadonlyMap<string, FlowState> | undefined,
|
|
31
|
+
): boolean {
|
|
32
|
+
if (flowState?.status === "running") return true;
|
|
33
|
+
return flowStates ? Array.from(flowStates.values()).some((s) => s.status === "running") : false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* `session-card-action-bar` claim: the flow ACTIONS (Run Flow…, Open flow…,
|
|
38
|
+
* New / Edit…, Delete) rendered as an `ActionList` for the session actions menu,
|
|
39
|
+
* plus the dialogs they open and the edit-mode reconcile. Flow STATUS stays in
|
|
40
|
+
* the FLOWS subcard (`SessionFlowActionsClaim`).
|
|
41
|
+
*
|
|
42
|
+
* The claim stays mounted for the card's lifetime (dialogs portal to body and
|
|
43
|
+
* survive the menu closing; the reconcile runs without the menu being opened).
|
|
44
|
+
* Gated by availability — a `flows` / `flows:*` command (not `flows:new` alone)
|
|
45
|
+
* or any flow event; never by `flowsList` length.
|
|
46
|
+
*
|
|
47
|
+
* See change: add-session-actions-flyout (D7, D12).
|
|
48
|
+
*/
|
|
49
|
+
export function SessionFlowMenuClaim({ session }: { session: DashboardSession }) {
|
|
50
|
+
const t = useT();
|
|
51
|
+
const ConfirmDialog = useUiPrimitive(UI_PRIMITIVE_KEYS.confirmDialog);
|
|
52
|
+
const SearchableSelectDialog = useUiPrimitive(UI_PRIMITIVE_KEYS.searchableSelectDialog);
|
|
53
|
+
const flows = useSessionData<FlowInfo[]>(session.id, "flowsList") ?? [];
|
|
54
|
+
const commands = useSessionData<CommandInfo[]>(session.id, "commandsList") ?? [];
|
|
55
|
+
const { flowState, flowStates, lastFlowStartedAt } = useFlowsSessionState(session.id);
|
|
56
|
+
const events = useSessionEvents(session.id);
|
|
57
|
+
const send = usePluginSend();
|
|
58
|
+
// The edit-mode reconcile and author-prompt handlers cannot own the send
|
|
59
|
+
// promise — discard it explicitly. See change: cleanup-client-plugin-promises.
|
|
60
|
+
const dispatch = useMemo(() => makeSafeSend(send), [send]);
|
|
61
|
+
const config = usePluginConfig<FlowsPluginConfig>();
|
|
62
|
+
const editMode = config.editFlow ?? false;
|
|
63
|
+
|
|
64
|
+
// commandsList (subscribed above) + the event stream drive re-evaluation; the
|
|
65
|
+
// gate reads the same sources as `flowsActionsAvailable`.
|
|
66
|
+
const available = hasFlowsCommand(commands) || sessionHasFlowEvents(session.id);
|
|
67
|
+
const hasFlowsDelete = commands.some((c) => c.name === "flows:delete");
|
|
68
|
+
|
|
69
|
+
const [pickerOpen, setPickerOpen] = useState(false);
|
|
70
|
+
const [openPickerOpen, setOpenPickerOpen] = useState(false);
|
|
71
|
+
const [editPickerOpen, setEditPickerOpen] = useState(false);
|
|
72
|
+
// After picking from the edit launcher, capture intent before launching the skill.
|
|
73
|
+
const [authorTarget, setAuthorTarget] = useState<{ mode: "new" | "edit"; flowName?: string } | null>(null);
|
|
74
|
+
const [deletePickerOpen, setDeletePickerOpen] = useState(false);
|
|
75
|
+
const [deleteFlowName, setDeleteFlowName] = useState<string | null>(null);
|
|
76
|
+
const [selectedFlow, setSelectedFlow] = useState<FlowInfo | null>(null);
|
|
77
|
+
|
|
78
|
+
// Reconcile the GLOBAL edit-mode default down to this session once flows is
|
|
79
|
+
// available. pi-flows persists it to the project .pi/settings.json. Idempotent
|
|
80
|
+
// — re-emits only when the default changes. See change:
|
|
81
|
+
// rework-flows-plugin-for-new-pi-flows (D4), add-session-actions-flyout (D12).
|
|
82
|
+
const reconciledRef = useRef<boolean | null>(null);
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (!available) return; // wait until flows is available
|
|
85
|
+
if (reconciledRef.current === editMode) return;
|
|
86
|
+
reconciledRef.current = editMode;
|
|
87
|
+
dispatch({ type: "flow_management", sessionId: session.id, action: "set-edit-mode", enabled: editMode });
|
|
88
|
+
}, [available, editMode, session.id, dispatch]);
|
|
89
|
+
|
|
90
|
+
if (!available) return null;
|
|
91
|
+
|
|
92
|
+
const anyRunning = isAnyFlowRunning(flowState, flowStates);
|
|
93
|
+
const hasFlows = flows.length > 0;
|
|
94
|
+
|
|
95
|
+
const flowOptions: SelectOption[] = flows.map((f) => ({
|
|
96
|
+
value: f.name,
|
|
97
|
+
label: f.name,
|
|
98
|
+
description: f.description,
|
|
99
|
+
}));
|
|
100
|
+
// Edit launcher options: existing flows + a "new flow" sentinel.
|
|
101
|
+
const editOptions: SelectOption[] = [
|
|
102
|
+
{ value: "__new__", label: t("newFlowOption", undefined, "+ New flow"), description: t("newFlowOptionDesc", undefined, "Author a new flow with the edit-flow skill") },
|
|
103
|
+
...flowOptions,
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
const actions = [
|
|
107
|
+
...(hasFlows
|
|
108
|
+
? [{ label: t("runFlowButton", undefined, "Run Flow..."), icon: "mdiPlay", onClick: () => setPickerOpen(true) }]
|
|
109
|
+
: []),
|
|
110
|
+
...(hasFlows
|
|
111
|
+
? [{
|
|
112
|
+
label: t("openFlowButton", undefined, "Open flow…"),
|
|
113
|
+
icon: "mdiEyeOutline",
|
|
114
|
+
disabled: anyRunning,
|
|
115
|
+
tooltip: anyRunning ? t("openFlowDisabledRunning", undefined, "A flow is running") : undefined,
|
|
116
|
+
onClick: () => setOpenPickerOpen(true),
|
|
117
|
+
}]
|
|
118
|
+
: []),
|
|
119
|
+
...(editMode
|
|
120
|
+
? [{ label: t("newEditButton", undefined, "New / Edit…"), icon: "mdiPencil", onClick: () => setEditPickerOpen(true) }]
|
|
121
|
+
: []),
|
|
122
|
+
...(hasFlowsDelete && hasFlows
|
|
123
|
+
? [{ label: `${t("delete", undefined, "Delete")}…`, icon: "mdiDeleteOutline", onClick: () => setDeletePickerOpen(true) }]
|
|
124
|
+
: []),
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
const onFlowAction = (action: string, opts?: { flowName?: string; task?: string }) =>
|
|
128
|
+
dispatch({
|
|
129
|
+
type: "flow_management",
|
|
130
|
+
sessionId: session.id,
|
|
131
|
+
action,
|
|
132
|
+
flowName: opts?.flowName,
|
|
133
|
+
task: opts?.task,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const onEditFlow = (flowName: string | undefined, instruction: string) => {
|
|
137
|
+
const intent = instruction.trim();
|
|
138
|
+
// New flow: instruction describes what to build. Edit: flow name is
|
|
139
|
+
// token-1 (the skill reads that file), instruction follows on a new line.
|
|
140
|
+
const text = flowName
|
|
141
|
+
? intent
|
|
142
|
+
? `/skill:manage-flows ${flowName}\n\n${intent}`
|
|
143
|
+
: `/skill:manage-flows ${flowName}`
|
|
144
|
+
: `/skill:manage-flows ${intent}`;
|
|
145
|
+
dispatch({ type: "send_prompt", sessionId: session.id, text });
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<>
|
|
150
|
+
{actions.length > 0 && <ActionList actions={actions} />}
|
|
151
|
+
|
|
152
|
+
{/* Run: pick flow → task dialog */}
|
|
153
|
+
{pickerOpen && (
|
|
154
|
+
<SearchableSelectDialog
|
|
155
|
+
title={t("runFlowDialogTitle", undefined, "Run Flow")}
|
|
156
|
+
options={flowOptions}
|
|
157
|
+
placeholder={t("searchFlows", undefined, "Search flows...")}
|
|
158
|
+
emptyMessage={t("noFlowsAvailable", undefined, "No flows available")}
|
|
159
|
+
onSelect={(value) => {
|
|
160
|
+
const flow = flows.find((f) => f.name === value);
|
|
161
|
+
if (flow) setSelectedFlow(flow);
|
|
162
|
+
setPickerOpen(false);
|
|
163
|
+
}}
|
|
164
|
+
onCancel={() => setPickerOpen(false)}
|
|
165
|
+
/>
|
|
166
|
+
)}
|
|
167
|
+
|
|
168
|
+
{selectedFlow && (
|
|
169
|
+
<FlowLaunchDialog
|
|
170
|
+
flowName={selectedFlow.name}
|
|
171
|
+
description={selectedFlow.description}
|
|
172
|
+
onSubmit={(task) => {
|
|
173
|
+
onFlowAction("run", { flowName: selectedFlow.name, task: task || undefined });
|
|
174
|
+
setSelectedFlow(null);
|
|
175
|
+
}}
|
|
176
|
+
onCancel={() => setSelectedFlow(null)}
|
|
177
|
+
/>
|
|
178
|
+
)}
|
|
179
|
+
|
|
180
|
+
{/* Open: pick flow → attach it to the flow slot (not started). See change:
|
|
181
|
+
attach-flow-before-run (D7). */}
|
|
182
|
+
{openPickerOpen && (
|
|
183
|
+
<SearchableSelectDialog
|
|
184
|
+
title={t("openFlowDialogTitle", undefined, "Open flow")}
|
|
185
|
+
options={flowOptions}
|
|
186
|
+
placeholder={t("searchFlows", undefined, "Search flows...")}
|
|
187
|
+
emptyMessage={t("noFlowsAvailable", undefined, "No flows available")}
|
|
188
|
+
onSelect={(value) => {
|
|
189
|
+
const flow = flows.find((f) => f.name === value);
|
|
190
|
+
if (flow) {
|
|
191
|
+
// Baseline = newest flow_started seen now; null on an empty (not yet
|
|
192
|
+
// replayed) stream — the flow slot resolves it from the first batch.
|
|
193
|
+
// See change: attach-flow-before-run (D4).
|
|
194
|
+
setAttachment(session.id, {
|
|
195
|
+
id: newAttachmentId(),
|
|
196
|
+
name: flow.name,
|
|
197
|
+
source: flow.source,
|
|
198
|
+
baselineStartedAt: events.length > 0 ? (lastFlowStartedAt ?? 0) : null,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
setOpenPickerOpen(false);
|
|
202
|
+
}}
|
|
203
|
+
onCancel={() => setOpenPickerOpen(false)}
|
|
204
|
+
/>
|
|
205
|
+
)}
|
|
206
|
+
|
|
207
|
+
{/* New / Edit: pick an existing flow or "new" → launch the edit-flow skill */}
|
|
208
|
+
{editPickerOpen && (
|
|
209
|
+
<SearchableSelectDialog
|
|
210
|
+
title={t("newEditFlowTitle", undefined, "New / Edit flow")}
|
|
211
|
+
options={editOptions}
|
|
212
|
+
placeholder={t("pickFlowToEdit", undefined, "Pick a flow to edit, or + New flow…")}
|
|
213
|
+
emptyMessage={t("noFlowsYet", undefined, "No flows yet — pick + New flow")}
|
|
214
|
+
onSelect={(value) => {
|
|
215
|
+
setAuthorTarget(
|
|
216
|
+
value === "__new__" ? { mode: "new" } : { mode: "edit", flowName: value },
|
|
217
|
+
);
|
|
218
|
+
setEditPickerOpen(false);
|
|
219
|
+
}}
|
|
220
|
+
onCancel={() => setEditPickerOpen(false)}
|
|
221
|
+
/>
|
|
222
|
+
)}
|
|
223
|
+
|
|
224
|
+
{/* New / Edit: capture intent → launch the manage-flows skill */}
|
|
225
|
+
{authorTarget && (
|
|
226
|
+
<FlowAuthorPromptDialog
|
|
227
|
+
mode={authorTarget.mode}
|
|
228
|
+
flowName={authorTarget.flowName}
|
|
229
|
+
onSubmit={(instruction) => {
|
|
230
|
+
onEditFlow(authorTarget.flowName, instruction);
|
|
231
|
+
setAuthorTarget(null);
|
|
232
|
+
}}
|
|
233
|
+
onCancel={() => setAuthorTarget(null)}
|
|
234
|
+
/>
|
|
235
|
+
)}
|
|
236
|
+
|
|
237
|
+
{/* Delete: pick flow → confirm dialog */}
|
|
238
|
+
{deletePickerOpen && (
|
|
239
|
+
<SearchableSelectDialog
|
|
240
|
+
title={t("deleteFlowTitle", undefined, "Delete Flow")}
|
|
241
|
+
options={flowOptions}
|
|
242
|
+
placeholder={t("searchFlows", undefined, "Search flows...")}
|
|
243
|
+
emptyMessage={t("noFlowsAvailable", undefined, "No flows available")}
|
|
244
|
+
onSelect={(value) => {
|
|
245
|
+
setDeleteFlowName(value);
|
|
246
|
+
setDeletePickerOpen(false);
|
|
247
|
+
}}
|
|
248
|
+
onCancel={() => setDeletePickerOpen(false)}
|
|
249
|
+
/>
|
|
250
|
+
)}
|
|
251
|
+
|
|
252
|
+
{deleteFlowName && (
|
|
253
|
+
<ConfirmDialog
|
|
254
|
+
message={t("deleteFlowConfirm", { name: deleteFlowName }, `Delete flow "${deleteFlowName}"? This will remove the flow file and any associated agents.`)}
|
|
255
|
+
confirmLabel={t("delete", undefined, "Delete")}
|
|
256
|
+
onConfirm={() => {
|
|
257
|
+
onFlowAction("delete", { flowName: deleteFlowName });
|
|
258
|
+
setDeleteFlowName(null);
|
|
259
|
+
}}
|
|
260
|
+
onCancel={() => setDeleteFlowName(null)}
|
|
261
|
+
/>
|
|
262
|
+
)}
|
|
263
|
+
</>
|
|
264
|
+
);
|
|
265
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Actions gate for flows-plugin's `session-card-action-bar` claim
|
|
3
|
+
* (`SessionFlowMenuClaim`). Distinct from the FLOWS-subcard gate in
|
|
4
|
+
* `shouldRender.ts` (flow events only).
|
|
5
|
+
*
|
|
6
|
+
* Open iff pi-flows is active in the session's cwd — a command named `flows` or
|
|
7
|
+
* starting with `flows:` in `commandsList`, the removed `flows:new` alone NOT
|
|
8
|
+
* counting — OR the session has any flow event (live or replayed). Never gates on
|
|
9
|
+
* `flowsList` length, so an active-but-empty cwd still offers New / Edit….
|
|
10
|
+
* Closed by default: no `commandsList` published yet → closed.
|
|
11
|
+
*
|
|
12
|
+
* Synchronous and side-effect-free; reads `getSessionData` directly like
|
|
13
|
+
* `shouldRender.ts`.
|
|
14
|
+
*
|
|
15
|
+
* See change: add-session-actions-flyout (D12).
|
|
16
|
+
*/
|
|
17
|
+
import { getSessionData } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
18
|
+
import type { CommandInfo } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
19
|
+
import { sessionHasFlowEvents } from "./flowsAvailability.js";
|
|
20
|
+
|
|
21
|
+
/** True when `commands` carries a `flows` / `flows:*` signal (`flows:new` ignored). */
|
|
22
|
+
export function hasFlowsCommand(commands: readonly CommandInfo[] | null | undefined): boolean {
|
|
23
|
+
if (!Array.isArray(commands)) return false;
|
|
24
|
+
return commands.some(
|
|
25
|
+
(c) => c.name !== "flows:new" && (c.name === "flows" || c.name.startsWith("flows:")),
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Whether the flows actions (menu claim) are available for `sessionId`. */
|
|
30
|
+
export function flowsActionsAvailable(sessionId: string): boolean {
|
|
31
|
+
return (
|
|
32
|
+
hasFlowsCommand(getSessionData<CommandInfo[]>(sessionId, "commandsList")) ||
|
|
33
|
+
sessionHasFlowEvents(sessionId)
|
|
34
|
+
);
|
|
35
|
+
}
|
package/src/client/index.tsx
CHANGED
|
@@ -25,26 +25,27 @@ export { FlowAgentsToolRenderer } from "./FlowAgentsToolRenderer.js";
|
|
|
25
25
|
// session-card-badge claim was dropped because the badge belongs in the
|
|
26
26
|
// FLOWS subcard, not WORKSPACE. SessionFlowActions now renders the badge
|
|
27
27
|
// directly via the FlowActivityBadge component.
|
|
28
|
-
export { FlowDashboard, FlowDashboardClaim } from "./FlowDashboard.js";
|
|
29
28
|
export { computeLayout, FlowGraph, flowStateToGraphSteps } from "./FlowGraph.js";
|
|
30
29
|
// Input-wiring editor claimed into automation-plugin's `automation-action-editor`
|
|
31
30
|
// slot for `flows.run`. See change: wire-flow-inputs-in-automation.
|
|
32
|
-
export { FlowInputWiring, FlowInputWiringClaim } from "./FlowInputWiring.js";
|
|
33
31
|
export { FlowLaunchDialog } from "./FlowLaunchDialog.js";
|
|
34
32
|
export { FlowSummary, FlowSummaryClaim } from "./FlowSummary.js";
|
|
35
33
|
export type { FlowsPluginConfig } from "./FlowsSettings.js";
|
|
36
34
|
|
|
37
35
|
// Settings section (global edit-mode default) — manifest `settings-section` claim.
|
|
38
|
-
export { FlowsSettings } from "./FlowsSettings.js";
|
|
39
36
|
export { FlowTabBar } from "./FlowTabBar.js";
|
|
40
37
|
// Authoring tool-renderers (main-session timeline) — referenced by the
|
|
41
38
|
// manifest's `tool-renderer` claims. See change: rework-flows-plugin-for-new-pi-flows.
|
|
42
|
-
export { FlowWriteToolRenderer } from "./FlowWriteToolRenderer.js";
|
|
43
|
-
export { FlowYamlPreviewClaim } from "./FlowYamlPreview.js";
|
|
44
39
|
export { SessionFlowActions, SessionFlowActionsClaim } from "./SessionFlowActions.js";
|
|
45
40
|
|
|
46
|
-
//
|
|
47
|
-
//
|
|
41
|
+
// `session-card-action-bar` claim: flow actions (Run / Open / New-Edit / Delete)
|
|
42
|
+
// in the session actions menu + dialogs + edit-mode reconcile, and its
|
|
43
|
+
// availability gate. See change: add-session-actions-flyout.
|
|
44
|
+
export { flowsActionsAvailable, hasFlowsCommand } from "./flowsActionsGate.js";
|
|
45
|
+
export { SessionFlowMenuClaim } from "./SessionFlowMenuClaim.js";
|
|
46
|
+
|
|
47
|
+
// Manifest-level shouldRender predicate for the `session-card-flows` claim
|
|
48
|
+
// (any flow event). See change: add-flows-subcard, add-session-actions-flyout.
|
|
48
49
|
export { shouldRenderFlowsSubcard } from "./shouldRender.js";
|
|
49
50
|
|
|
50
51
|
// Flow slash commands (`/flows`, `/flows:new`, `/flows:edit`, `/flows:delete`)
|
|
@@ -2,37 +2,22 @@
|
|
|
2
2
|
* Manifest-level `shouldRender` callback for flows-plugin's
|
|
3
3
|
* `session-card-flows` claim (`SessionFlowActionsClaim`).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* consulting this predicate) never paints an empty panel when the claim would
|
|
10
|
-
* render `null`.
|
|
5
|
+
* The FLOWS subcard carries flow STATUS only, so it renders IFF the session has
|
|
6
|
+
* any flow event (live or replayed). It no longer depends on `flowsList`, edit
|
|
7
|
+
* mode or extension presence — those gate the flow ACTIONS, which live in the
|
|
8
|
+
* `session-card-action-bar` claim (see `flowsActionsGate.ts`).
|
|
11
9
|
*
|
|
12
10
|
* Must be synchronous and side-effect-free (manifest-level `shouldRender`
|
|
13
|
-
* contract). Reads live
|
|
14
|
-
* (`getPluginConfig`) directly — the same synchronous sources the claim reads —
|
|
15
|
-
* instead of a mirrored availability cache. Closed-by-default holds: on cold
|
|
16
|
-
* boot `flowsList` is empty, edit mode off, no events → `false` → hidden, then
|
|
17
|
-
* visible once flows populate (the acceptable hidden→visible direction).
|
|
11
|
+
* contract). Reads the live event stream directly via `sessionHasFlowEvents`.
|
|
18
12
|
*
|
|
19
|
-
* See change: fix-empty-flows-subcard.
|
|
13
|
+
* See change: fix-empty-flows-subcard, add-session-actions-flyout.
|
|
20
14
|
*/
|
|
21
|
-
import { getSessionData } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
22
|
-
import { getPluginConfig } from "@blackbelt-technology/dashboard-plugin-runtime/context";
|
|
23
15
|
import type { DashboardSession } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
24
|
-
import type { FlowInfo } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
25
16
|
import { sessionHasFlowEvents } from "./flowsAvailability.js";
|
|
26
17
|
|
|
27
18
|
export function shouldRenderFlowsSubcard(
|
|
28
19
|
session: DashboardSession | null | undefined,
|
|
29
20
|
): boolean {
|
|
30
21
|
if (!session) return false;
|
|
31
|
-
|
|
32
|
-
const editMode = (getPluginConfig("flows") as { editFlow?: boolean }).editFlow ?? false;
|
|
33
|
-
return (
|
|
34
|
-
(Array.isArray(flows) && flows.length > 0) ||
|
|
35
|
-
editMode ||
|
|
36
|
-
sessionHasFlowEvents(session.id)
|
|
37
|
-
);
|
|
22
|
+
return sessionHasFlowEvents(session.id);
|
|
38
23
|
}
|
package/src/i18n.ts
CHANGED
|
@@ -25,6 +25,9 @@ export const catalog = {
|
|
|
25
25
|
dismiss: "关闭",
|
|
26
26
|
flowsHeading: "流程",
|
|
27
27
|
editModeLabel: "编辑模式",
|
|
28
|
+
settingsIntro: "多智能体工作流。这是所有会话的默认设置。",
|
|
29
|
+
editModeHintPre: "允许主会话创建和修改流程与智能体。启用",
|
|
30
|
+
editModeHintPost: "以及 edit-flow 技能。默认关闭。",
|
|
28
31
|
runFlowTitle: "运行流程:{flowName}",
|
|
29
32
|
taskPlaceholder: "描述任务(可选)…",
|
|
30
33
|
summary: "摘要",
|
|
@@ -76,6 +79,9 @@ export const catalog = {
|
|
|
76
79
|
dismiss: "Bezárás",
|
|
77
80
|
flowsHeading: "Folyamatok",
|
|
78
81
|
editModeLabel: "Szerkesztő mód",
|
|
82
|
+
settingsIntro: "Többügynökös munkafolyamatok. Ez az alapértelmezés minden munkamenetre.",
|
|
83
|
+
editModeHintPre: "Lehetővé teszi, hogy a fő munkamenet folyamatokat és ügynököket hozzon létre és módosítson. Bekapcsolja a",
|
|
84
|
+
editModeHintPost: "eszközöket és az edit-flow skillt. Alapértelmezetten kikapcsolva.",
|
|
79
85
|
runFlowTitle: "Folyamat futtatása: {flowName}",
|
|
80
86
|
taskPlaceholder: "Írd le a feladatot (opcionális)…",
|
|
81
87
|
summary: "Összefoglaló",
|