Skip to content

Commit 9fb83ba

Browse files
committed
Fix auto-approval
1 parent 0cb3e23 commit 9fb83ba

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/core/webview/webviewMessageHandler.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
184184
await provider.postStateToWebview()
185185
break
186186
case "askResponse":
187-
provider.getCurrentCline()?.handleWebviewAskResponse(message.askResponse!, message.text, message.images)
187+
const instance = provider.getCurrentCline()
188+
console.log("askResponse ->", message, !!instance)
189+
instance?.handleWebviewAskResponse(message.askResponse!, message.text, message.images)
188190
break
189191
case "terminalOperation":
190192
if (message.terminalOperation) {

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
439439
(text?: string, images?: string[]) => {
440440
const trimmedInput = text?.trim()
441441

442+
console.log(`handlePrimaryButtonClick -> clineAsk=${clineAsk}`, text)
443+
442444
switch (clineAsk) {
443445
case "api_req_failed":
444446
case "command":
@@ -748,7 +750,8 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
748750
return alwaysAllowExecute && isAllowedCommand(message)
749751
}
750752

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

@@ -1113,13 +1116,19 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
11131116
}
11141117

11151118
const autoApprove = async () => {
1116-
if (isAutoApproved(lastMessage)) {
1119+
if (lastMessage?.ask && isAutoApproved(lastMessage)) {
11171120
// Add delay for write operations.
1118-
if (lastMessage?.ask === "tool" && isWriteToolAction(lastMessage)) {
1121+
if (lastMessage.ask === "tool" && isWriteToolAction(lastMessage)) {
11191122
await new Promise((resolve) => setTimeout(resolve, writeDelayMs))
11201123
}
11211124

1122-
handlePrimaryButtonClick()
1125+
vscode.postMessage({ type: "askResponse", askResponse: "yesButtonClicked" })
1126+
1127+
setInputValue("")
1128+
setSelectedImages([])
1129+
setTextAreaDisabled(true)
1130+
setClineAsk(undefined)
1131+
setEnableButtons(false)
11231132
}
11241133
}
11251134
autoApprove()

0 commit comments

Comments
 (0)