fix(tui): show skill name in mini tool output (#38250)
This commit is contained in:
parent
23483ea013
commit
ca6da05d07
2 changed files with 38 additions and 3 deletions
|
|
@ -49,6 +49,7 @@ type PatchFile = {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ToolInput = ToolDict & {
|
type ToolInput = ToolDict & {
|
||||||
|
id?: string
|
||||||
path?: string
|
path?: string
|
||||||
pattern?: string
|
pattern?: string
|
||||||
url?: string
|
url?: string
|
||||||
|
|
@ -67,6 +68,7 @@ type ToolInput = ToolDict & {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ToolMetadata = ToolDict & {
|
type ToolMetadata = ToolDict & {
|
||||||
|
name?: string
|
||||||
count?: number
|
count?: number
|
||||||
matches?: number
|
matches?: number
|
||||||
diff?: string
|
diff?: string
|
||||||
|
|
@ -416,9 +418,10 @@ function runTask(p: ToolProps): ToolInline {
|
||||||
}
|
}
|
||||||
|
|
||||||
function runSkill(p: ToolProps): ToolInline {
|
function runSkill(p: ToolProps): ToolInline {
|
||||||
|
const name = p.metadata.name ?? p.input.id ?? ""
|
||||||
return {
|
return {
|
||||||
icon: "→",
|
icon: "→",
|
||||||
title: `Skill "${p.input.name ?? ""}"`,
|
title: `Skill "${name}"`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -819,7 +822,7 @@ function scrollLspStart(p: ToolProps): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollSkillStart(p: ToolProps): string {
|
function scrollSkillStart(p: ToolProps): string {
|
||||||
return `→ Skill "${p.input.name ?? ""}"`
|
return `→ Skill "${p.metadata.name ?? p.input.id ?? ""}"`
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollGlobStart(p: ToolProps): string {
|
function scrollGlobStart(p: ToolProps): string {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { describe, expect, test } from "bun:test"
|
import { describe, expect, test } from "bun:test"
|
||||||
import { normalizeTool, toolOutputText, toolPath } from "../../src/mini/tool"
|
import { normalizeTool, toolInlineInfo, toolOutputText, toolPath, toolScroll } from "../../src/mini/tool"
|
||||||
|
|
||||||
describe("Mini tool presentation", () => {
|
describe("Mini tool presentation", () => {
|
||||||
test("uses V2 shell output without the model-facing status", () => {
|
test("uses V2 shell output without the model-facing status", () => {
|
||||||
|
|
@ -73,6 +73,38 @@ describe("Mini tool presentation", () => {
|
||||||
).toMatchObject({ name: "subagent", state: { input: { agent: "explore" } } })
|
).toMatchObject({ name: "subagent", state: { input: { agent: "explore" } } })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("renders the skill name from structured metadata with the input id as fallback", () => {
|
||||||
|
const skill = (structured: { name?: string }) => ({
|
||||||
|
type: "tool" as const,
|
||||||
|
id: "call-skill",
|
||||||
|
name: "skill",
|
||||||
|
state: {
|
||||||
|
status: "completed" as const,
|
||||||
|
input: { id: "tigerstyle" },
|
||||||
|
structured,
|
||||||
|
content: [],
|
||||||
|
},
|
||||||
|
time: { created: 1, ran: 1, completed: 2 },
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(toolInlineInfo(skill({ name: "effect" })).title).toBe('Skill "effect"')
|
||||||
|
expect(toolInlineInfo(skill({})).title).toBe('Skill "tigerstyle"')
|
||||||
|
expect(
|
||||||
|
toolScroll("start", {
|
||||||
|
directory: "/work/project",
|
||||||
|
raw: "",
|
||||||
|
name: "skill",
|
||||||
|
input: { id: "tigerstyle" },
|
||||||
|
meta: { name: "effect" },
|
||||||
|
state: {},
|
||||||
|
status: "completed",
|
||||||
|
error: "",
|
||||||
|
output: "",
|
||||||
|
time: {},
|
||||||
|
}),
|
||||||
|
).toBe('→ Skill "effect"')
|
||||||
|
})
|
||||||
|
|
||||||
test("keeps segment-safe contained tool paths relative", () => {
|
test("keeps segment-safe contained tool paths relative", () => {
|
||||||
expect(toolPath("..cache/result.txt", { directory: "/work/project" })).toBe("..cache/result.txt")
|
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")
|
expect(toolPath("../shared/result.txt", { directory: "/work/project" })).toBe("/work/shared/result.txt")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue