Commit 3bb7f93
committed
Migrate legacy workspace metadata on load
Codex P0: Fix missing name/projectPath fields in old metadata
Old installations have metadata.json with only id/projectName/workspacePath.
When getAllWorkspaceMetadata() loads these files, enrichMetadataWithPaths()
fails because getWorkspacePaths() requires metadata.name and metadata.projectPath.
Solution: Detect missing fields when loading metadata and migrate in-place:
- Add name field (from workspace basename)
- Add projectPath field (from config)
- Save migrated metadata to disk
This prevents the empty workspace list bug where legacy workspaces disappear
from the UI after upgrading to stable IDs.
Add detailed error logging for missing projectPath in executeBash
Helps diagnose git status failures by showing full metadata when
projectPath is missing, revealing why the migration didn't apply.
🤖 Centralize workspace metadata in config.json
Move workspace metadata from scattered metadata.json files to centralized
config.json. This establishes config as the single source of truth for
workspace data and fixes missing projectPath errors in git status checks.
**New config structure:**
- Workspace entries now include: id, name, createdAt (optional)
- Legacy path-only entries still supported (backward compat)
- Automatic migration on app startup: reads metadata.json, writes to config
**Benefits:**
- Single source of truth (no scattered session files)
- No more missing projectPath errors
- Simpler architecture
- Backward compatible
**Changes:**
- Workspace interface: Added optional id/name/createdAt fields
- getAllWorkspaceMetadata(): Prefers config, falls back to metadata files
- Workspace create/rename: Now writes full metadata to config
- Migration: Automatic on first load, writes back to config
**Migration strategy:**
- Config entries with id/name: Used directly (new format)
- Config entries with path only: Read from metadata.json, migrate to config
- No metadata file: Generate legacy ID, save to config
- Config saved once if any migrations occurred
Metadata.json files kept for backward compat with older cmux versions.
Fixes #259 (git status not appearing due to missing projectPath)
🤖 Fix formatting
🤖 Remove redundant path field from ProjectConfig
Project path was duplicated as both the Map key and the ProjectConfig.path
field. Removed the redundant field and updated all code to use the Map key.
**Changes:**
- Created src/types/project.ts with lightweight ProjectConfig types
- ProjectConfig now only has workspaces array (path is the Map key)
- Updated IPC handler to return [projectPath, projectConfig] tuples
- Updated frontend hooks to construct Map from tuples
- Preload imports from types/project.ts (not heavy config.ts)
**Benefits:**
- Eliminates data duplication (single source of truth)
- Lighter preload imports (types-only, no runtime code)
- Cleaner config structure
- -10 lines of code (removed redundant path assignments)
🤖 Fix formatting
🤖 Fix getWorkspaceMetadata to use centralized config
getWorkspaceMetadata() was reading directly from metadata.json files,
bypassing the migration logic in getAllWorkspaceMetadata(). This caused
git status checks to fail with missing projectPath errors.
**Root Cause:**
- getAllWorkspaceMetadata() applies migration and returns complete data
- getWorkspaceMetadata() read files directly, got old format without projectPath
- Git status calls getWorkspaceMetadata(), failed validation
**Solution:**
- getWorkspaceMetadata() now calls getAllWorkspaceMetadata() and finds by ID
- Single source of truth: all metadata access goes through config
- Migration logic applied consistently everywhere
**Why this works:**
- getAllWorkspaceMetadata() reads config first (already migrated)
- Falls back to metadata files only for legacy entries
- Applies migration on the fly if needed
- Returns complete WorkspaceMetadata with all required fields
This ensures git status (and all other metadata consumers) always get
complete, validated metadata regardless of the underlying storage format.
🤖 Add debug logging to diagnose missing projectPath
🤖 Use log.info instead of console.error
🤖 Add more debug logging in WORKSPACE_EXECUTE_BASH handler1 parent 3d5e5db commit 3bb7f93
File tree
10 files changed
+209
-92
lines changed- src
- hooks
- services
- types
- utils/commands
10 files changed
+209
-92
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | 148 | | |
150 | 149 | | |
151 | 150 | | |
| |||
161 | 160 | | |
162 | 161 | | |
163 | 162 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
175 | 171 | | |
176 | 172 | | |
177 | 173 | | |
| |||
198 | 194 | | |
199 | 195 | | |
200 | 196 | | |
201 | | - | |
202 | 197 | | |
203 | 198 | | |
204 | 199 | | |
205 | 200 | | |
206 | 201 | | |
207 | | - | |
| 202 | + | |
208 | 203 | | |
209 | 204 | | |
210 | 205 | | |
211 | 206 | | |
212 | 207 | | |
213 | 208 | | |
214 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
215 | 220 | | |
216 | 221 | | |
217 | 222 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 11 | + | |
| 12 | + | |
24 | 13 | | |
25 | 14 | | |
26 | 15 | | |
| |||
292 | 281 | | |
293 | 282 | | |
294 | 283 | | |
295 | | - | |
296 | 284 | | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
305 | 292 | | |
306 | 293 | | |
307 | 294 | | |
308 | 295 | | |
| 296 | + | |
309 | 297 | | |
310 | 298 | | |
311 | 299 | | |
| |||
316 | 304 | | |
317 | 305 | | |
318 | 306 | | |
319 | | - | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
320 | 322 | | |
| 323 | + | |
321 | 324 | | |
322 | 325 | | |
323 | 326 | | |
324 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
325 | 345 | | |
326 | | - | |
327 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
328 | 351 | | |
329 | 352 | | |
330 | 353 | | |
331 | 354 | | |
332 | 355 | | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
349 | 366 | | |
350 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
351 | 373 | | |
352 | 374 | | |
| 375 | + | |
353 | 376 | | |
354 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
355 | 396 | | |
356 | 397 | | |
357 | 398 | | |
| |||
360 | 401 | | |
361 | 402 | | |
362 | 403 | | |
363 | | - | |
| 404 | + | |
364 | 405 | | |
365 | 406 | | |
366 | 407 | | |
367 | 408 | | |
368 | 409 | | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
369 | 415 | | |
370 | 416 | | |
371 | 417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | | - | |
| 40 | + | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
206 | 194 | | |
207 | 195 | | |
208 | 196 | | |
209 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
210 | 202 | | |
| 203 | + | |
211 | 204 | | |
212 | 205 | | |
213 | 206 | | |
| |||
0 commit comments