Merge pull request #1545 from RooVetGit/cte/action-registraion-cleanup

This commit is contained in:
Chris Estreich 2025-03-10 18:45:00 -07:00 committed by GitHub
commit 00bca30695
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 75 additions and 90 deletions

View file

@ -115,37 +115,40 @@ Make Roo Code work your way with:
## Local Setup & Development
1. **Clone** the repo:
```bash
git clone https://github.com/RooVetGit/Roo-Code.git
```
```sh
git clone https://github.com/RooVetGit/Roo-Code.git
```
2. **Install dependencies**:
```bash
npm run install:all
```
if that fails, try:
```bash
npm run install:ci
```
```sh
npm run install:all
```
3. **Build** the extension:
```bash
npm run build
```
- A `.vsix` file will appear in the `bin/` directory.
4. **Install** the `.vsix` manually if desired:
```bash
code --install-extension bin/roo-code-4.0.0.vsix
```
5. **Start the webview (Vite/React app with HMR)**:
```bash
npm run dev
```
6. **Debug**:
- Press `F5` (or **Run****Start Debugging**) in VSCode to open a new session with Roo Code loaded.
3. **Start the webview (Vite/React app with HMR)**:
```sh
npm run dev
```
4. **Debug**:
Press `F5` (or **Run****Start Debugging**) in VSCode to open a new session with Roo Code loaded.
Changes to the webview will appear immediately. Changes to the core extension will require a restart of the extension host.
Alternatively you can build a .vsix and install it directly in VSCode:
```sh
npm run build
```
A `.vsix` file will appear in the `bin/` directory which can be installed with:
```sh
code --install-extension bin/roo-cline-<version>.vsix
```
We use [changesets](https://github.com/changesets/changesets) for versioning and publishing. Check our `CHANGELOG.md` for release notes.
---

View file

@ -0,0 +1,26 @@
// Callback mapping of human relay response.
const humanRelayCallbacks = new Map<string, (response: string | undefined) => void>()
/**
* Register a callback function for human relay response.
* @param requestId
* @param callback
*/
export const registerHumanRelayCallback = (requestId: string, callback: (response: string | undefined) => void) =>
humanRelayCallbacks.set(requestId, callback)
export const unregisterHumanRelayCallback = (requestId: string) => humanRelayCallbacks.delete(requestId)
export const handleHumanRelayResponse = (response: { requestId: string; text?: string; cancelled?: boolean }) => {
const callback = humanRelayCallbacks.get(response.requestId)
if (callback) {
if (response.cancelled) {
callback(undefined)
} else {
callback(response.text)
}
humanRelayCallbacks.delete(response.requestId)
}
}

View file

@ -3,6 +3,8 @@ import delay from "delay"
import { ClineProvider } from "../core/webview/ClineProvider"
import { registerHumanRelayCallback, unregisterHumanRelayCallback, handleHumanRelayResponse } from "./humanRelay"
// Store panel references in both modes
let sidebarPanel: vscode.WebviewView | undefined = undefined
let tabPanel: vscode.WebviewPanel | undefined = undefined
@ -43,22 +45,6 @@ export const registerCommands = (options: RegisterCommandOptions) => {
for (const [command, callback] of Object.entries(getCommandsMap(options))) {
context.subscriptions.push(vscode.commands.registerCommand(command, callback))
}
// Human Relay Dialog Command
context.subscriptions.push(
vscode.commands.registerCommand(
"roo-cline.showHumanRelayDialog",
(params: { requestId: string; promptText: string }) => {
if (getPanel()) {
getPanel()?.webview.postMessage({
type: "showHumanRelayDialog",
requestId: params.requestId,
promptText: params.promptText,
})
}
},
),
)
}
const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOptions) => {
@ -85,6 +71,20 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
"roo-cline.helpButtonClicked": () => {
vscode.env.openExternal(vscode.Uri.parse("https://docs.roocode.com"))
},
"roo-cline.showHumanRelayDialog": (params: { requestId: string; promptText: string }) => {
const panel = getPanel()
if (panel) {
panel?.webview.postMessage({
type: "showHumanRelayDialog",
requestId: params.requestId,
promptText: params.promptText,
})
}
},
"roo-cline.registerHumanRelayCallback": registerHumanRelayCallback,
"roo-cline.unregisterHumanRelayCallback": unregisterHumanRelayCallback,
"roo-cline.handleHumanRelayResponse": handleHumanRelayResponse,
}
}

View file

@ -11,15 +11,17 @@ try {
console.warn("Failed to load environment variables:", e)
}
import { ClineProvider } from "./core/webview/ClineProvider"
import { createClineAPI } from "./exports"
import "./utils/path" // Necessary to have access to String.prototype.toPosix.
import { createClineAPI } from "./exports"
import { ClineProvider } from "./core/webview/ClineProvider"
import { CodeActionProvider } from "./core/CodeActionProvider"
import { DIFF_VIEW_URI_SCHEME } from "./integrations/editor/DiffViewProvider"
import { handleUri, registerCommands, registerCodeActions } from "./activate"
import { McpServerManager } from "./services/mcp/McpServerManager"
import { telemetryService } from "./services/telemetry/TelemetryService"
import { handleUri, registerCommands, registerCodeActions } from "./activate"
/**
* Built using https://github.com/microsoft/vscode-webview-ui-toolkit
*
@ -31,18 +33,6 @@ import { telemetryService } from "./services/telemetry/TelemetryService"
let outputChannel: vscode.OutputChannel
let extensionContext: vscode.ExtensionContext
// Callback mapping of human relay response
const humanRelayCallbacks = new Map<string, (response: string | undefined) => void>()
/**
* Register a callback function for human relay response
* @param requestId
* @param callback
*/
export function registerHumanRelayCallback(requestId: string, callback: (response: string | undefined) => void): void {
humanRelayCallbacks.set(requestId, callback)
}
// This method is called when your extension is activated.
// Your extension is activated the very first time the command is executed.
export function activate(context: vscode.ExtensionContext) {
@ -72,40 +62,6 @@ export function activate(context: vscode.ExtensionContext) {
registerCommands({ context, outputChannel, provider: sidebarProvider })
// Register human relay callback registration command
context.subscriptions.push(
vscode.commands.registerCommand(
"roo-cline.registerHumanRelayCallback",
(requestId: string, callback: (response: string | undefined) => void) => {
registerHumanRelayCallback(requestId, callback)
},
),
)
// Register human relay response processing command
context.subscriptions.push(
vscode.commands.registerCommand(
"roo-cline.handleHumanRelayResponse",
(response: { requestId: string; text?: string; cancelled?: boolean }) => {
const callback = humanRelayCallbacks.get(response.requestId)
if (callback) {
if (response.cancelled) {
callback(undefined)
} else {
callback(response.text)
}
humanRelayCallbacks.delete(response.requestId)
}
},
),
)
context.subscriptions.push(
vscode.commands.registerCommand("roo-cline.unregisterHumanRelayCallback", (requestId: string) => {
humanRelayCallbacks.delete(requestId)
}),
)
/**
* We use the text document content provider API to show the left side for diff
* view by creating a virtual document for the original content. This makes it