Repository navigation
feat(ui): merge a GitHub stack up to the cursor PR atomically - #170
Merged
Merged
Conversation
…ilure and narrow prompts
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.
Closes #169
Summary
Son a PR in a GitHub stack merges every not-yet-merged layer from the bottom of the stack up to and including that PR, in one atomic, server-side operation, behind a confirm prompt such asMerge stack up to #142 (3 PRs: #140 #141 #142)?. The merge is a squash when it goes directly into the base, or uses the queue's own method when the base merges through a merge queue. On a non-stacked PR,SshowsPR #N is not in a stackand merges nothing. There is no fallback that merges layers one at a time.Flow:
Stack changed since the prompt — press S again.actionDoneMsg.merged, which drives the session-merged marks and branch cleanup, and invalidate the cache for every layer.Endpoint, taken from
github/gh-stackv0.2.1 (29a36d3):PUT /repos/{o}/{r}/pulls/{n}/merge-async(internal/github/merge_async.go:221-241).{"merge_method":"squash","merge_action":"direct_merge"}, or{"merge_action":"merge_queue"}with no method when the base has a merge queue. This is how gh-stack itself routes (cmd/merge.go:148-155, 471-476).GET /repos/{o}/{r}/pulls/{n}/merge-async/{uuid}(merge_async.go:247-254). Statuses:pending,merged,enqueued,failed(:96-107).GET /repos/{o}/{r}/stacks?pull_request={n}(internal/github/github.go:515-526).mergeQueue(branch:)field or aMERGE_QUEUEref rule (merge_async.go:166-205).Accept: application/vnd.github+json. No preview header; gh-stack uses a stock go-gh REST client (github.go:66-88).Layers that are not on the loaded board are never assumed fine. Their state and draft flag come from the REST membership, and their mergeability from a batched
FetchDetails.Plan:
docs/superpowers/plans/2026-10-11-stack-merge.md; spec:docs/superpowers/specs/2026-10-11-stack-merge-design.md.Contract:
gh.MutationSourcegainsMergeStackandStackMergeStatus. Both are REST calls and take the PR number, not the node ID. A newgh.StackSourceis wired inmain.go.GraphSourceand both test fakes are updated.confirmPanelis now capped at the terminal width and wraps its question, so a long stack prompt can't cut off its PR numbers. Single-line prompts render exactly as before.Testing
nix build -L .#checks.x86_64-linux.go-gate(golangci-lint, nilaway,go test,go test -race -short): passgo test -count=1 ./internal/gh ./internal/ui ./internal/action: passhttptestand assert method, path, headers and exact body. No real stack merge was run against GitHub.Review notes
m/u/cascade) on plan layers while a stack merge runs: refuted. Allowed on purpose (spec S5). A moved head or an already-merged layer makes the atomic merge fail with nothing merged.Stack merged ×1badge on a single-layer stack: dropped (below bar).Assumptions
Agent ledger
Acceptance ledger
TestStackRange(bottom/middle/top),TestStackMergeRefusesNonStackedPR,TestCheckStackLayersRefusals(closed/draft/conflicted/pending, names the PR),TestMergeStackDirect/TestMergeStackQueue/TestStackMergeStatus(method/path/body via httptest),TestStackMergeConfirmMergesEveryLayer(merged = [140 141 142]): passTestStackMergePlanQuestion,TestStackMergeMiddleLayerPromptsWithOffBoardLayer: passReview: mode full. Round 1: go-reviewer (opus, promoted), charm-tui-reviewer (opus), security-reviewer (opus), test-runner. Round 2: a targeted go and charm-tui re-review of fix commit 4d36185 approved all seven fixes. Roster base 868c08e, harness-only (no repo-local reviewers). The diverse cursor one-shot timed out. recurrence_escalation: unused.
TestStackMergeSubmitRefusesChangedMembership+ round-2 reviewdirect_mergeTestLoadStackPlanMergeQueueDetectionErrorRefusesTestConfirmPanelFitsLongStackQuestion(50/80 cols)yconfirmed a late promptTestStackMergeLoadDroppedAfterLaterKeyTestStackMergeRunUnknownStatusKeepsPollingTestStackMergeLoadDroppedDuringCascadem/uduring a stack runFetchDetailserror reported as pendingTestLoadStackPlanDetailFetchErrorRefuses×1badge on a single layerConsumer map
MutationSource: implemented byGraphSource,fakeMutationSourceandpartialMergeSource.MergeStackandStackMergeStatusare called only fromstackmerge.go.StackSource: implemented byGraphSource, wired viamain.goSetStackSource, consumed byloadStackPlanand the re-check inrunStackMerge.actionDoneMsg.stackMerge: produced only bystackMergeRun; every other producer leaves it false.m.pendingset site clearspendingStackMerge.actionOrder/keyPanes: the newShint. The panel height it reserves still matches what renders.