@@ -11,8 +11,8 @@ import { SuggestionMenu, type SuggestionItem } from './suggestion-menu'
1111import { useAskUserBridge } from '../hooks/use-ask-user-bridge'
1212import { useEvent } from '../hooks/use-event'
1313import { useChatStore } from '../state/chat-store'
14+ import { shouldInterceptChatInputKey } from '../utils/chat-input-key-intercept'
1415import { getInputModeConfig } from '../utils/input-modes'
15- import { isLinefeedActingAsEnter } from '../utils/terminal-enter-detection'
1616import { BORDER_CHARS } from '../utils/ui-constants'
1717
1818import type { useTheme } from '../hooks/use-theme'
@@ -133,38 +133,13 @@ export const ChatInputBar = ({
133133 meta ?: boolean
134134 option ?: boolean
135135 } ) => {
136- const isPlainEnter =
137- ( key . name === 'return' || key . name === 'enter' ||
138- ( key . name === 'linefeed' && isLinefeedActingAsEnter ( ) ) ) &&
139- ! key . shift &&
140- ! key . ctrl &&
141- ! key . meta &&
142- ! key . option
143- const isTab = key . name === 'tab' && ! key . ctrl && ! key . meta && ! key . option
144- const isUp = key . name === 'up' && ! key . ctrl && ! key . meta && ! key . option
145- const isDown = key . name === 'down' && ! key . ctrl && ! key . meta && ! key . option
146- const isUpDown = isUp || isDown
147-
148- const hasSuggestions = hasSlashSuggestions || hasMentionSuggestions
149- if ( hasSuggestions ) {
150- if ( isUpDown && lastEditDueToNav ) {
151- return true
152- }
153- if ( isPlainEnter || isTab || isUpDown ) {
154- return true
155- }
156- }
157-
158- const historyUpEnabled = lastEditDueToNav || cursorPosition === 0
159- const historyDownEnabled = lastEditDueToNav || cursorPosition === inputValue . length
160- if ( isUp && historyUpEnabled ) {
161- return true
162- }
163- if ( isDown && historyDownEnabled ) {
164- return true
165- }
166-
167- return false
136+ return shouldInterceptChatInputKey ( key , {
137+ hasSlashSuggestions,
138+ hasMentionSuggestions,
139+ lastEditDueToNav,
140+ cursorPosition,
141+ inputLength : inputValue . length ,
142+ } )
168143 } ,
169144 )
170145
0 commit comments