Skip to content

fix(mark): handle amended commits on resumed sessions and clean up stale reviews#369

Merged
matt2e merged 4 commits intomainfrom
out-of-order
Mar 11, 2026
Merged

fix(mark): handle amended commits on resumed sessions and clean up stale reviews#369
matt2e merged 4 commits intomainfrom
out-of-order

Conversation

@matt2e
Copy link
Contributor

@matt2e matt2e commented Mar 11, 2026

Summary

  • Detect amended commits when resuming sessions by capturing pre-HEAD SHA and using get_commit_by_session (not just pending commits)
  • Delete associated reviews (and their sessions) when a commit is deleted, preventing orphaned review data
  • Filter stale auto reviews by ensuring find_latest_auto_review only returns reviews created after the most recent commit on the branch

Test plan

  • Resume a session linked to an existing commit, amend it, and verify the commit SHA updates correctly
  • Delete a commit and verify associated reviews are also removed
  • Amend a commit and verify the old auto review is no longer surfaced

🤖 Generated with Claude Code

matt2e and others added 2 commits March 11, 2026 15:15
…auto reviews

When resuming a session linked to a commit, capture pre_head_sha so
amended commits are detected and the commit record is updated with the
new SHA. Also filter find_latest_auto_review to only return reviews
created after the most recent commit, preventing stale auto reviews
from surfacing after amendments.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When deleting a commit (pending or landed), find all reviews on the
branch created at or after the commit's timestamp and delete them.
Active review sessions are cancelled via the registry before deletion,
preventing stale auto reviews from resurfacing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@matt2e matt2e requested review from baxen and wesbillman as code owners March 11, 2026 04:25
This method became unused after get_commit_by_session replaced it
in session_runner.rs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ffaff750c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

registry: &session_runner::SessionRegistry,
commit: &store::models::Commit,
) {
let reviews = match store.find_reviews_created_since(&commit.branch_id, commit.created_at) {

Choose a reason for hiding this comment

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

P1 Badge Restrict review cleanup to the deleted commit

cleanup_reviews_after_commit selects reviews only by branch_id and created_at >= commit.created_at, so deleting a pending commit (or deleting HEAD after later manual reviews were added) will also delete unrelated reviews and their sessions on the same branch. For example, a manual review created later for an older surviving commit is still removed because it matches the timestamp window, which causes user data loss beyond the commit being deleted.

Useful? React with 👍 / 👎.

Pending/failed commits without a SHA never produced a reviewable diff,
so deleting them should not cascade-delete reviews on the branch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@matt2e matt2e merged commit 5aba223 into main Mar 11, 2026
4 checks passed
@matt2e matt2e deleted the out-of-order branch March 11, 2026 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant