Commit 0384d7f
committed
Add stable workspace IDs
Workspaces now use stable, unique IDs (10 hex chars) instead of deriving IDs from paths. This simplifies workspace renames from 150 lines of complex migration logic to ~60 lines of metadata updates.
## Core Changes
**Stable ID Generation:**
- Generate at workspace creation: `crypto.randomBytes(5).toString('hex')`
- Separate `id` (stable, immutable) from `name` (mutable, user-facing)
- Add symlinks for UX: `~/.cmux/src/<project>/<name>` → `<id>`
**Type System:**
- `WorkspaceMetadata`: Backend type with stable ID, no path field
- `WorkspaceMetadataWithPaths`: Frontend type with computed paths
- IPC layer enriches metadata with `stableWorkspacePath` and `namedWorkspacePath`
**Workspace Operations:**
- Create: Generate stable ID before creating worktree
- Rename: Update metadata + symlink only (ID unchanged, ~60 lines)
- Remove: Clean up worktree, session data, and symlinks
**Frontend Integration:**
- Build `pathToMetadata` map for lookups (handles both stable and legacy)
- Use map lookups instead of parsing workspace IDs from paths
- Support both new stable-ID workspaces and legacy name-based workspaces
## File Structure
```
# New workspace
~/.cmux/src/cmux/a1b2c3d4e5/ # Worktree (stable ID)
~/.cmux/src/cmux/feature-branch → a1b2c3d4e5 # Symlink
~/.cmux/sessions/a1b2c3d4e5/ # Session data
# Legacy workspace (unchanged)
~/.cmux/src/cmux/stable-ids/ # Worktree
~/.cmux/sessions/cmux-stable-ids/ # Session data
```
## Benefits
- **Instant renames**: No file moves, just metadata update
- **Simpler code**: Removed 90 lines of complex migration/rollback logic
- **Better UX**: Symlinks let users navigate by readable names
- **Stable references**: Chat history, config stay valid across renames
- **Future-proof**: Enables workspace aliases, templates, cross-project refs
## Testing
- ✅ 511 unit tests pass
- ✅ 8 rename integration tests pass
- ✅ 5 remove integration tests pass
- ✅ 13 E2E tests pass
- ✅ 9 new config unit tests1 parent 8de6d12 commit 0384d7f
File tree
29 files changed
+909
-392
lines changed- src
- components
- hooks
- services
- stores
- types
- utils/commands
- tests
- e2e/utils
- ipcMain
29 files changed
+909
-392
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
175 | 187 | | |
176 | 188 | | |
177 | 189 | | |
| |||
230 | 242 | | |
231 | 243 | | |
232 | 244 | | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
248 | 252 | | |
249 | 253 | | |
250 | 254 | | |
| |||
329 | 333 | | |
330 | 334 | | |
331 | 335 | | |
332 | | - | |
333 | | - | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
334 | 339 | | |
335 | 340 | | |
336 | 341 | | |
| |||
354 | 359 | | |
355 | 360 | | |
356 | 361 | | |
357 | | - | |
| 362 | + | |
358 | 363 | | |
359 | 364 | | |
360 | 365 | | |
| |||
382 | 387 | | |
383 | 388 | | |
384 | 389 | | |
385 | | - | |
| 390 | + | |
| 391 | + | |
386 | 392 | | |
387 | 393 | | |
388 | 394 | | |
| |||
392 | 398 | | |
393 | 399 | | |
394 | 400 | | |
395 | | - | |
| 401 | + | |
396 | 402 | | |
397 | 403 | | |
398 | 404 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
| 474 | + | |
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
| |||
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
515 | 526 | | |
516 | 527 | | |
517 | 528 | | |
| |||
822 | 833 | | |
823 | 834 | | |
824 | 835 | | |
825 | | - | |
| 836 | + | |
| 837 | + | |
826 | 838 | | |
827 | 839 | | |
828 | 840 | | |
| |||
833 | 845 | | |
834 | 846 | | |
835 | 847 | | |
| 848 | + | |
836 | 849 | | |
837 | 850 | | |
838 | 851 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | 13 | | |
20 | 14 | | |
21 | 15 | | |
| |||
134 | 128 | | |
135 | 129 | | |
136 | 130 | | |
| 131 | + | |
137 | 132 | | |
138 | 133 | | |
139 | 134 | | |
| |||
147 | 142 | | |
148 | 143 | | |
149 | 144 | | |
| 145 | + | |
150 | 146 | | |
151 | 147 | | |
152 | 148 | | |
| |||
167 | 163 | | |
168 | 164 | | |
169 | 165 | | |
170 | | - | |
| 166 | + | |
| 167 | + | |
171 | 168 | | |
172 | 169 | | |
173 | 170 | | |
| |||
0 commit comments