Skip to content

Commit ad148d4

Browse files
fix(chat): When user reject executing command, it should not send messages to LLM (aws#7052)
## Problem Right now, when user reject executing command, chat would send the reject message to LLM and LLM would response. The loop would still continue <img width="428" alt="Screenshot 2025-04-15 at 11 36 15 AM" src="https://github.com/user-attachments/assets/cd5d1c03-271a-416e-9c9e-d62068a82020" /> ## Solution <img width="428" alt="Screenshot 2025-04-15 at 11 44 57 AM" src="https://github.com/user-attachments/assets/66a6a05a-444d-4e90-bce1-c1bfb2ffa217" /> --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: chungjac <[email protected]>
1 parent ba18d86 commit ad148d4

File tree

1 file changed

+14
-1
lines changed
  • packages/core/src/codewhispererChat/controllers/chat

1 file changed

+14
-1
lines changed

packages/core/src/codewhispererChat/controllers/chat/controller.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,8 @@ export class ChatController {
894894
currentToolUse.name === ToolType.ListDirectory)
895895
) {
896896
session.toolUseWithError.error = new Error('Tool use was rejected by the user.')
897+
session.setToolUseWithError(undefined)
898+
this.messenger.sendAsyncEventProgress(message.tabID!, false, undefined)
897899
} else {
898900
getLogger().error(
899901
`toolUse name: ${currentToolUse!.name} of toolUseWithError in the stored session doesn't match when click shell command reject button.`
@@ -928,13 +930,24 @@ export class ChatController {
928930
case 'reject-shell-command':
929931
case 'reject-tool-use':
930932
await this.rejectShellCommand(message)
931-
await this.processToolUseMessage(message)
933+
if (message.tabID) {
934+
await this.sendCommandRejectMessage(message.tabID)
935+
}
936+
if (message.triggerId) {
937+
ConversationTracker.getInstance().markTriggerCompleted(message.triggerId)
938+
}
932939
break
933940
default:
934941
getLogger().warn(`Unhandled action: ${message.action.id}`)
935942
}
936943
}
937944

945+
private async sendCommandRejectMessage(tabID: string) {
946+
const session = this.sessionStorage.getSession(tabID)
947+
session.setAgenticLoopInProgress(false)
948+
this.messenger.sendDirectiveMessage(tabID, '', 'Command Rejected')
949+
}
950+
938951
private async restoreBackup(message: CustomFormActionMessage) {
939952
const tabID = message.tabID
940953
const toolUseId = message.action.formItemValues?.toolUseId

0 commit comments

Comments
 (0)