Skip to content

fix(staged): stop "Rebase onto Origin" misrouting onto a stale remote tip#751

Merged
matt2e merged 3 commits into
mainfrom
bad-rebase
May 27, 2026
Merged

fix(staged): stop "Rebase onto Origin" misrouting onto a stale remote tip#751
matt2e merged 3 commits into
mainfrom
bad-rebase

Conversation

@matt2e
Copy link
Copy Markdown
Contributor

@matt2e matt2e commented May 27, 2026

Summary

Fixes a bug where the "Rebase onto Origin" action could silently rebase onto a stale remote tip when the remote branch was itself behind the configured base.

  • Rename base_branch to rebase_target in build_commit_pipeline_steps; pass both the configured base and the actual rebase target through so the AI handoff prompt can flag suspect targets, and persist rebaseTarget on queued PipelineExecutions so dequeues no longer downgrade a queued "Rebase onto Origin" to a base rebase.
  • Add an upstream.behindBase signal to BranchGitState; the timeline's diverged row uses it to disable the rebase-onto-origin action with a clarifying reason when the remote branch is behind the configured base.
  • Label rebase-onto-origin pipeline steps with the actual target (Fetch origin/{target} / Rebase onto origin/{target}) instead of generic "base" wording, so labels agree with the clicked action.
  • Refine the UpstreamGitState::behind_base doc comment to match the timeline's user-facing reason string.

Test plan

  • Trigger "Rebase onto Origin" while the remote tip is behind the configured base — confirm the action is disabled with the new reason.
  • Queue a "Rebase onto Origin" pipeline and confirm it dequeues onto the remote target (not the base).
  • Verify pipeline step labels show Fetch origin/{target} and Rebase onto origin/{target}.

matt2e and others added 3 commits May 26, 2026 21:26
…le remote tip

Rename `base_branch` to `rebase_target` in `build_commit_pipeline_steps`,
pass both the configured base and the actual rebase target through so the
AI handoff prompt can flag suspect targets, persist `rebaseTarget` on
queued `PipelineExecution`s so the dequeue path no longer downgrades a
queued "Rebase onto Origin" to a base rebase, and add an
`upstream.behindBase` signal to `BranchGitState` that the timeline's
diverged row uses to disable the rebase-onto-origin action with a
clarifying reason when the remote branch is itself behind the configured
base.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
…target

When `rebase_target` differs from `base_branch`, render the fetch and
rebase step labels as `Fetch origin/{target}` / `Rebase onto
origin/{target}` instead of the generic "base" wording, so a user
watching a "Rebase onto Origin" pipeline sees labels that agree with the
action they clicked.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
Reword the `UpstreamGitState::behind_base` doc comment from "would
produce an unmergeable result" to "would skip the latest base commits
and almost always be the wrong action" — the rebase itself still
succeeds, the result just omits the latest base commits, which matches
the timeline's user-facing reason string more precisely.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
@matt2e matt2e requested review from baxen and wesbillman as code owners May 27, 2026 04:19
Copy link
Copy Markdown

@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: c7b52ea283

ℹ️ 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".

Comment on lines +480 to +483
let rebase_ref = queued_rebase_target
.clone()
.unwrap_or_else(|| base_branch.clone());
let steps = build_commit_pipeline_steps(&kind, &base_branch, &rebase_ref);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Revalidate queued origin rebases before honoring target

When a Rebase onto Origin session is queued while origin/{branch} is caught up, but origin/{base} advances before this dequeue path runs, this reconstructs the pipeline from the persisted rebaseTarget without refreshing or recomputing behindBase; the generated steps then fetch only origin/{rebaseTarget} and proceed to rebase onto that now-behind remote tip. That leaves the stale-target misroute this change is trying to prevent for queued sessions, so the dequeue path should refresh/check the base-vs-target relationship before preserving the origin target.

Useful? React with 👍 / 👎.

@matt2e matt2e merged commit 6dd0f8b into main May 27, 2026
5 checks passed
@matt2e matt2e deleted the bad-rebase branch May 27, 2026 04:42
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