opencode-mission-control
opencode-mission-control copied to clipboard
feat: Add pre-merge rebase option to mc_merge
Description
mc_merge merges a job branch directly into main. If main has moved since the job branched (e.g. another job merged first), the merge can fail with conflicts.
There's no option to rebase the job branch onto current main before merging. Users must manually: mc_sync → wait → mc_merge, and mc_sync itself has issues (see related sync bug).
Expected Behavior
mc_merge should support an opt-in rebase flag that rebases the job branch onto the current base branch before performing the merge:
mc_merge(name: "fix-auth", rebase: true)
This catches conflicts at rebase time (before the merge) and gives the user a clean fast-forward path.
Proposed Design
Add rebase: boolean (default false) parameter to mc_merge:
- If
rebase: true:- Rebase job branch onto current local main in the job's worktree
- If rebase conflicts → abort, report conflicts, don't merge
- If rebase succeeds → proceed with the configured merge strategy
- If
rebase: false(default): current behavior unchanged
Files
src/tools/merge.ts— addrebaseparametersrc/lib/worktree.tsorsrc/lib/git.ts— rebase utility (can reuse improvedsyncWorktreelogic)
Notes
- Keep opt-in to avoid surprising users with history rewrites
- Complements the mc_sync fix — this is inline conflict prevention at merge time