Commit 8bf7432
committed
🤖 Remove ipcMain coupling with git worktrees
Problem: ipcMain directly imported and called git worktree functions
(removeWorktree, pruneWorktrees), breaking the Runtime abstraction:
- Created leaky abstraction with if (type !== 'ssh') checks
- Exposed LocalRuntime implementation details (worktrees) to business logic
- Inconsistent - some ops went through Runtime, others bypassed it
Key insight: Worktrees are an internal concept of LocalRuntime. SSHRuntime
uses plain directories. The Runtime interface should never expose
worktree-specific operations.
Solution: Make LocalRuntime.deleteWorkspace() fully idempotent and
self-sufficient:
1. LocalRuntime.deleteWorkspace() now:
- Checks if directory exists before attempting deletion
- Prunes stale git records when directory is already gone
- Handles 'not a working tree' errors gracefully by auto-pruning
- Returns success for already-deleted workspaces (idempotent)
2. ipcMain cleanup paths now use runtime.deleteWorkspace():
- Line 608: Fork cleanup now calls runtime.deleteWorkspace(force=true)
- Lines 1067-1078: Removed manual pruning logic entirely
3. Removed git imports from ipcMain:
- Deleted removeWorktree and pruneWorktrees imports
- Only kept branch query operations (getCurrentBranch, etc.)
Benefits:
✅ Proper encapsulation - Worktree concerns stay in LocalRuntime
✅ No leaky abstractions - Removed if (type !== 'ssh') check from ipcMain
✅ Consistent - All workspace mutations go through Runtime interface
✅ Idempotent - deleteWorkspace() succeeds on already-deleted workspaces
✅ Zero Runtime interface changes - Solution internal to LocalRuntime
Result: Clean architecture, no git coupling in ipcMain, all tests pass.
_Generated with `cmux`_1 parent 28f0fb7 commit 8bf7432
2 files changed
+38
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
478 | 478 | | |
479 | 479 | | |
480 | 480 | | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
481 | 493 | | |
482 | 494 | | |
483 | 495 | | |
| |||
492 | 504 | | |
493 | 505 | | |
494 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
495 | 526 | | |
496 | 527 | | |
497 | 528 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | 13 | | |
16 | 14 | | |
17 | 15 | | |
| |||
604 | 602 | | |
605 | 603 | | |
606 | 604 | | |
607 | | - | |
608 | | - | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
609 | 608 | | |
610 | 609 | | |
611 | 610 | | |
612 | 611 | | |
613 | | - | |
| 612 | + | |
614 | 613 | | |
615 | 614 | | |
616 | 615 | | |
| |||
1053 | 1052 | | |
1054 | 1053 | | |
1055 | 1054 | | |
1056 | | - | |
| 1055 | + | |
1057 | 1056 | | |
1058 | 1057 | | |
1059 | 1058 | | |
1060 | | - | |
1061 | | - | |
1062 | | - | |
1063 | | - | |
1064 | | - | |
1065 | | - | |
1066 | | - | |
1067 | | - | |
1068 | | - | |
1069 | | - | |
1070 | | - | |
1071 | | - | |
1072 | | - | |
1073 | | - | |
1074 | | - | |
1075 | | - | |
1076 | | - | |
1077 | | - | |
1078 | | - | |
1079 | | - | |
1080 | | - | |
1081 | | - | |
1082 | | - | |
1083 | | - | |
| 1059 | + | |
| 1060 | + | |
1084 | 1061 | | |
1085 | 1062 | | |
1086 | 1063 | | |
| |||
0 commit comments