Allow the user to send context with approval or rejection

This commit is contained in:
Nathan Apter
2025-01-29 10:21:36 -05:00
parent fc688bbe8e
commit 3aa5b3f9be
2 changed files with 12 additions and 21 deletions

View File

@@ -1085,34 +1085,22 @@ export class Cline {
const askApproval = async (type: ClineAsk, partialMessage?: string) => { const askApproval = async (type: ClineAsk, partialMessage?: string) => {
const { response, text, images } = await this.ask(type, partialMessage, false) const { response, text, images } = await this.ask(type, partialMessage, false)
if (response !== "yesButtonClicked") { if (response !== "yesButtonClicked") {
if (response === "messageResponse") { // Handle both messageResponse and noButtonClicked with text
if (text) {
await this.say("user_feedback", text, images) await this.say("user_feedback", text, images)
pushToolResult( pushToolResult(
formatResponse.toolResult(formatResponse.toolDeniedWithFeedback(text), images), formatResponse.toolResult(formatResponse.toolDeniedWithFeedback(text), images),
) )
// this.userMessageContent.push({ } else {
// type: "text", pushToolResult(formatResponse.toolDenied())
// text: `${toolDescription()}`, }
// })
// this.toolResults.push({
// type: "tool_result",
// tool_use_id: toolUseId,
// content: this.formatToolResponseWithImages(
// await this.formatToolDeniedFeedback(text),
// images
// ),
// })
this.didRejectTool = true this.didRejectTool = true
return false return false
} }
pushToolResult(formatResponse.toolDenied()) // Handle yesButtonClicked with text
// this.toolResults.push({ if (text) {
// type: "tool_result", await this.say("user_feedback", text, images)
// tool_use_id: toolUseId, pushToolResult(formatResponse.toolResult(formatResponse.toolApprovedWithFeedback(text), images))
// content: await this.formatToolDenied(),
// })
this.didRejectTool = true
return false
} }
return true return true
} }

View File

@@ -8,6 +8,9 @@ export const formatResponse = {
toolDeniedWithFeedback: (feedback?: string) => toolDeniedWithFeedback: (feedback?: string) =>
`The user denied this operation and provided the following feedback:\n<feedback>\n${feedback}\n</feedback>`, `The user denied this operation and provided the following feedback:\n<feedback>\n${feedback}\n</feedback>`,
toolApprovedWithFeedback: (feedback?: string) =>
`The user approved this operation and provided the following context:\n<feedback>\n${feedback}\n</feedback>`,
toolError: (error?: string) => `The tool execution failed with the following error:\n<error>\n${error}\n</error>`, toolError: (error?: string) => `The tool execution failed with the following error:\n<error>\n${error}\n</error>`,
noToolsUsed: () => noToolsUsed: () =>