mirror of
https://github.com/cline/cline.git
synced 2026-09-11 16:42:40 +08:00
* feat: checkpoint subagent tool workflow and approval UX * feat: support subagent tool execution without native tool calls * fix: expose use_subagents when native tool calling is disabled * fix: stabilize subagent command UX and suppress nested command rows * chore: tune subagent prompt guidance for context-heavy exploration * fix: align subagent row spacing with chat row conventions * fix: keep cancelled subagent state during immediate resume * feat: implement subagent message rendering for approval prompts and progress updates * feat: enhance SubagentRunner with tool use ID resolution and fallback handling * fix: stabilize subagent cline requests with ulid and initial workspace metadata * refactor: unify subagent chat row rendering * feat: surface subagent costs in task metrics and status rows * fix: refine cli subagent tree alignment and wrapping * fix: refine subagent streaming rows in cli and webview * fix: ensure unique act mode hint keys in CLI chat * feat: add subagents settings toggle wiring across webview and cli * fix(webview): stream subagent stats per prompt while constructing prompts * fix: remove duplicate subagentsEnabled declaration after rebase * chore: restore package lockfiles to main * fix: harden task history usage parsing and clean prompt separators * chore: refine subagent response formatting guidance * feat: collapse subagent prompts with show more * feat: show latest subagent tool call in status rows * fix: fall back to non-native mode for subagents when native tools are unavailable * fix: retry empty subagent responses before failing * fix(subagents): require attempt_completion and dedupe tool result formatting * feat(subagents): polish prompt guidance and webview status row
107 lines
2.9 KiB
TypeScript
107 lines
2.9 KiB
TypeScript
import type { ClineMessage } from "@shared/ExtensionMessage"
|
|
import { render } from "ink-testing-library"
|
|
import React from "react"
|
|
import { describe, expect, it, vi } from "vitest"
|
|
import { ChatMessage } from "./ChatMessage"
|
|
|
|
vi.mock("../hooks/useTerminalSize", () => ({
|
|
useTerminalSize: () => ({
|
|
columns: 120,
|
|
rows: 40,
|
|
resizeKey: 0,
|
|
}),
|
|
}))
|
|
|
|
describe("ChatMessage subagent rendering", () => {
|
|
it("renders subagent approval prompts as a tree", () => {
|
|
const message: ClineMessage = {
|
|
ts: Date.now(),
|
|
type: "ask",
|
|
ask: "use_subagents",
|
|
text: JSON.stringify({
|
|
prompts: [
|
|
"Find codebase stats and size",
|
|
"Find funny comments and easter eggs",
|
|
"Find unusual patterns and history",
|
|
],
|
|
}),
|
|
}
|
|
|
|
const { lastFrame } = render(React.createElement(ChatMessage, { message, mode: "act" }))
|
|
const frame = lastFrame() || ""
|
|
|
|
expect(frame).toContain("Cline wants to run subagents")
|
|
expect(frame).toContain("├─ Find codebase stats and size")
|
|
expect(frame).toContain("├─ Find funny comments and easter eggs")
|
|
expect(frame).toContain("└─ Find unusual patterns and history")
|
|
})
|
|
|
|
it("renders subagent progress rows with compact token stats and completion checks", () => {
|
|
const message: ClineMessage = {
|
|
ts: Date.now(),
|
|
type: "say",
|
|
say: "subagent",
|
|
text: JSON.stringify({
|
|
status: "running",
|
|
total: 3,
|
|
completed: 1,
|
|
successes: 1,
|
|
failures: 0,
|
|
toolCalls: 21,
|
|
inputTokens: 0,
|
|
outputTokens: 0,
|
|
contextWindow: 0,
|
|
maxContextTokens: 0,
|
|
maxContextUsagePercentage: 0,
|
|
items: [
|
|
{
|
|
index: 1,
|
|
prompt: "Find codebase stats and size",
|
|
status: "completed",
|
|
toolCalls: 5,
|
|
inputTokens: 0,
|
|
outputTokens: 0,
|
|
totalCost: 0.034,
|
|
contextTokens: 24400,
|
|
contextWindow: 200000,
|
|
contextUsagePercentage: 12.2,
|
|
},
|
|
{
|
|
index: 2,
|
|
prompt: "Find funny comments and easter eggs",
|
|
status: "running",
|
|
toolCalls: 11,
|
|
inputTokens: 0,
|
|
outputTokens: 0,
|
|
totalCost: 0.056,
|
|
contextTokens: 31600,
|
|
contextWindow: 200000,
|
|
contextUsagePercentage: 15.8,
|
|
},
|
|
{
|
|
index: 3,
|
|
prompt: "Find unusual patterns and history",
|
|
status: "pending",
|
|
toolCalls: 5,
|
|
inputTokens: 0,
|
|
outputTokens: 0,
|
|
totalCost: 0,
|
|
contextTokens: 28900,
|
|
contextWindow: 200000,
|
|
contextUsagePercentage: 14.4,
|
|
},
|
|
],
|
|
}),
|
|
}
|
|
|
|
const { lastFrame } = render(React.createElement(ChatMessage, { isStreaming: true, message, mode: "act" }))
|
|
const frame = lastFrame() || ""
|
|
|
|
expect(frame).toContain("Cline is running subagents")
|
|
expect(frame).toContain("✓ Find codebase stats and size")
|
|
expect(frame).toContain("5 tool uses · 24.4k tokens · $0.03")
|
|
expect(frame).toContain("11 tool uses · 31.6k tokens · $0.06")
|
|
expect(frame).toContain("5 tool uses · 28.9k tokens · $0.00")
|
|
})
|
|
})
|