Commit 4616813
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 d4fd1aa commit 4616813
2 files changed
+38
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
491 | 503 | | |
492 | 504 | | |
493 | 505 | | |
| |||
502 | 514 | | |
503 | 515 | | |
504 | 516 | | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
505 | 536 | | |
506 | 537 | | |
507 | 538 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | 13 | | |
16 | 14 | | |
17 | 15 | | |
| |||
628 | 626 | | |
629 | 627 | | |
630 | 628 | | |
631 | | - | |
632 | | - | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
633 | 632 | | |
634 | 633 | | |
635 | 634 | | |
636 | 635 | | |
637 | | - | |
| 636 | + | |
638 | 637 | | |
639 | 638 | | |
640 | 639 | | |
| |||
1077 | 1076 | | |
1078 | 1077 | | |
1079 | 1078 | | |
1080 | | - | |
| 1079 | + | |
1081 | 1080 | | |
1082 | 1081 | | |
1083 | 1082 | | |
1084 | | - | |
1085 | | - | |
1086 | | - | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
1102 | | - | |
1103 | | - | |
1104 | | - | |
1105 | | - | |
1106 | | - | |
1107 | | - | |
| 1083 | + | |
| 1084 | + | |
1108 | 1085 | | |
1109 | 1086 | | |
1110 | 1087 | | |
| |||
0 commit comments