Files
tutti/packages/agent/gui/shared/workspaceAgentToolCallDisplay.spec.ts
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

103 lines
2.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { WorkspaceAgentActivityTimelineItem } from "./workspaceAgentTimelineTypes";
import {
buildWorkspaceAgentToolCallDisplay,
resolveWorkspaceAgentToolName
} from "./workspaceAgentToolCallDisplay";
describe("resolveWorkspaceAgentToolName", () => {
it.each([
["edit", "apply_patch", "Success. Updated index.html", "Edit"],
["execute", "python3 -c 'print(1)'", "python3 finished", "Bash"],
["read", "read", "/workspace/index.html", "Read"],
["search", "glob", "/workspace/**/*.ts", "Glob"],
["other", "todowrite", "0 todos", "TodoWrite"],
["other", "skill", "Loaded skill: webapp-testing", "Skill"]
])(
"recovers canonical %s tools from previously persisted standard ACP input",
(kind, title, dynamicName, expected) => {
expect(
resolveWorkspaceAgentToolName(
legacyStandardACPCall({ kind, title, dynamicName })
)
).toBe(expected);
}
);
});
describe("buildWorkspaceAgentToolCallDisplay", () => {
it("marks a structured provider error as failed when no terminal status exists", () => {
const display = buildWorkspaceAgentToolCallDisplay({
id: 2,
agentSessionId: "session-1",
eventId: "event-2",
actorType: "agent",
actorId: "cursor",
itemType: "call",
callType: "tool",
name: "MCP request",
payload: {
toolName: "McpTool",
error: {
response: { detail: { message: "MCP request failed" } }
}
}
});
expect(display.statusKind).toBe("failed");
expect(display.detail).toBe("MCP request failed");
});
it("keeps a canonical completed status while preserving diagnostic detail", () => {
const display = buildWorkspaceAgentToolCallDisplay({
id: 3,
agentSessionId: "session-1",
eventId: "event-3",
actorType: "agent",
actorId: "cursor",
itemType: "call.completed",
callType: "tool",
name: "MCP request",
payload: {
toolName: "McpTool",
error: {
stderr: "provider emitted a diagnostic after completion"
}
}
});
expect(display.statusKind).toBe("completed");
expect(display.detail).toBe(
"provider emitted a diagnostic after completion"
);
});
});
function legacyStandardACPCall(input: {
kind: string;
title: string;
dynamicName: string;
}): WorkspaceAgentActivityTimelineItem {
return {
id: 1,
agentSessionId: "session-1",
eventId: "event-1",
actorType: "agent",
actorId: "opencode",
itemType: "call",
callType: "tool",
callId: "call-1",
name: input.dynamicName,
payload: {
callId: "call-1",
callType: "tool",
toolName: input.dynamicName,
input: {
kind: input.kind,
title: input.title,
rawInput: {}
}
}
};
}