feat(core): compact durable tool metadata (#38343)

This commit is contained in:
Kit Langton 2026-07-22 12:09:48 -04:00 committed by GitHub
commit 7a1f9764a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 169 additions and 14 deletions

View file

@ -2669,8 +2669,7 @@ function WebFetch(props: ToolProps) {
function WebSearch(props: ToolProps) {
return (
<InlineTool icon="◈" pending="Searching web..." complete={stringValue(props.input.query)} part={props.part}>
{webSearchProviderLabel(props.metadata.provider)} "{stringValue(props.input.query)}"{" "}
<Show when={finiteNumber(props.metadata.numResults)}>({finiteNumber(props.metadata.numResults)} results)</Show>
{webSearchProviderLabel(props.metadata.provider)} "{stringValue(props.input.query)}"
</InlineTool>
)
}

View file

@ -1,5 +1,6 @@
import { describe, expect, test } from "bun:test"
import { normalizeTool, toolInlineInfo, toolOutputText, toolPath, toolScroll } from "../../src/mini/tool"
import { canonicalToolPart } from "./fixture/tool-part"
describe("Mini tool presentation", () => {
test("uses V2 shell output without the model-facing status", () => {
@ -105,6 +106,29 @@ describe("Mini tool presentation", () => {
).toBe('→ Skill "effect"')
})
test("renders compact search metadata", () => {
expect(
toolInlineInfo(
canonicalToolPart("glob", {
status: "completed",
input: { pattern: "*.ts" },
structured: { count: 3 },
content: [],
}),
).description,
).toBe("3 matches")
expect(
toolInlineInfo(
canonicalToolPart("grep", {
status: "completed",
input: { pattern: "needle" },
structured: { matches: 1 },
content: [],
}),
).description,
).toBe("1 match")
})
test("keeps segment-safe contained tool paths relative", () => {
expect(toolPath("..cache/result.txt", { directory: "/work/project" })).toBe("..cache/result.txt")
expect(toolPath("../shared/result.txt", { directory: "/work/project" })).toBe("/work/shared/result.txt")