fix: show actual parsing errors instead of "user denied" message

- Add try-catch in askApproval to properly handle parsing errors
- Add new parsingError response type for clearer error messages
- Fixes #6028 where complex command syntax showed misleading error
This commit is contained in:
Roo Code 2025-07-21 18:04:37 +00:00
parent 9fce90be9d
commit 964ffa6537
2 changed files with 37 additions and 21 deletions

View file

@ -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 (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
}
// 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 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)
// Use parsingError for better clarity about what happened
pushToolResult(formatResponse.parsingError(errorMessage))
return false
}
// Handle yesButtonClicked with text.
if (text) {
await cline.say("user_feedback", text, images)
pushToolResult(formatResponse.toolResult(formatResponse.toolApprovedWithFeedback(text), images))
}
return true
}
const askFinishSubTaskApproval = async () => {

View file

@ -15,6 +15,9 @@ export const formatResponse = {
toolError: (error?: string) => `The tool execution failed with the following error:\n<error>\n${error}\n</error>`,
parsingError: (error?: string) =>
`Failed to parse command or request:\n<error>\n${error}\n</error>\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.`,