Skip to content

Detect when a PR is merged and open a new PR instead of pushing to it #2667

@charlesvien

Description

@charlesvien

Description

When a PR has already been merged, PostHog Code keeps pushing new commits to that same now-dead branch instead of recognizing the work is done. Once a branch's PR is merged, further changes should start from a fresh main and go into a new PR, not pile onto the merged branch.

The app already knows the merged state. The indicator in the top right corner shows "merged", so the signal exists in the UI. The agent just does not act on it today. Getting this right would be a real advantage, since Claude Code frequently mishandles this exact case.

Proposed solution

When the agent detects that the current branch's PR is merged (the same signal that drives the top-right merged indicator), it should stop pushing to that branch. Instead it should pull fresh main, create a new branch off it, and open a new PR for any subsequent work.


Related (not a duplicate): #1090 covers the behind-main case, a different branch state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or requestWorktreeThis issue is related to worktrees

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions