Skip to content

Commit 476eaa0

Browse files
committed
feat: add Cmd+R/Ctrl+R keyboard shortcut for new task
- Added keybinding configuration in package.json for roo-cline.newTask command - Created utility function to detect OS and format keyboard shortcuts - Updated ChatView.tsx to display keyboard shortcut in tooltip - Shortcut shows as ⌘R on Mac and Ctrl+R on Windows/Linux
1 parent d90bab7 commit 476eaa0

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

src/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,15 @@
312312
"label": "%views.terminalMenu.label%"
313313
}
314314
],
315+
"keybindings": [
316+
{
317+
"command": "roo-cline.newTask",
318+
"key": "cmd+r",
319+
"mac": "cmd+r",
320+
"win": "ctrl+r",
321+
"linux": "ctrl+r"
322+
}
323+
],
315324
"configuration": {
316325
"title": "%configuration.title%",
317326
"properties": {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { LRUCache } from "lru-cache"
99

1010
import { useDebounceEffect } from "@src/utils/useDebounceEffect"
1111
import { appendImages } from "@src/utils/imageUtils"
12+
import { getNewTaskShortcut } from "@src/utils/keyboardShortcuts"
1213

1314
import type { ClineAsk, ClineMessage } from "@roo-code/types"
1415

@@ -1897,7 +1898,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
18971898
: primaryButtonText === t("chat:runCommand.title")
18981899
? t("chat:runCommand.tooltip")
18991900
: primaryButtonText === t("chat:startNewTask.title")
1900-
? t("chat:startNewTask.tooltip")
1901+
? `${t("chat:startNewTask.tooltip")} (${getNewTaskShortcut()})`
19011902
: primaryButtonText === t("chat:resumeTask.title")
19021903
? t("chat:resumeTask.tooltip")
19031904
: primaryButtonText ===
@@ -1923,7 +1924,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
19231924
isStreaming
19241925
? t("chat:cancel.tooltip")
19251926
: secondaryButtonText === t("chat:startNewTask.title")
1926-
? t("chat:startNewTask.tooltip")
1927+
? `${t("chat:startNewTask.tooltip")} (${getNewTaskShortcut()})`
19271928
: secondaryButtonText === t("chat:reject.title")
19281929
? t("chat:reject.tooltip")
19291930
: secondaryButtonText === t("chat:terminate.title")
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Utility functions for handling keyboard shortcuts
3+
*/
4+
5+
/**
6+
* Detects the operating system and returns the appropriate keyboard shortcut format
7+
* @param commandKey The command key (e.g., "r")
8+
* @returns Formatted keyboard shortcut (e.g., "⌘R" for Mac, "Ctrl+R" for others)
9+
*/
10+
export function getKeyboardShortcut(commandKey: string): string {
11+
// Check if we're on macOS
12+
const isMac =
13+
navigator.platform.toUpperCase().indexOf("MAC") >= 0 || navigator.userAgent.toUpperCase().indexOf("MAC") >= 0
14+
15+
if (isMac) {
16+
// Use ⌘ symbol for Mac
17+
return `⌘${commandKey.toUpperCase()}`
18+
} else {
19+
// Use Ctrl for Windows/Linux
20+
return `Ctrl+${commandKey.toUpperCase()}`
21+
}
22+
}
23+
24+
/**
25+
* Gets the formatted keyboard shortcut for the new task command
26+
* @returns Formatted keyboard shortcut
27+
*/
28+
export function getNewTaskShortcut(): string {
29+
return getKeyboardShortcut("r")
30+
}

0 commit comments

Comments
 (0)