Skip to content

Regenerate PR title and body when updating an existing PR#1522

Closed
zerone0x wants to merge 1 commit intopingdotgg:mainfrom
zerone0x:fix/pr-title-reuse
Closed

Regenerate PR title and body when updating an existing PR#1522
zerone0x wants to merge 1 commit intopingdotgg:mainfrom
zerone0x:fix/pr-title-reuse

Conversation

@zerone0x
Copy link
Copy Markdown

@zerone0x zerone0x commented Mar 29, 2026

Summary

Fixes #1487

When an open PR already exists for the current branch, runPrStep previously short-circuited and returned the stale PR metadata (title, body) from GitHub without regenerating it. This caused the original PR title to persist across subsequent pushes — only the commits changed, not the description.

The fix removes the early-return path and instead always:

  1. Resolves the base branch and computes fresh range context (baseBranch..HEAD)
  2. Generates new PR title and body from the current diffs via generatePrContent
  3. If an existing open PR is found, calls editPullRequest to update its title and body on GitHub
  4. If no existing PR exists, creates a new one as before

This ensures each push produces an accurate, up-to-date PR description reflecting the current state of the branch.

Test plan

  • Updated test fake to handle pr edit commands
  • Added editPullRequest to the fake GitHubCliShape in tests
  • Existing opened_existing tests should pass (they verify status and PR number, not title text)
  • Create a PR, push more commits, trigger PR step again — verify title/body are updated

Note

Medium Risk
Changes the PR creation flow to mutate existing GitHub PRs via gh pr edit, which can overwrite titles/bodies and relies on new CLI interactions/temp-file handling.

Overview
runPrStep no longer short-circuits when an open PR already exists for the current branch. It now always recomputes the base branch and range context, regenerates PR title/body via generatePrContent, and updates the existing PR by calling gh pr edit with a temp body file; otherwise it creates a PR as before.

Tests update the fake gh executor to accept pr edit and add an editPullRequest helper so existing-PR scenarios can exercise the new update path.

Written by Cursor Bugbot for commit 5c5b0ea. This will update automatically on new commits. Configure here.

Note

Regenerate and update PR title/body when an existing open PR is found

  • Previously, runPrStep returned early without changes when an open PR already existed for the current branch.
  • Now, PR content (title and body) is always generated, and if an existing PR is found, it is updated via gh pr edit before returning opened_existing with the new title.
  • Behavioral Change: Existing PRs will have their title and body overwritten on each run of runPrStep.

Macroscope summarized 5c5b0ea.

When an open PR already exists for the current branch, runPrStep
previously short-circuited and returned the stale PR metadata
without regenerating the title or body. This caused the original
PR title to persist across subsequent pushes.

Now the code always computes fresh range context and generates
new PR content regardless of whether a PR exists. For existing
PRs it calls editPullRequest to update the title and body on
GitHub, ensuring each push produces an accurate PR description.

Fixes pingdotgg#1487

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

coderabbitai bot commented Mar 29, 2026

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

Run ID: 0ab02485-7e45-462c-9b66-2398fb7932bd

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions github-actions bot added size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 29, 2026
@zerone0x
Copy link
Copy Markdown
Author

Closing duplicate — #1519 is the primary fix.

@zerone0x zerone0x closed this Mar 29, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

const existing = yield* findOpenPr(cwd, headContext.headSelectors);
if (existing) {
return {
status: "opened_existing" as const,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Content generated against wrong base for retargeted PRs

Medium Severity

When an existing PR is found, baseBranch from resolveBaseBranch is used to compute the range context and generate the new title/body, but the existing PR on GitHub may target a different branch (existing.baseRefName). The readRangeContext diff is computed as baseBranch..HEAD using the locally-resolved base, while the PR's "Files changed" tab on GitHub shows the diff against existing.baseRefName. If someone retargets the PR on GitHub (or local config changes), the regenerated description would describe changes against the wrong base branch. Using existing.baseRefName for content generation when an existing PR is found would keep the description consistent with what GitHub displays.

Additional Locations (1)
Fix in Cursor Fix in Web

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.

[Bug]: Generated PR title keeps being reused on new PRs

1 participant