fix(server): drop pending approvals when a thread reverts - #8425
fix(server): drop pending approvals when a thread reverts#8425Adolanium wants to merge 1 commit into
Conversation
Revert already dropped later-turn messages and activities. Pending approval rows stayed. The shell count still included them, so the user could answer a request the provider no longer had. On thread.reverted, drop pending approvals whose turn was discarded. Approvals with no turn stay, matching activities. The shell pending count then follows.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused projection bug fix that removes stale pending approvals for discarded turns while preserving valid approvals and updating the existing thread count. The production logic is small, follows neighboring revert handlers, and is covered by a regression test. You can add or adjust custom eligibility rules. Learn more. |
What Changed
thread.revertednow drops pending approvals for discarded turns.Messages, activities, and proposed plans already did this. The pending-approvals projector ignored revert, so later-turn rows stayed
pending. The shell count still included them.Approvals with no turn stay, same as activities. The shell pending count then follows.
Why
The user could answer a request the provider no longer had.
Checklist
Note
Medium Risk
Changes approval projection on revert, which affects what users can respond to; logic mirrors existing revert handlers but incorrect turn filtering could drop or keep wrong requests.
Overview
Thread revert now prunes
projection_pending_approvalsfor turns that are rolled back, matching messages, activities, and proposed plans.On
thread.reverted, the pending-approvals projector keeps rows tied to retained checkpoint turns (or approvals with noturnId) and deletes the rest viadeleteByRequestId. A sharedretainProjectionPendingApprovalsAfterReverthelper applies the same checkpointturnCountrule as the other retain helpers.This stops stale pending approval UI and fixes
pending_approval_countonprojection_threadsafter revert (via the existing shell refresh on revert). An integration test asserts only the first-turn approval remains and the count is1.Reviewed by Cursor Bugbot for commit e98cd24. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Drop pending approvals for reverted turns in
ProjectionPipelinethread.revertedcase tomakeOrchestrationProjectionPipeline.applyProjectsProjectionthat deletes pending approvals tied to turns beyond the event'sturnCountretainProjectionPendingApprovalsAfterRevertkeeps approvals whoseturnIdis null or whose turn'scheckpointTurnCountis <= the revertturnCountpending_approval_countupdates to 1thread.revertedevent now mutatesprojection_pending_approvalsby deleting approvals not in the retained subset, identified byrequestIdMacroscope summarized e98cd24.