"use client"; import { FileIcon } from "./FileIcon"; import { ToolUseBlock } from "./ToolUseBlock"; interface ToolGlobProps { input: { pattern: string; path?: string; }; result?: string; isError?: boolean; isRunning?: boolean; startedAt?: number; completedAt?: number; } function parseFilePaths(result: string): string[] { return result .split("\n") .map((l) => l.trim()) .filter(Boolean); } export function ToolGlob({ input, result, isError = false, isRunning = false, startedAt, completedAt, }: ToolGlobProps) { const files = result ? parseFilePaths(result) : []; const fileCount = files.length; return ( {/* Pattern header */}
{input.pattern} {input.path && ( in {input.path} )} {!isRunning && fileCount > 0 && ( {fileCount} match{fileCount !== 1 ? "es" : ""} )}
{/* File list */} {isRunning ? (
Searching…
) : isError ? (
{result}
) : files.length === 0 ? (
No matches found.
) : (
{files.map((filePath, i) => (
{filePath}
))}
)}
); }