@blackbelt-technology/pi-dashboard-flows-plugin 0.10.0 → 0.12.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/README.md +5 -1
- package/package.json +33 -4
- package/src/bridge/flow-catalog-publisher.ts +138 -0
- package/src/bridge/flow-event-forward.ts +132 -0
- package/src/bridge/flow-files-reporter.ts +16 -14
- package/src/bridge/flow-open-tool.ts +124 -0
- package/src/bridge/flow-probe.ts +20 -0
- package/src/bridge/flow-tool-registry.ts +298 -0
- package/src/bridge/flow-tools-guideline.ts +52 -0
- package/src/bridge/index.ts +67 -10
- package/src/bridge/run-snapshot-reporter.ts +146 -0
- package/src/catalog-timings.ts +70 -0
- package/src/client/AskSession.tsx +82 -0
- package/src/client/FlowActionDialogs.tsx +143 -0
- package/src/client/FlowActivityBadge.tsx +47 -9
- package/src/client/FlowAgentCard.tsx +63 -8
- package/src/client/FlowAgentDetail.tsx +3 -5
- package/src/client/FlowDashboard.tsx +381 -273
- package/src/client/FlowEditMenu.tsx +69 -0
- package/src/client/FlowEditPopover.tsx +130 -0
- package/src/client/FlowGraph.tsx +127 -44
- package/src/client/FlowHeaderActions.tsx +83 -0
- package/src/client/FlowInputWiring.tsx +1 -1
- package/src/client/FlowOpenListener.tsx +82 -0
- package/src/client/FlowQuestionBlock.tsx +226 -0
- package/src/client/FlowStepCards.tsx +189 -0
- package/src/client/FlowSummary.tsx +72 -240
- package/src/client/FlowWriteToolRenderer.tsx +46 -17
- package/src/client/FlowYamlPopoverButton.tsx +2 -2
- package/src/client/FlowsContextGroup.tsx +156 -0
- package/src/client/FlowsSessionStateContext.tsx +202 -54
- package/src/client/FlowsSettings.tsx +145 -18
- package/src/client/SessionFlowActions.tsx +65 -10
- package/src/client/SessionFlowMenuClaim.tsx +48 -248
- package/src/client/ask-session-store.ts +243 -0
- package/src/client/flow-attach-store.ts +2 -0
- package/src/client/flow-card-grid.ts +2 -2
- package/src/client/flow-collapse-storage.ts +36 -6
- package/src/client/flow-edges.ts +91 -35
- package/src/client/flow-files.ts +16 -4
- package/src/client/flow-idle-state.ts +93 -37
- package/src/client/flowsActionsGate.ts +1 -1
- package/src/client/flowsAvailability.ts +8 -2
- package/src/client/index.tsx +13 -11
- package/src/client/shouldRender.ts +1 -1
- package/src/client/useEditModeState.ts +78 -0
- package/src/client/useFlowActions.tsx +191 -0
- package/src/client/useFlowCatalog.ts +69 -0
- package/src/client/useMinuteClock.ts +21 -0
- package/src/client/useRunReattach.ts +50 -0
- package/src/configSchema.json +37 -2
- package/src/flow-catalog-contract.ts +65 -0
- package/src/flow-questions.ts +138 -0
- package/src/flow-reducer.ts +434 -13
- package/src/flow-state-serialize.ts +132 -0
- package/src/i18n.ts +144 -6
- package/src/server/automation-actions.ts +4 -3
- package/src/server/edit-mode.ts +307 -0
- package/src/server/flow-catalog.ts +127 -0
- package/src/server/flow-control.ts +263 -0
- package/src/server/flow-files.ts +140 -14
- package/src/server/flow-inputs.ts +56 -1
- package/src/server/flow-open.ts +385 -0
- package/src/server/index.ts +123 -40
- package/src/server/render-actions.ts +3 -2
- package/src/server/state-store.ts +11 -5
- package/src/types.ts +180 -0
- package/src/bridge/flow-question-adapter.ts +0 -93
- package/src/client/FlowQuestionCard.tsx +0 -218
- package/src/client/FlowQuestionTranscriptPill.tsx +0 -58
- package/src/client/FlowsCommandRoutes.tsx +0 -245
- package/src/client/flow-yaml-parse.ts +0 -140
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **Ask session** state + button, split from `FlowQuestionBlock` so the eager
|
|
3
|
+
* session-card bar (`SessionFlowActions`) does not pull the Question block into
|
|
4
|
+
* the index chunk. See change: adopt-flow-parent-mailbox (D5).
|
|
5
|
+
*/
|
|
6
|
+
import { useT } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
7
|
+
import { mdiCheck, mdiSend } from "@mdi/js";
|
|
8
|
+
import { Icon } from "@mdi/react";
|
|
9
|
+
import { createContext, type ReactNode, useContext } from "react";
|
|
10
|
+
import { type AskView, useAskSession } from "./ask-session-store.js";
|
|
11
|
+
|
|
12
|
+
/** Ask session state + action shared by every block / header of one session. */
|
|
13
|
+
export interface AskSessionApi {
|
|
14
|
+
view: (questionId: string) => AskView;
|
|
15
|
+
ask: (questionIds: readonly string[]) => void;
|
|
16
|
+
unsent: (questionIds: readonly string[]) => string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const AskSessionContext = createContext<AskSessionApi | null>(null);
|
|
20
|
+
|
|
21
|
+
/** Provide one Ask session store binding for `sessionId` to the subtree.
|
|
22
|
+
* `openIds`: every open question of the session's runs (prunes the rest). */
|
|
23
|
+
export function AskSessionProvider({
|
|
24
|
+
sessionId,
|
|
25
|
+
openIds,
|
|
26
|
+
children,
|
|
27
|
+
}: {
|
|
28
|
+
sessionId: string | undefined;
|
|
29
|
+
openIds: readonly string[];
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
}) {
|
|
32
|
+
const api = useAskSession(sessionId, openIds);
|
|
33
|
+
return <AskSessionContext.Provider value={api}>{children}</AskSessionContext.Provider>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function useAskSessionApi(): AskSessionApi | null {
|
|
37
|
+
return useContext(AskSessionContext);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** **Ask session** / **Sent** button. `size="line"` for headers and the badge. */
|
|
41
|
+
export function AskSessionButton({
|
|
42
|
+
view,
|
|
43
|
+
onAsk,
|
|
44
|
+
size = "card",
|
|
45
|
+
testId,
|
|
46
|
+
}: {
|
|
47
|
+
view: AskView | null;
|
|
48
|
+
onAsk: () => void;
|
|
49
|
+
size?: "card" | "line";
|
|
50
|
+
testId?: string;
|
|
51
|
+
}) {
|
|
52
|
+
const t = useT();
|
|
53
|
+
const pad = size === "card" ? "min-h-6 px-2 py-0.5 text-[11px]" : "px-1.5 py-0.5 text-[11px]";
|
|
54
|
+
if (view?.sent) {
|
|
55
|
+
return (
|
|
56
|
+
<button
|
|
57
|
+
type="button"
|
|
58
|
+
disabled
|
|
59
|
+
data-testid={testId}
|
|
60
|
+
className={`${pad} rounded inline-flex items-center gap-1 border border-[var(--tint-purple-border)] text-[var(--accent-purple-text)] flex-shrink-0`}
|
|
61
|
+
title={t("askSessionSentTitle", undefined, "pi-flows posted this question into the session")}
|
|
62
|
+
>
|
|
63
|
+
<Icon path={mdiCheck} size={0.5} /> {t("askSessionSent", undefined, "Sent")}
|
|
64
|
+
</button>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return (
|
|
68
|
+
<button
|
|
69
|
+
type="button"
|
|
70
|
+
data-testid={testId}
|
|
71
|
+
disabled={!view || view.disabled}
|
|
72
|
+
onClick={(e) => {
|
|
73
|
+
e.stopPropagation();
|
|
74
|
+
onAsk();
|
|
75
|
+
}}
|
|
76
|
+
className={`${pad} focus-ring rounded inline-flex items-center gap-1 border tint-action-purple font-medium flex-shrink-0 disabled:opacity-50 disabled:cursor-not-allowed`}
|
|
77
|
+
title={t("askSessionTitle", undefined, "Send this question to the session's model (follow-up prompt)")}
|
|
78
|
+
>
|
|
79
|
+
<Icon path={mdiSend} size={0.5} /> {t("askSession", undefined, "Ask session")}
|
|
80
|
+
</button>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dialogs the shared flow actions open (pickers, task dialog, author
|
|
3
|
+
* prompt, delete confirm, edit-mode error). Click-only, so this module is a
|
|
4
|
+
* lazy chunk loaded by `FlowActionDialogs` in `useFlowActions.tsx` the first
|
|
5
|
+
* time a dialog opens — the eager chip / menu claims stay small.
|
|
6
|
+
* See change: flows-dock-chip-and-panel-actions (D6).
|
|
7
|
+
*/
|
|
8
|
+
import { useT, useUiPrimitive } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
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 { FlowCatalogEntry } from "../flow-catalog-contract.js";
|
|
12
|
+
import { FlowAuthorPromptDialog } from "./FlowAuthorPromptDialog.js";
|
|
13
|
+
import { FlowLaunchDialog } from "./FlowLaunchDialog.js";
|
|
14
|
+
import type { FlowActions } from "./useFlowActions.js";
|
|
15
|
+
|
|
16
|
+
export function FlowActionDialogsImpl({ actions }: { actions: FlowActions }) {
|
|
17
|
+
const t = useT();
|
|
18
|
+
const ConfirmDialog = useUiPrimitive(UI_PRIMITIVE_KEYS.confirmDialog);
|
|
19
|
+
const SearchableSelectDialog = useUiPrimitive(UI_PRIMITIVE_KEYS.searchableSelectDialog);
|
|
20
|
+
const Dialog = useUiPrimitive(UI_PRIMITIVE_KEYS.dialog);
|
|
21
|
+
const d = actions.dialogs;
|
|
22
|
+
const flows = actions.flows;
|
|
23
|
+
|
|
24
|
+
const flowOptions: SelectOption[] = flows.map((f) => ({ value: f.name, label: f.name, description: f.description }));
|
|
25
|
+
const close = () => d.setPicker(null);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
{/* Per-project edit-mode change did not land: tell the user. */}
|
|
30
|
+
{d.editModeError && (
|
|
31
|
+
<Dialog open onClose={d.clearEditModeError} title={t("editModeErrorTitle", undefined, "Edit mode not changed")} size="sm" testId="flows-edit-mode-error">
|
|
32
|
+
<p className="text-xs text-[var(--text-secondary)]">
|
|
33
|
+
{d.editModeError === "not-delivered"
|
|
34
|
+
? t("editModeErrorNotDelivered", undefined, "The session could not be reached. Edit mode for this project is unchanged.")
|
|
35
|
+
: t("editModeErrorTimeout", undefined, "pi-flows did not confirm the change in time. The menu shows the current value.")}
|
|
36
|
+
</p>
|
|
37
|
+
<Dialog.Footer>
|
|
38
|
+
<Dialog.Cancel onClick={d.clearEditModeError}>{t("dismiss", undefined, "Dismiss")}</Dialog.Cancel>
|
|
39
|
+
</Dialog.Footer>
|
|
40
|
+
</Dialog>
|
|
41
|
+
)}
|
|
42
|
+
|
|
43
|
+
{/* Run: pick flow → task dialog */}
|
|
44
|
+
{d.picker === "run" && (
|
|
45
|
+
<SearchableSelectDialog
|
|
46
|
+
title={t("runFlowDialogTitle", undefined, "Run Flow")}
|
|
47
|
+
options={flowOptions}
|
|
48
|
+
placeholder={t("searchFlows", undefined, "Search flows...")}
|
|
49
|
+
emptyMessage={t("noFlowsAvailable", undefined, "No flows available")}
|
|
50
|
+
onSelect={(value) => {
|
|
51
|
+
const flow = flows.find((f) => f.name === value);
|
|
52
|
+
if (flow) d.setSelectedFlow(flow);
|
|
53
|
+
close();
|
|
54
|
+
}}
|
|
55
|
+
onCancel={close}
|
|
56
|
+
/>
|
|
57
|
+
)}
|
|
58
|
+
|
|
59
|
+
{d.selectedFlow && (
|
|
60
|
+
<FlowLaunchDialog
|
|
61
|
+
flowName={d.selectedFlow.name}
|
|
62
|
+
description={d.selectedFlow.description}
|
|
63
|
+
onSubmit={(task) => {
|
|
64
|
+
d.dispatchRun((d.selectedFlow as FlowCatalogEntry).name, task || undefined);
|
|
65
|
+
d.setSelectedFlow(null);
|
|
66
|
+
}}
|
|
67
|
+
onCancel={() => d.setSelectedFlow(null)}
|
|
68
|
+
/>
|
|
69
|
+
)}
|
|
70
|
+
|
|
71
|
+
{/* Open: pick flow → attach it to the flow slot (not started). See change:
|
|
72
|
+
attach-flow-before-run (D7). */}
|
|
73
|
+
{d.picker === "open" && (
|
|
74
|
+
<SearchableSelectDialog
|
|
75
|
+
title={t("openFlowDialogTitle", undefined, "Open flow")}
|
|
76
|
+
options={flowOptions}
|
|
77
|
+
placeholder={t("searchFlows", undefined, "Search flows...")}
|
|
78
|
+
emptyMessage={t("noFlowsAvailable", undefined, "No flows available")}
|
|
79
|
+
onSelect={(value) => {
|
|
80
|
+
const flow = flows.find((f) => f.name === value);
|
|
81
|
+
if (flow) d.attach(flow);
|
|
82
|
+
close();
|
|
83
|
+
}}
|
|
84
|
+
onCancel={close}
|
|
85
|
+
/>
|
|
86
|
+
)}
|
|
87
|
+
|
|
88
|
+
{/* Edit: pick an existing flow → capture intent → manage-flows skill */}
|
|
89
|
+
{d.picker === "edit" && (
|
|
90
|
+
<SearchableSelectDialog
|
|
91
|
+
title={t("editFlowTitle", undefined, "Edit flow")}
|
|
92
|
+
options={flowOptions}
|
|
93
|
+
placeholder={t("pickFlowToEdit", undefined, "Pick a flow to edit…")}
|
|
94
|
+
emptyMessage={t("noFlowsAvailable", undefined, "No flows available")}
|
|
95
|
+
onSelect={(value) => {
|
|
96
|
+
d.setAuthorTarget({ mode: "edit", flowName: value });
|
|
97
|
+
close();
|
|
98
|
+
}}
|
|
99
|
+
onCancel={close}
|
|
100
|
+
/>
|
|
101
|
+
)}
|
|
102
|
+
|
|
103
|
+
{d.authorTarget && (
|
|
104
|
+
<FlowAuthorPromptDialog
|
|
105
|
+
mode={d.authorTarget.mode}
|
|
106
|
+
flowName={d.authorTarget.flowName}
|
|
107
|
+
onSubmit={(instruction) => {
|
|
108
|
+
d.dispatchAuthor(d.authorTarget?.flowName, instruction);
|
|
109
|
+
d.setAuthorTarget(null);
|
|
110
|
+
}}
|
|
111
|
+
onCancel={() => d.setAuthorTarget(null)}
|
|
112
|
+
/>
|
|
113
|
+
)}
|
|
114
|
+
|
|
115
|
+
{/* Delete: pick flow → confirm dialog */}
|
|
116
|
+
{d.picker === "delete" && (
|
|
117
|
+
<SearchableSelectDialog
|
|
118
|
+
title={t("deleteFlowTitle", undefined, "Delete Flow")}
|
|
119
|
+
options={flowOptions}
|
|
120
|
+
placeholder={t("searchFlows", undefined, "Search flows...")}
|
|
121
|
+
emptyMessage={t("noFlowsAvailable", undefined, "No flows available")}
|
|
122
|
+
onSelect={(value) => {
|
|
123
|
+
d.setDeleteFlowName(value);
|
|
124
|
+
close();
|
|
125
|
+
}}
|
|
126
|
+
onCancel={close}
|
|
127
|
+
/>
|
|
128
|
+
)}
|
|
129
|
+
|
|
130
|
+
{d.deleteFlowName && (
|
|
131
|
+
<ConfirmDialog
|
|
132
|
+
message={t("deleteFlowConfirm", { name: d.deleteFlowName }, `Delete flow "${d.deleteFlowName}"? This will remove the flow file and any associated agents.`)}
|
|
133
|
+
confirmLabel={t("delete", undefined, "Delete")}
|
|
134
|
+
onConfirm={() => {
|
|
135
|
+
d.dispatchDelete(d.deleteFlowName as string);
|
|
136
|
+
d.setDeleteFlowName(null);
|
|
137
|
+
}}
|
|
138
|
+
onCancel={() => d.setDeleteFlowName(null)}
|
|
139
|
+
/>
|
|
140
|
+
)}
|
|
141
|
+
</>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { useT } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
14
|
-
import type { FlowStatus } from "
|
|
15
|
-
import { mdiAlertCircle, mdiCheckCircle, mdiLoading, mdiStop, mdiStopCircle } from "@mdi/js";
|
|
14
|
+
import type { FlowStatus } from "../types.js";
|
|
15
|
+
import { mdiAlertCircle, mdiCheckCircle, mdiHelpCircleOutline, mdiLoading, mdiStop, mdiStopCircle } from "@mdi/js";
|
|
16
16
|
import { Icon } from "@mdi/react";
|
|
17
17
|
import React, { type ReactNode } from "react";
|
|
18
18
|
|
|
19
19
|
const statusConfig: Record<string, { icon: ReactNode; color: string }> = {
|
|
20
|
-
running: { icon: <Icon path={mdiLoading} size={0.45} className="animate-spin" />, color: "text-blue-
|
|
21
|
-
success: { icon: <Icon path={mdiCheckCircle} size={0.45} />, color: "text-green-
|
|
22
|
-
error: { icon: <Icon path={mdiAlertCircle} size={0.45} />, color: "text-red-
|
|
23
|
-
aborted: { icon: <Icon path={mdiStopCircle} size={0.45} />, color: "text-orange-
|
|
20
|
+
running: { icon: <Icon path={mdiLoading} size={0.45} className="animate-spin" />, color: "text-[var(--accent-blue-text)]" },
|
|
21
|
+
success: { icon: <Icon path={mdiCheckCircle} size={0.45} />, color: "text-[var(--accent-green-text)]" },
|
|
22
|
+
error: { icon: <Icon path={mdiAlertCircle} size={0.45} />, color: "text-[var(--accent-red-text)]" },
|
|
23
|
+
aborted: { icon: <Icon path={mdiStopCircle} size={0.45} />, color: "text-[var(--accent-orange-text)]" },
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export interface FlowActivityBadgeProps {
|
|
@@ -30,6 +30,12 @@ export interface FlowActivityBadgeProps {
|
|
|
30
30
|
status?: FlowStatus;
|
|
31
31
|
/** When provided AND status === "running", renders an "Abort" button after the badge. */
|
|
32
32
|
onAbort?: () => void;
|
|
33
|
+
/** Whole-run waiting state (open parent questions). `waiting`: a static
|
|
34
|
+
* purple `?`, `· waiting` and the nearest time; `mixed`: spinner, counts and
|
|
35
|
+
* a purple `?N`. See change: adopt-flow-parent-mailbox (D6). */
|
|
36
|
+
waiting?: { kind: "waiting" | "mixed"; n: number; remaining?: string | null } | null;
|
|
37
|
+
/** **Ask session** control, rendered before Abort while waiting / mixed. */
|
|
38
|
+
askSession?: ReactNode;
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
export function FlowActivityBadge({
|
|
@@ -38,28 +44,60 @@ export function FlowActivityBadge({
|
|
|
38
44
|
agentsTotal,
|
|
39
45
|
status,
|
|
40
46
|
onAbort,
|
|
47
|
+
waiting,
|
|
48
|
+
askSession,
|
|
41
49
|
}: FlowActivityBadgeProps) {
|
|
42
50
|
const t = useT();
|
|
43
|
-
const { icon, color } = statusConfig[status ?? "running"] ?? statusConfig.running;
|
|
44
51
|
const isRunning = status === "running";
|
|
52
|
+
const isWaiting = isRunning && waiting?.kind === "waiting";
|
|
53
|
+
const isMixed = isRunning && waiting?.kind === "mixed";
|
|
54
|
+
const base = statusConfig[status ?? "running"] ?? statusConfig.running;
|
|
55
|
+
const { icon, color } = isWaiting
|
|
56
|
+
? {
|
|
57
|
+
icon: <Icon path={mdiHelpCircleOutline} size={0.45} aria-label={t("waitingAria", undefined, "waiting for an answer")} />,
|
|
58
|
+
color: "text-[var(--accent-purple-text)]",
|
|
59
|
+
}
|
|
60
|
+
: base;
|
|
45
61
|
|
|
46
62
|
return (
|
|
47
63
|
<div className={`text-[11px] flex items-center gap-1 ${color}`}>
|
|
48
64
|
<span className="inline-flex">{icon}</span>
|
|
49
65
|
<span className="truncate flex-1 min-w-0">
|
|
50
66
|
{flowName}
|
|
51
|
-
{
|
|
67
|
+
{isWaiting && (
|
|
68
|
+
<span className="font-medium" title={t("waitingAria", undefined, "waiting for an answer")}>
|
|
69
|
+
{" · "}
|
|
70
|
+
{t("waitingShort", undefined, "waiting")}
|
|
71
|
+
</span>
|
|
72
|
+
)}
|
|
73
|
+
{isRunning && !isWaiting && agentsTotal != null && agentsTotal > 0 && (
|
|
52
74
|
<span className="text-[var(--text-secondary)]"> · {agentsDone ?? 0}/{agentsTotal} agents</span>
|
|
53
75
|
)}
|
|
54
76
|
{!isRunning && (
|
|
55
77
|
<span className="text-[var(--text-secondary)]"> · {status}</span>
|
|
56
78
|
)}
|
|
57
79
|
</span>
|
|
80
|
+
{isWaiting && waiting?.remaining && (
|
|
81
|
+
<span data-testid="flow-badge-remaining" className="text-[var(--text-tertiary)] flex-shrink-0">
|
|
82
|
+
{waiting.remaining}
|
|
83
|
+
</span>
|
|
84
|
+
)}
|
|
85
|
+
{isMixed && waiting && (
|
|
86
|
+
<span
|
|
87
|
+
data-testid="flow-badge-waiting-count"
|
|
88
|
+
title={t("nWaitingForAnswer", { n: waiting.n }, `${waiting.n} waiting for answer`)}
|
|
89
|
+
className="inline-flex items-center gap-0.5 rounded-full border border-[var(--tint-purple-border)] bg-[var(--tint-purple-bg)] px-1 font-medium text-[var(--accent-purple-text)] flex-shrink-0"
|
|
90
|
+
>
|
|
91
|
+
<Icon path={mdiHelpCircleOutline} size={0.4} />
|
|
92
|
+
{waiting.n}
|
|
93
|
+
</span>
|
|
94
|
+
)}
|
|
95
|
+
{(isWaiting || isMixed) && askSession}
|
|
58
96
|
{isRunning && onAbort && (
|
|
59
97
|
<button
|
|
60
98
|
type="button"
|
|
61
99
|
onClick={(e) => { e.stopPropagation(); onAbort(); }}
|
|
62
|
-
className="inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[
|
|
100
|
+
className="inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[12px] rounded border border-[var(--tint-red-border)] text-[var(--tint-red-fg)] bg-[var(--tint-red-bg)] hover:brightness-110 transition-colors flex-shrink-0"
|
|
63
101
|
title={t("abortRunningFlow", undefined, "Abort running flow")}
|
|
64
102
|
>
|
|
65
103
|
<Icon path={mdiStop} size={0.4} />
|
|
@@ -3,14 +3,20 @@ import { useT, useUiPrimitive, useUiPrimitiveOrNull } from "@blackbelt-technolog
|
|
|
3
3
|
// — it stays as a direct import. See add-plugin-ui-primitive-registry Decision 4.
|
|
4
4
|
import { AgentMetricSlot } from "@blackbelt-technology/pi-dashboard-client-utils/extension-ui/AgentMetricSlot";
|
|
5
5
|
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
6
|
-
import type { DashboardSession
|
|
7
|
-
import {
|
|
6
|
+
import type { DashboardSession } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
7
|
+
import { closeLine } from "../flow-questions.js";
|
|
8
|
+
import type { FlowAgentState, FlowQuestionState } from "../types.js";
|
|
9
|
+
import { mdiCallSplit, mdiCodeBraces, mdiCodeTags, mdiEyeOffOutline, mdiEyeOutline, mdiFileDocumentOutline, mdiHelpCircleOutline, mdiRefresh, mdiSourceBranch } from "@mdi/js";
|
|
8
10
|
import { Icon } from "@mdi/react";
|
|
9
11
|
import React, { useState } from "react";
|
|
10
12
|
import { FlowAgentDetail } from "./FlowAgentDetail.js";
|
|
13
|
+
import { FlowQuestionBlock } from "./FlowQuestionBlock.js";
|
|
11
14
|
import { useOpenFileInEditor } from "./flow-files.js";
|
|
12
15
|
import { formatCost } from "./format-cost.js";
|
|
13
16
|
|
|
17
|
+
/** Shared shape of the card header's small badges (kind, question). */
|
|
18
|
+
const HEADER_BADGE = "text-[9px] px-1 rounded flex-shrink-0 inline-flex items-center gap-0.5";
|
|
19
|
+
|
|
14
20
|
/** Last path segment — the card's basename line. Mirrors the editor-pane copies. */
|
|
15
21
|
function basenameOf(p: string): string {
|
|
16
22
|
const parts = p.split("/");
|
|
@@ -23,8 +29,18 @@ export function FlowAgentCard({
|
|
|
23
29
|
session,
|
|
24
30
|
sessionId,
|
|
25
31
|
onSelect,
|
|
32
|
+
openQuestions,
|
|
33
|
+
questionHistory,
|
|
34
|
+
now,
|
|
26
35
|
}: {
|
|
27
36
|
agent: FlowAgentState;
|
|
37
|
+
/** Open parent-mailbox questions on this card (purple border, `question`
|
|
38
|
+
* badge, Question block). See change: adopt-flow-parent-mailbox (D4). */
|
|
39
|
+
openQuestions?: readonly FlowQuestionState[];
|
|
40
|
+
/** Closed questions on this card (`Questions (n)` history). */
|
|
41
|
+
questionHistory?: readonly FlowQuestionState[];
|
|
42
|
+
/** Clock for remaining times (one per panel, passed down). */
|
|
43
|
+
now?: number;
|
|
28
44
|
selected?: boolean;
|
|
29
45
|
/** Phase-2 decorator host — used for `agent-metric` filtering by agentId. */
|
|
30
46
|
session?: Pick<DashboardSession, "uiDecorators">;
|
|
@@ -68,11 +84,11 @@ export function FlowAgentCard({
|
|
|
68
84
|
const isCodeKind = kind === "code" || kind === "code-decision";
|
|
69
85
|
const kindBadge =
|
|
70
86
|
kind === "code"
|
|
71
|
-
? <span className=
|
|
87
|
+
? <span className={`${HEADER_BADGE} text-cyan-400/80 bg-cyan-400/10`}><Icon path={mdiCodeTags} size={0.4} /> code</span>
|
|
72
88
|
: kind === "code-decision"
|
|
73
|
-
? <span className=
|
|
89
|
+
? <span className={`${HEADER_BADGE} text-cyan-400/80 bg-cyan-400/10`}><Icon path={mdiCallSplit} size={0.4} /> decision</span>
|
|
74
90
|
: kind === "fork" || kind === "agent-decision"
|
|
75
|
-
? <span className=
|
|
91
|
+
? <span className={`${HEADER_BADGE} text-amber-400/70 bg-amber-400/10`}><Icon path={mdiSourceBranch} size={0.4} /> fork</span>
|
|
76
92
|
: null;
|
|
77
93
|
|
|
78
94
|
// Code-node program logs ride the assistant-text channel; the card's
|
|
@@ -82,7 +98,9 @@ export function FlowAgentCard({
|
|
|
82
98
|
: [];
|
|
83
99
|
const outputs = agent.typedOutputs ? Object.entries(agent.typedOutputs).filter(([k]) => k !== "branch") : [];
|
|
84
100
|
|
|
85
|
-
const
|
|
101
|
+
const asking = (openQuestions?.length ?? 0) > 0;
|
|
102
|
+
const history = questionHistory ?? [];
|
|
103
|
+
const baseHeaderRight = agent.loopIteration != null && agent.loopIteration > 0 ? (
|
|
86
104
|
<span className="text-[10px] text-blue-400 flex-shrink-0 inline-flex items-center gap-0.5">
|
|
87
105
|
<Icon path={mdiRefresh} size={0.4} />{agent.loopIteration}/{agent.loopMax}
|
|
88
106
|
</span>
|
|
@@ -91,6 +109,20 @@ export function FlowAgentCard({
|
|
|
91
109
|
<Icon path={mdiRefresh} size={0.4} />{agent.runCount}
|
|
92
110
|
</span>
|
|
93
111
|
) : kindBadge;
|
|
112
|
+
// The `question` badge goes BEFORE the loop / re-run / kind badge (all kept).
|
|
113
|
+
const headerRight = asking ? (
|
|
114
|
+
<span className="inline-flex items-center gap-1 flex-shrink-0">
|
|
115
|
+
<span
|
|
116
|
+
data-testid="flow-card-question-badge"
|
|
117
|
+
className={`${HEADER_BADGE} text-[var(--accent-purple-text)] bg-[var(--tint-purple-bg)]`}
|
|
118
|
+
>
|
|
119
|
+
<Icon path={mdiHelpCircleOutline} size={0.4} /> {t("questionBadge", undefined, "question")}
|
|
120
|
+
</span>
|
|
121
|
+
{baseHeaderRight}
|
|
122
|
+
</span>
|
|
123
|
+
) : (
|
|
124
|
+
baseHeaderRight
|
|
125
|
+
);
|
|
94
126
|
|
|
95
127
|
// The stats line is the single carrier for secondary values (D7): a pending
|
|
96
128
|
// blocked card shows `waiting: <deps>` there, else the complete/model/role
|
|
@@ -102,7 +134,7 @@ export function FlowAgentCard({
|
|
|
102
134
|
const stats = waiting ? (
|
|
103
135
|
<span>{waiting}</span>
|
|
104
136
|
) : isComplete && agent.tokens ? (
|
|
105
|
-
<span
|
|
137
|
+
<span>↓{formatTokens(agent.tokens.input)} ↑{formatTokens(agent.tokens.output)}{agent.cost != null && agent.cost > 0 ? ` · ${formatCost(agent.cost)}` : ""} · {formatDuration(agent.duration ?? 0)}</span>
|
|
106
138
|
) : displayModel ? (
|
|
107
139
|
<span>{displayModel}</span>
|
|
108
140
|
) : displayRole ? (
|
|
@@ -124,13 +156,14 @@ export function FlowAgentCard({
|
|
|
124
156
|
const recentTools = agent.recentTools.slice(-2).reverse();
|
|
125
157
|
|
|
126
158
|
return (
|
|
127
|
-
<div data-step={stepId} className="h-full [&>*]:h-full">
|
|
159
|
+
<div data-step={stepId} data-selected={selected ? "true" : undefined} className="h-full [&>*]:h-full">
|
|
128
160
|
<AgentCardShell
|
|
129
161
|
name={displayName}
|
|
130
162
|
status={agent.status}
|
|
131
163
|
headerRight={headerRight}
|
|
132
164
|
stats={stats}
|
|
133
165
|
selected={selected}
|
|
166
|
+
{...(asking ? { accent: "question" as const } : {})}
|
|
134
167
|
onClick={onSelect ? () => onSelect(stepId) : undefined}
|
|
135
168
|
>
|
|
136
169
|
<div className="flex flex-col flex-1">
|
|
@@ -180,6 +213,9 @@ export function FlowAgentCard({
|
|
|
180
213
|
</div>
|
|
181
214
|
)}
|
|
182
215
|
|
|
216
|
+
{/* Open questions: the Question block after the body. */}
|
|
217
|
+
{openQuestions?.map((q) => <FlowQuestionBlock key={q.id} q={q} now={now ?? Date.now()} />)}
|
|
218
|
+
|
|
183
219
|
{/* Chosen branch (code-decision / agent-decision) */}
|
|
184
220
|
{agent.branch && (
|
|
185
221
|
<div className="mt-1 text-[10px] font-mono">
|
|
@@ -207,6 +243,25 @@ export function FlowAgentCard({
|
|
|
207
243
|
<div className="mt-1 text-[10px] text-red-400">✕ hard-failed — halted flow</div>
|
|
208
244
|
)}
|
|
209
245
|
|
|
246
|
+
{/* Closed questions: `Questions (n)` with one close line each; the full
|
|
247
|
+
line and the answerer's notes are the tooltip. */}
|
|
248
|
+
{history.length > 0 && (
|
|
249
|
+
<div data-testid="flow-card-question-history" className="mt-2 flex flex-col gap-0.5 border-t border-[var(--border-subtle)] pt-1 text-[11px]">
|
|
250
|
+
<span className="text-[var(--text-tertiary)]">{t("questionsHistory", { n: history.length }, `Questions (${history.length})`)}</span>
|
|
251
|
+
{history.map((q) => {
|
|
252
|
+
const line = closeLine(q, t);
|
|
253
|
+
const tip = [q.question, line, q.closed?.notes].filter(Boolean).join("\n");
|
|
254
|
+
return (
|
|
255
|
+
<div key={q.id} data-testid="flow-card-question-line" className="flex gap-1 min-w-0 text-[var(--text-secondary)]" title={tip}>
|
|
256
|
+
<Icon path={mdiHelpCircleOutline} size={0.4} className="shrink-0 mt-0.5 text-[var(--text-tertiary)]" />
|
|
257
|
+
<span className="truncate flex-1 min-w-0">{q.question}</span>
|
|
258
|
+
<span data-testid="flow-card-question-close" className="truncate max-w-[50%] text-[var(--text-tertiary)]">{line}</span>
|
|
259
|
+
</div>
|
|
260
|
+
);
|
|
261
|
+
})}
|
|
262
|
+
</div>
|
|
263
|
+
)}
|
|
264
|
+
|
|
210
265
|
{/* View source / detail icons — bottom-right of card */}
|
|
211
266
|
<div className="flex justify-end mt-auto pt-1 gap-1">
|
|
212
267
|
{openInEditor && isCodeKind && agent.codeTarget && (
|
|
@@ -15,11 +15,7 @@ import {
|
|
|
15
15
|
MinimalChatView,
|
|
16
16
|
} from "@blackbelt-technology/pi-dashboard-client-utils/minimal-chat";
|
|
17
17
|
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
18
|
-
import type {
|
|
19
|
-
FlowAgentState,
|
|
20
|
-
FlowAgentStatus,
|
|
21
|
-
FlowDetailEntry,
|
|
22
|
-
} from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
18
|
+
import type { FlowAgentState, FlowAgentStatus, FlowDetailEntry } from "../types.js";
|
|
23
19
|
import React from "react";
|
|
24
20
|
import { formatCost } from "./format-cost.js";
|
|
25
21
|
|
|
@@ -35,6 +31,8 @@ function mapFlowStatus(status: FlowAgentStatus): MinimalChatStatus {
|
|
|
35
31
|
return "error";
|
|
36
32
|
case "blocked":
|
|
37
33
|
return "blocked";
|
|
34
|
+
case "skipped":
|
|
35
|
+
return "pending";
|
|
38
36
|
default: {
|
|
39
37
|
const _exhaustive: never = status;
|
|
40
38
|
void _exhaustive;
|