opencode-mission-control
opencode-mission-control copied to clipboard
bug: Plan job branches can collide with standalone jobs — no plan-scoped naming
Description
Plan jobs default to branch name mc/<jobName>. Standalone mc_launch jobs also use mc/<jobName>. If a plan job has the same name as a previous standalone job (or a job from a different plan), createWorktree() will reuse the existing branch instead of creating a fresh one.
This can lead to:
- Stale code from a previous job leaking into the new job
- Unexpected merge results when the branch has commits from unrelated work
- Silent failures that are hard to debug
Expected Behavior
Plan job branches should be scoped to the plan to avoid collisions:
mc/plan/<planId-short>/<jobName>
Example: mc/plan/a1b2c3d4/api-endpoints
Current Behavior
// src/lib/orchestrator.ts — launchJob()
const branch = job.branch ?? `mc/${job.name}`;
And in createWorktree():
const branchCheckResult = await gitCommand(['branch', '--list', opts.branch]);
const branchExists = branchCheckResult.stdout.includes(opts.branch);
if (branchExists) {
createResult = await gitCommand(['worktree', 'add', worktreePath, opts.branch]);
// Reuses the existing branch with all its old commits!
}
Proposed Fix
- Default plan job branches to
mc/plan/<planId-short>/<jobName>inorchestrator.ts - Keep standalone
mc_launchbranches asmc/<jobName>(backward compatible) - Optionally: warn or error if a branch already exists when creating a plan job
Files
src/lib/orchestrator.ts— branch naming inlaunchJob()- Status/overview output may need updating to display the longer branch names
Risk
- Longer branch names in tmux displays
- Existing users may have scripts that assume
mc/<name>format — only change default for plan jobs