Skip to content

Commit 00bca30

Browse files
authored
Merge pull request RooCodeInc#1545 from RooVetGit/cte/action-registraion-cleanup
2 parents 6cfc1cd + 5a3c207 commit 00bca30

File tree

4 files changed

+77
-92
lines changed

4 files changed

+77
-92
lines changed

README.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -115,37 +115,40 @@ Make Roo Code work your way with:
115115
## Local Setup & Development
116116

117117
1. **Clone** the repo:
118-
```bash
119-
git clone https://github.com/RooVetGit/Roo-Code.git
120-
```
118+
119+
```sh
120+
git clone https://github.com/RooVetGit/Roo-Code.git
121+
```
122+
121123
2. **Install dependencies**:
122-
```bash
123-
npm run install:all
124-
```
125-
126-
if that fails, try:
127-
```bash
128-
npm run install:ci
129-
```
130-
131-
3. **Build** the extension:
132-
```bash
133-
npm run build
134-
```
135-
- A `.vsix` file will appear in the `bin/` directory.
136-
4. **Install** the `.vsix` manually if desired:
137-
```bash
138-
code --install-extension bin/roo-code-4.0.0.vsix
139-
```
140-
5. **Start the webview (Vite/React app with HMR)**:
141-
```bash
142-
npm run dev
143-
```
144-
6. **Debug**:
145-
- Press `F5` (or **Run****Start Debugging**) in VSCode to open a new session with Roo Code loaded.
124+
125+
```sh
126+
npm run install:all
127+
```
128+
129+
3. **Start the webview (Vite/React app with HMR)**:
130+
131+
```sh
132+
npm run dev
133+
```
134+
135+
4. **Debug**:
136+
Press `F5` (or **Run****Start Debugging**) in VSCode to open a new session with Roo Code loaded.
146137

147138
Changes to the webview will appear immediately. Changes to the core extension will require a restart of the extension host.
148139

140+
Alternatively you can build a .vsix and install it directly in VSCode:
141+
142+
```sh
143+
npm run build
144+
```
145+
146+
A `.vsix` file will appear in the `bin/` directory which can be installed with:
147+
148+
```sh
149+
code --install-extension bin/roo-cline-<version>.vsix
150+
```
151+
149152
We use [changesets](https://github.com/changesets/changesets) for versioning and publishing. Check our `CHANGELOG.md` for release notes.
150153

151154
---

src/activate/humanRelay.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Callback mapping of human relay response.
2+
const humanRelayCallbacks = new Map<string, (response: string | undefined) => void>()
3+
4+
/**
5+
* Register a callback function for human relay response.
6+
* @param requestId
7+
* @param callback
8+
*/
9+
export const registerHumanRelayCallback = (requestId: string, callback: (response: string | undefined) => void) =>
10+
humanRelayCallbacks.set(requestId, callback)
11+
12+
export const unregisterHumanRelayCallback = (requestId: string) => humanRelayCallbacks.delete(requestId)
13+
14+
export const handleHumanRelayResponse = (response: { requestId: string; text?: string; cancelled?: boolean }) => {
15+
const callback = humanRelayCallbacks.get(response.requestId)
16+
17+
if (callback) {
18+
if (response.cancelled) {
19+
callback(undefined)
20+
} else {
21+
callback(response.text)
22+
}
23+
24+
humanRelayCallbacks.delete(response.requestId)
25+
}
26+
}

src/activate/registerCommands.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import delay from "delay"
33

44
import { ClineProvider } from "../core/webview/ClineProvider"
55

6+
import { registerHumanRelayCallback, unregisterHumanRelayCallback, handleHumanRelayResponse } from "./humanRelay"
7+
68
// Store panel references in both modes
79
let sidebarPanel: vscode.WebviewView | undefined = undefined
810
let tabPanel: vscode.WebviewPanel | undefined = undefined
@@ -43,22 +45,6 @@ export const registerCommands = (options: RegisterCommandOptions) => {
4345
for (const [command, callback] of Object.entries(getCommandsMap(options))) {
4446
context.subscriptions.push(vscode.commands.registerCommand(command, callback))
4547
}
46-
47-
// Human Relay Dialog Command
48-
context.subscriptions.push(
49-
vscode.commands.registerCommand(
50-
"roo-cline.showHumanRelayDialog",
51-
(params: { requestId: string; promptText: string }) => {
52-
if (getPanel()) {
53-
getPanel()?.webview.postMessage({
54-
type: "showHumanRelayDialog",
55-
requestId: params.requestId,
56-
promptText: params.promptText,
57-
})
58-
}
59-
},
60-
),
61-
)
6248
}
6349

6450
const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOptions) => {
@@ -85,6 +71,20 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
8571
"roo-cline.helpButtonClicked": () => {
8672
vscode.env.openExternal(vscode.Uri.parse("https://docs.roocode.com"))
8773
},
74+
"roo-cline.showHumanRelayDialog": (params: { requestId: string; promptText: string }) => {
75+
const panel = getPanel()
76+
77+
if (panel) {
78+
panel?.webview.postMessage({
79+
type: "showHumanRelayDialog",
80+
requestId: params.requestId,
81+
promptText: params.promptText,
82+
})
83+
}
84+
},
85+
"roo-cline.registerHumanRelayCallback": registerHumanRelayCallback,
86+
"roo-cline.unregisterHumanRelayCallback": unregisterHumanRelayCallback,
87+
"roo-cline.handleHumanRelayResponse": handleHumanRelayResponse,
8888
}
8989
}
9090

src/extension.ts

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ try {
1111
console.warn("Failed to load environment variables:", e)
1212
}
1313

14-
import { ClineProvider } from "./core/webview/ClineProvider"
15-
import { createClineAPI } from "./exports"
1614
import "./utils/path" // Necessary to have access to String.prototype.toPosix.
15+
16+
import { createClineAPI } from "./exports"
17+
import { ClineProvider } from "./core/webview/ClineProvider"
1718
import { CodeActionProvider } from "./core/CodeActionProvider"
1819
import { DIFF_VIEW_URI_SCHEME } from "./integrations/editor/DiffViewProvider"
19-
import { handleUri, registerCommands, registerCodeActions } from "./activate"
2020
import { McpServerManager } from "./services/mcp/McpServerManager"
2121
import { telemetryService } from "./services/telemetry/TelemetryService"
2222

23+
import { handleUri, registerCommands, registerCodeActions } from "./activate"
24+
2325
/**
2426
* Built using https://github.com/microsoft/vscode-webview-ui-toolkit
2527
*
@@ -31,18 +33,6 @@ import { telemetryService } from "./services/telemetry/TelemetryService"
3133
let outputChannel: vscode.OutputChannel
3234
let extensionContext: vscode.ExtensionContext
3335

34-
// Callback mapping of human relay response
35-
const humanRelayCallbacks = new Map<string, (response: string | undefined) => void>()
36-
37-
/**
38-
* Register a callback function for human relay response
39-
* @param requestId
40-
* @param callback
41-
*/
42-
export function registerHumanRelayCallback(requestId: string, callback: (response: string | undefined) => void): void {
43-
humanRelayCallbacks.set(requestId, callback)
44-
}
45-
4636
// This method is called when your extension is activated.
4737
// Your extension is activated the very first time the command is executed.
4838
export function activate(context: vscode.ExtensionContext) {
@@ -72,40 +62,6 @@ export function activate(context: vscode.ExtensionContext) {
7262

7363
registerCommands({ context, outputChannel, provider: sidebarProvider })
7464

75-
// Register human relay callback registration command
76-
context.subscriptions.push(
77-
vscode.commands.registerCommand(
78-
"roo-cline.registerHumanRelayCallback",
79-
(requestId: string, callback: (response: string | undefined) => void) => {
80-
registerHumanRelayCallback(requestId, callback)
81-
},
82-
),
83-
)
84-
85-
// Register human relay response processing command
86-
context.subscriptions.push(
87-
vscode.commands.registerCommand(
88-
"roo-cline.handleHumanRelayResponse",
89-
(response: { requestId: string; text?: string; cancelled?: boolean }) => {
90-
const callback = humanRelayCallbacks.get(response.requestId)
91-
if (callback) {
92-
if (response.cancelled) {
93-
callback(undefined)
94-
} else {
95-
callback(response.text)
96-
}
97-
humanRelayCallbacks.delete(response.requestId)
98-
}
99-
},
100-
),
101-
)
102-
103-
context.subscriptions.push(
104-
vscode.commands.registerCommand("roo-cline.unregisterHumanRelayCallback", (requestId: string) => {
105-
humanRelayCallbacks.delete(requestId)
106-
}),
107-
)
108-
10965
/**
11066
* We use the text document content provider API to show the left side for diff
11167
* view by creating a virtual document for the original content. This makes it

0 commit comments

Comments
 (0)