# All files / src/components/tools ToolCard.tsx

31.91% Statements 15/47
100% Branches 0/0
0% Functions 0/1
31.91% Lines 15/47

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

    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x

    1x

     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} />;
      }
    }