fix(server): drop pending approvals when a thread reverts #8425
main fromrefs/pull/8425/head·opened View on GitHubWhat Changed#
thread.reverted now 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#
- This PR is small and focused
- I explained what changed and why
- I included before/after screenshots for any UI changes (N/A)
- I included a video for animation/interaction changes (N/A)
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_approvals for 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 no turnId) and deletes the rest via deleteByRequestId. A shared retainProjectionPendingApprovalsAfterRevert helper applies the same checkpoint turnCount rule as the other retain helpers.
This stops stale pending approval UI and fixes pending_approval_count on projection_threads after revert (via the existing shell refresh on revert). An integration test asserts only the first-turn approval remains and the count is 1.
Note
Drop pending approvals for reverted turns in ProjectionPipeline#
- Adds a
thread.revertedcase tomakeOrchestrationProjectionPipeline.applyProjectsProjectionthat deletes pending approvals tied to turns beyond the event'sturnCount - New helper
retainProjectionPendingApprovalsAfterRevertkeeps approvals whoseturnIdis null or whose turn'scheckpointTurnCountis <= the revertturnCount - Adds a test in ProjectionPipeline.test.ts verifying that later-turn approvals are removed and
pending_approval_countupdates to 1 - Behavioral Change: processing a
thread.revertedevent now mutatesprojection_pending_approvalsby deleting approvals not in the retained subset, identified byrequestId
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Approvability#
Verdict: Approved at
e98cd24Macroscope'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](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Note
This comment is posted by Julius' dot
The added regression test checks approval rows and the pending count after a revert, but the PR does not report running it or give an observed result. The available checks show automated reviews and labeling, not execution of that regression. The verification rule requires showing how the changed behavior was checked. Please run the focused revert test, report the command and result for retained and discarded approvals and the pending count, and request reconsideration.
juliusmarminge closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
edca279d-173e-4d78-ace6-69abfc34733cYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Comment `@coderabbitai help` to get the list of available commands.