feat(staged): show "Force push" on PR button when branch has diverged#752
Merged
Conversation
Replaces the boolean `shouldShowPushChanges` predicate with a richer `derivePrPushAction` that mirrors the timeline's logic: `localAhead` becomes `'push'`, `diverged` becomes `'forcePush'`, and the PR button's label, click handler, and tooltip all read from it. Alt remains a manual override so users can still force-push a fast-forward branch, and fork PRs (missing upstream) keep the existing `'push'` + backend non-FF rejection fallback. Signed-off-by: Matt Toohey <contact@matttoohey.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a4f21c9e80
ℹ️ 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".
When the PR button is in "Force push" mode (branch diverged from origin) clicking it now opens the existing force-push confirmation dialog instead of force-pushing immediately. Holding alt at click time skips the confirmation, matching the alt-override semantics used elsewhere for power users who know they want to clobber the remote. Signed-off-by: Matt Toohey <contact@matttoohey.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a branch has diverged from its upstream (e.g. after a rebase or amend), the PR button now shows "Force push" instead of "Push changes" without needing to hold the option key. Holding option still forces a force push when the local state alone wouldn't have triggered it.
Changes
derivePrPushActionreturning'none' | 'push' | 'forcePush', classifyingdivergedasforcePushandlocalAheadaspush.shouldShowPushChangesis preserved as a thin wrapper for callers that only need the boolean.BranchCardPrButtonderivespushActionand uses it for the label, tooltip, and click handler — option-held still forces force push.origin/<branch>) keep the existing fallback: classified aspush, with the backend's non-FF rejection driving the force-push dialog.Test plan
localAheadbranch still triggers force push