Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 34 additions & 21 deletions src/core/assistant-message/presentAssistantMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
3 changes: 3 additions & 0 deletions src/core/prompts/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,

Expand Down
Loading