Files
paseo/packages/server/src/shared/tool-call-display.test.ts
T
Mohamed Boudra 5b3ec572cb feat: service proxy, health monitor, hover card, and homepage section
Built-in service proxy with branch-based URLs, service health
monitoring, workspace hover card with service status, and
"Forget about ports" homepage section.
2026-04-01 10:31:15 +07:00

145 lines
3.5 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { buildToolCallDisplayModel } from "./tool-call-display.js";
describe("shared tool-call display mapping", () => {
it("builds summary from canonical detail", () => {
const display = buildToolCallDisplayModel({
name: "read_file",
status: "running",
error: null,
detail: {
type: "read",
filePath: "/tmp/repo/src/index.ts",
},
cwd: "/tmp/repo",
});
expect(display).toEqual({
displayName: "Read",
summary: "src/index.ts",
});
});
it("does not infer summaries from unknown raw detail", () => {
const display = buildToolCallDisplayModel({
name: "exec_command",
status: "running",
error: null,
detail: {
type: "unknown",
input: { command: "npm test" },
output: null,
},
});
expect(display).toEqual({
displayName: "Exec Command",
});
});
it("uses sub-agent detail for task label and description", () => {
const display = buildToolCallDisplayModel({
name: "task",
status: "running",
error: null,
detail: {
type: "sub_agent",
subAgentType: "Explore",
description: "Inspect repository structure",
log: "[Read] README.md",
actions: [
{
index: 1,
toolName: "Read",
summary: "README.md",
},
],
},
});
expect(display).toEqual({
displayName: "Explore",
summary: "Inspect repository structure",
});
});
it("builds display model for worktree setup detail", () => {
const display = buildToolCallDisplayModel({
name: "paseo_worktree_setup",
status: "running",
error: null,
detail: {
type: "worktree_setup",
worktreePath: "/tmp/repo/.paseo/worktrees/repo/branch",
branchName: "feature-branch",
log: "==> [1/1] Running: npm install\n",
commands: [
{
index: 1,
command: "npm install",
cwd: "/tmp/repo/.paseo/worktrees/repo/branch",
log: "==> [1/1] Running: npm install\n",
status: "running",
exitCode: null,
},
],
},
});
expect(display).toEqual({
displayName: "Worktree Setup",
summary: "feature-branch",
});
});
it("provides errorText for failed calls", () => {
const display = buildToolCallDisplayModel({
name: "shell",
status: "failed",
error: { message: "boom" },
detail: {
type: "unknown",
input: null,
output: null,
},
});
expect(display.errorText).toBe('{\n "message": "boom"\n}');
});
it("labels terminal interaction rows without a summary when no command is available", () => {
const display = buildToolCallDisplayModel({
name: "terminal",
status: "completed",
error: null,
detail: {
type: "plain_text",
icon: "square_terminal",
},
});
expect(display).toEqual({
displayName: "Terminal",
});
});
it("uses the command as terminal interaction summary when available", () => {
const display = buildToolCallDisplayModel({
name: "terminal",
status: "completed",
error: null,
detail: {
type: "plain_text",
label: "npm run test",
icon: "square_terminal",
},
});
expect(display).toEqual({
displayName: "Terminal",
summary: "npm run test",
});
});
});