Skip to content

fix: harden auto-approval timeout cancellation with backend safeguards#11446

Open
0xMink wants to merge 1 commit intoRooCodeInc:mainfrom
0xMink:fix/auto-approval-timeout-hardening
Open

fix: harden auto-approval timeout cancellation with backend safeguards#11446
0xMink wants to merge 1 commit intoRooCodeInc:mainfrom
0xMink:fix/auto-approval-timeout-hardening

Conversation

@0xMink
Copy link
Contributor

@0xMink 0xMink commented Feb 12, 2026

Closes #11445

Summary

PR #11439 fixed the UI cleanup wiring so FollowUpSuggest's useEffect cleanup correctly sends cancelAutoApproval to the backend. This follow-up hardens the backend independently so stale timeouts cannot auto-commit even if the UI cancellation chain is missed.

  • Hard-cancel on toggle-off: webviewMessageHandler.ts now calls cancelAutoApprovalTimeout() on the current task when autoApprovalEnabled is toggled off — independent of React lifecycle
  • Defensive gate in timeout callback: The setTimeout callback re-checks autoApprovalEnabled via getState() and verifies the ask is not stale before auto-committing. Full try/catch wraps the entire async callback body to prevent unhandled rejections
  • Backend regression tests: 4 tests covering explicit cancellation, defensive gate (state changed but cancel not called), superseded ask (new message arrived), and happy-path auto-select

Test plan

  • New: 4 backend tests in auto-approval-timeout-cancellation.spec.ts using fake timers and mocked checkAutoApproval
  • Existing: ask-queued-message-drain.spec.ts (1/1 passed), FollowUpSuggest.spec.tsx (18/18 passed)

When auto-approve is toggled off mid-countdown, the backend setTimeout
could still fire and auto-commit a selection. PR RooCodeInc#11439 fixed the UI
cleanup wiring; this hardens the backend independently.

- webviewMessageHandler: cancel pending timeout when autoApprovalEnabled
  is toggled off
- Task.ts: timeout callback re-checks autoApprovalEnabled and ask
  staleness before committing, with full try/catch to prevent unhandled
  rejections from the async callback
- Added 4 backend regression tests covering explicit cancellation,
  defensive gate, superseded ask, and happy-path auto-select

Closes RooCodeInc#11445
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Feb 12, 2026
@roomote
Copy link
Contributor

roomote bot commented Feb 12, 2026

Rooviewer Clock   See task

Reviewed all 3 changed files. The defensive gate logic and the hard-cancel on toggle-off are well-structured. All 4 new tests pass. One minor suggestion:

  • Add console.error to the silent catch block in Task.ts timeout callback (consistent with other catch blocks in the file)

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment on lines +1544 to +1548
} catch {
// If anything fails (state read, approval fn, or response handling),
// do not auto-commit.
return
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bare catch silently swallows all errors with no logging. If getState() rejects or handleWebviewAskResponse throws, there will be zero diagnostic trace. The fail-safe behavior (don't auto-commit) is correct, but other catch blocks in this file (e.g., line 1697) log via console.error before continuing. Adding a log line here would preserve debuggability without changing the safety semantics.

Suggested change
} catch {
// If anything fails (state read, approval fn, or response handling),
// do not auto-commit.
return
}
} catch (error) {
// If anything fails (state read, approval fn, or response handling),
// do not auto-commit.
console.error("Auto-approval timeout callback failed:", error)
return
}

Fix it with Roo Code or mention @roomote and request a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-approve countdown can commit selection after auto-approve toggled off

1 participant