@mcp-b/react-components 0.33.0 → 0.34.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.
|
@@ -15,6 +15,11 @@ interface AgentToolDetailProps<State = unknown, MessageT extends UIMessage = UIM
|
|
|
15
15
|
messages?: ThinkChatMessagesProps<MessageT>;
|
|
16
16
|
/** App-authored TanStack Router Link to the parent conversation. */
|
|
17
17
|
backLink?: React.ReactElement;
|
|
18
|
+
/**
|
|
19
|
+
* Route-owned run controls (the app's cancel callable, for example),
|
|
20
|
+
* rendered in a `SubagentRunActions` bar pinned to the bottom edge.
|
|
21
|
+
*/
|
|
22
|
+
actions?: React.ReactNode;
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
20
25
|
* Live retained-child detail composed from upstream connection and chat values.
|
|
@@ -22,6 +27,7 @@ interface AgentToolDetailProps<State = unknown, MessageT extends UIMessage = UIM
|
|
|
22
27
|
* compact parent-side stream projection and is never promoted to fake history.
|
|
23
28
|
*/
|
|
24
29
|
declare function AgentToolDetail<State = unknown, MessageT extends UIMessage = UIMessage>({
|
|
30
|
+
actions,
|
|
25
31
|
backLink,
|
|
26
32
|
chat,
|
|
27
33
|
className,
|
|
@@ -41,9 +47,20 @@ interface SelectedAgentToolChildProps<ParentAgentT extends ThinkAgent<ParentStat
|
|
|
41
47
|
* configuration as the parent; the selected `run.subAgent` is appended.
|
|
42
48
|
*/
|
|
43
49
|
connectionOptions?: UseAgentOptions<ChildState>;
|
|
50
|
+
/**
|
|
51
|
+
* Initial child-transcript loader for hosts that do not serve the agent HTTP
|
|
52
|
+
* routes (upstream's default fetches `/get-messages` over HTTP). Receives the
|
|
53
|
+
* connected child agent so socket-only hosts can read through its stub;
|
|
54
|
+
* wired into `useAgentChat({ getInitialMessages })`.
|
|
55
|
+
*/
|
|
56
|
+
getInitialMessages?: (childAgent: ReturnType<typeof useAgent<ThinkAgent<ChildState>, ChildState>>) => Promise<MessageT[]>;
|
|
44
57
|
messages?: ThinkChatMessagesProps<MessageT>;
|
|
45
58
|
/** App-authored TanStack Router Link to the parent conversation. */
|
|
46
59
|
backLink?: React.ReactElement;
|
|
60
|
+
/** Rendered while the child transcript loads (the internal Suspense fallback). */
|
|
61
|
+
fallback?: React.ReactNode;
|
|
62
|
+
/** Route-owned run controls, forwarded to `AgentToolDetail`'s pinned actions bar. */
|
|
63
|
+
actions?: React.ReactNode;
|
|
47
64
|
}
|
|
48
65
|
/**
|
|
49
66
|
* Child connection options for a selected retained run: the parent's
|
|
@@ -58,10 +75,22 @@ declare function selectedAgentToolChildOptions<ChildState = unknown>(parentAgent
|
|
|
58
75
|
name: string;
|
|
59
76
|
}>;
|
|
60
77
|
}, run: Pick<AgentToolRunState, "subAgent">, connectionOptions?: UseAgentOptions<ChildState>): UseAgentOptions<ChildState>;
|
|
61
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Lazily connects one selected retained child and renders its real Think chat.
|
|
80
|
+
*
|
|
81
|
+
* The Suspense boundary between the connection and the chat is load-bearing:
|
|
82
|
+
* the child socket opens in an effect, and `useAgentChat` suspends while the
|
|
83
|
+
* initial transcript loads. Under one suspension the render never commits, the
|
|
84
|
+
* effect never runs, and the socket the load is waiting on never dials — so
|
|
85
|
+
* this component holds the connection and always commits, while the chat
|
|
86
|
+
* suspends behind the internal boundary.
|
|
87
|
+
*/
|
|
62
88
|
declare function SelectedAgentToolChild<ParentAgentT extends ThinkAgent<ParentState>, ParentState = unknown, ChildState = unknown, MessageT extends UIMessage = UIMessage>({
|
|
89
|
+
actions,
|
|
63
90
|
backLink,
|
|
64
91
|
connectionOptions,
|
|
92
|
+
fallback,
|
|
93
|
+
getInitialMessages,
|
|
65
94
|
messages,
|
|
66
95
|
parentAgent,
|
|
67
96
|
run
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as cx } from "../../class-names-BiMDVpUo.js";
|
|
2
2
|
import { r as ArrowLeftIcon } from "../../icons-B1Qw05te.js";
|
|
3
3
|
import { TransitionSurface } from "../foundations/TransitionSurface.js";
|
|
4
|
-
import { SubagentRunMilestone, SubagentRunMilestones, SubagentRunProgress } from "../agents-sdk/SubagentRunDetails.js";
|
|
4
|
+
import { SubagentRunActions, SubagentRunMilestone, SubagentRunMilestones, SubagentRunProgress } from "../agents-sdk/SubagentRunDetails.js";
|
|
5
5
|
import { SubagentRunIndicator, getSubagentRunName } from "../agents-sdk/SubagentRunIndicator.js";
|
|
6
6
|
import { t as ThinkChat } from "../../ThinkChat-en0UbkVv.js";
|
|
7
7
|
import { AppTopBar } from "../general-purpose/AppTopBar.js";
|
|
@@ -16,7 +16,7 @@ import { useAgent } from "agents/react";
|
|
|
16
16
|
* The full child transcript comes from `chat.messages`; `run.parts` remains a
|
|
17
17
|
* compact parent-side stream projection and is never promoted to fake history.
|
|
18
18
|
*/
|
|
19
|
-
function AgentToolDetail({ backLink, chat, className, messages, ref, run, ...props }) {
|
|
19
|
+
function AgentToolDetail({ actions, backLink, chat, className, messages, ref, run, ...props }) {
|
|
20
20
|
const backRef = React.useRef(null);
|
|
21
21
|
const name = getSubagentRunName(run);
|
|
22
22
|
const progressLabel = run.progress?.message ?? run.progress?.phase;
|
|
@@ -76,7 +76,8 @@ function AgentToolDetail({ backLink, chat, className, messages, ref, run, ...pro
|
|
|
76
76
|
showComposer: false
|
|
77
77
|
})
|
|
78
78
|
})
|
|
79
|
-
})
|
|
79
|
+
}),
|
|
80
|
+
actions ? /* @__PURE__ */ jsx(SubagentRunActions, { children: actions }) : null
|
|
80
81
|
]
|
|
81
82
|
});
|
|
82
83
|
}
|
|
@@ -95,14 +96,41 @@ function selectedAgentToolChildOptions(parentAgent, run, connectionOptions) {
|
|
|
95
96
|
sub: [...connectionOptions?.sub ?? parentSubPath, run.subAgent]
|
|
96
97
|
};
|
|
97
98
|
}
|
|
98
|
-
/**
|
|
99
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Lazily connects one selected retained child and renders its real Think chat.
|
|
101
|
+
*
|
|
102
|
+
* The Suspense boundary between the connection and the chat is load-bearing:
|
|
103
|
+
* the child socket opens in an effect, and `useAgentChat` suspends while the
|
|
104
|
+
* initial transcript loads. Under one suspension the render never commits, the
|
|
105
|
+
* effect never runs, and the socket the load is waiting on never dials — so
|
|
106
|
+
* this component holds the connection and always commits, while the chat
|
|
107
|
+
* suspends behind the internal boundary.
|
|
108
|
+
*/
|
|
109
|
+
function SelectedAgentToolChild({ actions, backLink, connectionOptions, fallback, getInitialMessages, messages, parentAgent, run }) {
|
|
110
|
+
const childAgent = useAgent(selectedAgentToolChildOptions(parentAgent, run, connectionOptions));
|
|
111
|
+
return /* @__PURE__ */ jsx(React.Suspense, {
|
|
112
|
+
fallback: fallback ?? null,
|
|
113
|
+
children: /* @__PURE__ */ jsx(SelectedAgentToolChildChat, {
|
|
114
|
+
actions,
|
|
115
|
+
backLink,
|
|
116
|
+
childAgent,
|
|
117
|
+
getInitialMessages,
|
|
118
|
+
messages,
|
|
119
|
+
run
|
|
120
|
+
}, run.runId)
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function SelectedAgentToolChildChat({ actions, backLink, childAgent, getInitialMessages, messages, run }) {
|
|
100
124
|
return /* @__PURE__ */ jsx(AgentToolDetail, {
|
|
101
125
|
run,
|
|
102
|
-
chat: useAgentChat({
|
|
126
|
+
chat: useAgentChat({
|
|
127
|
+
agent: childAgent,
|
|
128
|
+
...getInitialMessages ? { getInitialMessages: () => getInitialMessages(childAgent) } : {}
|
|
129
|
+
}),
|
|
103
130
|
messages,
|
|
104
|
-
backLink
|
|
105
|
-
|
|
131
|
+
backLink,
|
|
132
|
+
actions
|
|
133
|
+
});
|
|
106
134
|
}
|
|
107
135
|
//#endregion
|
|
108
136
|
export { AgentToolDetail, SelectedAgentToolChild, selectedAgentToolChildOptions };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.agent-tool-detail {
|
|
2
2
|
display: grid;
|
|
3
|
-
grid-template-rows: auto auto minmax(0, 1fr);
|
|
3
|
+
grid-template-rows: auto auto minmax(0, 1fr) auto;
|
|
4
4
|
min-inline-size: 0;
|
|
5
5
|
block-size: 100%;
|
|
6
6
|
background-color: var(--sigvelo-color-surface);
|
|
@@ -47,8 +47,18 @@
|
|
|
47
47
|
block-size: 100%;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
.agent-tool-detail > .subagent-run__actions {
|
|
51
|
+
grid-row: 4;
|
|
52
|
+
display: flex;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
padding: var(--sigvelo-spacing-2) var(--sigvelo-spacing-3);
|
|
55
|
+
border-block-start: var(--sigvelo-border-width) var(--sigvelo-border-style)
|
|
56
|
+
var(--sigvelo-color-neutral-border-subtle);
|
|
57
|
+
}
|
|
58
|
+
|
|
50
59
|
@media (forced-colors: active) {
|
|
51
|
-
.agent-tool-detail__run-state
|
|
60
|
+
.agent-tool-detail__run-state,
|
|
61
|
+
.agent-tool-detail > .subagent-run__actions {
|
|
52
62
|
border-color: CanvasText;
|
|
53
63
|
}
|
|
54
64
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-b/react-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "MCP-B React components built on Base UI and shared design tokens, including Cloudflare Think chat primitives.",
|
|
5
5
|
"homepage": "https://design-system.sigvelo.com",
|
|
6
6
|
"bugs": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"streamdown": "^2.5.0",
|
|
59
59
|
"unist-util-visit": "^5.1.0",
|
|
60
60
|
"yet-another-react-lightbox": "^3.32.1",
|
|
61
|
-
"@mcp-b/design-tokens": "0.
|
|
61
|
+
"@mcp-b/design-tokens": "0.34.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@ai-sdk/react": "^3.0.230",
|