Skip to content

Commit 976f3b7

Browse files
committed
revert: restore str-replace, diff-viewer, and tool-call-item components from main
1 parent 66ad0c1 commit 976f3b7

File tree

3 files changed

+24
-56
lines changed

3 files changed

+24
-56
lines changed

cli/src/components/tools/diff-viewer.tsx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,25 @@ const lineColor = (line: string): { fg: string; attrs?: number } => {
4141
export const DiffViewer = ({ diffText }: DiffViewerProps) => {
4242
const theme = useTheme()
4343
const lines = diffText.split('\n')
44-
const filteredLines = lines.filter((rawLine) => !rawLine.startsWith('@@'))
4544

4645
return (
47-
<text style={{ wrapMode: 'none', marginTop: 0, marginBottom: 0 }}>
48-
{filteredLines.map((rawLine, idx) => {
49-
const line = rawLine.length === 0 ? ' ' : rawLine
50-
const { fg, attrs } = lineColor(line)
51-
const resolvedFg = fg || theme.foreground
52-
return (
53-
<span key={`diff-line-${idx}`} fg={resolvedFg} attributes={attrs}>
54-
{line}
55-
{idx < filteredLines.length - 1 ? '\n' : ''}
56-
</span>
57-
)
58-
})}
59-
</text>
46+
<box
47+
style={{ flexDirection: 'column', gap: 0, width: '100%', flexGrow: 1 }}
48+
>
49+
{lines
50+
.filter((rawLine) => !rawLine.startsWith('@@'))
51+
.map((rawLine, idx) => {
52+
const line = rawLine.length === 0 ? ' ' : rawLine
53+
const { fg, attrs } = lineColor(line)
54+
const resolvedFg = fg || theme.foreground
55+
return (
56+
<text key={`diff-line-${idx}`} style={{ wrapMode: 'none' }}>
57+
<span fg={resolvedFg} attributes={attrs}>
58+
{line}
59+
</span>
60+
</text>
61+
)
62+
})}
63+
</box>
6064
)
6165
}

cli/src/components/tools/str-replace.tsx

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,8 @@ const EditHeader = ({ name, filePath }: EditHeaderProps) => {
5050
const bulletChar = '• '
5151

5252
return (
53-
<box
54-
style={{
55-
flexDirection: 'row',
56-
alignItems: 'center',
57-
width: '100%',
58-
marginTop: 0,
59-
marginBottom: 0,
60-
}}
61-
>
62-
<text style={{ wrapMode: 'word', marginTop: 0, marginBottom: 0 }}>
53+
<box style={{ flexDirection: 'row', alignItems: 'center', width: '100%' }}>
54+
<text style={{ wrapMode: 'word' }}>
6355
<span fg={theme.foreground}>{bulletChar}</span>
6456
<span fg={theme.foreground} attributes={TextAttributes.BOLD}>
6557
{name}
@@ -77,34 +69,12 @@ interface EditBodyProps {
7769
}
7870

7971
const EditBody = ({ name, filePath, diffText }: EditBodyProps) => {
80-
const hasDiff = diffText && diffText.trim().length > 0
81-
8272
return (
83-
<box
84-
style={{
85-
flexDirection: 'column',
86-
gap: 0,
87-
width: '100%',
88-
marginTop: 0,
89-
marginBottom: 0,
90-
}}
91-
>
73+
<box style={{ flexDirection: 'column', gap: 0, width: '100%' }}>
9274
<EditHeader name={name} filePath={filePath} />
93-
{hasDiff && (
94-
<box
95-
style={{
96-
paddingLeft: 2,
97-
paddingRight: 0,
98-
paddingTop: 0,
99-
paddingBottom: 0,
100-
width: '100%',
101-
marginTop: 0,
102-
marginBottom: 0,
103-
}}
104-
>
105-
<DiffViewer diffText={diffText} />
106-
</box>
107-
)}
75+
<box style={{ paddingLeft: 2, width: '100%' }}>
76+
<DiffViewer diffText={diffText} />
77+
</box>
10878
</box>
10979
)
11080
}

cli/src/components/tools/tool-call-item.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,6 @@ const renderExpandedContent = (
110110
)
111111
}
112112

113-
// Check if value is a plain object (not a React element)
114-
if (typeof value === 'object' && value !== null && !React.isValidElement(value)) {
115-
console.warn('Attempted to render plain object in tool content:', value)
116-
return null
117-
}
118-
119113
return (
120114
<box
121115
key="tool-expanded-unknown"

0 commit comments

Comments
 (0)