Skip to content

Commit 1bc10f3

Browse files
committed
refactor: convert unnecessary named handlers to inline functions
Simplifies code by removing named handler functions that only pass through arguments to other functions without adding meaningful logic or transformation. Changes: - terminal-link.tsx: handleMouseOver/handleMouseOut → inline arrow functions - message-block.tsx: handleToggleAgentListCollapsed → inline arrow function - chat.tsx: handleActivateRepoPath → inline arrow function This improves consistency with existing inline patterns in the codebase and reduces unnecessary indirection.
1 parent 76eacea commit 1bc10f3

File tree

3 files changed

+11
-30
lines changed

3 files changed

+11
-30
lines changed

cli/src/chat.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,6 @@ export const App = ({
283283
? repoRoot // If outside home dir, show absolute path
284284
: `~/${relativePath}`
285285

286-
const handleActivateRepoPath = async () => {
287-
await openFileAtPath(repoRoot)
288-
}
289-
290286
const renderRepoPathInfo = () => (
291287
<text wrap={true}>
292288
Codebuff can read and write files in{' '}
@@ -295,7 +291,7 @@ export const App = ({
295291
color="#3b82f6"
296292
inline={true}
297293
underlineOnHover={true}
298-
onActivate={handleActivateRepoPath}
294+
onActivate={() => openFileAtPath(repoRoot)}
299295
/>
300296
, and run terminal commands to help you build.
301297
</text>

cli/src/components/message-block.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,6 @@ export const MessageBlock = ({
252252
isLastBranch: boolean,
253253
keyPrefix: string,
254254
): React.ReactNode {
255-
const handleToggleAgentListCollapsed = () => {
256-
onToggleCollapsed(agentListBlock.id)
257-
}
258-
259255
const TRUNCATE_LIMIT = 5
260256
const isCollapsed = collapsedAgents.has(agentListBlock.id)
261257
const { agents } = agentListBlock
@@ -330,7 +326,7 @@ export const MessageBlock = ({
330326
streamingPreview=""
331327
finishedPreview={finishedPreview}
332328
theme={theme}
333-
onToggle={handleToggleAgentListCollapsed}
329+
onToggle={() => onToggleCollapsed(agentListBlock.id)}
334330
/>
335331
</box>
336332
)

cli/src/components/terminal-link.tsx

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,15 @@ export const TerminalLink: React.FC<TerminalLinkProps> = ({
5555
return <span fg={displayColor}>{text}</span>
5656
}
5757

58-
const handleMouseOver = () => {
59-
setIsHovered(true)
58+
const renderLine = (line: string, index: number) => {
59+
const coloredText = <span fg={displayColor}>{line}</span>
60+
return (
61+
<text key={index} wrap={lineWrap}>
62+
{shouldUnderline ? <u>{coloredText}</u> : coloredText}
63+
</text>
64+
)
6065
}
6166

62-
const handleMouseOut = () => {
63-
setIsHovered(false)
64-
}
65-
66-
const renderLine = (line: string, index: number) => (
67-
<text key={index} wrap={lineWrap}>
68-
{shouldUnderline ? (
69-
<u>
70-
<span fg={displayColor}>{line}</span>
71-
</u>
72-
) : (
73-
<span fg={displayColor}>{line}</span>
74-
)}
75-
</text>
76-
)
77-
7867
return (
7968
<box
8069
style={{
@@ -84,8 +73,8 @@ export const TerminalLink: React.FC<TerminalLinkProps> = ({
8473
gap: 0,
8574
...containerStyle,
8675
}}
87-
onMouseOver={handleMouseOver}
88-
onMouseOut={handleMouseOut}
76+
onMouseOver={() => setIsHovered(true)}
77+
onMouseOut={() => setIsHovered(false)}
8978
onMouseDown={handleActivate}
9079
>
9180
{displayLines.map(renderLine)}

0 commit comments

Comments
 (0)