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
This commit is contained in:
Roo Code 2025-08-05 11:21:23 +00:00
parent d90bab71ff
commit 476eaa0e2a
3 changed files with 42 additions and 2 deletions

View file

@ -312,6 +312,15 @@
"label": "%views.terminalMenu.label%"
}
],
"keybindings": [
{
"command": "roo-cline.newTask",
"key": "cmd+r",
"mac": "cmd+r",
"win": "ctrl+r",
"linux": "ctrl+r"
}
],
"configuration": {
"title": "%configuration.title%",
"properties": {

View file

@ -9,6 +9,7 @@ import { LRUCache } from "lru-cache"
import { useDebounceEffect } from "@src/utils/useDebounceEffect"
import { appendImages } from "@src/utils/imageUtils"
import { getNewTaskShortcut } from "@src/utils/keyboardShortcuts"
import type { ClineAsk, ClineMessage } from "@roo-code/types"
@ -1897,7 +1898,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
: primaryButtonText === t("chat:runCommand.title")
? t("chat:runCommand.tooltip")
: primaryButtonText === t("chat:startNewTask.title")
? t("chat:startNewTask.tooltip")
? `${t("chat:startNewTask.tooltip")} (${getNewTaskShortcut()})`
: primaryButtonText === t("chat:resumeTask.title")
? t("chat:resumeTask.tooltip")
: primaryButtonText ===
@ -1923,7 +1924,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
isStreaming
? t("chat:cancel.tooltip")
: secondaryButtonText === t("chat:startNewTask.title")
? t("chat:startNewTask.tooltip")
? `${t("chat:startNewTask.tooltip")} (${getNewTaskShortcut()})`
: secondaryButtonText === t("chat:reject.title")
? t("chat:reject.tooltip")
: secondaryButtonText === t("chat:terminate.title")

View file

@ -0,0 +1,30 @@
/**
* Utility functions for handling keyboard shortcuts
*/
/**
* Detects the operating system and returns the appropriate keyboard shortcut format
* @param commandKey The command key (e.g., "r")
* @returns Formatted keyboard shortcut (e.g., "⌘R" for Mac, "Ctrl+R" for others)
*/
export function getKeyboardShortcut(commandKey: string): string {
// Check if we're on macOS
const isMac =
navigator.platform.toUpperCase().indexOf("MAC") >= 0 || navigator.userAgent.toUpperCase().indexOf("MAC") >= 0
if (isMac) {
// Use ⌘ symbol for Mac
return `${commandKey.toUpperCase()}`
} else {
// Use Ctrl for Windows/Linux
return `Ctrl+${commandKey.toUpperCase()}`
}
}
/**
* Gets the formatted keyboard shortcut for the new task command
* @returns Formatted keyboard shortcut
*/
export function getNewTaskShortcut(): string {
return getKeyboardShortcut("r")
}