Skip to content

Commit bbc2338

Browse files
committed
memoize handleSubmit
1 parent 57ebaa7 commit bbc2338

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

cli/src/ui/components/CommandInput.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Updated to use useCommandInput, useWebviewMessage, useApprovalHandler, and useFollowupSuggestions hooks
44
*/
55

6-
import React, { useEffect } from "react"
6+
import React, { useCallback, useEffect } from "react"
77
import { Box, Text } from "ink"
88
import { useSetAtom, useAtomValue, useAtom } from "jotai"
99
import { submissionCallbackAtom } from "../../state/atoms/keyboard.js"
@@ -96,15 +96,18 @@ export const CommandInput: React.FC<CommandInputProps> = ({
9696
const isInputDisabled = disabled || isApprovalPending || isCommittingParallelMode
9797

9898
// Enhanced submission handler for shell mode
99-
const handleSubmit = (value: string) => {
100-
if (isShellModeActive) {
101-
// Execute as shell command
102-
executeShellCommand(value)
103-
} else {
104-
// Normal submission
105-
onSubmit(value)
106-
}
107-
}
99+
const handleSubmit = useCallback(
100+
(value: string) => {
101+
if (isShellModeActive) {
102+
// Execute as shell command
103+
executeShellCommand(value)
104+
} else {
105+
// Normal submission
106+
onSubmit(value)
107+
}
108+
},
109+
[isShellModeActive, executeShellCommand, onSubmit],
110+
)
108111

109112
// Set the submission callback so keyboard handler can trigger onSubmit
110113
useEffect(() => {

0 commit comments

Comments
 (0)