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

14.28% Statements 4/28
100% Branches 0/0
0% Functions 0/2
14.28% Lines 4/28

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
    1x

    1x
    1x

    1x

     import type { JSX } from "react";
    import { CornerDownRight } from "lucide-react";
    import type { ToolCardProps } from "./ToolCardProps.js";
    import { ICON_SM } from "../../utils/iconSize.js";
    import styles from "./toolCards.module.scss";

    /** Extracts a human-readable summary from metadata tool args. */
    function getSummary(tool: string, args: unknown): string {
      if (args === null || args === undefined || typeof args !== "object") {
        return "";
      }
      const a = args as Record<string, unknown>;

      // report_intent: show the intent value
      if (typeof a.intent === "string") {
        return a.intent;
      }

      // Generic: show first string value
      for (const value of Object.values(a)) {
        if (typeof value === "string") {
          return value;
        }
      }

      return tool;
    }

    /** Renders a metadata/intent tool call as a minimal inline annotation. */
    export function MetadataCard({ tool, args }: ToolCardProps): JSX.Element {
      const summary = getSummary(tool, args);

      return (
        <div className={styles.metadata} data-testid="tool-card-metadata">
          <span className={styles.metadataPrefix}>
            <CornerDownRight size={ICON_SM} />
          </span>
          {summary}
        </div>
      );
    }