Skip to content

Commit b77b5ce

Browse files
committed
Fix keyboard input conflict between feedback modal and chat input
- Disable chat input focus when feedback modal is open - Add disabled state to keyboard handlers to prevent chat shortcuts from firing - Ensure modal has exclusive keyboard control when active
1 parent 1d6bb46 commit b77b5ce

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

cli/src/chat.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ export const Chat = ({
549549
},
550550
historyNavUpEnabled,
551551
historyNavDownEnabled,
552+
disabled: isFeedbackOpen,
552553
})
553554

554555
const { tree: messageTree, topLevelMessages } = useMemo(

cli/src/hooks/use-keyboard-handlers.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ interface KeyboardHandlersConfig {
1919
onInterrupt: () => void
2020
historyNavUpEnabled: boolean
2121
historyNavDownEnabled: boolean
22+
disabled?: boolean
2223
}
2324

2425
export const useKeyboardHandlers = ({
@@ -37,10 +38,13 @@ export const useKeyboardHandlers = ({
3738
onInterrupt,
3839
historyNavUpEnabled,
3940
historyNavDownEnabled,
41+
disabled = false,
4042
}: KeyboardHandlersConfig) => {
4143
useKeyboard(
4244
useCallback(
4345
(key) => {
46+
if (disabled) return
47+
4448
const isEscape = key.name === 'escape'
4549
const isCtrlC = key.ctrl && key.name === 'c'
4650

@@ -71,13 +75,14 @@ export const useKeyboardHandlers = ({
7175
}
7276
}
7377
},
74-
[isStreaming, isWaitingForResponse, abortControllerRef, onCtrlC, onInterrupt],
78+
[isStreaming, isWaitingForResponse, abortControllerRef, onCtrlC, onInterrupt, disabled],
7579
),
7680
)
7781

7882
useKeyboard(
7983
useCallback(
8084
(key) => {
85+
if (disabled) return
8186
if (!focusedAgentId) return
8287

8388
const isSpace =
@@ -125,13 +130,14 @@ export const useKeyboardHandlers = ({
125130
})
126131
}
127132
},
128-
[focusedAgentId, setCollapsedAgents],
133+
[focusedAgentId, setCollapsedAgents, disabled],
129134
),
130135
)
131136

132137
useKeyboard(
133138
useCallback(
134139
(key) => {
140+
if (disabled) return
135141
if (key.name === 'escape' && focusedAgentId) {
136142
if (
137143
'preventDefault' in key &&
@@ -144,14 +150,16 @@ export const useKeyboardHandlers = ({
144150
inputRef.current?.focus()
145151
}
146152
},
147-
[focusedAgentId, setFocusedAgentId, setInputFocused, inputRef],
153+
[focusedAgentId, setFocusedAgentId, setInputFocused, inputRef, disabled],
148154
),
149155
)
150156

151157
// Handle chat history navigation
152158
useKeyboard(
153159
useCallback(
154160
(key) => {
161+
if (disabled) return
162+
155163
const isUpArrow =
156164
key.name === 'up' && !key.ctrl && !key.meta && !key.shift
157165
const isDownArrow =
@@ -174,13 +182,15 @@ export const useKeyboardHandlers = ({
174182
navigateDown()
175183
}
176184
},
177-
[historyNavUpEnabled, historyNavDownEnabled, navigateUp, navigateDown],
185+
[historyNavUpEnabled, historyNavDownEnabled, navigateUp, navigateDown, disabled],
178186
),
179187
)
180188

181189
useKeyboard(
182190
useCallback(
183191
(key) => {
192+
if (disabled) return
193+
184194
const isShiftTab =
185195
key.shift && key.name === 'tab' && !key.ctrl && !key.meta
186196

@@ -195,7 +205,7 @@ export const useKeyboardHandlers = ({
195205

196206
toggleAgentMode()
197207
},
198-
[toggleAgentMode],
208+
[toggleAgentMode, disabled],
199209
),
200210
)
201211
}

0 commit comments

Comments
 (0)