Skip to content
Source
Sign inSign up
pingdotgg/t3code

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

ClosedAdolanium(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/8425/headopened View on GitHub

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](https://cursor.com/bugbot) for commit e98cd24d67de738481581f6dcab767025ef8bd1b. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

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.
    1. 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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. 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](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. 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.

    5. juliusmarminge closed this

Sign in to join this conversation.