Skip to content

Commit 9035cdd

Browse files
committed
Tab: also toggle agent mode
1 parent 45b15a4 commit 9035cdd

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

cli/src/components/multiline-input.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ export const MultilineInput = forwardRef<
900900
// Handle character input (regular chars and tab)
901901
const handleCharacterInput = useCallback(
902902
(key: KeyEvent): boolean => {
903-
// Tab: insert literal tab when no modifiers are held
903+
// Tab: let higher-level keyboard handlers (like chat keyboard shortcuts) handle it
904904
if (
905905
key.name === 'tab' &&
906906
key.sequence &&
@@ -909,9 +909,8 @@ export const MultilineInput = forwardRef<
909909
!key.meta &&
910910
!key.option
911911
) {
912-
preventKeyDefault(key)
913-
insertTextAtCursor('\t')
914-
return true
912+
// Don't insert a literal tab character here; allow global keyboard handlers to process it
913+
return false
915914
}
916915

917916
// Regular character input

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,13 @@ function dispatchAction(
151151
case 'mention-menu-complete':
152152
handlers.onMentionMenuComplete()
153153
return true
154-
case 'open-file-menu-with-tab':
155-
return handlers.onOpenFileMenuWithTab()
154+
case 'open-file-menu-with-tab': {
155+
const opened = handlers.onOpenFileMenuWithTab()
156+
if (!opened) {
157+
handlers.onToggleAgentMode()
158+
}
159+
return true
160+
}
156161
case 'history-up':
157162
handlers.onHistoryUp()
158163
return true

cli/src/utils/__tests__/keyboard-actions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,13 @@ describe('resolveChatKeyboardAction', () => {
358358
})
359359
})
360360

361-
test('tab disabled when disableSlashSuggestions is true', () => {
361+
test('tab toggles agent mode when disableSlashSuggestions is true', () => {
362362
const state: ChatKeyboardState = {
363363
...defaultState,
364364
disableSlashSuggestions: true,
365365
}
366366
expect(resolveChatKeyboardAction(tabKey, state)).toEqual({
367-
type: 'none',
367+
type: 'toggle-agent-mode',
368368
})
369369
})
370370
})

cli/src/utils/keyboard-actions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,12 @@ export function resolveChatKeyboardAction(
282282
return { type: 'history-down' }
283283
}
284284

285-
// Priority 11: Agent mode toggle (shift-tab when not in menus)
286-
if (isShiftTab && !state.slashMenuActive && !state.mentionMenuActive) {
285+
// Priority 11: Agent mode toggle (tab or shift-tab when not in menus)
286+
if (
287+
(isShiftTab || isTab) &&
288+
!state.slashMenuActive &&
289+
!state.mentionMenuActive
290+
) {
287291
return { type: 'toggle-agent-mode' }
288292
}
289293

0 commit comments

Comments
 (0)