Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Repo Assist] Fix gh stack up/down navigation when on a queued branch - #17

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/fix-navigate-from-queued-2026-04-23-517d080f5a9a4765
Draft

github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/fix-navigate-from-queued-2026-04-23-517d080f5a9a4765

Conversation

@github-actions

Copy link
Copy Markdown

πŸ€– This is an automated pull request from Repo Assist, an AI assistant.

Summary

gh stack up / gh stack down behaved incorrectly when the current branch was queued (in a merge queue).

Root cause

// Before (cmd/navigate.go ~L100)
onMerged := s.Branches[idx].IsMerged()  // false for queued branches!

IsQueued() and IsMerged() are both "inactive" states, but the navigation code only recognised IsMerged(). When you were on a queued branch:

  • onMerged = false β†’ fell into the "active branch" navigation path
  • activeIndices = s.ActiveBranchIndices() β†’ queued branch not included
  • activePos = -1 (branch not found)
  • newActivePos = -1 + delta β†’ for up (+1): index 0 (first active); for down (-1): clamped to 0

Both 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] on b2:

Command Expected Before fix
gh stack up b3 b1 (wrong!)
gh stack down b1 b1 (accidentally correct but wrong reason)

With a deeper stack like [b1, b2, b3(queued), b4, b5] on b3:

Command Expected Before fix
gh stack up b4 b1 (wrong!)
gh stack down b2 b1 (wrong!)

Fix

  • Renamed onMerged β†’ onSkipped, using IsSkipped() (= IsMerged() || IsQueued())
  • Both merged and queued branches now navigate by raw index (Β±1 step), consistent with existing merged-branch behaviour
  • Added a separate warning message for queued branches: "Warning: you are on queued branch %q"
  • Updated the skip counter (in the active-branch path) from IsMerged() β†’ IsSkipped() and the message from "Skipped N merged branches" β†’ "Skipped N inactive branches"

Relationship to other PRs

Test Status

⚠️ Tests could not be run in this environment due to network restrictions preventing Go toolchain download (sum.golang.org is 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 above
  • TestNavigate_DownFromQueuedBranch β€” verifies down-navigation steps to the adjacent branch below

Existing tests are unaffected: TestNavigate_SkipsMergedBranches asserts Contains(output, "Skipped") which matches the updated "Skipped N inactive branches" message; TestNavigate_AllMerged_Up checks "you are on merged branch" which is still emitted in the IsMerged() case.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • sum.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "sum.golang.org"

See Network Configuration for more information.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@11c9a2c442e519ff2b427bf58679f5a525353f76

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants