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

Function ToolFileWrite

web/components/tools/ToolFileWrite.tsx:43–103  ·  view source on GitHub ↗
({
  input,
  result,
  isError = false,
  isRunning = false,
  startedAt,
  completedAt,
}: ToolFileWriteProps)

Source from the content-addressed store, hash-verified

41}
42
43export function ToolFileWrite({
44 input,
45 result,
46 isError = false,
47 isRunning = false,
48 startedAt,
49 completedAt,
50}: ToolFileWriteProps) {
51 const lang = getLanguageFromPath(input.file_path);
52 const lineCount = input.content.split("\n").length;
53
54 return (
55 <ToolUseBlock
56 toolName="write"
57 toolInput={input}
58 toolResult={result}
59 isError={isError}
60 isRunning={isRunning}
61 startedAt={startedAt}
62 completedAt={completedAt}
63 >
64 {/* File path header */}
65 <div className="flex items-center gap-2 px-3 py-2 border-b border-surface-700/50 bg-surface-850">
66 <FileIcon
67 filePath={input.file_path}
68 className="w-3.5 h-3.5 text-surface-400 flex-shrink-0"
69 />
70 <FileBreadcrumb filePath={input.file_path} />
71 <div className="ml-auto flex items-center gap-2 flex-shrink-0">
72 <span className="text-xs text-surface-500">{lineCount} lines</span>
73 <span
74 className={
75 isNewFile(result)
76 ? "text-xs px-1.5 py-0.5 rounded bg-green-900/40 text-green-400 border border-green-800/50"
77 : "text-xs px-1.5 py-0.5 rounded bg-yellow-900/30 text-yellow-400 border border-yellow-800/40"
78 }
79 >
80 {isNewFile(result) ? "New file" : "Overwrite"}
81 </span>
82 </div>
83 </div>
84
85 {/* Content */}
86 {isRunning ? (
87 <div className="px-3 py-4 text-surface-500 text-xs animate-pulse">
88 Writing…
89 </div>
90 ) : isError ? (
91 <div className="px-3 py-3 text-red-400 text-xs font-mono">{result}</div>
92 ) : (
93 <div className="overflow-auto max-h-[480px] [&_pre]:!bg-transparent [&_pre]:!m-0 [&_.shiki]:!bg-transparent">
94 <SyntaxHighlight
95 code={input.content}
96 lang={lang}
97 className="text-xs [&_pre]:p-3 [&_pre]:leading-5"
98 />
99 </div>
100 )}

Callers

nothing calls this directly

Calls 2

getLanguageFromPathFunction · 0.90
isNewFileFunction · 0.85

Tested by

no test coverage detected