-
-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathBashToolViewer.tsx
More file actions
52 lines (42 loc) · 1.42 KB
/
Copy pathBashToolViewer.tsx
File metadata and controls
52 lines (42 loc) · 1.42 KB
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
43
44
45
46
47
48
49
50
51
52
/**
* BashToolViewer
*
* Renders Bash tool calls with syntax-highlighted command input
* via CodeBlockViewer and collapsible output section.
*/
import React from 'react';
import { CodeBlockViewer } from '@renderer/components/chat/viewers';
import { type ItemStatus } from '../BaseItem';
import { CollapsibleOutputSection } from './CollapsibleOutputSection';
import { renderOutput } from './renderHelpers';
import type { LinkedToolItem } from '@renderer/types/groups';
interface BashToolViewerProps {
linkedTool: LinkedToolItem;
status: ItemStatus;
}
export const BashToolViewer: React.FC<BashToolViewerProps> = ({ linkedTool, status }) => {
const command = linkedTool.input.command as string;
const description = linkedTool.input.description as string | undefined;
// Use the description (truncated) as the file name label, or fallback to "bash"
const fileName = description
? description.length > 60
? description.slice(0, 57) + '...'
: description
: 'bash';
return (
<>
{/* Input Section — Syntax-highlighted command */}
<CodeBlockViewer
fileName={fileName}
content={command}
language="bash"
/>
{/* Output Section — Collapsible */}
{!linkedTool.isOrphaned && linkedTool.result && (
<CollapsibleOutputSection status={status}>
{renderOutput(linkedTool.result.content)}
</CollapsibleOutputSection>
)}
</>
);
};