Conversation
skarim
added this pull request to stack #522
September 22, 2026 17:03
This was referenced Sep 22, 2026
skarim
removed this pull request from stack #522
September 29, 2026 12:50
skarim
force-pushed
the
skarim/worktrees-modify
branch
from
September 29, 2026 13:03
f9a47f9 to
c088459
Compare
skarim
changed the base branch from
skarim/worktrees-support
to
skarim/worktrees-distributed-rebase-sync
September 29, 2026 13:03
skarim
added this pull request to stack #530
September 29, 2026 13:04
This was referenced Sep 29, 2026
skarim
marked this pull request as ready for review
September 29, 2026 16:28
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Fold normalization ordering contradicts its new test, and checkout restoration can select the wrong fold receiver.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Adds distributed worktree support to gh stack modify, including owner-scoped actions, conflict recovery, and documentation.
Changes:
- Executes stack modifications in each branch’s owning worktree.
- Persists action progress and strengthens continuation/abort recovery.
- Adds extensive distributed-worktree tests and documentation.
| File | Description |
|---|---|
.github/copilot-instructions.md |
Documents distributed-modify constraints. |
AGENTS.md |
Updates architecture guidance. |
README.md |
Describes cross-worktree modify behavior. |
cmd/modify.go |
Routes conflicts to recorded owners. |
cmd/modify_test.go |
Tests command and TUI behavior. |
docs/src/content/docs/getting-started/quick-start.md |
Updates quick-start guidance. |
docs/src/content/docs/guides/modify.md |
Documents distributed modification and recovery. |
docs/src/content/docs/guides/workflows.md |
Updates worktree workflows. |
docs/src/content/docs/reference/cli.md |
Updates CLI requirements and behavior. |
internal/modify/actions.go |
Implements persisted structural actions. |
internal/modify/apply.go |
Coordinates owner-scoped execution and continuation. |
internal/modify/apply_test.go |
Adds distributed execution and recovery coverage. |
internal/modify/plan.go |
Compiles action targets and execution order. |
internal/modify/preconditions.go |
Adds owner validation and targeted preflight. |
internal/modify/recovery.go |
Implements distributed rollback and checkout restoration. |
internal/modify/state.go |
Persists execution and recovery metadata. |
skills/gh-stack/SKILL.md |
Updates agent-facing behavior guidance. |
skills/gh-stack/references/troubleshooting.md |
Updates distributed recovery troubleshooting. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+366
to
+368
| if !aborting { | ||
| target = resolveCheckoutBranch(state.OriginalBranch, state.Plan, state.Snapshot, s) | ||
| } |
Comment on lines
+137
to
+138
| for i, n := range nodes { | ||
| if n.PendingAction == nil || (n.PendingAction.Type != modifyview.ActionFoldDown && n.PendingAction.Type != modifyview.ActionFoldUp) { |
This branch has not been deployed
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.


Lets users restructure a stack with
gh stack modifywhile its branches remain checked out in different worktrees. Building on #529, the interactive editor applies each planned change in the checkout that holds the affected branch.Functionality and user impact
Boundary: the starting worktree and other checkouts that will be changed must be clean and available; read-only source worktrees are left alone. Git 2.36+, linear history, an interactive terminal, and no queued PRs remain requirements. Reordering cannot be mixed with drops, folds, inserts, or renames in one session. No automatic stashing or worktree creation/removal is added.
Key areas to review
internal/modify/plan.go:compileActionsdetermines final branch names, which branch receives each fold, and which commits to remove before changing Git history. Check the action order and rejection of unsupported combinations.internal/modify/actions.go:runActions,applyRename,applyInsert, andapplyFoldexecute the plan. Focus on the exact commits each fold includes, preserving removed branches, and saving progress after each action.internal/modify/preconditions.go:preflightBrancheschecks that branches are still in the expected checkouts and those checkouts are ready. On continuation, check other worktrees first; the checkout containing the conflict is expected to have unfinished Git work.internal/modify/apply.go:ApplyPlan,rebaseRemaining, andContinueApplyconnect branch edits to the following rebases and resume remaining steps after conflicts, even when the next conflict is in another worktree.internal/modify/recovery.go:startRefMutation,checkPendingHead,unwindState, andrestoreCheckoutcheck saved commit IDs before changing branches, undo recorded changes, and restore the starting checkout without taking over another worktree.Related issues
gh stack rebasesilently succeeds whengit rebase --ontofails to start (in branch checked out in another worktree) #35