Skip to content

fix(chain): rebase pre-existing worktrees onto chain base (#289) - #291

Merged
admarble merged 1 commit into
mainfrom
feature/289-chain-mode-silently-fails-when-worktrees-pre-exist
Feb 18, 2026
Merged

admarble merged 1 commit into
mainfrom
feature/289-chain-mode-silently-fails-when-worktrees-pre-exist

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

  • Fix chain mode to properly handle pre-existing worktrees by rebasing them onto the previous chain link
  • Add chain and qaGate flags to RunConfigSchema for better run log completeness
  • Handle rebase conflicts gracefully with abort and warning messages

Changes

Core Fix (src/commands/run.ts)

When ensureWorktree() finds an existing worktree and chain mode is active with a base branch:

  1. Attempts to rebase the existing branch onto the chain's base branch
  2. On conflict: aborts the rebase and continues with the branch in its original state (logs warning)
  3. Returns rebased: true on success, rebased: false on failure

Schema Update (src/lib/workflow/run-log-schema.ts)

  • Added optional chain: boolean field to RunConfigSchema
  • Added optional qaGate: boolean field to RunConfigSchema
  • Both fields are optional for backwards compatibility with existing logs

Test Coverage

  • Added tests for pre-existing worktree rebase behavior in chain mode
  • Added tests for chain and qaGate fields in RunConfigSchema

Test plan

  • npm run build passes
  • npm run lint passes
  • npm test passes (1228 tests)

Closes #289

🤖 Generated with Claude Code

When running chain mode with pre-existing worktrees, the ensureWorktree()
function now rebases the existing worktree onto the chain's base branch.

Changes:
- Add rebase logic in ensureWorktree() when chainMode=true and baseBranch is set
- Handle rebase conflicts gracefully with abort and warning
- Add chain/qaGate flags to RunConfigSchema for log completeness
- Add comprehensive test cases for pre-existing worktree behavior

Closes #289
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chain mode silently fails when worktrees pre-exist from earlier runs

1 participant