Skip to content

Commit 3e39dc3

Browse files
committed
feat: add Cmd+Shift+. keyboard shortcut for previous mode switching
- Add switchToPreviousMode function that cycles backwards through modes array - Update handleKeyDown to detect Cmd+Shift+. keyboard combination - Update modeShortcutText to display both next and previous mode shortcuts - Add forPreviousMode translation key to all 18 language files - Implements backwards mode cycling using modulo arithmetic for proper array wrapping Fixes #5692
1 parent a163053 commit 3e39dc3

File tree

19 files changed

+36
-4
lines changed

19 files changed

+36
-4
lines changed

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
7979
})
8080
const { t } = useAppTranslation()
8181
const { t: tSettings } = useTranslation("settings")
82-
const modeShortcutText = `${isMac ? "⌘" : "Ctrl"} + . ${t("chat:forNextMode")}`
82+
const modeShortcutText = `${isMac ? "⌘" : "Ctrl"} + . ${t("chat:forNextMode")}, ${isMac ? "⌘" : "Ctrl"} + Shift + . ${t("chat:forPreviousMode")}`
8383
const {
8484
clineMessages: messages,
8585
currentTaskItem,
@@ -1555,16 +1555,30 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
15551555
switchToMode(allModes[nextModeIndex].slug)
15561556
}, [mode, customModes, switchToMode])
15571557

1558+
// Function to handle switching to previous mode
1559+
const switchToPreviousMode = useCallback(() => {
1560+
const allModes = getAllModes(customModes)
1561+
const currentModeIndex = allModes.findIndex((m) => m.slug === mode)
1562+
const previousModeIndex = (currentModeIndex - 1 + allModes.length) % allModes.length
1563+
// Update local state and notify extension to sync mode change
1564+
switchToMode(allModes[previousModeIndex].slug)
1565+
}, [mode, customModes, switchToMode])
1566+
15581567
// Add keyboard event handler
15591568
const handleKeyDown = useCallback(
15601569
(event: KeyboardEvent) => {
1561-
// Check for Command + . (period)
1562-
if ((event.metaKey || event.ctrlKey) && event.key === ".") {
1570+
// Check for Command + . (period) for next mode
1571+
if ((event.metaKey || event.ctrlKey) && !event.shiftKey && event.key === ".") {
15631572
event.preventDefault() // Prevent default browser behavior
15641573
switchToNextMode()
15651574
}
1575+
// Check for Command + Shift + . (period) for previous mode
1576+
else if ((event.metaKey || event.ctrlKey) && event.shiftKey && event.key === ".") {
1577+
event.preventDefault() // Prevent default browser behavior
1578+
switchToPreviousMode()
1579+
}
15661580
},
1567-
[switchToNextMode],
1581+
[switchToNextMode, switchToPreviousMode],
15681582
)
15691583

15701584
// Add event listener

webview-ui/src/i18n/locales/ca/chat.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"separator": "Separador",
124124
"edit": "Edita...",
125125
"forNextMode": "per al següent mode",
126+
"forPreviousMode": "per al mode anterior",
126127
"error": "Error",
127128
"diffError": {
128129
"title": "Edició fallida"

webview-ui/src/i18n/locales/de/chat.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"separator": "Trennlinie",
124124
"edit": "Bearbeiten...",
125125
"forNextMode": "für nächsten Modus",
126+
"forPreviousMode": "für vorherigen Modus",
126127
"error": "Fehler",
127128
"diffError": {
128129
"title": "Bearbeitung fehlgeschlagen"

webview-ui/src/i18n/locales/en/chat.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
"separator": "Separator",
132132
"edit": "Edit...",
133133
"forNextMode": "for next mode",
134+
"forPreviousMode": "for previous mode",
134135
"apiRequest": {
135136
"title": "API Request",
136137
"failed": "API Request Failed",

webview-ui/src/i18n/locales/es/chat.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"separator": "Separador",
124124
"edit": "Editar...",
125125
"forNextMode": "para el siguiente modo",
126+
"forPreviousMode": "para el modo anterior",
126127
"error": "Error",
127128
"diffError": {
128129
"title": "Edición fallida"

webview-ui/src/i18n/locales/fr/chat.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"separator": "Séparateur",
124124
"edit": "Éditer...",
125125
"forNextMode": "pour le prochain mode",
126+
"forPreviousMode": "pour le mode précédent",
126127
"error": "Erreur",
127128
"diffError": {
128129
"title": "Modification échouée"

webview-ui/src/i18n/locales/hi/chat.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"separator": "विभाजक",
124124
"edit": "संपादित करें...",
125125
"forNextMode": "अगले मोड के लिए",
126+
"forPreviousMode": "पिछले मोड के लिए",
126127
"error": "त्रुटि",
127128
"diffError": {
128129
"title": "संपादन असफल"

webview-ui/src/i18n/locales/id/chat.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
"separator": "Pemisah",
138138
"edit": "Edit...",
139139
"forNextMode": "untuk mode selanjutnya",
140+
"forPreviousMode": "untuk mode sebelumnya",
140141
"apiRequest": {
141142
"title": "Permintaan API",
142143
"failed": "Permintaan API Gagal",

webview-ui/src/i18n/locales/it/chat.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"separator": "Separatore",
124124
"edit": "Modifica...",
125125
"forNextMode": "per la prossima modalità",
126+
"forPreviousMode": "per la modalità precedente",
126127
"instructions": {
127128
"wantsToFetch": "Roo vuole recuperare istruzioni dettagliate per aiutare con l'attività corrente"
128129
},

webview-ui/src/i18n/locales/ja/chat.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"separator": "区切り",
124124
"edit": "編集...",
125125
"forNextMode": "次のモード用",
126+
"forPreviousMode": "前のモード用",
126127
"error": "エラー",
127128
"diffError": {
128129
"title": "編集に失敗しました"

0 commit comments

Comments
 (0)