feat: add provider-native request switches (#5254)

This commit is contained in:
chengyongru
2026-08-05 18:26:39 +08:00
committed by GitHub
parent 5a1ab44baa
commit 67805f5db8
32 changed files with 1130 additions and 52 deletions
+45
View File
@@ -610,6 +610,51 @@ describe("useNanobotStream", () => {
]);
});
it("replaces a hosted search placeholder when its query arrives", () => {
const fake = fakeClient();
const { result } = renderHook(() => useNanobotStream("chat-hosted-search", EMPTY_MESSAGES), {
wrapper: wrap(fake.client),
});
act(() => {
fake.emit("chat-hosted-search", {
event: "message",
chat_id: "chat-hosted-search",
text: "web_search()",
kind: "tool_hint",
tool_events: [{
phase: "start",
call_id: "ws-1",
name: "web_search",
arguments: {},
}],
});
fake.emit("chat-hosted-search", {
event: "message",
chat_id: "chat-hosted-search",
text: "",
kind: "progress",
tool_events: [{
phase: "end",
call_id: "ws-1",
name: "web_search",
arguments: { query: "nanobot news" },
result: { status: "completed" },
}],
});
});
expect(result.current.messages).toHaveLength(1);
expect(result.current.messages[0].traces).toEqual([
'web_search({"query":"nanobot news"})',
]);
expect(result.current.messages[0].toolEvents).toMatchObject([{
phase: "end",
call_id: "ws-1",
arguments: { query: "nanobot news" },
}]);
});
it("keeps phase updates when a tool event trace line is deduped", () => {
const fake = fakeClient();
const { result } = renderHook(() => useNanobotStream("chat-tool-phase", EMPTY_MESSAGES), {