diff --git a/docs/users/features/approval-mode.md b/docs/users/features/approval-mode.md index e072f237cd12..c46067093d01 100644 --- a/docs/users/features/approval-mode.md +++ b/docs/users/features/approval-mode.md @@ -20,7 +20,7 @@ Qwen Code offers three distinct permission modes that allow you to flexibly cont > [!tip] > -> You can quickly cycle through modes during a session using **Shift+Tab**. The terminal status bar shows your current mode, so you always know what permissions Qwen Code has. +> You can quickly cycle through modes during a session using **Shift+Tab** (or **Tab** on Windows). The terminal status bar shows your current mode, so you always know what permissions Qwen Code has. ## 1. Use Plan Mode for safe code analysis @@ -36,9 +36,9 @@ Plan Mode instructs Qwen Code to create a plan by analyzing the codebase with ** **Turn on Plan Mode during a session** -You can switch into Plan Mode during a session using **Shift+Tab** to cycle through permission modes. +You can switch into Plan Mode during a session using **Shift+Tab** (or **Tab** on Windows) to cycle through permission modes. -If you are in Normal Mode, **Shift+Tab** first switches into `auto-edits` Mode, indicated by `⏵⏵ accept edits on` at the bottom of the terminal. A subsequent **Shift+Tab** will switch into Plan Mode, indicated by `⏸ plan mode`. +If you are in Normal Mode, **Shift+Tab** (or **Tab** on Windows) first switches into `auto-edits` Mode, indicated by `⏵⏵ accept edits on` at the bottom of the terminal. A subsequent **Shift+Tab** (or **Tab** on Windows) will switch into Plan Mode, indicated by `⏸ plan mode`. **Start a new session in Plan Mode** @@ -100,7 +100,7 @@ Default Mode is the standard way to work with Qwen Code. In this mode, you maint **Turn on Default Mode during a session** -You can switch into Default Mode during a session using **Shift+Tab**​ to cycle through permission modes. If you're in any other mode, pressing **Shift+Tab**​ will eventually cycle back to Default Mode, indicated by the absence of any mode indicator at the bottom of the terminal. +You can switch into Default Mode during a session using **Shift+Tab**​ (or **Tab** on Windows) to cycle through permission modes. If you're in any other mode, pressing **Shift+Tab** (or **Tab** on Windows) will eventually cycle back to Default Mode, indicated by the absence of any mode indicator at the bottom of the terminal. **Start a new session in Default Mode** @@ -164,7 +164,7 @@ Auto-Edit Mode instructs Qwen Code to automatically approve file edits while req /approval-mode auto-edit # Or use keyboard shortcut -Shift+Tab # Switch from other modes +Shift+Tab (or Tab on Windows) # Switch from other modes ``` ### Workflow Example @@ -235,7 +235,7 @@ qwen --prompt "Run the test suite, fix all failing tests, then commit changes" ### Keyboard Shortcut Switching -During a Qwen Code session, use **Shift+Tab**​ to quickly cycle through the three modes: +During a Qwen Code session, use **Shift+Tab**​ (or **Tab** on Windows) to quickly cycle through the three modes: ``` Default Mode → Auto-Edit Mode → YOLO Mode → Plan Mode → Default Mode diff --git a/docs/users/reference/keyboard-shortcuts.md b/docs/users/reference/keyboard-shortcuts.md index 46f3c8c420a8..fc2f86286522 100644 --- a/docs/users/reference/keyboard-shortcuts.md +++ b/docs/users/reference/keyboard-shortcuts.md @@ -4,16 +4,16 @@ This document lists the available keyboard shortcuts in Qwen Code. ## General -| Shortcut | Description | -| ----------- | --------------------------------------------------------------------------------------------------------------------- | -| `Esc` | Close dialogs and suggestions. | -| `Ctrl+C` | Cancel the ongoing request and clear the input. Press twice to exit the application. | -| `Ctrl+D` | Exit the application if the input is empty. Press twice to confirm. | -| `Ctrl+L` | Clear the screen. | -| `Ctrl+O` | Toggle the display of the debug console. | -| `Ctrl+S` | Allows long responses to print fully, disabling truncation. Use your terminal's scrollback to view the entire output. | -| `Ctrl+T` | Toggle the display of tool descriptions. | -| `Shift+Tab` | Cycle approval modes (`plan` → `default` → `auto-edit` → `yolo`). | +| Shortcut | Description | +| ------------------------------ | --------------------------------------------------------------------------------------------------------------------- | +| `Esc` | Close dialogs and suggestions. | +| `Ctrl+C` | Cancel the ongoing request and clear the input. Press twice to exit the application. | +| `Ctrl+D` | Exit the application if the input is empty. Press twice to confirm. | +| `Ctrl+L` | Clear the screen. | +| `Ctrl+O` | Toggle the display of the debug console. | +| `Ctrl+S` | Allows long responses to print fully, disabling truncation. Use your terminal's scrollback to view the entire output. | +| `Ctrl+T` | Toggle the display of tool descriptions. | +| `Shift+Tab` (`Tab` on Windows) | Cycle approval modes (`plan` → `default` → `auto-edit` → `yolo`) | ## Input Prompt diff --git a/packages/cli/src/i18n/locales/de.js b/packages/cli/src/i18n/locales/de.js index 44d982378209..a4f0597d8228 100644 --- a/packages/cli/src/i18n/locales/de.js +++ b/packages/cli/src/i18n/locales/de.js @@ -23,6 +23,7 @@ export default { 'auto-accept edits': 'Änderungen automatisch akzeptieren', 'Accepting edits': 'Änderungen werden akzeptiert', '(shift + tab to cycle)': '(Umschalt + Tab zum Wechseln)', + '(tab to cycle)': '(Tab zum Wechseln)', 'Execute shell commands via {{symbol}} (e.g., {{example1}}) or use natural language (e.g., {{example2}}).': 'Shell-Befehle über {{symbol}} ausführen (z.B. {{example1}}) oder natürliche Sprache verwenden (z.B. {{example2}}).', '!': '!', @@ -1368,4 +1369,8 @@ export default { 'Erweiterungsseite wird im Browser geöffnet: {{url}}', 'Failed to open browser. Check out the extensions gallery at {{url}}': 'Browser konnte nicht geöffnet werden. Besuchen Sie die Erweiterungsgalerie unter {{url}}', + 'You can switch permission mode quickly with Shift+Tab or /approval-mode.': + 'Sie können den Berechtigungsmodus schnell mit Shift+Tab oder /approval-mode wechseln.', + 'You can switch permission mode quickly with Tab or /approval-mode.': + 'Sie können den Berechtigungsmodus schnell mit Tab oder /approval-mode wechseln.', }; diff --git a/packages/cli/src/i18n/locales/en.js b/packages/cli/src/i18n/locales/en.js index 95d908b115b4..367fc5fe632a 100644 --- a/packages/cli/src/i18n/locales/en.js +++ b/packages/cli/src/i18n/locales/en.js @@ -23,6 +23,7 @@ export default { 'auto-accept edits': 'auto-accept edits', 'Accepting edits': 'Accepting edits', '(shift + tab to cycle)': '(shift + tab to cycle)', + '(tab to cycle)': '(tab to cycle)', 'Execute shell commands via {{symbol}} (e.g., {{example1}}) or use natural language (e.g., {{example2}}).': 'Execute shell commands via {{symbol}} (e.g., {{example1}}) or use natural language (e.g., {{example2}}).', '!': '!', @@ -1101,6 +1102,8 @@ export default { 'You can resume a previous conversation by running qwen --continue or qwen --resume.', 'You can switch permission mode quickly with Shift+Tab or /approval-mode.': 'You can switch permission mode quickly with Shift+Tab or /approval-mode.', + 'You can switch permission mode quickly with Tab or /approval-mode.': + 'You can switch permission mode quickly with Tab or /approval-mode.', // ============================================================================ // Exit Screen / Stats diff --git a/packages/cli/src/i18n/locales/ru.js b/packages/cli/src/i18n/locales/ru.js index 8bdee0b5c0cf..a6b97ed41cda 100644 --- a/packages/cli/src/i18n/locales/ru.js +++ b/packages/cli/src/i18n/locales/ru.js @@ -23,6 +23,7 @@ export default { 'auto-accept edits': 'Режим принятия правок', 'Accepting edits': 'Принятие правок', '(shift + tab to cycle)': '(shift + tab для переключения)', + '(tab to cycle)': '(Tab для переключения)', 'Execute shell commands via {{symbol}} (e.g., {{example1}}) or use natural language (e.g., {{example2}}).': 'Выполняйте команды терминала через {{symbol}} (например, {{example1}}) или используйте естественный язык (например, {{example2}}).', '!': '!', @@ -1372,4 +1373,8 @@ export default { 'Открываем страницу расширений в браузере: {{url}}', 'Failed to open browser. Check out the extensions gallery at {{url}}': 'Не удалось открыть браузер. Посетите галерею расширений по адресу {{url}}', + 'You can switch permission mode quickly with Shift+Tab or /approval-mode.': + 'Вы можете быстро переключать режим разрешений с помощью Shift+Tab или /approval-mode.', + 'You can switch permission mode quickly with Tab or /approval-mode.': + 'Вы можете быстро переключать режим разрешений с помощью Tab или /approval-mode.', }; diff --git a/packages/cli/src/i18n/locales/zh.js b/packages/cli/src/i18n/locales/zh.js index 4f0523d7de43..8bb85cc7fc65 100644 --- a/packages/cli/src/i18n/locales/zh.js +++ b/packages/cli/src/i18n/locales/zh.js @@ -22,6 +22,7 @@ export default { 'auto-accept edits': '自动接受编辑', 'Accepting edits': '接受编辑', '(shift + tab to cycle)': '(shift + tab 切换)', + '(tab to cycle)': '(按 tab 切换)', 'Execute shell commands via {{symbol}} (e.g., {{example1}}) or use natural language (e.g., {{example2}}).': '通过 {{symbol}} 执行 shell 命令(例如,{{example1}})或使用自然语言(例如,{{example2}})', '!': '!', @@ -1041,6 +1042,8 @@ export default { '运行 qwen --continue 或 qwen --resume 可继续之前的会话。', 'You can switch permission mode quickly with Shift+Tab or /approval-mode.': '按 Shift+Tab 或输入 /approval-mode 可快速切换权限模式。', + 'You can switch permission mode quickly with Tab or /approval-mode.': + '按 Tab 或输入 /approval-mode 可快速切换权限模式。', // ============================================================================ // Exit Screen / Stats diff --git a/packages/cli/src/ui/components/AutoAcceptIndicator.tsx b/packages/cli/src/ui/components/AutoAcceptIndicator.tsx index 550c77dc7a5d..d22b39a19432 100644 --- a/packages/cli/src/ui/components/AutoAcceptIndicator.tsx +++ b/packages/cli/src/ui/components/AutoAcceptIndicator.tsx @@ -21,21 +21,26 @@ export const AutoAcceptIndicator: React.FC = ({ let textContent = ''; let subText = ''; + const cycleText = + process.platform === 'win32' + ? ` ${t('(tab to cycle)')}` + : ` ${t('(shift + tab to cycle)')}`; + switch (approvalMode) { case ApprovalMode.PLAN: textColor = theme.status.success; textContent = t('plan mode'); - subText = ` ${t('(shift + tab to cycle)')}`; + subText = cycleText; break; case ApprovalMode.AUTO_EDIT: textColor = theme.status.warning; textContent = t('auto-accept edits'); - subText = ` ${t('(shift + tab to cycle)')}`; + subText = cycleText; break; case ApprovalMode.YOLO: textColor = theme.status.error; textContent = t('YOLO mode'); - subText = ` ${t('(shift + tab to cycle)')}`; + subText = cycleText; break; case ApprovalMode.DEFAULT: default: diff --git a/packages/cli/src/ui/components/Help.test.tsx b/packages/cli/src/ui/components/Help.test.tsx index 0540247dbbe8..23b379eaf779 100644 --- a/packages/cli/src/ui/components/Help.test.tsx +++ b/packages/cli/src/ui/components/Help.test.tsx @@ -46,6 +46,18 @@ const mockCommands: readonly SlashCommand[] = [ ]; describe('Help Component', () => { + it('should render platform-specific keyboard shortcuts', () => { + const { lastFrame } = render(); + const output = lastFrame(); + + if (process.platform === 'win32') { + expect(output).toContain('Tab'); + expect(output).not.toContain('Shift+Tab'); + } else { + expect(output).toContain('Shift+Tab'); + } + }); + it('should not render hidden commands', () => { const { lastFrame } = render(); const output = lastFrame(); diff --git a/packages/cli/src/ui/components/Help.tsx b/packages/cli/src/ui/components/Help.tsx index 6b51a6a8c7a2..64c2f76885f3 100644 --- a/packages/cli/src/ui/components/Help.tsx +++ b/packages/cli/src/ui/components/Help.tsx @@ -154,7 +154,7 @@ export const Help: React.FC = ({ commands, width }) => ( - Shift+Tab + {process.platform === 'win32' ? 'Tab' : 'Shift+Tab'} {' '} - {t('Cycle approval modes')} diff --git a/packages/cli/src/ui/components/KeyboardShortcuts.tsx b/packages/cli/src/ui/components/KeyboardShortcuts.tsx index 75ca5eca9b14..9ce49b4157b0 100644 --- a/packages/cli/src/ui/components/KeyboardShortcuts.tsx +++ b/packages/cli/src/ui/components/KeyboardShortcuts.tsx @@ -28,7 +28,10 @@ const getShortcuts = (): Shortcut[] => [ { key: '/', description: t('for commands') }, { key: '@', description: t('for file paths') }, { key: 'esc esc', description: t('to clear input') }, - { key: 'shift+tab', description: t('to cycle approvals') }, + { + key: process.platform === 'win32' ? 'tab' : 'shift+tab', + description: t('to cycle approvals'), + }, { key: 'ctrl+c', description: t('to quit') }, { key: getNewlineKey(), description: t('for newline') + ' ⏎' }, { key: 'ctrl+l', description: t('to clear screen') }, diff --git a/packages/cli/src/ui/components/Tips.tsx b/packages/cli/src/ui/components/Tips.tsx index 62d82ba4c4bf..d1b6a71bfd79 100644 --- a/packages/cli/src/ui/components/Tips.tsx +++ b/packages/cli/src/ui/components/Tips.tsx @@ -17,7 +17,9 @@ const startupTips = [ 'You can run any shell commands from Qwen Code using ! (e.g. !ls).', 'Type / to open the command popup; Tab autocompletes slash commands and saved prompts.', 'You can resume a previous conversation by running qwen --continue or qwen --resume.', - 'You can switch permission mode quickly with Shift+Tab or /approval-mode.', + process.platform === 'win32' + ? 'You can switch permission mode quickly with Tab or /approval-mode.' + : 'You can switch permission mode quickly with Shift+Tab or /approval-mode.', ] as const; export const Tips: React.FC = () => { diff --git a/packages/cli/src/ui/hooks/useAutoAcceptIndicator.test.ts b/packages/cli/src/ui/hooks/useAutoAcceptIndicator.test.ts index 35e7d7430564..430fc4c3c66d 100644 --- a/packages/cli/src/ui/hooks/useAutoAcceptIndicator.test.ts +++ b/packages/cli/src/ui/hooks/useAutoAcceptIndicator.test.ts @@ -240,7 +240,13 @@ describe('useAutoAcceptIndicator', () => { shift: false, } as Key); }); - expect(mockConfigInstance.setApprovalMode).not.toHaveBeenCalled(); + if (process.platform === 'win32') { + // On Windows, Tab alone toggles approval mode + expect(mockConfigInstance.setApprovalMode).toHaveBeenCalled(); + mockConfigInstance.setApprovalMode.mockClear(); + } else { + expect(mockConfigInstance.setApprovalMode).not.toHaveBeenCalled(); + } act(() => { capturedUseKeypressHandler({ diff --git a/packages/cli/src/ui/hooks/useAutoAcceptIndicator.ts b/packages/cli/src/ui/hooks/useAutoAcceptIndicator.ts index e09c5d0eb506..e3908608cb5c 100644 --- a/packages/cli/src/ui/hooks/useAutoAcceptIndicator.ts +++ b/packages/cli/src/ui/hooks/useAutoAcceptIndicator.ts @@ -36,7 +36,16 @@ export function useAutoAcceptIndicator({ useKeypress( (key) => { // Handle Shift+Tab to cycle through all modes - if (key.shift && key.name === 'tab') { + // On Windows, Shift+Tab is indistinguishable from Tab (\t) in some terminals, + // so we allow Tab to switch modes as well to support the shortcut. + const isShiftTab = key.shift && key.name === 'tab'; + const isWindowsTab = + process.platform === 'win32' && + key.name === 'tab' && + !key.ctrl && + !key.meta; + + if (isShiftTab || isWindowsTab) { const currentMode = config.getApprovalMode(); const currentIndex = APPROVAL_MODES.indexOf(currentMode); const nextIndex =