fix: ensure todo tool respects approve/reject flow

- Clear approvedTodoList on rejection to prevent stale state
- Clear approvedTodoList after processing to avoid persistence
- Fixes issue where todo list was updated even when user rejected

Fixes #9705
This commit is contained in:
Roo Code 2025-11-30 17:11:36 +00:00
parent 4591e960ed
commit 72bd98f05a

View file

@ -59,15 +59,19 @@ export class UpdateTodoListTool extends BaseTool<"update_todo_list"> {
todos: normalizedTodos,
})
approvedTodoList = cloneDeep(normalizedTodos)
const didApprove = await askApproval("tool", approvalMsg)
if (!didApprove) {
// Clear approvedTodoList on rejection to prevent stale state
approvedTodoList = undefined
pushToolResult("User declined to update the todoList.")
return
}
// Check if user edited the todos during approval
const isTodoListChanged =
approvedTodoList !== undefined && JSON.stringify(normalizedTodos) !== JSON.stringify(approvedTodoList)
// If user edited the todos, use the edited version
if (isTodoListChanged) {
normalizedTodos = approvedTodoList ?? []
task.say(
@ -79,6 +83,9 @@ export class UpdateTodoListTool extends BaseTool<"update_todo_list"> {
)
}
// Clear approvedTodoList after processing to prevent stale state
approvedTodoList = undefined
await setTodoListForTask(task, normalizedTodos)
if (isTodoListChanged) {