Skip to content

fix(server): drop pending approvals when a thread reverts - #8425

Open
Adolanium wants to merge 1 commit into
pingdotgg:mainfrom
Adolanium:fix/drop-approvals-on-revert
Open

fix(server): drop pending approvals when a thread reverts#8425
Adolanium wants to merge 1 commit into
pingdotgg:mainfrom
Adolanium:fix/drop-approvals-on-revert

Conversation

@Adolanium

@Adolanium Adolanium commented Aug 27, 2026

Copy link
Copy Markdown

What 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.

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 ProjectionPipeline

  • Adds a thread.reverted case to makeOrchestrationProjectionPipeline.applyProjectsProjection that deletes pending approvals tied to turns beyond the event's turnCount
  • New helper retainProjectionPendingApprovalsAfterRevert keeps approvals whose turnId is null or whose turn's checkpointTurnCount is <= the revert turnCount
  • Adds a test in ProjectionPipeline.test.ts verifying that later-turn approvals are removed and pending_approval_count updates to 1
  • Behavioral Change: processing a thread.reverted event now mutates projection_pending_approvals by deleting approvals not in the retained subset, identified by requestId

Macroscope summarized e98cd24.

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.
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: edca279d-173e-4d78-ace6-69abfc34733c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 27, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at e98cd24

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.

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

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant