diff --git a/src/core/assistant-message/presentAssistantMessage.ts b/src/core/assistant-message/presentAssistantMessage.ts
index ee3fa148b41..aa8dc4890bd 100644
--- a/src/core/assistant-message/presentAssistantMessage.ts
+++ b/src/core/assistant-message/presentAssistantMessage.ts
@@ -266,33 +266,46 @@ export async function presentAssistantMessage(cline: Task) {
progressStatus?: ToolProgressStatus,
isProtected?: boolean,
) => {
- const { response, text, images } = await cline.ask(
- type,
- partialMessage,
- false,
- progressStatus,
- isProtected || false,
- )
+ try {
+ const { response, text, images } = await cline.ask(
+ type,
+ partialMessage,
+ false,
+ progressStatus,
+ isProtected || false,
+ )
+
+ if (response !== "yesButtonClicked") {
+ // Handle both messageResponse and noButtonClicked with text.
+ if (text) {
+ await cline.say("user_feedback", text, images)
+ pushToolResult(
+ formatResponse.toolResult(formatResponse.toolDeniedWithFeedback(text), images),
+ )
+ } else {
+ pushToolResult(formatResponse.toolDenied())
+ }
+ cline.didRejectTool = true
+ return false
+ }
- if (response !== "yesButtonClicked") {
- // Handle both messageResponse and noButtonClicked with text.
+ // Handle yesButtonClicked with text.
if (text) {
await cline.say("user_feedback", text, images)
- pushToolResult(formatResponse.toolResult(formatResponse.toolDeniedWithFeedback(text), images))
- } else {
- pushToolResult(formatResponse.toolDenied())
+ pushToolResult(formatResponse.toolResult(formatResponse.toolApprovedWithFeedback(text), images))
}
- cline.didRejectTool = true
- return false
- }
- // Handle yesButtonClicked with text.
- if (text) {
- await cline.say("user_feedback", text, images)
- pushToolResult(formatResponse.toolResult(formatResponse.toolApprovedWithFeedback(text), images))
- }
+ return true
+ } catch (error) {
+ // Instead of silently returning false, properly handle the error
+ const errorMessage =
+ error instanceof Error ? error.message : "Unknown error occurred while processing command"
+ await cline.say("error", errorMessage)
- return true
+ // Use parsingError for better clarity about what happened
+ pushToolResult(formatResponse.parsingError(errorMessage))
+ return false
+ }
}
const askFinishSubTaskApproval = async () => {
diff --git a/src/core/prompts/responses.ts b/src/core/prompts/responses.ts
index 3f38789fdc9..c29fca18407 100644
--- a/src/core/prompts/responses.ts
+++ b/src/core/prompts/responses.ts
@@ -15,6 +15,9 @@ export const formatResponse = {
toolError: (error?: string) => `The tool execution failed with the following error:\n\n${error}\n`,
+ parsingError: (error?: string) =>
+ `Failed to parse command or request:\n\n${error}\n\n\nThis error occurred before the approval dialog could be shown. Please check the command syntax and try again.`,
+
rooIgnoreError: (path: string) =>
`Access to ${path} is blocked by the .rooignore file settings. You must try to continue in the task without using this file, or ask the user to update the .rooignore file.`,