Skip to content

Commit 69ac7ec

Browse files
committed
Merge branch 'feat/issue-5290-add-and-run-commands' of https://github.com/RooCodeInc/Roo-Code into feat/issue-5290-add-and-run-commands
2 parents 32ce45d + 961b409 commit 69ac7ec

File tree

28 files changed

+1530
-353
lines changed

28 files changed

+1530
-353
lines changed

src/core/webview/__tests__/webviewMessageHandler.spec.ts

Lines changed: 93 additions & 275 deletions
Large diffs are not rendered by default.

src/core/webview/webviewMessageHandler.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,36 @@ export const webviewMessageHandler = async (
783783
.getConfiguration(Package.name)
784784
.update("allowedCommands", validCommands, vscode.ConfigurationTarget.Global)
785785

786+
// Post state update to webview to reflect changes in UI
787+
await provider.postStateToWebview()
788+
789+
break
790+
}
791+
case "addToWhitelist": {
792+
// Handle adding a command pattern to the whitelist and then running it
793+
if (message.pattern) {
794+
// Get current allowed commands
795+
const currentAllowedCommands = getGlobalState("allowedCommands") || []
796+
797+
// Add the new pattern if it's not already in the list
798+
if (!currentAllowedCommands.includes(message.pattern)) {
799+
const updatedCommands = [...currentAllowedCommands, message.pattern]
800+
801+
// Update global state
802+
await updateGlobalState("allowedCommands", updatedCommands)
803+
804+
// Also update workspace settings
805+
await vscode.workspace
806+
.getConfiguration(Package.name)
807+
.update("allowedCommands", updatedCommands, vscode.ConfigurationTarget.Global)
808+
809+
// Post state update to webview
810+
await provider.postStateToWebview()
811+
}
812+
813+
// After whitelisting, approve the pending command execution
814+
provider.getCurrentCline()?.handleWebviewAskResponse("yesButtonClicked")
815+
}
786816
break
787817
}
788818
case "openCustomModesSettings": {

src/shared/ExtensionMessage.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,13 @@ export interface ExtensionMessage {
118118
| "didBecomeVisible"
119119
| "focusInput"
120120
| "switchTab"
121-
invoke?: "newChat" | "sendMessage" | "primaryButtonClick" | "secondaryButtonClick" | "setChatBoxMessage"
121+
invoke?:
122+
| "newChat"
123+
| "sendMessage"
124+
| "primaryButtonClick"
125+
| "secondaryButtonClick"
126+
| "tertiaryButtonClick"
127+
| "setChatBoxMessage"
122128
state?: ExtensionState
123129
images?: string[]
124130
filePaths?: string[]

src/shared/WebviewMessage.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import { marketplaceItemSchema } from "@roo-code/types"
1212

1313
import { Mode } from "./modes"
1414

15-
export type ClineAskResponse = "yesButtonClicked" | "noButtonClicked" | "messageResponse" | "objectResponse"
15+
export type ClineAskResponse =
16+
| "yesButtonClicked"
17+
| "noButtonClicked"
18+
| "addAndRunButtonClicked"
19+
| "messageResponse"
20+
| "objectResponse"
1621

1722
export type PromptMode = Mode | "enhance"
1823

@@ -193,6 +198,7 @@ export interface WebviewMessage {
193198
| "checkRulesDirectoryResult"
194199
| "saveCodeIndexSettingsAtomic"
195200
| "requestCodeIndexSecretStatus"
201+
| "addToWhitelist"
196202
text?: string
197203
editedMessageContent?: string
198204
tab?: "settings" | "history" | "mcp" | "modes" | "chat" | "marketplace" | "account"
@@ -234,6 +240,8 @@ export interface WebviewMessage {
234240
visibility?: ShareVisibility // For share visibility
235241
hasContent?: boolean // For checkRulesDirectoryResult
236242
checkOnly?: boolean // For deleteCustomMode check
243+
commandPattern?: string // For "Add & Run" button - the extracted command pattern to whitelist
244+
pattern?: string // For "addToWhitelist" message - the command pattern to add to whitelist
237245
codeIndexSettings?: {
238246
// Global state settings
239247
codebaseIndexEnabled: boolean

0 commit comments

Comments
 (0)