Skip to content

fix(feedback): clone existing batch branch directly to prevent non-fast-forward push failure#2791

Merged
CommanderStorm merged 7 commits intomainfrom
copilot/fix-coordinate-batching-logic
Mar 19, 2026
Merged

fix(feedback): clone existing batch branch directly to prevent non-fast-forward push failure#2791
CommanderStorm merged 7 commits intomainfrom
copilot/fix-coordinate-batching-logic

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 16, 2026

When a batch PR already exists, subsequent coordinate feedback submissions failed with "Could apply changes, please try again later" because the git push was rejected.

Proposed Change(s)

  • clone_and_checkout in tmp_repo.rs always cloned main then ran git checkout -b <branch> main, creating a local branch that diverged from the existing remote batch branch. The push was rejected as non-fast-forward.
  • Split clone_and_checkout into two dedicated methods in tmp_repo.rs:
    • clone_and_checkout_new_branch — clones main and creates a fresh branch from it (used when no batch PR exists yet)
    • clone_and_checkout_existing_branch — clones directly with --branch <name> to check out the already-existing remote branch (used when adding an edit to an existing batch PR), making the subsequent push a clean fast-forward

Checklist

  • Documentation
    • I have updated the documentation
    • No need to update the documentation

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…h failure

Co-authored-by: CommanderStorm <26258709+CommanderStorm@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix flawed coordinate batching logic feedback system fix(feedback): clone existing batch branch directly to prevent non-fast-forward push failure Mar 16, 2026
Copilot AI requested a review from CommanderStorm March 16, 2026 20:17
Copy link
Copy Markdown
Member

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

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

@copilot instead of the branch_is_new flag on clone_and_checkout, please just add another method to tmp_repo.rs, since the methods content entirely depends on this.

Co-authored-by: CommanderStorm <26258709+CommanderStorm@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 16, 2026

@copilot instead of the branch_is_new flag on clone_and_checkout, please just add another method to tmp_repo.rs, since the methods content entirely depends on this.

Done in 4725916. clone_and_checkout is now split into clone_and_checkout_new_branch and clone_and_checkout_existing_branch, each with its own focused implementation. The branch_is_new flag is gone from tmp_repo.rs; mod.rs calls whichever method is appropriate.

Copilot AI requested a review from CommanderStorm March 16, 2026 20:38
@CommanderStorm CommanderStorm marked this pull request as ready for review March 16, 2026 20:48
Copilot AI review requested due to automatic review settings March 16, 2026 20:48
@CommanderStorm CommanderStorm enabled auto-merge (squash) March 16, 2026 20:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes feedback batching pushes by ensuring edits to an existing batch PR fast-forward cleanly, avoiding non-fast-forward rejections when the remote batch branch already exists.

Changes:

  • Split TempRepo::clone_and_checkout into clone_and_checkout_new_branch and clone_and_checkout_existing_branch.
  • Update feedback edit flow to choose the appropriate clone strategy depending on whether a batch PR already exists.
  • Adjust existing tests to use the renamed “new branch” clone method.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
server/src/routes/feedback/proposed_edits/tmp_repo.rs Adds separate clone/checkout paths for new vs. existing remote branches to avoid divergent histories.
server/src/routes/feedback/proposed_edits/mod.rs Threads a branch_is_new flag into edit application to select the correct TempRepo clone method.

Comment thread server/src/routes/feedback/proposed_edits/tmp_repo.rs Outdated
Comment thread server/src/routes/feedback/proposed_edits/tmp_repo.rs
Comment on lines +55 to +64
}
}

/// Clone the repository by checking out an already-existing remote branch `branch_name`.
///
/// Use this when adding an edit to an existing batch PR. Cloning `main` and branching from
/// it would create a diverging history and cause the subsequent push to be rejected as
/// non-fast-forward.
#[tracing::instrument]
pub async fn clone_and_checkout_existing_branch(
Comment thread server/src/routes/feedback/proposed_edits/mod.rs
CommanderStorm and others added 2 commits March 16, 2026 22:00
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@CommanderStorm CommanderStorm merged commit d39104e into main Mar 19, 2026
40 of 42 checks passed
@CommanderStorm CommanderStorm deleted the copilot/fix-coordinate-batching-logic branch March 19, 2026 16:18
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.

3 participants