All files / src/components/tools ToolCard.tsx

75% Statements 12/16
71.42% Branches 10/14
100% Functions 1/1
75% Lines 12/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58                                                147x   147x   49x   14x       23x               8x   7x   6x   5x   4x   6x   25x      
import type { JSX } from "react";
import type { ToolCardProps } from "./ToolCardProps.js";
import { classifyTool } from "./classifyTool.js";
import { FileReadCard } from "./FileReadCard.js";
import { FileEditCard } from "./FileEditCard.js";
import { ShellCard } from "./ShellCard.js";
import { SearchCard } from "./SearchCard.js";
import { TodoCard } from "./TodoCard.js";
import { MetadataCard } from "./MetadataCard.js";
import { TaskCard } from "./TaskCard.js";
import { WorkpadCard } from "./WorkpadCard.js";
import { KnowledgeCard } from "./KnowledgeCard.js";
import { IpcCard } from "./IpcCard.js";
import { ToolSearchCard } from "./ToolSearchCard.js";
import { GenericToolCard } from "./GenericToolCard.js";
import { AgentToolCard } from "./AgentToolCard.js";
 
/**
 * Routes a tool event to the appropriate specialized card component.
 *
 * This is a thin classifier + router — all rendering logic lives in the
 * individual card components, which are independently testable via Storybook.
 */
export function ToolCard(props: ToolCardProps): JSX.Element {
  const category = classifyTool(props.tool);
 
  switch (category) {
    case "file-read":
      return <FileReadCard {...props} />;
    case "file-edit":
      return <FileEditCard {...props} />;
    case "file-write":
      return <FileReadCard {...props} writeVariant />;
    case "shell":
      return <ShellCard {...props} />;
    case "search":
      return <SearchCard {...props} />;
    case "todo":
      return <TodoCard {...props} />;
    case "metadata":
      return <MetadataCard {...props} />;
    case "task":
      return <TaskCard {...props} />;
    case "workpad":
      return <WorkpadCard {...props} />;
    case "knowledge":
      return <KnowledgeCard {...props} />;
    case "ipc":
      return <IpcCard {...props} />;
    case "tool-search":
      return <ToolSearchCard {...props} />;
    case "agent":
      return <AgentToolCard {...props} />;
    default:
      return <GenericToolCard {...props} />;
  }
}