Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,16 @@ export class Task extends EventEmitter<ClineEvents> {
throw new Error(`[RooCode#ask] task ${this.taskId}.${this.instanceId} aborted`)
}

// Check for auto-approval before proceeding with user interaction
const state = await this.providerRef.deref()?.getState()
if (state?.autoApprovalEnabled) {
const shouldAutoApprove = this.shouldAutoApprove(type, state)
if (shouldAutoApprove) {
// Return immediate approval without user interaction
return { response: "yesButtonClicked" }
}
}

let askTs: number

if (partial !== undefined) {
Expand Down Expand Up @@ -524,6 +534,25 @@ export class Task extends EventEmitter<ClineEvents> {
return result
}

/**
* Determines if a request should be auto-approved based on the ask type and current settings
*/
private shouldAutoApprove(type: ClineAsk, state: any): boolean {
switch (type) {
case "use_mcp_server":
return state.alwaysAllowMcp === true
case "command":
return state.alwaysAllowExecute === true
case "browser_action_launch":
return state.alwaysAllowBrowser === true
case "tool":
// For general tool requests, check if read-only operations are always allowed
return state.alwaysAllowReadOnly === true
default:
return false
}
}

async handleWebviewAskResponse(askResponse: ClineAskResponse, text?: string, images?: string[]) {
this.askResponse = askResponse
this.askResponseText = text
Expand Down
Loading