(askResponse: ClineAskResponse, text?: string, images?: string[])
| 1422 | } |
| 1423 | |
| 1424 | handleWebviewAskResponse(askResponse: ClineAskResponse, text?: string, images?: string[]) { |
| 1425 | // Clear any pending auto-approval timeout when user responds |
| 1426 | this.cancelAutoApprovalTimeout() |
| 1427 | |
| 1428 | this.askResponse = askResponse |
| 1429 | this.askResponseText = text |
| 1430 | this.askResponseImages = images |
| 1431 | |
| 1432 | // Create a checkpoint whenever the user sends a message. |
| 1433 | // Use allowEmpty=true to ensure a checkpoint is recorded even if there are no file changes. |
| 1434 | // Suppress the checkpoint_saved chat row for this particular checkpoint to keep the timeline clean. |
| 1435 | if (askResponse === "messageResponse") { |
| 1436 | void this.checkpointSave(false, true) |
| 1437 | } |
| 1438 | |
| 1439 | // Mark the last follow-up question as answered |
| 1440 | if (askResponse === "messageResponse" || askResponse === "yesButtonClicked") { |
| 1441 | // Find the last unanswered follow-up message using findLastIndex |
| 1442 | const lastFollowUpIndex = findLastIndex( |
| 1443 | this.clineMessages, |
| 1444 | (msg) => msg.type === "ask" && msg.ask === "followup" && !msg.isAnswered, |
| 1445 | ) |
| 1446 | |
| 1447 | if (lastFollowUpIndex !== -1) { |
| 1448 | // Mark this follow-up as answered |
| 1449 | this.clineMessages[lastFollowUpIndex].isAnswered = true |
| 1450 | // Save the updated messages |
| 1451 | this.saveClineMessages().catch((error) => { |
| 1452 | console.error("Failed to save answered follow-up state:", error) |
| 1453 | }) |
| 1454 | } |
| 1455 | } |
| 1456 | |
| 1457 | // Mark the last tool-approval ask as answered when user approves (or auto-approval) |
| 1458 | if (askResponse === "yesButtonClicked") { |
| 1459 | const lastToolAskIndex = findLastIndex( |
| 1460 | this.clineMessages, |
| 1461 | (msg) => msg.type === "ask" && msg.ask === "tool" && !msg.isAnswered, |
| 1462 | ) |
| 1463 | if (lastToolAskIndex !== -1) { |
| 1464 | this.clineMessages[lastToolAskIndex].isAnswered = true |
| 1465 | void this.updateClineMessage(this.clineMessages[lastToolAskIndex]).catch((error) => { |
| 1466 | console.error("[Task#handleWebviewAskResponse] updateClineMessage failed:", error) |
| 1467 | }) |
| 1468 | this.saveClineMessages().catch((error) => { |
| 1469 | console.error("Failed to save answered tool-ask state:", error) |
| 1470 | }) |
| 1471 | } |
| 1472 | } |
| 1473 | } |
| 1474 | |
| 1475 | /** |
| 1476 | * Cancel any pending auto-approval timeout. |
no test coverage detected