Files
paseo/packages/app/src/utils/tool-call-icon.test.ts
T
Mohamed BoudraandGitHub 0832b12608 Show task notifications as synthetic tool calls in chat (#79)
* fix(server): render claude task notifications as synthetic tool calls

* refactor(claude): extract task-notification tool-call mapper

* refactor: drive tool icons from plain_text detail metadata

* refactor(claude): make task-notification parsing schema-first
2026-02-24 18:15:23 +07:00

73 lines
1.8 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
const iconMocks = vi.hoisted(() => ({
Bot: () => null,
Brain: () => null,
Eye: () => null,
MicVocal: () => null,
Pencil: () => null,
Search: () => null,
Sparkles: () => null,
SquareTerminal: () => null,
Wrench: () => null,
}));
vi.mock("lucide-react-native", () => iconMocks);
import { resolveToolCallIcon } from "./tool-call-icon";
describe("tool-call-icon", () => {
it("uses robot icon for task sub-agent details", () => {
const icon = resolveToolCallIcon("Task", {
type: "sub_agent",
subAgentType: "Explore",
description: "Inspect repository",
log: "[Read] README.md",
actions: [{ index: 1, toolName: "Read", summary: "README.md" }],
});
expect(icon).toBe(iconMocks.Bot);
});
it("uses robot icon for task calls without canonical detail", () => {
const icon = resolveToolCallIcon("Task", {
type: "unknown",
input: null,
output: null,
});
expect(icon).toBe(iconMocks.Bot);
expect(resolveToolCallIcon("Task")).toBe(iconMocks.Bot);
});
it("keeps thinking icon override for unknown detail", () => {
const icon = resolveToolCallIcon("thinking", {
type: "unknown",
input: null,
output: null,
});
expect(icon).toBe(iconMocks.Brain);
});
it("uses custom icon from plain_text detail", () => {
const icon = resolveToolCallIcon("custom_tool", {
type: "plain_text",
label: "Background task completed",
icon: "sparkles",
text: "notification payload",
});
expect(icon).toBe(iconMocks.Sparkles);
});
it("does not special-case skill tool names", () => {
const icon = resolveToolCallIcon("skill", {
type: "plain_text",
label: "Skill output",
});
expect(icon).toBe(iconMocks.Wrench);
});
});