diff --git a/src/activate/registerTerminalActions.ts b/src/activate/registerTerminalActions.ts index b4ad7bf797..fbf2a0510c 100644 --- a/src/activate/registerTerminalActions.ts +++ b/src/activate/registerTerminalActions.ts @@ -15,9 +15,21 @@ export const registerTerminalActions = (context: vscode.ExtensionContext) => { registerTerminalAction(context, terminalManager, TERMINAL_COMMAND_IDS.ADD_TO_CONTEXT, "TERMINAL_ADD_TO_CONTEXT") - registerTerminalActionPair(context, terminalManager, TERMINAL_COMMAND_IDS.FIX, "TERMINAL_FIX") + registerTerminalActionPair( + context, + terminalManager, + TERMINAL_COMMAND_IDS.FIX, + "TERMINAL_FIX", + "What would you like Roo to fix?", + ) - registerTerminalActionPair(context, terminalManager, TERMINAL_COMMAND_IDS.EXPLAIN, "TERMINAL_EXPLAIN") + registerTerminalActionPair( + context, + terminalManager, + TERMINAL_COMMAND_IDS.EXPLAIN, + "TERMINAL_EXPLAIN", + "What would you like Roo to explain?", + ) } const registerTerminalAction = ( @@ -25,6 +37,7 @@ const registerTerminalAction = ( terminalManager: TerminalManager, command: string, promptType: "TERMINAL_ADD_TO_CONTEXT" | "TERMINAL_FIX" | "TERMINAL_EXPLAIN", + inputPrompt?: string, ) => { context.subscriptions.push( vscode.commands.registerCommand(command, async (args: any) => { @@ -38,7 +51,18 @@ const registerTerminalAction = ( return } - await ClineProvider.handleTerminalAction(command, promptType, content) + const params: Record = { + terminalContent: content, + } + + if (inputPrompt) { + params.userInput = + (await vscode.window.showInputBox({ + prompt: inputPrompt, + })) ?? "" + } + + await ClineProvider.handleTerminalAction(command, promptType, params) }), ) } @@ -48,9 +72,10 @@ const registerTerminalActionPair = ( terminalManager: TerminalManager, baseCommand: string, promptType: "TERMINAL_ADD_TO_CONTEXT" | "TERMINAL_FIX" | "TERMINAL_EXPLAIN", + inputPrompt?: string, ) => { // Register new task version - registerTerminalAction(context, terminalManager, baseCommand, promptType) + registerTerminalAction(context, terminalManager, baseCommand, promptType, inputPrompt) // Register current task version - registerTerminalAction(context, terminalManager, `${baseCommand}InCurrentTask`, promptType) + registerTerminalAction(context, terminalManager, `${baseCommand}InCurrentTask`, promptType, inputPrompt) } diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 0c729332e4..9326c83350 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -132,42 +132,6 @@ export class ClineProvider implements vscode.WebviewViewProvider { public static readonly tabPanelId = "roo-cline.TabPanelProvider" private static activeInstances: Set = new Set() private disposables: vscode.Disposable[] = [] - - public static async handleTerminalAction( - command: string, - promptType: "TERMINAL_ADD_TO_CONTEXT" | "TERMINAL_FIX" | "TERMINAL_EXPLAIN", - terminalContent: string, - ): Promise { - const visibleProvider = await ClineProvider.getInstance() - if (!visibleProvider) { - return - } - - const { customSupportPrompts } = await visibleProvider.getState() - - const prompt = supportPrompt.create(promptType, { terminalContent }, customSupportPrompts) - - if (command.endsWith("AddToContext")) { - await visibleProvider.postMessageToWebview({ - type: "invoke", - invoke: "setChatBoxMessage", - text: prompt, - }) - return - } - - if (visibleProvider.cline && command.endsWith("InCurrentTask")) { - await visibleProvider.postMessageToWebview({ - type: "invoke", - invoke: "sendMessage", - text: prompt, - }) - return - } - - await visibleProvider.initClineWithTask(prompt) - } - private view?: vscode.WebviewView | vscode.WebviewPanel private isViewLaunched = false private cline?: Cline @@ -292,6 +256,41 @@ export class ClineProvider implements vscode.WebviewViewProvider { await visibleProvider.initClineWithTask(prompt) } + public static async handleTerminalAction( + command: string, + promptType: "TERMINAL_ADD_TO_CONTEXT" | "TERMINAL_FIX" | "TERMINAL_EXPLAIN", + params: Record, + ): Promise { + const visibleProvider = await ClineProvider.getInstance() + if (!visibleProvider) { + return + } + + const { customSupportPrompts } = await visibleProvider.getState() + + const prompt = supportPrompt.create(promptType, params, customSupportPrompts) + + if (command.endsWith("AddToContext")) { + await visibleProvider.postMessageToWebview({ + type: "invoke", + invoke: "setChatBoxMessage", + text: prompt, + }) + return + } + + if (visibleProvider.cline && command.endsWith("InCurrentTask")) { + await visibleProvider.postMessageToWebview({ + type: "invoke", + invoke: "sendMessage", + text: prompt, + }) + return + } + + await visibleProvider.initClineWithTask(prompt) + } + async resolveWebviewView(webviewView: vscode.WebviewView | vscode.WebviewPanel) { this.outputChannel.appendLine("Resolving webview view") this.view = webviewView diff --git a/src/shared/support-prompt.ts b/src/shared/support-prompt.ts index 95370c5b61..3861da3139 100644 --- a/src/shared/support-prompt.ts +++ b/src/shared/support-prompt.ts @@ -105,7 +105,8 @@ Provide the improved code along with explanations for each enhancement.`, label: "Add Terminal Content to Context", description: "Add terminal output to your current task or conversation. Useful for providing command outputs or logs. Available in the terminal context menu (right-click on selected terminal content).", - template: `Terminal output: + template: `\${userInput} +Terminal output: \`\`\` \${terminalContent} \`\`\``, @@ -114,7 +115,8 @@ Provide the improved code along with explanations for each enhancement.`, label: "Fix Terminal Command", description: "Get help fixing terminal commands that failed or need improvement. Available in the terminal context menu (right-click on selected terminal content).", - template: `Fix this terminal command: + template: `\${userInput} +Fix this terminal command: \`\`\` \${terminalContent} \`\`\` @@ -128,7 +130,8 @@ Please: label: "Explain Terminal Command", description: "Get detailed explanations of terminal commands and their outputs. Available in the terminal context menu (right-click on selected terminal content).", - template: `Explain this terminal command: + template: `\${userInput} +Explain this terminal command: \`\`\` \${terminalContent} \`\`\`