You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🤖 Prevent SSH workspace deletion with unpushed refs (#460)
## Problem
SSH workspaces are independent git clones. Unlike local worktrees (which
share `.git`), deleting an SSH workspace with unpushed commits
permanently loses that work. The deletion code only checked for
uncommitted changes, not unpushed refs.
## Solution
Added unpushed refs check to `SSHRuntime.deleteWorkspace()`:
- Checks for unpushed commits when `force=false`
- Only checks when git remotes are configured (no remote = no concept of
"unpushed")
- Returns error when unpushed commits exist, requiring `force=true` to
proceed
## Performance Optimization
Combined all pre-deletion checks into a single bash script to minimize
SSH round trips:
- **Before:** 5 separate exec calls (check exists, check dirty, check
remotes, check unpushed, delete)
- **After:** 2 exec calls (combined checks, delete)
- **Reduction:** 60% fewer SSH round trips
Exit code mapping:
- 0: Safe to delete
- 1: Uncommitted changes
- 2: Unpushed commits
- 3: Doesn't exist (idempotent)
## Testing
Added integration tests for SSH workspaces:
- `should fail to delete SSH workspace with unpushed refs without force
flag`
- `should delete SSH workspace with unpushed refs when force flag is
set`
All 16 deletion tests pass (9 local + 7 SSH).
_Generated with `cmux`_
0 commit comments