Skip to content

feat: Add stacked branches / stacked PRs as first-class worktree feature #62

@Cheezeiii365

Description

@Cheezeiii365

Summary

Add first-class support for stacked branches (branch-from-branch development) inside aIDE's worktree system. This lets users keep shipping while PRs are under review by branching from in-flight feature branches instead of waiting for them to merge to main.

Background

This is a well-established workflow supported by tools like Graphite, ghstack, Git Town, and Sapling. The core idea:

  1. Branch B from branch A (your PR branch), not from main
  2. Open PR(B) with base=A
  3. Keep shipping while A is under review
  4. After A merges: rebase B onto main, resolve conflicts once, continue

aIDE already has strong primitives for this via worktrees and base-branch creation in worktreeManager.ts and CreateWorktreeModal.tsx.

Proposed Feature (v1)

Core Capabilities

  • "Create Child Branch" action from a worktree item
  • Track parent/child relationships in local app state (not committed)
  • "Sync Stack" command:
    • Fetch + detect merged parents
    • Auto-rebase children in order
    • Pause on conflict with guided resolve UI
  • Stack graph in Worktree panel (A → B → C) with statuses:
    • Ahead/behind, needs rebase, conflicted, merged parent
  • Optional GitHub integration: create stacked PRs and auto-retarget base branches

Important Caveats

  • This rewrites commit history (rebases) — educate users on force-push-to-feature-branch
  • Never auto-rebase without opt-in + dry-run preview
  • Conflict handling UX is the make-or-break piece

File Map

File Action Description
packages/shared/src/index.ts edit Add branch-stack types (node id, parent branch, sync status, conflict state) + IPC channels (STACK_LIST, STACK_CREATE_CHILD, STACK_SYNC, STACK_RETARGET)
packages/main/src/workspace/worktreeManager.ts edit Add child-branch creation handler (base defaults to active branch) + stack-sync orchestration (ordered rebase pipeline, dry-run mode, conflict reporting)
packages/main/src/git/branchStack.ts new Pure git operations: merge-base, rebase, ancestry checks, merged detection — separated from IPC/UI concerns
packages/renderer/src/components/WorktreePanel/WorktreePanel.tsx edit Render parent/child indicators, "Create Child Branch" action, sync status badges, conflict CTAs
packages/renderer/src/components/WorktreePanel/CreateWorktreeModal.tsx edit Add "Create as child of current branch" shortcut preset, preselect base branch to active worktree branch
packages/renderer/src/hooks/useWorktrees.ts edit Subscribe to stack status updates, expose sync actions to UI

Practical Workflow (Manual, Available Now)

  1. Build feature A on feature/A
  2. While A in review, create feature/B from feature/A in a separate worktree
  3. Open PR B with base branch = feature/A
  4. Keep bugfixing A; periodically rebase feature/B onto updated feature/A
  5. When A merges, rebase B onto main, retarget PR B to main

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions