[Repo Assist] Fix gh stack up/down navigation when on a queued branch - #17
Draft
github-actions[bot] wants to merge 1 commit into
Draft
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
When the current branch is queued (in a merge queue), its PR is
non-merged but also not in ActiveBranchIndices(). The previous code
used onMerged = s.Branches[idx].IsMerged(), which was false for queued
branches. This caused the navigation to fall into the 'active branch'
path, where activePos = -1 (queued branch not in activeIndices), and
newActivePos = -1 + delta. The result:
- gh stack up from a queued branch β always went to activeIndices[0]
(the first active branch), not the next adjacent branch
- gh stack down from a queued branch β clamped to activeIndices[0] too
Fix: rename onMerged β onSkipped and use IsSkipped() (= IsMerged() ||
IsQueued()). Both merged and queued branches now navigate by raw index
(Β±delta), which is consistent with the existing merged-branch behaviour.
Also consolidates the two skip-counter checks (IsMerged β IsSkipped)
and updates the user message from 'Skipped N merged branches' to
'Skipped N inactive branches' to accurately reflect that queued
branches are now counted too.
Two new tests:
- TestNavigate_UpFromQueuedBranch
- TestNavigate_DownFromQueuedBranch
Co-authored-by: Copilot <[email protected]>
This was referenced Apr 24, 2026
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.
π€ This is an automated pull request from Repo Assist, an AI assistant.
Summary
gh stack up/gh stack downbehaved incorrectly when the current branch was queued (in a merge queue).Root cause
IsQueued()andIsMerged()are both "inactive" states, but the navigation code only recognisedIsMerged(). When you were on a queued branch:onMerged = falseβ fell into the "active branch" navigation pathactiveIndices = s.ActiveBranchIndices()β queued branch not includedactivePos = -1(branch not found)newActivePos = -1 + deltaβ forup(+1): index 0 (first active); fordown(-1): clamped to 0Both directions ended up at
activeIndices[0]β the first active branch β regardless of where in the stack the queued branch sat. For example, with stack[b1, b2(queued), b3]onb2:gh stack upb3b1(wrong!)gh stack downb1b1(accidentally correct but wrong reason)With a deeper stack like
[b1, b2, b3(queued), b4, b5]onb3:gh stack upb4b1(wrong!)gh stack downb2b1(wrong!)Fix
onMerged β onSkipped, usingIsSkipped()(= IsMerged() || IsQueued())"Warning: you are on queued branch %q"IsMerged()βIsSkipped()and the message from"Skipped N merged branches"β"Skipped N inactive branches"Relationship to other PRs
gh stack topto useLastActiveBranchIndex()β unrelated to this change.Test Status
sum.golang.orgis blocked). The CI workflow (test.yml) will run tests on GitHub.Two new tests cover the fixed behaviour:
TestNavigate_UpFromQueuedBranchβ verifies up-navigation steps to the adjacent branch aboveTestNavigate_DownFromQueuedBranchβ verifies down-navigation steps to the adjacent branch belowExisting tests are unaffected:
TestNavigate_SkipsMergedBranchesassertsContains(output, "Skipped")which matches the updated"Skipped N inactive branches"message;TestNavigate_AllMerged_Upchecks"you are on merged branch"which is still emitted in theIsMerged()case.Warning
The following domain was blocked by the firewall during workflow execution:
sum.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.