mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-09-04 10:11:46 +03:00
feat: add provider-native request switches (#5254)
This commit is contained in:
@@ -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), {
|
||||
|
||||
Reference in New Issue
Block a user