Skip to content

Commit 679866c

Browse files
committed
add user input
1 parent 0ceb370 commit 679866c

File tree

3 files changed

+71
-44
lines changed

3 files changed

+71
-44
lines changed

src/activate/registerTerminalActions.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,29 @@ export const registerTerminalActions = (context: vscode.ExtensionContext) => {
1515

1616
registerTerminalAction(context, terminalManager, TERMINAL_COMMAND_IDS.ADD_TO_CONTEXT, "TERMINAL_ADD_TO_CONTEXT")
1717

18-
registerTerminalActionPair(context, terminalManager, TERMINAL_COMMAND_IDS.FIX, "TERMINAL_FIX")
18+
registerTerminalActionPair(
19+
context,
20+
terminalManager,
21+
TERMINAL_COMMAND_IDS.FIX,
22+
"TERMINAL_FIX",
23+
"What would you like Roo to fix?",
24+
)
1925

20-
registerTerminalActionPair(context, terminalManager, TERMINAL_COMMAND_IDS.EXPLAIN, "TERMINAL_EXPLAIN")
26+
registerTerminalActionPair(
27+
context,
28+
terminalManager,
29+
TERMINAL_COMMAND_IDS.EXPLAIN,
30+
"TERMINAL_EXPLAIN",
31+
"What would you like Roo to explain?",
32+
)
2133
}
2234

2335
const registerTerminalAction = (
2436
context: vscode.ExtensionContext,
2537
terminalManager: TerminalManager,
2638
command: string,
2739
promptType: "TERMINAL_ADD_TO_CONTEXT" | "TERMINAL_FIX" | "TERMINAL_EXPLAIN",
40+
inputPrompt?: string,
2841
) => {
2942
context.subscriptions.push(
3043
vscode.commands.registerCommand(command, async (args: any) => {
@@ -38,7 +51,18 @@ const registerTerminalAction = (
3851
return
3952
}
4053

41-
await ClineProvider.handleTerminalAction(command, promptType, content)
54+
const params: Record<string, any> = {
55+
terminalContent: content,
56+
}
57+
58+
if (inputPrompt) {
59+
params.userInput =
60+
(await vscode.window.showInputBox({
61+
prompt: inputPrompt,
62+
})) ?? ""
63+
}
64+
65+
await ClineProvider.handleTerminalAction(command, promptType, params)
4266
}),
4367
)
4468
}
@@ -48,9 +72,10 @@ const registerTerminalActionPair = (
4872
terminalManager: TerminalManager,
4973
baseCommand: string,
5074
promptType: "TERMINAL_ADD_TO_CONTEXT" | "TERMINAL_FIX" | "TERMINAL_EXPLAIN",
75+
inputPrompt?: string,
5176
) => {
5277
// Register new task version
53-
registerTerminalAction(context, terminalManager, baseCommand, promptType)
78+
registerTerminalAction(context, terminalManager, baseCommand, promptType, inputPrompt)
5479
// Register current task version
55-
registerTerminalAction(context, terminalManager, `${baseCommand}InCurrentTask`, promptType)
80+
registerTerminalAction(context, terminalManager, `${baseCommand}InCurrentTask`, promptType, inputPrompt)
5681
}

src/core/webview/ClineProvider.ts

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -132,42 +132,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
132132
public static readonly tabPanelId = "roo-cline.TabPanelProvider"
133133
private static activeInstances: Set<ClineProvider> = new Set()
134134
private disposables: vscode.Disposable[] = []
135-
136-
public static async handleTerminalAction(
137-
command: string,
138-
promptType: "TERMINAL_ADD_TO_CONTEXT" | "TERMINAL_FIX" | "TERMINAL_EXPLAIN",
139-
terminalContent: string,
140-
): Promise<void> {
141-
const visibleProvider = await ClineProvider.getInstance()
142-
if (!visibleProvider) {
143-
return
144-
}
145-
146-
const { customSupportPrompts } = await visibleProvider.getState()
147-
148-
const prompt = supportPrompt.create(promptType, { terminalContent }, customSupportPrompts)
149-
150-
if (command.endsWith("AddToContext")) {
151-
await visibleProvider.postMessageToWebview({
152-
type: "invoke",
153-
invoke: "setChatBoxMessage",
154-
text: prompt,
155-
})
156-
return
157-
}
158-
159-
if (visibleProvider.cline && command.endsWith("InCurrentTask")) {
160-
await visibleProvider.postMessageToWebview({
161-
type: "invoke",
162-
invoke: "sendMessage",
163-
text: prompt,
164-
})
165-
return
166-
}
167-
168-
await visibleProvider.initClineWithTask(prompt)
169-
}
170-
171135
private view?: vscode.WebviewView | vscode.WebviewPanel
172136
private isViewLaunched = false
173137
private cline?: Cline
@@ -292,6 +256,41 @@ export class ClineProvider implements vscode.WebviewViewProvider {
292256
await visibleProvider.initClineWithTask(prompt)
293257
}
294258

259+
public static async handleTerminalAction(
260+
command: string,
261+
promptType: "TERMINAL_ADD_TO_CONTEXT" | "TERMINAL_FIX" | "TERMINAL_EXPLAIN",
262+
params: Record<string, string | any[]>,
263+
): Promise<void> {
264+
const visibleProvider = await ClineProvider.getInstance()
265+
if (!visibleProvider) {
266+
return
267+
}
268+
269+
const { customSupportPrompts } = await visibleProvider.getState()
270+
271+
const prompt = supportPrompt.create(promptType, params, customSupportPrompts)
272+
273+
if (command.endsWith("AddToContext")) {
274+
await visibleProvider.postMessageToWebview({
275+
type: "invoke",
276+
invoke: "setChatBoxMessage",
277+
text: prompt,
278+
})
279+
return
280+
}
281+
282+
if (visibleProvider.cline && command.endsWith("InCurrentTask")) {
283+
await visibleProvider.postMessageToWebview({
284+
type: "invoke",
285+
invoke: "sendMessage",
286+
text: prompt,
287+
})
288+
return
289+
}
290+
291+
await visibleProvider.initClineWithTask(prompt)
292+
}
293+
295294
async resolveWebviewView(webviewView: vscode.WebviewView | vscode.WebviewPanel) {
296295
this.outputChannel.appendLine("Resolving webview view")
297296
this.view = webviewView

src/shared/support-prompt.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ Provide the improved code along with explanations for each enhancement.`,
105105
label: "Add Terminal Content to Context",
106106
description:
107107
"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).",
108-
template: `Terminal output:
108+
template: `\${userInput}
109+
Terminal output:
109110
\`\`\`
110111
\${terminalContent}
111112
\`\`\``,
@@ -114,7 +115,8 @@ Provide the improved code along with explanations for each enhancement.`,
114115
label: "Fix Terminal Command",
115116
description:
116117
"Get help fixing terminal commands that failed or need improvement. Available in the terminal context menu (right-click on selected terminal content).",
117-
template: `Fix this terminal command:
118+
template: `\${userInput}
119+
Fix this terminal command:
118120
\`\`\`
119121
\${terminalContent}
120122
\`\`\`
@@ -128,7 +130,8 @@ Please:
128130
label: "Explain Terminal Command",
129131
description:
130132
"Get detailed explanations of terminal commands and their outputs. Available in the terminal context menu (right-click on selected terminal content).",
131-
template: `Explain this terminal command:
133+
template: `\${userInput}
134+
Explain this terminal command:
132135
\`\`\`
133136
\${terminalContent}
134137
\`\`\`

0 commit comments

Comments
 (0)