t1048: Fix auto-rebase: handle AI-completed rebase and increase max attempts#1477
t1048: Fix auto-rebase: handle AI-completed rebase and increase max attempts#1477marcusquinn merged 1 commit intomainfrom
Conversation
Summary of ChangesHello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the robustness of the automated rebase mechanism by addressing a critical failure point where the system would incorrectly attempt to continue a rebase that an AI agent had already completed. Additionally, it improves the system's resilience to frequent rebase requirements by allowing more attempts, which is crucial for environments with many interdependent pull requests. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThis change enhances the deploy.sh script's rebase conflict resolution logic by increasing auto-rebase retry attempts from 2 to 5 and adding state detection to determine whether a rebase remains in progress after AI-assisted conflict resolution, conditionally continuing or treating the operation as complete based on git state. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Sat Feb 14 14:52:55 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
There was a problem hiding this comment.
Code Review
This pull request effectively addresses a race condition where an AI conflict resolver completes a rebase before the script attempts to continue it. The logic to check for an in-progress rebase is sound, and increasing the maximum rebase attempts is a sensible adjustment for handling complex, cascading merges. I've included two medium-severity comments: one regarding a style guide violation for missing explicit return statements, and another suggesting a refactor to reduce significant code duplication, which would improve maintainability.
| # t1048: Check if rebase is still in progress — the AI agent | ||
| # may have already run `git rebase --continue` itself, leaving | ||
| # no rebase in progress for us to continue. | ||
| local git_state_dir | ||
| git_state_dir="$(git -C "$git_dir" rev-parse --git-dir 2>/dev/null)" | ||
| if [[ -d "$git_state_dir/rebase-merge" || -d "$git_state_dir/rebase-apply" ]]; then | ||
| log_info "rebase_sibling_pr: AI resolved conflicts for $task_id — continuing rebase" | ||
| if git -C "$git_dir" rebase --continue 2>>"$SUPERVISOR_LOG"; then | ||
| log_success "rebase_sibling_pr: rebase completed after AI resolution for $task_id" | ||
| else | ||
| log_warn "rebase_sibling_pr: rebase --continue failed after AI resolution for $task_id" | ||
| git -C "$git_dir" rebase --abort 2>>"$SUPERVISOR_LOG" || true | ||
| return 1 | ||
| fi | ||
| else | ||
| log_warn "rebase_sibling_pr: rebase --continue failed after AI resolution for $task_id" | ||
| git -C "$git_dir" rebase --abort 2>>"$SUPERVISOR_LOG" || true | ||
| return 1 | ||
| # AI agent already completed the rebase — treat as success | ||
| log_success "rebase_sibling_pr: rebase completed (AI resolved and continued) for $task_id" | ||
| fi |
There was a problem hiding this comment.
This block of logic for handling the post-AI-resolution rebase is nearly identical to the block at lines 2223-2240. This duplication can make future maintenance more difficult and error-prone. To improve maintainability, consider refactoring this repeated logic into a helper function.
The main difference between the blocks is the error handling when git rebase --continue fails (one path checks out the original branch, the other doesn't). The helper function could be designed to accommodate this difference, for example by accepting a parameter or returning a specific status code.
| if [[ -d "$git_state_dir/rebase-merge" || -d "$git_state_dir/rebase-apply" ]]; then | ||
| log_info "rebase_sibling_pr: AI resolved conflicts for $task_id — continuing rebase" | ||
| if git -C "$git_dir" rebase --continue 2>>"$SUPERVISOR_LOG"; then | ||
| log_success "rebase_sibling_pr: rebase completed after AI resolution for $task_id" | ||
| else | ||
| log_warn "rebase_sibling_pr: rebase --continue failed after AI resolution for $task_id" | ||
| git -C "$git_dir" rebase --abort 2>>"$SUPERVISOR_LOG" || true | ||
| # Return to original branch | ||
| git -C "$git_dir" checkout "${current_branch:-main}" 2>>"$SUPERVISOR_LOG" || true | ||
| return 1 | ||
| fi | ||
| else | ||
| log_warn "rebase_sibling_pr: rebase --continue failed after AI resolution for $task_id" | ||
| git -C "$git_dir" rebase --abort 2>>"$SUPERVISOR_LOG" || true | ||
| # Return to original branch | ||
| git -C "$git_dir" checkout "${current_branch:-main}" 2>>"$SUPERVISOR_LOG" || true | ||
| return 1 | ||
| # AI agent already completed the rebase — treat as success | ||
| log_success "rebase_sibling_pr: rebase completed (AI resolved and continued) for $task_id" | ||
| fi |
There was a problem hiding this comment.
The repository style guide requires all functions to have explicit return statements. The success paths in this block (lines 2229 and 2239) are missing return 0;. A similar issue exists in the duplicated block at lines 2189-2201. Please add return 0 to all successful exit points in this function to adhere to the style guide.
| if [[ -d "$git_state_dir/rebase-merge" || -d "$git_state_dir/rebase-apply" ]]; then | |
| log_info "rebase_sibling_pr: AI resolved conflicts for $task_id — continuing rebase" | |
| if git -C "$git_dir" rebase --continue 2>>"$SUPERVISOR_LOG"; then | |
| log_success "rebase_sibling_pr: rebase completed after AI resolution for $task_id" | |
| else | |
| log_warn "rebase_sibling_pr: rebase --continue failed after AI resolution for $task_id" | |
| git -C "$git_dir" rebase --abort 2>>"$SUPERVISOR_LOG" || true | |
| # Return to original branch | |
| git -C "$git_dir" checkout "${current_branch:-main}" 2>>"$SUPERVISOR_LOG" || true | |
| return 1 | |
| fi | |
| else | |
| log_warn "rebase_sibling_pr: rebase --continue failed after AI resolution for $task_id" | |
| git -C "$git_dir" rebase --abort 2>>"$SUPERVISOR_LOG" || true | |
| # Return to original branch | |
| git -C "$git_dir" checkout "${current_branch:-main}" 2>>"$SUPERVISOR_LOG" || true | |
| return 1 | |
| # AI agent already completed the rebase — treat as success | |
| log_success "rebase_sibling_pr: rebase completed (AI resolved and continued) for $task_id" | |
| fi | |
| if [[ -d "$git_state_dir/rebase-merge" || -d "$git_state_dir/rebase-apply" ]]; then | |
| log_info "rebase_sibling_pr: AI resolved conflicts for $task_id — continuing rebase" | |
| if git -C "$git_dir" rebase --continue 2>>"$SUPERVISOR_LOG"; then | |
| log_success "rebase_sibling_pr: rebase completed after AI resolution for $task_id" | |
| return 0 | |
| else | |
| log_warn "rebase_sibling_pr: rebase --continue failed after AI resolution for $task_id" | |
| git -C "$git_dir" rebase --abort 2>>"$SUPERVISOR_LOG" || true | |
| # Return to original branch | |
| git -C "$git_dir" checkout "${current_branch:-main}" 2>>"$SUPERVISOR_LOG" || true | |
| return 1 | |
| fi | |
| else | |
| # AI agent already completed the rebase — treat as success | |
| log_success "rebase_sibling_pr: rebase completed (AI resolved and continued) for $task_id" | |
| return 0 | |
| fi |
References
- All functions must have explicit
returnstatements. (link)
rebase_sibling_pr() failed when resolve_rebase_conflicts() spawned an AI agent that completed the rebase itself. The shell script then called `git rebase --continue` which got `fatal: no rebase in progress`, treating it as failure and blocking the task. Fix: after AI resolution succeeds, check if rebase state dirs still exist before calling --continue. If the AI already finished the rebase, treat it as success. Also increase max_rebase_attempts from 2 to 5 — with 10+ sibling PRs merging sequentially, branches fall behind multiple times. Unblocks 17 PRs stuck in CONFLICTING/DIRTY state.
e6ac1a2 to
f9e7646
Compare
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Sat Feb 14 14:57:08 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|



Summary
rebase_sibling_pr()failing when the AI conflict resolver already completes the rebase — check for rebase state dirs before calling--continuemax_rebase_attemptsfrom 2 to 5 to handle cascading rebases across 10+ sibling PRsRoot Cause
resolve_rebase_conflicts()spawns a full AI agent session (opencode run) that resolves conflict markers, runsgit add, and often also runsgit rebase --continueitself. When the shell script then callsgit rebase --continue, it getsfatal: no rebase in progress— which was treated as failure, blocking the task.17 of 20 open PRs were stuck in
CONFLICTING/DIRTYstate because of this.Fix
After AI resolution succeeds, check if
rebase-mergeorrebase-applydirectories still exist (usinggit rev-parse --git-dirwhich works correctly for both worktrees and main repos). If the rebase is already done, log success and proceed to force-push.Also increased
max_rebase_attemptsfrom 2 to 5 — with many sibling PRs merging sequentially, a branch can fall behind multiple times before all siblings are processed.Testing
bash -nsyntax check: passshellcheck -S warning -x: no new warnings (3 pre-existing SC2034 for unused read vars)Summary by CodeRabbit