Fix branch selector confusion during merge/rebase conflicts#2017
Draft
posthog[bot] wants to merge 1 commit intomainfrom
Draft
Fix branch selector confusion during merge/rebase conflicts#2017posthog[bot] wants to merge 1 commit intomainfrom
posthog[bot] wants to merge 1 commit intomainfrom
Conversation
When a repo is mid-rebase (or merge/cherry-pick/revert), the new task input's branch selector showed three confusing things: 1. The first item in the dropdown was `(no` — simple-git's `branchLocal()` parser misreads git's `(no branch, rebasing main)` pseudo-branch line. Switched `getAllBranches` to `git for-each-ref refs/heads/`, which only returns real local branches. 2. The label said "No branch" with no hint that an operation was in progress. Added a `getGitBusyState` query that exposes rebase/merge/cherry-pick/revert state, and the selector now shows "Rebasing", "Merging", etc. when there is no current branch. 3. Selecting a branch threw a checkout error because git refuses checkout while a working-tree operation is in progress. The selector is now disabled in local mode while busy, with a tooltip explaining how to recover. The busy-state probe (rebase-merge/, MERGE_HEAD, etc.) was already implemented inside `CaptureCheckpointSaga`; extracted it to `inspectGitBusyState` in `queries.ts` so the saga and the new public `getGitBusyState(baseDir)` share one implementation. Generated-By: PostHog Code Task-Id: e47ff9ba-d59b-4212-bc43-c49a5cd8db16
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 the local repo is mid-rebase (or merge/cherry-pick/revert), the new task input's branch selector behaved badly in three ways. This PR cleans all three up.
(nosimple-git'sbranchLocal()parser greedily mis-parses git's* (no branch, rebasing main)pseudo-branch line and returns(noas a "branch name"getAllBranchestogit for-each-ref refs/heads/so only real branches are returnedgetCurrentBranchreturnsnullduring rebase (HEAD is detached on the rebase pseudo-ref)getGitBusyStatetRPC query reportsrebase/merge/cherry-pick/revert; the selector now shows "Rebasing", "Merging", etc. when there's no current branchFailed to checkout …checkoutwhile an operation is in progressThe busy-state probe (
rebase-merge/,MERGE_HEAD,CHERRY_PICK_HEAD,REVERT_HEAD) was already implemented insideCaptureCheckpointSaga. It's now extracted toinspectGitBusyStateinqueries.tsso the saga and the new publicgetGitBusyState(baseDir)share one implementation — no behavior change for the saga; existing 18 checkpoint tests still pass.Worktree and cloud modes are unaffected (
busyStateonly applies when!isSelectionOnly).Test plan
getAllBranchesfiltering the(nopseudo-branch during a rebase conflictgetGitBusyStatereporting{ busy: true, operation: "rebase" }mid-rebasecheckpoint sagastests still pass after extractinginspectGitBusyStateCreated with PostHog Code