Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/types/src/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const commandIds = [
"focusInput",
"acceptInput",
"focusPanel",
"enhancePrompt",
] as const

export type CommandId = (typeof commandIds)[number]
Expand Down
9 changes: 9 additions & 0 deletions src/activate/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt

visibleProvider.postMessageToWebview({ type: "acceptInput" })
},
enhancePrompt: () => {
const visibleProvider = getVisibleProviderOrLog(outputChannel)

if (!visibleProvider) {
return
}

visibleProvider.postMessageToWebview({ type: "action", action: "triggerEnhancePrompt" as any })
},
})

export const openClineInNewTab = async ({ context, outputChannel }: Omit<RegisterCommandOptions, "provider">) => {
Expand Down
15 changes: 14 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@
"command": "roo-cline.acceptInput",
"title": "%command.acceptInput.title%",
"category": "%configuration.title%"
},
{
"command": "roo-cline.enhancePrompt",
"title": "%command.enhancePrompt.title%",
"category": "%configuration.title%"
}
],
"menus": {
Expand Down Expand Up @@ -388,7 +393,15 @@
"description": "%settings.autoImportSettingsPath.description%"
}
}
}
},
"keybindings": [
{
"command": "roo-cline.enhancePrompt",
"key": "ctrl+shift+e",
"mac": "cmd+shift+e",
"when": "view == roo-cline.SidebarProvider || activeWebviewPanelId == roo-cline.TabPanelProvider"
}
]
},
"scripts": {
"lint": "eslint . --ext=ts --max-warnings=0",
Expand Down
1 change: 1 addition & 0 deletions src/shared/ExtensionMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export interface ExtensionMessage {
| "didBecomeVisible"
| "focusInput"
| "switchTab"
| "triggerEnhancePrompt"
invoke?: "newChat" | "sendMessage" | "primaryButtonClick" | "secondaryButtonClick" | "setChatBoxMessage"
state?: ExtensionState
images?: string[]
Expand Down
1 change: 1 addition & 0 deletions src/shared/WebviewMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export interface WebviewMessage {
| "diagnosticsEnabled"
| "enhancePrompt"
| "enhancedPrompt"
| "triggerEnhancePrompt"
| "draggedImages"
| "deleteMessage"
| "deleteMessageConfirm"
Expand Down
4 changes: 4 additions & 0 deletions webview-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ const App = () => {
if (message.type === "acceptInput") {
chatViewRef.current?.acceptInput()
}

if (message.type === "action" && message.action === "triggerEnhancePrompt") {
chatViewRef.current?.triggerEnhancePrompt()
}
},
[switchTab],
)
Expand Down
4 changes: 3 additions & 1 deletion webview-ui/src/components/chat/ChatTextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { cn } from "@/lib/utils"
import { usePromptHistory } from "./hooks/usePromptHistory"
import { EditModeControls } from "./EditModeControls"

const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0

interface ChatTextAreaProps {
inputValue: string
setInputValue: (value: string) => void
Expand Down Expand Up @@ -1110,7 +1112,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
/>

<div className="absolute top-1 right-1 z-30">
<StandardTooltip content={t("chat:enhancePrompt")}>
<StandardTooltip content={`${t("chat:enhancePrompt")} (${isMac ? "⌘" : "Ctrl"}+Shift+E)`}>
<button
aria-label={t("chat:enhancePrompt")}
disabled={sendingDisabled}
Expand Down
8 changes: 8 additions & 0 deletions webview-ui/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export interface ChatViewProps {

export interface ChatViewRef {
acceptInput: () => void
triggerEnhancePrompt: () => void
}

export const MAX_IMAGES_PER_MESSAGE = 20 // Anthropic limits to 20 images
Expand Down Expand Up @@ -1616,6 +1617,13 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
handleSendMessage(inputValue, selectedImages)
}
},
triggerEnhancePrompt: () => {
// Find the enhance prompt button and trigger its click
const enhanceButton = document.querySelector('[aria-label*="enhance"]') as HTMLButtonElement
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using document.querySelector('[aria-label*="enhance"]') to find the enhance prompt button, consider passing a ref from the ChatTextArea component. This will improve reliability and maintainability.

if (enhanceButton && !sendingDisabled) {
enhanceButton.click()
}
},
}))

const handleCondenseContext = (taskId: string) => {
Expand Down