@blackbelt-technology/pi-dashboard-flows-plugin 0.5.3 → 0.5.4
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 +39 -4
- package/src/__tests__/FlowsSessionStateContext.test.tsx +260 -0
- package/src/__tests__/FlowsUiStateContext.test.tsx +140 -0
- package/src/__tests__/flowsAvailability.test.ts +92 -0
- package/src/__tests__/manifest-discoverability.test.ts +97 -0
- package/src/__tests__/render-actions.test.ts +63 -0
- package/src/bridge/flow-question-adapter.ts +93 -0
- package/src/bridge/index.ts +30 -0
- package/src/client/FlowActivityBadge.tsx +36 -9
- package/src/client/FlowAgentCard.tsx +180 -41
- package/src/client/FlowAgentDetail.tsx +95 -154
- package/src/client/FlowAgentPopoutClaim.tsx +66 -0
- package/src/client/FlowAgentPopoutPage.tsx +177 -0
- package/src/client/FlowArchitect.tsx +297 -220
- package/src/client/FlowArchitectPopoutClaim.tsx +52 -0
- package/src/client/FlowArchitectPopoutPage.tsx +133 -0
- package/src/client/FlowDashboard.tsx +194 -31
- package/src/client/FlowGraph.tsx +6 -2
- package/src/client/FlowLaunchDialog.tsx +8 -2
- package/src/client/FlowQuestionCard.tsx +213 -0
- package/src/client/FlowQuestionTranscriptPill.tsx +58 -0
- package/src/client/FlowSummary.tsx +43 -21
- package/src/client/FlowYamlPopoverButton.tsx +109 -0
- package/src/client/FlowYamlPreview.tsx +65 -0
- package/src/client/FlowsCommandRoutes.tsx +237 -0
- package/src/client/FlowsSessionStateContext.tsx +161 -0
- package/src/client/FlowsUiStateContext.tsx +169 -0
- package/src/client/SessionFlowActions.tsx +96 -5
- package/src/client/flowsAvailability.ts +103 -0
- package/src/client/index.tsx +94 -7
- package/src/client/popout-url.ts +59 -0
- package/src/client/shouldRender.ts +26 -0
- package/src/server/index.ts +87 -0
- package/src/server/render-actions.ts +88 -0
- package/src/server/state-store.ts +85 -0
|
@@ -1,173 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlowAgentDetail — thin adapter shim over `MinimalChatView`.
|
|
3
|
+
*
|
|
4
|
+
* Maps `FlowAgentState` → `MinimalChatViewProps`. Preserves the existing
|
|
5
|
+
* public API (`agent`, `onBack`) so `FlowAgentCard`'s eye-button popover
|
|
6
|
+
* (and the future `FlowAgentPopoutPage` route) keep working without change.
|
|
7
|
+
*
|
|
8
|
+
* See change: extract-minimal-chat-view.
|
|
9
|
+
*/
|
|
1
10
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
import type {
|
|
12
|
+
FlowAgentState,
|
|
13
|
+
FlowAgentStatus,
|
|
14
|
+
FlowDetailEntry,
|
|
15
|
+
} from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
16
|
+
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
17
|
+
import { useUiPrimitive } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
18
|
+
import {
|
|
19
|
+
MinimalChatView,
|
|
20
|
+
type MinimalChatEntry,
|
|
21
|
+
type MinimalChatStatus,
|
|
22
|
+
} from "@blackbelt-technology/pi-dashboard-client-utils/minimal-chat";
|
|
6
23
|
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return String(inp.file_path || inp.path || "");
|
|
25
|
-
case "bash":
|
|
26
|
-
return String(inp.command || "").slice(0, 80);
|
|
27
|
-
case "grep":
|
|
28
|
-
return String(inp.pattern || "").slice(0, 40);
|
|
29
|
-
default:
|
|
30
|
-
return JSON.stringify(input).slice(0, 60);
|
|
24
|
+
function mapFlowStatus(status: FlowAgentStatus): MinimalChatStatus {
|
|
25
|
+
switch (status) {
|
|
26
|
+
case "pending":
|
|
27
|
+
return "pending";
|
|
28
|
+
case "running":
|
|
29
|
+
return "running";
|
|
30
|
+
case "complete":
|
|
31
|
+
return "complete";
|
|
32
|
+
case "error":
|
|
33
|
+
return "error";
|
|
34
|
+
case "blocked":
|
|
35
|
+
return "blocked";
|
|
36
|
+
default: {
|
|
37
|
+
const _exhaustive: never = status;
|
|
38
|
+
void _exhaustive;
|
|
39
|
+
return "pending";
|
|
40
|
+
}
|
|
31
41
|
}
|
|
32
42
|
}
|
|
33
43
|
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
</pre>
|
|
59
|
-
)}
|
|
60
|
-
</div>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function TextEntry({ text }: { text: string }) {
|
|
65
|
-
return (
|
|
66
|
-
<div className="py-1.5 pl-3">
|
|
67
|
-
<MarkdownContent content={text} />
|
|
68
|
-
</div>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function ThinkingEntry({ text }: { text: string }) {
|
|
73
|
-
const [expanded, setExpanded] = React.useState(false);
|
|
74
|
-
return (
|
|
75
|
-
<div className="py-1 pl-3">
|
|
76
|
-
<div
|
|
77
|
-
className="flex items-center gap-1 cursor-pointer text-[11px] text-purple-400/70"
|
|
78
|
-
onClick={() => setExpanded(!expanded)}
|
|
79
|
-
>
|
|
80
|
-
<span>{expanded ? "▾" : "▸"}</span>
|
|
81
|
-
<span>Thinking</span>
|
|
82
|
-
</div>
|
|
83
|
-
{expanded && (
|
|
84
|
-
<pre className="text-[11px] text-[var(--text-muted)] mt-1 whitespace-pre-wrap break-words max-h-64 overflow-y-auto">
|
|
85
|
-
{text}
|
|
86
|
-
</pre>
|
|
87
|
-
)}
|
|
88
|
-
</div>
|
|
89
|
-
);
|
|
44
|
+
function mapFlowEntries(detailHistory: FlowDetailEntry[]): MinimalChatEntry[] {
|
|
45
|
+
return detailHistory.map((e) => {
|
|
46
|
+
switch (e.kind) {
|
|
47
|
+
case "tool":
|
|
48
|
+
return {
|
|
49
|
+
kind: "tool",
|
|
50
|
+
toolName: e.toolName,
|
|
51
|
+
input: e.input,
|
|
52
|
+
output: e.output,
|
|
53
|
+
isError: e.isError,
|
|
54
|
+
};
|
|
55
|
+
case "text":
|
|
56
|
+
return { kind: "text", text: e.text };
|
|
57
|
+
case "thinking":
|
|
58
|
+
return { kind: "thinking", text: e.text };
|
|
59
|
+
case "error":
|
|
60
|
+
return { kind: "error", text: e.text };
|
|
61
|
+
default: {
|
|
62
|
+
const _exhaustive: never = e;
|
|
63
|
+
void _exhaustive;
|
|
64
|
+
return { kind: "error", text: "(unknown entry)" };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
90
68
|
}
|
|
91
69
|
|
|
92
70
|
export function FlowAgentDetail({
|
|
93
71
|
agent,
|
|
94
72
|
onBack,
|
|
73
|
+
sessionId,
|
|
95
74
|
}: {
|
|
96
75
|
agent: FlowAgentState;
|
|
97
|
-
onBack
|
|
76
|
+
onBack?: () => void;
|
|
77
|
+
/** Forwarded to MinimalChatView so per-tool renderers can build session-scoped links. */
|
|
78
|
+
sessionId?: string;
|
|
98
79
|
}) {
|
|
99
|
-
const
|
|
100
|
-
const
|
|
80
|
+
const MarkdownContent = useUiPrimitive(UI_PRIMITIVE_KEYS.markdownContent);
|
|
81
|
+
const title = agent.label || agent.agentName;
|
|
82
|
+
const status = mapFlowStatus(agent.status);
|
|
83
|
+
const isComplete =
|
|
84
|
+
agent.status === "complete" || agent.status === "error" || agent.status === "blocked";
|
|
101
85
|
|
|
102
|
-
const
|
|
103
|
-
: agent.status === "error" ? mdiCloseCircle
|
|
104
|
-
: agent.status === "blocked" ? mdiAlertCircle
|
|
105
|
-
: agent.status === "running" ? mdiCircle
|
|
106
|
-
: mdiCircleOutline;
|
|
86
|
+
const entries = mapFlowEntries(agent.detailHistory);
|
|
107
87
|
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<div className="flex flex-col h-full overflow-hidden">
|
|
116
|
-
{/* Header */}
|
|
117
|
-
<div className="px-3 py-2 border-b border-[var(--border-subtle)] bg-[var(--bg-secondary)] flex items-center gap-2">
|
|
118
|
-
<button
|
|
119
|
-
onClick={onBack}
|
|
120
|
-
className="text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors"
|
|
121
|
-
>
|
|
122
|
-
<Icon path={mdiArrowLeft} size={0.7} />
|
|
123
|
-
</button>
|
|
124
|
-
<span className={`${statusColor} inline-flex`}><Icon path={statusIconPath} size={0.6} /></span>
|
|
125
|
-
<span className="text-sm font-medium text-[var(--text-primary)]">{displayName}</span>
|
|
126
|
-
{agent.model && (
|
|
127
|
-
<span className="text-[11px] text-[var(--text-tertiary)]">{agent.model}</span>
|
|
128
|
-
)}
|
|
129
|
-
{isComplete && agent.tokens && (
|
|
130
|
-
<span className="text-[11px] text-[var(--text-muted)] ml-auto">
|
|
131
|
-
↑{formatTokens(agent.tokens.input)} ↓{formatTokens(agent.tokens.output)} · {formatDuration(agent.duration ?? 0)}
|
|
132
|
-
</span>
|
|
133
|
-
)}
|
|
134
|
-
</div>
|
|
88
|
+
const footer = agent.summary ? (
|
|
89
|
+
<div className="mt-3 pt-2 border-t border-[var(--border-subtle)]">
|
|
90
|
+
<div className="text-[11px] text-[var(--text-muted)] mb-1">Summary</div>
|
|
91
|
+
<MarkdownContent content={agent.summary} />
|
|
92
|
+
</div>
|
|
93
|
+
) : undefined;
|
|
135
94
|
|
|
136
|
-
|
|
137
|
-
<div className="flex-1 overflow-y-auto px-3 py-2 space-y-0.5">
|
|
138
|
-
{agent.detailHistory.length === 0 ? (
|
|
139
|
-
<div className="text-sm text-[var(--text-muted)] py-4 text-center">
|
|
140
|
-
{agent.status === "pending" ? "Waiting to start..." : "No activity yet"}
|
|
141
|
-
</div>
|
|
142
|
-
) : (
|
|
143
|
-
agent.detailHistory.map((entry, i) => {
|
|
144
|
-
switch (entry.kind) {
|
|
145
|
-
case "tool":
|
|
146
|
-
return <ToolCallEntry key={i} entry={entry} />;
|
|
147
|
-
case "text":
|
|
148
|
-
return <TextEntry key={i} text={entry.text} />;
|
|
149
|
-
case "thinking":
|
|
150
|
-
return <ThinkingEntry key={i} text={entry.text} />;
|
|
151
|
-
case "error":
|
|
152
|
-
return (
|
|
153
|
-
<div key={i} className="py-1.5 pl-3 text-sm text-red-400">
|
|
154
|
-
{entry.text}
|
|
155
|
-
</div>
|
|
156
|
-
);
|
|
157
|
-
default:
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
})
|
|
161
|
-
)}
|
|
95
|
+
const emptyMessage = agent.status === "pending" ? "Waiting to start..." : "No activity yet";
|
|
162
96
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
97
|
+
return (
|
|
98
|
+
<MinimalChatView
|
|
99
|
+
title={title}
|
|
100
|
+
status={status}
|
|
101
|
+
entries={entries}
|
|
102
|
+
mode="popout"
|
|
103
|
+
onBack={onBack}
|
|
104
|
+
sessionId={sessionId}
|
|
105
|
+
meta={{
|
|
106
|
+
modelName: agent.model,
|
|
107
|
+
tokens: agent.tokens,
|
|
108
|
+
durationMs: isComplete ? agent.duration : undefined,
|
|
109
|
+
}}
|
|
110
|
+
emptyMessage={emptyMessage}
|
|
111
|
+
footer={footer}
|
|
112
|
+
/>
|
|
172
113
|
);
|
|
173
114
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlowAgentPopoutClaim — slot-claim wrapper for the `shell-overlay-route`
|
|
3
|
+
* registration `/session/:sid/flow/:flowId/agent/:agentId`.
|
|
4
|
+
*
|
|
5
|
+
* Self-derived from the slot props:
|
|
6
|
+
* - Reads `params.sid` / `params.flowId` (URL-decoded) / `params.agentId`.
|
|
7
|
+
* - Receives `session: DashboardSession | undefined` from the slot consumer.
|
|
8
|
+
* - Cold-open subscribes to the parent session via `usePluginSend`.
|
|
9
|
+
* - Reads flow state via `useFlowsSessionState(params.sid)`.
|
|
10
|
+
* - Renders the existing `FlowAgentPopoutPage` body.
|
|
11
|
+
*
|
|
12
|
+
* See change: add-flow-agent-popout.
|
|
13
|
+
*/
|
|
14
|
+
import React, { useEffect, useRef } from "react";
|
|
15
|
+
import {
|
|
16
|
+
usePluginSend,
|
|
17
|
+
useShellConnectionStatus,
|
|
18
|
+
} from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
19
|
+
import type { DashboardSession } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
20
|
+
import { useFlowsSessionState } from "./FlowsSessionStateContext.js";
|
|
21
|
+
import { FlowAgentPopoutPage } from "./FlowAgentPopoutPage.js";
|
|
22
|
+
|
|
23
|
+
export interface FlowAgentPopoutClaimProps {
|
|
24
|
+
params: Record<string, string>;
|
|
25
|
+
session?: DashboardSession;
|
|
26
|
+
onBack: () => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function FlowAgentPopoutClaim({ params, session, onBack }: FlowAgentPopoutClaimProps) {
|
|
30
|
+
const sessionId = params.sid ?? "";
|
|
31
|
+
const flowId = params.flowId ?? "";
|
|
32
|
+
const agentId = params.agentId ?? "";
|
|
33
|
+
const send = usePluginSend();
|
|
34
|
+
const { flowStates } = useFlowsSessionState(sessionId);
|
|
35
|
+
const connectionStatus = useShellConnectionStatus();
|
|
36
|
+
|
|
37
|
+
// Cold-open subscribe exactly once, AFTER the WebSocket is open.
|
|
38
|
+
// See change: fix-flows-plugin-polish (popout cold-open subscribe).
|
|
39
|
+
const subscribedRef = useRef(false);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!sessionId || subscribedRef.current) return;
|
|
42
|
+
if (connectionStatus !== "connected") return;
|
|
43
|
+
subscribedRef.current = true;
|
|
44
|
+
send({ type: "subscribe", sessionId, lastSeq: 0 });
|
|
45
|
+
}, [sessionId, send, connectionStatus]);
|
|
46
|
+
|
|
47
|
+
// The popout page's empty-state ladder evaluates loading → no session →
|
|
48
|
+
// no flow → no agent. We forward `flowStates` via the lightweight shape
|
|
49
|
+
// FlowAgentPopoutPage expects.
|
|
50
|
+
const subscriptionResolved = !!session || flowStates.size > 0;
|
|
51
|
+
const sessionLike = session || flowStates.size > 0
|
|
52
|
+
? { flowStates }
|
|
53
|
+
: undefined;
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<FlowAgentPopoutPage
|
|
57
|
+
sessionId={sessionId}
|
|
58
|
+
flowId={flowId}
|
|
59
|
+
agentId={agentId}
|
|
60
|
+
session={sessionLike}
|
|
61
|
+
subscriptionResolved={subscriptionResolved}
|
|
62
|
+
parentLabel={session?.cwd}
|
|
63
|
+
onBack={onBack}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlowAgentPopoutPage — fullscreen route content for
|
|
3
|
+
* `/session/:sid/flow/:flowId/agent/:agentId`.
|
|
4
|
+
*
|
|
5
|
+
* Mounts `FlowAgentDetail` in popout mode plus a chrome header. Graceful
|
|
6
|
+
* empty-state ladder:
|
|
7
|
+
* 1. Subscription not yet resolved → "Loading parent session…"
|
|
8
|
+
* 2. Parent session not found → close-tab CTA
|
|
9
|
+
* 3. Flow not present on parent session → "Flow not found"
|
|
10
|
+
* 4. Agent not present in flow → "Agent not found"
|
|
11
|
+
*
|
|
12
|
+
* Mirrors `SubagentPopoutPage` structurally; both popouts share the same
|
|
13
|
+
* four-tier empty-state contract.
|
|
14
|
+
*
|
|
15
|
+
* See change: add-flow-agent-popout.
|
|
16
|
+
*/
|
|
17
|
+
import React, { useEffect } from "react";
|
|
18
|
+
import { Icon } from "@mdi/react";
|
|
19
|
+
import { mdiArrowLeft, mdiClose } from "@mdi/js";
|
|
20
|
+
import type { FlowState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
21
|
+
import { FlowAgentDetail } from "./FlowAgentDetail.js";
|
|
22
|
+
|
|
23
|
+
/** Minimal session-state shape this page consumes. */
|
|
24
|
+
export interface FlowAgentPopoutSessionLike {
|
|
25
|
+
// Read-only: page only calls `.get(flowId)`. ReadonlyMap allows passing the
|
|
26
|
+
// frozen map returned by `useFlowsSessionState` directly.
|
|
27
|
+
flowStates?: ReadonlyMap<string, FlowState>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface FlowAgentPopoutPageProps {
|
|
31
|
+
sessionId: string;
|
|
32
|
+
flowId: string;
|
|
33
|
+
agentId: string;
|
|
34
|
+
/** Parent session state (or undefined if not yet subscribed). */
|
|
35
|
+
session: FlowAgentPopoutSessionLike | undefined;
|
|
36
|
+
/** True once the parent session's subscription has resolved. */
|
|
37
|
+
subscriptionResolved: boolean;
|
|
38
|
+
/** Optional parent-session display label (e.g. cwd basename) for the breadcrumb. */
|
|
39
|
+
parentLabel?: string;
|
|
40
|
+
onBack?: () => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function FlowAgentPopoutPage({
|
|
44
|
+
sessionId,
|
|
45
|
+
flowId,
|
|
46
|
+
agentId,
|
|
47
|
+
session,
|
|
48
|
+
subscriptionResolved,
|
|
49
|
+
parentLabel,
|
|
50
|
+
onBack,
|
|
51
|
+
}: FlowAgentPopoutPageProps) {
|
|
52
|
+
const flow = session?.flowStates?.get(flowId);
|
|
53
|
+
const agent = flow?.agents.get(agentId);
|
|
54
|
+
const agentName = agent?.label || agent?.agentName || agentId;
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
document.title = `${agentName} · ${flowId} · ${parentLabel ?? sessionId} · pi`;
|
|
58
|
+
return () => {
|
|
59
|
+
document.title = "pi";
|
|
60
|
+
};
|
|
61
|
+
}, [agentName, flowId, parentLabel, sessionId]);
|
|
62
|
+
|
|
63
|
+
// (1) Loading: subscription has not resolved yet.
|
|
64
|
+
if (!subscriptionResolved) {
|
|
65
|
+
return (
|
|
66
|
+
<div
|
|
67
|
+
data-testid="flow-agent-popout-loading"
|
|
68
|
+
className="flex flex-col h-full items-center justify-center text-sm text-[var(--text-muted)] gap-2"
|
|
69
|
+
>
|
|
70
|
+
<div>Loading parent session…</div>
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// (2) Parent session not found.
|
|
76
|
+
if (!session) {
|
|
77
|
+
return (
|
|
78
|
+
<div
|
|
79
|
+
data-testid="flow-agent-popout-no-session"
|
|
80
|
+
className="flex flex-col h-full items-center justify-center text-sm text-[var(--text-muted)] gap-3 px-6 text-center"
|
|
81
|
+
>
|
|
82
|
+
<div className="text-base text-[var(--text-primary)]">Parent session not found</div>
|
|
83
|
+
<div className="max-w-md">
|
|
84
|
+
It may have been archived or deleted. Close this tab — the session
|
|
85
|
+
this flow was launched from is no longer available in the dashboard.
|
|
86
|
+
</div>
|
|
87
|
+
<button
|
|
88
|
+
onClick={() => window.close()}
|
|
89
|
+
className="text-xs text-[var(--text-tertiary)] hover:text-[var(--text-primary)] inline-flex items-center gap-1 mt-2 px-3 py-1 border border-[var(--border-primary)] rounded"
|
|
90
|
+
>
|
|
91
|
+
<Icon path={mdiClose} size={0.5} /> Close tab
|
|
92
|
+
</button>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// (3) Flow not found on parent session.
|
|
98
|
+
if (!flow) {
|
|
99
|
+
return (
|
|
100
|
+
<div data-testid="flow-agent-popout-no-flow" className="flex flex-col h-full overflow-hidden">
|
|
101
|
+
<div className="px-3 py-2 border-b border-[var(--border-subtle)] bg-[var(--bg-secondary)] flex items-center gap-2 flex-shrink-0">
|
|
102
|
+
{onBack && (
|
|
103
|
+
<button
|
|
104
|
+
onClick={onBack}
|
|
105
|
+
className="text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors"
|
|
106
|
+
title="Back"
|
|
107
|
+
>
|
|
108
|
+
<Icon path={mdiArrowLeft} size={0.7} />
|
|
109
|
+
</button>
|
|
110
|
+
)}
|
|
111
|
+
<span className="text-sm text-[var(--text-primary)]">
|
|
112
|
+
Flow · {parentLabel ?? sessionId}
|
|
113
|
+
</span>
|
|
114
|
+
</div>
|
|
115
|
+
<div className="flex-1 flex items-center justify-center text-sm text-[var(--text-muted)] px-6 text-center">
|
|
116
|
+
Flow “{flowId}” is no longer active on this session.
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// (4) Agent not found in flow.
|
|
123
|
+
if (!agent) {
|
|
124
|
+
return (
|
|
125
|
+
<div data-testid="flow-agent-popout-no-agent" className="flex flex-col h-full overflow-hidden">
|
|
126
|
+
<div className="px-3 py-2 border-b border-[var(--border-subtle)] bg-[var(--bg-secondary)] flex items-center gap-2 flex-shrink-0">
|
|
127
|
+
{onBack && (
|
|
128
|
+
<button
|
|
129
|
+
onClick={onBack}
|
|
130
|
+
className="text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors"
|
|
131
|
+
title="Back"
|
|
132
|
+
>
|
|
133
|
+
<Icon path={mdiArrowLeft} size={0.7} />
|
|
134
|
+
</button>
|
|
135
|
+
)}
|
|
136
|
+
<span className="text-sm text-[var(--text-primary)]">
|
|
137
|
+
{parentLabel ?? sessionId} › {flowId}
|
|
138
|
+
</span>
|
|
139
|
+
</div>
|
|
140
|
+
<div className="flex-1 flex items-center justify-center text-sm text-[var(--text-muted)] px-6 text-center">
|
|
141
|
+
Agent “{agentId}” not found in this flow — it may have been cleared.
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// (5) Found — render the detail view with a chrome header.
|
|
148
|
+
return (
|
|
149
|
+
<div data-testid="flow-agent-popout" className="flex flex-col h-full overflow-hidden">
|
|
150
|
+
<div className="px-3 py-2 border-b border-[var(--border-primary)] bg-[var(--bg-primary)] flex items-center gap-2 flex-shrink-0">
|
|
151
|
+
{onBack && (
|
|
152
|
+
<button
|
|
153
|
+
onClick={onBack}
|
|
154
|
+
className="text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors"
|
|
155
|
+
title="Back"
|
|
156
|
+
>
|
|
157
|
+
<Icon path={mdiArrowLeft} size={0.7} />
|
|
158
|
+
</button>
|
|
159
|
+
)}
|
|
160
|
+
<span className="text-[11px] text-[var(--text-tertiary)] truncate flex-shrink-0">
|
|
161
|
+
{parentLabel ?? sessionId} › {flowId} ›
|
|
162
|
+
</span>
|
|
163
|
+
<span className="text-sm font-medium text-[var(--text-primary)] truncate flex-1 min-w-0">
|
|
164
|
+
{agentName}
|
|
165
|
+
</span>
|
|
166
|
+
</div>
|
|
167
|
+
{/* `min-h-0` required so body scrolls instead of overflowing.
|
|
168
|
+
See change: fix-flows-plugin-polish (scrollbar fix). */}
|
|
169
|
+
<div className="flex-1 min-h-0 overflow-hidden">
|
|
170
|
+
{/* FlowAgentDetail's own header carries status/model/tokens; the chrome
|
|
171
|
+
above carries breadcrumb + back nav. We omit `onBack` so the inner
|
|
172
|
+
header does not render a duplicate back arrow. */}
|
|
173
|
+
<FlowAgentDetail agent={agent} sessionId={sessionId} />
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
);
|
|
177
|
+
}
|