MCPcopy Index your code
hub / github.com/enowdev/enowX-Coder / ToolExecutionBlock

Function ToolExecutionBlock

src/components/chat/ToolExecutionBlock.tsx:18–70  ·  view source on GitHub ↗
({
  tool,
  defaultExpanded = false,
})

Source from the content-addressed store, hash-verified

16};
17
18export const ToolExecutionBlock: React.FC<ToolExecutionBlockProps> = ({
19 tool,
20 defaultExpanded = false,
21}) => {
22 const [open, setOpen] = useState(defaultExpanded);
23 const isFailed = tool.status === 'failed';
24
25 return (
26 <div>
27 <button
28 onClick={() => setOpen((v) => !v)}
29 className="flex items-center gap-1.5 text-[12px] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors py-1"
30 >
31 {open ? <CaretDown size={10} weight="bold" /> : <CaretRight size={10} weight="bold" />}
32 <Terminal size={12} weight="duotone" />
33 <span className="font-medium font-mono">{tool.toolName}</span>
34 <span
35 className={cn(
36 'text-[10px] px-1.5 py-0.5 rounded-full',
37 isFailed
38 ? 'text-[var(--danger)] bg-[var(--danger-bg)]'
39 : tool.status === 'running'
40 ? 'text-[var(--accent)] bg-[var(--hover-bg)]'
41 : 'text-[var(--text-subtle)] bg-[var(--surface-3)]',
42 )}
43 >
44 {statusLabel(tool.status)}
45 </span>
46 </button>
47
48 {open && (
49 <div className="ml-5 pl-3 border-l-2 border-[var(--border)] space-y-1.5 mt-1 mb-1">
50 <div className="font-mono text-[11px] text-[var(--text-muted)] whitespace-pre-wrap break-all bg-[var(--surface-2)] rounded-lg px-3 py-2">
51 {`> ${tool.toolName} ${tool.input}`}
52 </div>
53
54 {tool.output && (
55 <div className="font-mono text-[11px] text-[var(--text-subtle)] whitespace-pre-wrap break-all bg-[var(--surface-2)] rounded-lg px-3 py-2 max-h-48 overflow-y-auto custom-scrollbar">
56 {tool.output}
57 </div>
58 )}
59
60 {isFailed && (
61 <div className="flex items-start gap-1.5 text-[11px] text-[var(--danger)] bg-[var(--danger-bg)] rounded-lg px-3 py-2">
62 <WarningCircle size={13} className="mt-0.5 shrink-0" />
63 <span>{tool.error ?? 'Tool execution failed.'}</span>
64 </div>
65 )}
66 </div>
67 )}
68 </div>
69 );
70};

Callers

nothing calls this directly

Calls 2

cnFunction · 0.90
statusLabelFunction · 0.85

Tested by

no test coverage detected