Skip to content

Commit a563f91

Browse files
committed
feat: add keyboard shortcut for prompt enhancement
- Add Ctrl+Shift+E (Cmd+Shift+E on Mac) keyboard shortcut - Register new command roo-cline.enhancePrompt in VS Code - Connect command to trigger enhance prompt functionality - Update UI tooltip to show keyboard shortcut hint - Add triggerEnhancePrompt action to ExtensionMessage type
1 parent 9fce90b commit a563f91

File tree

8 files changed

+41
-2
lines changed

8 files changed

+41
-2
lines changed

packages/types/src/vscode.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const commandIds = [
5353
"focusInput",
5454
"acceptInput",
5555
"focusPanel",
56+
"enhancePrompt",
5657
] as const
5758

5859
export type CommandId = (typeof commandIds)[number]

src/activate/registerCommands.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,15 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
218218

219219
visibleProvider.postMessageToWebview({ type: "acceptInput" })
220220
},
221+
enhancePrompt: () => {
222+
const visibleProvider = getVisibleProviderOrLog(outputChannel)
223+
224+
if (!visibleProvider) {
225+
return
226+
}
227+
228+
visibleProvider.postMessageToWebview({ type: "action", action: "triggerEnhancePrompt" as any })
229+
},
221230
})
222231

223232
export const openClineInNewTab = async ({ context, outputChannel }: Omit<RegisterCommandOptions, "provider">) => {

src/package.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@
174174
"command": "roo-cline.acceptInput",
175175
"title": "%command.acceptInput.title%",
176176
"category": "%configuration.title%"
177+
},
178+
{
179+
"command": "roo-cline.enhancePrompt",
180+
"title": "%command.enhancePrompt.title%",
181+
"category": "%configuration.title%"
177182
}
178183
],
179184
"menus": {
@@ -388,7 +393,15 @@
388393
"description": "%settings.autoImportSettingsPath.description%"
389394
}
390395
}
391-
}
396+
},
397+
"keybindings": [
398+
{
399+
"command": "roo-cline.enhancePrompt",
400+
"key": "ctrl+shift+e",
401+
"mac": "cmd+shift+e",
402+
"when": "view == roo-cline.SidebarProvider || activeWebviewPanelId == roo-cline.TabPanelProvider"
403+
}
404+
]
392405
},
393406
"scripts": {
394407
"lint": "eslint . --ext=ts --max-warnings=0",

src/shared/ExtensionMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export interface ExtensionMessage {
120120
| "didBecomeVisible"
121121
| "focusInput"
122122
| "switchTab"
123+
| "triggerEnhancePrompt"
123124
invoke?: "newChat" | "sendMessage" | "primaryButtonClick" | "secondaryButtonClick" | "setChatBoxMessage"
124125
state?: ExtensionState
125126
images?: string[]

src/shared/WebviewMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export interface WebviewMessage {
110110
| "diagnosticsEnabled"
111111
| "enhancePrompt"
112112
| "enhancedPrompt"
113+
| "triggerEnhancePrompt"
113114
| "draggedImages"
114115
| "deleteMessage"
115116
| "deleteMessageConfirm"

webview-ui/src/App.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ const App = () => {
169169
if (message.type === "acceptInput") {
170170
chatViewRef.current?.acceptInput()
171171
}
172+
173+
if (message.type === "action" && message.action === "triggerEnhancePrompt") {
174+
chatViewRef.current?.triggerEnhancePrompt()
175+
}
172176
},
173177
[switchTab],
174178
)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import { cn } from "@/lib/utils"
3131
import { usePromptHistory } from "./hooks/usePromptHistory"
3232
import { EditModeControls } from "./EditModeControls"
3333

34+
const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0
35+
3436
interface ChatTextAreaProps {
3537
inputValue: string
3638
setInputValue: (value: string) => void
@@ -1110,7 +1112,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
11101112
/>
11111113

11121114
<div className="absolute top-1 right-1 z-30">
1113-
<StandardTooltip content={t("chat:enhancePrompt")}>
1115+
<StandardTooltip content={`${t("chat:enhancePrompt")} (${isMac ? "⌘" : "Ctrl"}+Shift+E)`}>
11141116
<button
11151117
aria-label={t("chat:enhancePrompt")}
11161118
disabled={sendingDisabled}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export interface ChatViewProps {
6565

6666
export interface ChatViewRef {
6767
acceptInput: () => void
68+
triggerEnhancePrompt: () => void
6869
}
6970

7071
export const MAX_IMAGES_PER_MESSAGE = 20 // Anthropic limits to 20 images
@@ -1616,6 +1617,13 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
16161617
handleSendMessage(inputValue, selectedImages)
16171618
}
16181619
},
1620+
triggerEnhancePrompt: () => {
1621+
// Find the enhance prompt button and trigger its click
1622+
const enhanceButton = document.querySelector('[aria-label*="enhance"]') as HTMLButtonElement
1623+
if (enhanceButton && !sendingDisabled) {
1624+
enhanceButton.click()
1625+
}
1626+
},
16191627
}))
16201628

16211629
const handleCondenseContext = (taskId: string) => {

0 commit comments

Comments
 (0)