MCPcopy Create free account
hub / github.com/codeaashu/claude-code / ToolFileRead

Function ToolFileRead

web/components/tools/ToolFileRead.tsx:45–119  ·  view source on GitHub ↗
({
  input,
  result,
  isError = false,
  isRunning = false,
  startedAt,
  completedAt,
}: ToolFileReadProps)

Source from the content-addressed store, hash-verified

43const MAX_LINES_COLLAPSED = 40;
44
45export function ToolFileRead({
46 input,
47 result,
48 isError = false,
49 isRunning = false,
50 startedAt,
51 completedAt,
52}: ToolFileReadProps) {
53 const [showAll, setShowAll] = useState(false);
54 const lang = getLanguageFromPath(input.file_path);
55
56 const lines = result?.split("\n") ?? [];
57 const isTruncated = !showAll && lines.length > MAX_LINES_COLLAPSED;
58 const displayContent = isTruncated
59 ? lines.slice(0, MAX_LINES_COLLAPSED).join("\n")
60 : (result ?? "");
61
62 return (
63 <ToolUseBlock
64 toolName="read"
65 toolInput={input}
66 toolResult={result}
67 isError={isError}
68 isRunning={isRunning}
69 startedAt={startedAt}
70 completedAt={completedAt}
71 >
72 {/* File path header */}
73 <div className="flex items-center gap-2 px-3 py-2 border-b border-surface-700/50 bg-surface-850">
74 <FileIcon
75 filePath={input.file_path}
76 className="w-3.5 h-3.5 text-surface-400 flex-shrink-0"
77 />
78 <FileBreadcrumb filePath={input.file_path} />
79 {(input.offset !== undefined || input.limit !== undefined) && (
80 <span className="ml-auto text-xs text-surface-500 flex-shrink-0">
81 {input.offset !== undefined && `offset: ${input.offset}`}
82 {input.offset !== undefined && input.limit !== undefined && " · "}
83 {input.limit !== undefined && `limit: ${input.limit}`}
84 </span>
85 )}
86 </div>
87
88 {/* Content */}
89 {isRunning ? (
90 <div className="px-3 py-4 text-surface-500 text-xs animate-pulse">
91 Reading…
92 </div>
93 ) : isError ? (
94 <div className="px-3 py-3 text-red-400 text-xs font-mono">{result}</div>
95 ) : result ? (
96 <div className="relative">
97 <div className="overflow-auto max-h-[480px] [&_pre]:!bg-transparent [&_pre]:!m-0 [&_.shiki]:!bg-transparent">
98 <SyntaxHighlight
99 code={displayContent}
100 lang={lang}
101 className="text-xs [&_pre]:p-3 [&_pre]:leading-5"
102 />

Callers

nothing calls this directly

Calls 1

getLanguageFromPathFunction · 0.90

Tested by

no test coverage detected