Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/dull-flowers-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"roo-cline": patch
---

Fix auto-approvals
2 changes: 1 addition & 1 deletion src/core/Cline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class Cline extends EventEmitter<ClineEvents> {
private askResponse?: ClineAskResponse
private askResponseText?: string
private askResponseImages?: string[]
private lastMessageTs?: number
public lastMessageTs?: number

// Not private since it needs to be accessible by tools.
consecutiveMistakeCount: number = 0
Expand Down
6 changes: 3 additions & 3 deletions src/core/tools/attemptCompletionTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ export async function attemptCompletionTool(
}

// Complete command message.
const executionId = Date.now().toString()
const didApprove = await askApproval("command", command, { id: executionId })
const didApprove = await askApproval("command", command)

if (!didApprove) {
return
}

const executionId = cline.lastMessageTs?.toString() ?? Date.now().toString()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a better value for executionId since it will get passed as message.ts for the command message. I was noticing issues with existing method for passing an executionId.

const options: ExecuteCommandOptions = { executionId, command }
const [userRejected, execCommandResult] = await executeCommand(cline, options)

Expand All @@ -108,7 +108,7 @@ export async function attemptCompletionTool(
}

// tell the provider to remove the current subtask and resume the previous task in the stack
await cline.providerRef.deref()?.finishSubTask(lastMessage?.text ?? "")
await cline.providerRef.deref()?.finishSubTask(result)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to make a lot more sense - hopefully not missing any obvious reason to use the lastMessage text

Copy link
Member

@daniel-lxs daniel-lxs May 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only the result parameter from the attempt_completion tool right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly. Seems like that's what we want to return to the parent task.

return
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/tools/executeCommandTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ export async function executeCommandTool(

cline.consecutiveMistakeCount = 0

const executionId = Date.now().toString()
command = unescapeHtmlEntities(command) // Unescape HTML entities.
const didApprove = await askApproval("command", command, { id: executionId })
const didApprove = await askApproval("command", command)

if (!didApprove) {
return
}

const executionId = cline.lastMessageTs?.toString() ?? Date.now().toString()
const clineProvider = await cline.providerRef.deref()
const clineProviderState = await clineProvider?.getState()
const { terminalOutputLineLimit = 500, terminalShellIntegrationDisabled = false } = clineProviderState ?? {}
Expand Down
2 changes: 0 additions & 2 deletions src/exports/roo-code.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ type ClineMessage = {
| undefined
progressStatus?:
| {
id?: string | undefined
icon?: string | undefined
text?: string | undefined
}
Expand Down Expand Up @@ -429,7 +428,6 @@ type RooCodeEvents = {
| undefined
progressStatus?:
| {
id?: string | undefined
icon?: string | undefined
text?: string | undefined
}
Expand Down
2 changes: 0 additions & 2 deletions src/exports/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ type ClineMessage = {
| undefined
progressStatus?:
| {
id?: string | undefined
icon?: string | undefined
text?: string | undefined
}
Expand Down Expand Up @@ -438,7 +437,6 @@ type RooCodeEvents = {
| undefined
progressStatus?:
| {
id?: string | undefined
icon?: string | undefined
text?: string | undefined
}
Expand Down
1 change: 0 additions & 1 deletion src/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,6 @@ export type ClineSay = z.infer<typeof clineSaySchema>
*/

export const toolProgressStatusSchema = z.object({
id: z.string().optional(),
icon: z.string().optional(),
text: z.string().optional(),
})
Expand Down
2 changes: 1 addition & 1 deletion webview-ui/src/components/chat/ChatRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ export const ChatRowContent = ({
{icon}
{title}
</div>
<CommandExecution executionId={message.progressStatus?.id} text={message.text} />
<CommandExecution executionId={message.ts.toString()} text={message.text} />
</>
)
case "use_mcp_server":
Expand Down
26 changes: 21 additions & 5 deletions webview-ui/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,9 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro

const isAutoApproved = useCallback(
(message: ClineMessage | undefined) => {
if (!autoApprovalEnabled || !message || message.type !== "ask") return false
if (!autoApprovalEnabled || !message || message.type !== "ask") {
return false
}

if (message.ask === "browser_action_launch") {
return alwaysAllowBrowser
Expand All @@ -749,7 +751,8 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
return alwaysAllowExecute && isAllowedCommand(message)
}

// For read/write operations, check if it's outside workspace and if we have permission for that
// For read/write operations, check if it's outside workspace and if
// we have permission for that.
if (message.ask === "tool") {
let tool: any = {}

Expand Down Expand Up @@ -1114,13 +1117,26 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
}

const autoApprove = async () => {
if (isAutoApproved(lastMessage)) {
if (lastMessage?.ask && isAutoApproved(lastMessage)) {
// Note that `isAutoApproved` can only return true if
// lastMessage is an ask of type "browser_action_launch",
// "use_mcp_server", "command", or "tool".

// Add delay for write operations.
if (lastMessage?.ask === "tool" && isWriteToolAction(lastMessage)) {
if (lastMessage.ask === "tool" && isWriteToolAction(lastMessage)) {
await new Promise((resolve) => setTimeout(resolve, writeDelayMs))
}

handlePrimaryButtonClick()
vscode.postMessage({ type: "askResponse", askResponse: "yesButtonClicked" })

// This is copied from `handlePrimaryButtonClick`, which we used
// to call from `autoApprove`. I'm not sure how many of these
// things are actually needed.
setInputValue("")
setSelectedImages([])
setTextAreaDisabled(true)
setClineAsk(undefined)
setEnableButtons(false)
}
}
autoApprove()
Expand Down
6 changes: 1 addition & 5 deletions webview-ui/src/components/chat/CommandExecution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { cn } from "@src/lib/utils"
import { Button } from "@src/components/ui"

interface CommandExecutionProps {
executionId?: string
executionId: string
text?: string
}

Expand All @@ -36,10 +36,6 @@ export const CommandExecution = ({ executionId, text }: CommandExecutionProps) =

const onMessage = useCallback(
(event: MessageEvent) => {
if (!executionId) {
return
}

const message: ExtensionMessage = event.data

if (message.type === "commandExecutionStatus") {
Expand Down