Skip to content

fix(run): rebase stacked epic session branch onto base so the session PR merges cleanly #303

@bradtaylorsf

Description

@bradtaylorsf

Problem

In stacked multi-epic runs (--epics A,B,C), epic B's session branch is created from epic A's session branch (src/commands/run.ts:1612 branchedFromBranch; :1615 rebaseOntoBranch). When epic A's session PR is squash-merged to base, base gains one squashed commit but epic B's branch still carries epic A's individual commits — so epic B's session PR shows as conflicting / a bloated diff against base. This forces a manual "rebuild a fresh branch off base and overlay the net changes" dance.

Knock-on effect: the session PR body already emits one Closes #N per successful child (src/lib/session.ts:629), so merging the real session PR to base would auto-close every child. The manual rebuild PR omits those Closes lines, so children must then be closed by hand. Fixing the conflict removes the dance and restores correct auto-close — no separate child-closing feature is needed.

Proposed change

rebaseOntoBranch is computed but not enforced. When starting/refreshing a stacked epic session whose base has advanced (prior epic merged), rebase the session branch onto the updated base (dropping commits already in base) before opening/refreshing the session PR. Alternatively, document/support a non-squash merge strategy for stacked epic PRs.

Files

src/commands/run.ts, src/lib/session.ts, src/lib/worktree.ts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingengineLoop engine infrastructure

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions