opencode-mission-control icon indicating copy to clipboard operation
opencode-mission-control copied to clipboard

feat: Add pre-merge rebase option to mc_merge

Open nigel-dev opened this issue 9 months ago • 0 comments

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:

  1. 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
  2. If rebase: false (default): current behavior unchanged

Files

  • src/tools/merge.ts — add rebase parameter
  • src/lib/worktree.ts or src/lib/git.ts — rebase utility (can reuse improved syncWorktree logic)

Notes

  • Keep opt-in to avoid surprising users with history rewrites
  • Complements the mc_sync fix — this is inline conflict prevention at merge time

nigel-dev avatar Feb 12 '26 06:02 nigel-dev