Skip to content

Commit 91413d5

Browse files
committed
🤖 Convert FileReadToolCall to CSS modules
- Removed all @emotion/styled usage from FileReadToolCall - Converted to CSS modules for Chromatic compatibility - Build still succeeds Remaining: FileEditToolCall, ProposePlanToolCall
1 parent 2db4e66 commit 91413d5

File tree

1 file changed

+21
-108
lines changed

1 file changed

+21
-108
lines changed

src/components/tools/FileReadToolCall.tsx

Lines changed: 21 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { useState } from "react";
2-
import styled from "@emotion/styled";
32
import type { FileReadToolArgs, FileReadToolResult } from "@/types/tools";
43
import {
54
ToolContainer,
@@ -12,93 +11,7 @@ import {
1211
HeaderButton,
1312
} from "./shared/ToolPrimitives";
1413
import { useToolExpansion, type ToolStatus } from "./shared/toolUtils";
15-
16-
// File read specific styled components
17-
18-
const CompactHeader = styled.div`
19-
display: flex;
20-
align-items: center;
21-
gap: 8px;
22-
flex: 1;
23-
font-size: 11px;
24-
color: var(--color-text);
25-
`;
26-
27-
const SearchIcon = styled.span`
28-
font-size: 14px;
29-
`;
30-
31-
const FilePath = styled.span`
32-
font-family: var(--font-monospace);
33-
color: var(--color-text);
34-
white-space: nowrap;
35-
overflow: hidden;
36-
text-overflow: ellipsis;
37-
max-width: 400px;
38-
`;
39-
40-
const TokenCount = styled.span`
41-
color: var(--color-text-secondary);
42-
font-size: 10px;
43-
margin-left: 4px;
44-
`;
45-
46-
const ContentBlock = styled.pre`
47-
margin: 0;
48-
padding: 6px 8px;
49-
background: rgba(0, 0, 0, 0.2);
50-
border-radius: 3px;
51-
border-left: 2px solid #2196f3;
52-
font-size: 11px;
53-
line-height: 1.4;
54-
white-space: pre-wrap;
55-
word-break: break-word;
56-
max-height: 400px;
57-
overflow-y: auto;
58-
`;
59-
60-
const MetadataRow = styled.div`
61-
display: flex;
62-
gap: 16px;
63-
font-size: 10px;
64-
color: var(--color-text-secondary);
65-
padding: 4px 0;
66-
`;
67-
68-
const ErrorMessage = styled.div`
69-
color: #f44336;
70-
font-size: 11px;
71-
padding: 6px 8px;
72-
background: rgba(244, 67, 54, 0.1);
73-
border-radius: 3px;
74-
border-left: 2px solid #f44336;
75-
`;
76-
77-
const StyledToolHeader = styled(ToolHeader)`
78-
cursor: default;
79-
80-
&:hover {
81-
color: var(--color-text-secondary);
82-
}
83-
`;
84-
85-
const LeftContent = styled.div`
86-
display: flex;
87-
align-items: center;
88-
gap: 8px;
89-
flex: 1;
90-
cursor: pointer;
91-
92-
&:hover {
93-
color: var(--color-text);
94-
}
95-
`;
96-
97-
const ButtonGroup = styled.div`
98-
display: flex;
99-
gap: 6px;
100-
margin-right: 8px;
101-
`;
14+
import styles from "./FileReadToolCall.module.css";
10215

10316
interface FileReadToolCallProps {
10417
args: FileReadToolArgs;
@@ -144,28 +57,28 @@ export const FileReadToolCall: React.FC<FileReadToolCallProps> = ({
14457
if (!expanded) {
14558
return (
14659
<ToolContainer expanded={false}>
147-
<StyledToolHeader onClick={toggleExpanded}>
148-
<CompactHeader>
149-
<SearchIcon>🔍</SearchIcon>
150-
<FilePath>{filePath}</FilePath>
151-
{tokenCount !== null && <TokenCount>~{tokenCount} tokens</TokenCount>}
152-
</CompactHeader>
153-
</StyledToolHeader>
60+
<div className={styles.styledToolHeader} onClick={toggleExpanded}>
61+
<div className={styles.compactHeader}>
62+
<span className={styles.searchIcon}>🔍</span>
63+
<span className={styles.filePath}>{filePath}</span>
64+
{tokenCount !== null && <span className={styles.tokenCount}>~{tokenCount} tokens</span>}
65+
</div>
66+
</div>
15467
</ToolContainer>
15568
);
15669
}
15770

15871
// Full display when expanded
15972
return (
16073
<ToolContainer expanded={expanded}>
161-
<StyledToolHeader>
162-
<LeftContent onClick={toggleExpanded}>
163-
<SearchIcon>🔍</SearchIcon>
164-
<FilePath>{filePath}</FilePath>
165-
{tokenCount !== null && <TokenCount>~{tokenCount} tokens</TokenCount>}
166-
</LeftContent>
74+
<div className={styles.styledToolHeader}>
75+
<div className={styles.leftContent} onClick={toggleExpanded}>
76+
<span className={styles.searchIcon}>🔍</span>
77+
<span className={styles.filePath}>{filePath}</span>
78+
{tokenCount !== null && <span className={styles.tokenCount}>~{tokenCount} tokens</span>}
79+
</div>
16780
{result && result.success && (
168-
<ButtonGroup>
81+
<div className={styles.buttonGroup}>
16982
<HeaderButton
17083
onClick={(e: React.MouseEvent) => {
17184
e.stopPropagation();
@@ -174,9 +87,9 @@ export const FileReadToolCall: React.FC<FileReadToolCallProps> = ({
17487
>
17588
{copied ? "✓ Copied" : "Copy Content"}
17689
</HeaderButton>
177-
</ButtonGroup>
90+
</div>
17891
)}
179-
</StyledToolHeader>
92+
</div>
18093

18194
{expanded && (
18295
<ToolDetails>
@@ -185,21 +98,21 @@ export const FileReadToolCall: React.FC<FileReadToolCallProps> = ({
18598
{result.success === false && result.error && (
18699
<DetailSection>
187100
<DetailLabel>Error</DetailLabel>
188-
<ErrorMessage>{result.error}</ErrorMessage>
101+
<div className={styles.errorMessage}>{result.error}</div>
189102
</DetailSection>
190103
)}
191104

192105
{result.success && (
193106
<>
194-
<MetadataRow>
107+
<div className={styles.metadataRow}>
195108
<span>Lines: {result.lines_read}</span>
196109
<span>Size: {formatFileSize(result.file_size)}</span>
197110
<span>Modified: {new Date(result.modifiedTime).toLocaleString()}</span>
198-
</MetadataRow>
111+
</div>
199112

200113
<DetailSection>
201114
<DetailLabel>Content</DetailLabel>
202-
<ContentBlock>{result.content}</ContentBlock>
115+
<pre className={styles.contentBlock}>{result.content}</pre>
203116
</DetailSection>
204117
</>
205118
)}

0 commit comments

Comments
 (0)