Skip to content

feat(worktree): auto-rescue dirty worktrees during cleanup#356

Open
dimakis wants to merge 2 commits into
mainfrom
feat/session-closeout-auto-pr
Open

feat(worktree): auto-rescue dirty worktrees during cleanup#356
dimakis wants to merge 2 commits into
mainfrom
feat/session-closeout-auto-pr

Conversation

@dimakis
Copy link
Copy Markdown
Owner

@dimakis dimakis commented May 22, 2026

Summary

  • Currently, stale dirty worktrees are detected during cleanup but only get an inbox notification — the uncommitted work is never committed, pushed, or PR'd. If the worktree directory is later removed, that work is lost.
  • This branch adds rescueDirtyWorktree() which stages all changes, commits them, pushes the session branch, and creates a draft PR via gh pr create, then posts the PR URL to the mgmt inbox.
  • If rescue fails (no remote, push rejected, etc.), the existing skip-and-notify behavior is preserved as a fallback.
  • The inbox notification is updated to distinguish between auto-rescued worktrees (with a PR link) and ones that still need manual rescue.

Test plan

  • server/__tests__/rescue-worktree.test.ts covers getRepoRemote() (SSH/HTTPS parsing, error cases) and rescueDirtyWorktree() (success path, failure at each step)
  • Manual verification: create a session, leave dirty files, wait for cleanup (or trigger manually), confirm draft PR is created and inbox entry contains the PR URL

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

dimakis and others added 2 commits April 28, 2026 23:24
…aft PR

Add rescueDirtyWorktree() that programmatically rescues stale worktrees
with uncommitted work: stages all changes, commits, pushes, and creates
a draft PR via gh CLI. Wired into cleanupStaleWorktrees so rescue is
attempted before falling back to the existing skip-and-notify behavior.

Also updates the CLOSEOUT_PROMPT in chat.ts to instruct the agent to
push branches and create PRs during session closeout, reducing the
number of dirty worktrees that need rescue.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- getMcpConfigPaths() now reads ~/.claude.json (same mcpServers format
  as Cursor) so context7 and other globally-configured MCP servers are
  available in Mitzo sessions
- Fix readonly tuple incompatibility with execFileSync in rescueDirtyWorktree

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Owner Author

@dimakis dimakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Centaur Review

LGTM — no issues found.

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.

1 participant