feat(xai): surface hosted X Search activity (#5050)

This commit is contained in:
chengyongru
2026-07-23 13:42:09 +08:00
committed by GitHub
parent f3099286ea
commit 9cf2fb19c2
14 changed files with 431 additions and 8 deletions
@@ -961,6 +961,35 @@ describe("AgentActivityCluster", () => {
expect(screen.getAllByTestId("activity-step")).toHaveLength(3);
});
it("renders hosted X search as an explicit search activity", () => {
const line = 'x_search({"query":"nanobot oauth"})';
render(
<AgentActivityCluster
messages={[{
id: "t-x-search",
role: "tool",
kind: "trace",
content: line,
traces: [line],
toolEvents: [{
phase: "end",
call_id: "x-search-1",
name: "x_search",
arguments: { query: "nanobot oauth" },
result: { name: "x_semantic_search" },
}],
createdAt: 1,
}]}
isTurnStreaming={false}
hasBodyBelow={false}
/>,
);
expect(screen.getByText("Searched X · nanobot oauth")).toBeInTheDocument();
expect(screen.queryByText(/Completed X search/i)).not.toBeInTheDocument();
expect(screen.getAllByTestId("activity-step")).toHaveLength(1);
});
it("redacts credentials from web search queries, titles, and links", () => {
const query = "release notes access_token=signed-secret";
const line = `web_search(${JSON.stringify({ query })})`;
@@ -32,6 +32,14 @@ describe("trace activity semantics", () => {
expect(describeTrace('web_search({"query":"status test"})', status).label).toBe(label);
});
it.each([
["running", "Searching X · status test"],
["done", "Searched X · status test"],
["error", "Could not search X · status test"],
] as const)("identifies hosted X search activity for %s", (status, label) => {
expect(describeTrace('x_search({"query":"status test"})', status).label).toBe(label);
});
it("never exposes URL credentials, query secrets, or private-network links", () => {
const publicResult = describeTrace(
'web_fetch({"url":"https://user:password@example.com/docs?api_key=secret#section"})',