Skip to content

Commit 964ffa6

Browse files
committed
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
1 parent 9fce90b commit 964ffa6

File tree

2 files changed

+37
-21
lines changed

2 files changed

+37
-21
lines changed

src/core/assistant-message/presentAssistantMessage.ts

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -266,33 +266,46 @@ export async function presentAssistantMessage(cline: Task) {
266266
progressStatus?: ToolProgressStatus,
267267
isProtected?: boolean,
268268
) => {
269-
const { response, text, images } = await cline.ask(
270-
type,
271-
partialMessage,
272-
false,
273-
progressStatus,
274-
isProtected || false,
275-
)
269+
try {
270+
const { response, text, images } = await cline.ask(
271+
type,
272+
partialMessage,
273+
false,
274+
progressStatus,
275+
isProtected || false,
276+
)
277+
278+
if (response !== "yesButtonClicked") {
279+
// Handle both messageResponse and noButtonClicked with text.
280+
if (text) {
281+
await cline.say("user_feedback", text, images)
282+
pushToolResult(
283+
formatResponse.toolResult(formatResponse.toolDeniedWithFeedback(text), images),
284+
)
285+
} else {
286+
pushToolResult(formatResponse.toolDenied())
287+
}
288+
cline.didRejectTool = true
289+
return false
290+
}
276291

277-
if (response !== "yesButtonClicked") {
278-
// Handle both messageResponse and noButtonClicked with text.
292+
// Handle yesButtonClicked with text.
279293
if (text) {
280294
await cline.say("user_feedback", text, images)
281-
pushToolResult(formatResponse.toolResult(formatResponse.toolDeniedWithFeedback(text), images))
282-
} else {
283-
pushToolResult(formatResponse.toolDenied())
295+
pushToolResult(formatResponse.toolResult(formatResponse.toolApprovedWithFeedback(text), images))
284296
}
285-
cline.didRejectTool = true
286-
return false
287-
}
288297

289-
// Handle yesButtonClicked with text.
290-
if (text) {
291-
await cline.say("user_feedback", text, images)
292-
pushToolResult(formatResponse.toolResult(formatResponse.toolApprovedWithFeedback(text), images))
293-
}
298+
return true
299+
} catch (error) {
300+
// Instead of silently returning false, properly handle the error
301+
const errorMessage =
302+
error instanceof Error ? error.message : "Unknown error occurred while processing command"
303+
await cline.say("error", errorMessage)
294304

295-
return true
305+
// Use parsingError for better clarity about what happened
306+
pushToolResult(formatResponse.parsingError(errorMessage))
307+
return false
308+
}
296309
}
297310

298311
const askFinishSubTaskApproval = async () => {

src/core/prompts/responses.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export const formatResponse = {
1515

1616
toolError: (error?: string) => `The tool execution failed with the following error:\n<error>\n${error}\n</error>`,
1717

18+
parsingError: (error?: string) =>
19+
`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.`,
20+
1821
rooIgnoreError: (path: string) =>
1922
`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.`,
2023

0 commit comments

Comments
 (0)