Skip to content

Commit 75de043

Browse files
author
Eric Wheeler
committed
Revert "Remove terminal actions"
This reverts commit 75dcc2f which has been fixed by PR #1365. Fixes: #1380
1 parent 384b469 commit 75de043

File tree

4 files changed

+137
-2
lines changed

4 files changed

+137
-2
lines changed

package.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,31 @@
128128
"command": "roo-cline.addToContext",
129129
"title": "Roo Code: Add To Context",
130130
"category": "Roo Code"
131+
},
132+
{
133+
"command": "roo-cline.terminalAddToContext",
134+
"title": "Roo Code: Add Terminal Content to Context",
135+
"category": "Terminal"
136+
},
137+
{
138+
"command": "roo-cline.terminalFixCommand",
139+
"title": "Roo Code: Fix This Command",
140+
"category": "Terminal"
141+
},
142+
{
143+
"command": "roo-cline.terminalExplainCommand",
144+
"title": "Roo Code: Explain This Command",
145+
"category": "Terminal"
146+
},
147+
{
148+
"command": "roo-cline.terminalFixCommandInCurrentTask",
149+
"title": "Roo Code: Fix This Command (Current Task)",
150+
"category": "Terminal"
151+
},
152+
{
153+
"command": "roo-cline.terminalExplainCommandInCurrentTask",
154+
"title": "Roo Code: Explain This Command (Current Task)",
155+
"category": "Terminal"
131156
}
132157
],
133158
"menus": {
@@ -153,6 +178,28 @@
153178
"group": "Roo Code@4"
154179
}
155180
],
181+
"terminal/context": [
182+
{
183+
"command": "roo-cline.terminalAddToContext",
184+
"group": "Roo Code@1"
185+
},
186+
{
187+
"command": "roo-cline.terminalFixCommand",
188+
"group": "Roo Code@2"
189+
},
190+
{
191+
"command": "roo-cline.terminalExplainCommand",
192+
"group": "Roo Code@3"
193+
},
194+
{
195+
"command": "roo-cline.terminalFixCommandInCurrentTask",
196+
"group": "Roo Code@5"
197+
},
198+
{
199+
"command": "roo-cline.terminalExplainCommandInCurrentTask",
200+
"group": "Roo Code@6"
201+
}
202+
],
156203
"view/title": [
157204
{
158205
"command": "roo-cline.plusButtonClicked",

src/activate/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export { handleUri } from "./handleUri"
22
export { registerCommands } from "./registerCommands"
33
export { registerCodeActions } from "./registerCodeActions"
44
export { createRooCodeAPI } from "./createRooCodeAPI"
5+
export { registerTerminalActions } from "./registerTerminalActions"
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import * as vscode from "vscode"
2+
import { ClineProvider } from "../core/webview/ClineProvider"
3+
import { TerminalManager } from "../integrations/terminal/TerminalManager"
4+
5+
const TERMINAL_COMMAND_IDS = {
6+
ADD_TO_CONTEXT: "roo-cline.terminalAddToContext",
7+
FIX: "roo-cline.terminalFixCommand",
8+
FIX_IN_CURRENT_TASK: "roo-cline.terminalFixCommandInCurrentTask",
9+
EXPLAIN: "roo-cline.terminalExplainCommand",
10+
EXPLAIN_IN_CURRENT_TASK: "roo-cline.terminalExplainCommandInCurrentTask",
11+
} as const
12+
13+
export const registerTerminalActions = (context: vscode.ExtensionContext) => {
14+
const terminalManager = new TerminalManager()
15+
16+
registerTerminalAction(context, terminalManager, TERMINAL_COMMAND_IDS.ADD_TO_CONTEXT, "TERMINAL_ADD_TO_CONTEXT")
17+
18+
registerTerminalActionPair(
19+
context,
20+
terminalManager,
21+
TERMINAL_COMMAND_IDS.FIX,
22+
"TERMINAL_FIX",
23+
"What would you like Roo to fix?",
24+
)
25+
26+
registerTerminalActionPair(
27+
context,
28+
terminalManager,
29+
TERMINAL_COMMAND_IDS.EXPLAIN,
30+
"TERMINAL_EXPLAIN",
31+
"What would you like Roo to explain?",
32+
)
33+
}
34+
35+
const registerTerminalAction = (
36+
context: vscode.ExtensionContext,
37+
terminalManager: TerminalManager,
38+
command: string,
39+
promptType: "TERMINAL_ADD_TO_CONTEXT" | "TERMINAL_FIX" | "TERMINAL_EXPLAIN",
40+
inputPrompt?: string,
41+
) => {
42+
context.subscriptions.push(
43+
vscode.commands.registerCommand(command, async (args: any) => {
44+
let content = args.selection
45+
if (!content || content === "") {
46+
content = await terminalManager.getTerminalContents(promptType === "TERMINAL_ADD_TO_CONTEXT" ? -1 : 1)
47+
}
48+
49+
if (!content) {
50+
vscode.window.showWarningMessage("No terminal content selected")
51+
return
52+
}
53+
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)
66+
}),
67+
)
68+
}
69+
70+
const registerTerminalActionPair = (
71+
context: vscode.ExtensionContext,
72+
terminalManager: TerminalManager,
73+
baseCommand: string,
74+
promptType: "TERMINAL_ADD_TO_CONTEXT" | "TERMINAL_FIX" | "TERMINAL_EXPLAIN",
75+
inputPrompt?: string,
76+
) => {
77+
// Register new task version
78+
registerTerminalAction(context, terminalManager, baseCommand, promptType, inputPrompt)
79+
// Register current task version
80+
registerTerminalAction(context, terminalManager, `${baseCommand}InCurrentTask`, promptType, inputPrompt)
81+
}

src/extension.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { DIFF_VIEW_URI_SCHEME } from "./integrations/editor/DiffViewProvider"
1919
import { McpServerManager } from "./services/mcp/McpServerManager"
2020
import { telemetryService } from "./services/telemetry/TelemetryService"
2121

22-
import { handleUri, registerCommands, registerCodeActions, createRooCodeAPI } from "./activate"
22+
import { handleUri, registerCommands, registerCodeActions, createRooCodeAPI, registerTerminalActions } from "./activate"
2323

2424
/**
2525
* Built using https://github.com/microsoft/vscode-webview-ui-toolkit
@@ -98,10 +98,16 @@ export function activate(context: vscode.ExtensionContext) {
9898

9999
registerCodeActions(context)
100100

101+
/**
102+
* Temporary disabled until we have a better way to share the terminal
103+
* manager.
104+
*/
105+
// registerTerminalActions(context)
106+
101107
return createRooCodeAPI(outputChannel, sidebarProvider)
102108
}
103109

104-
// This method is called when your extension is deactivated.
110+
// This method is called when your extension is deactivated
105111
export async function deactivate() {
106112
outputChannel.appendLine("Roo-Code extension deactivated")
107113
// Clean up MCP server manager

0 commit comments

Comments
 (0)