Commit 4a4f628
authored
🤖 Optimize sidebar renders (#248)
Follow-up cleanup work for MapStore implementation.
## Changes
**Extracted WorkspaceListItem component** (316 lines)
- Moved from nested component in ProjectSidebar to standalone file
- Includes all workspace-specific UI logic and styled components
- Self-contained with clear responsibilities
**Created RenameContext** (91 lines)
- Coordinates rename state across all workspace items ("one at a time"
enforcement)
- Handles the actual rename IPC call
- Components manage their own local edit state
**Reduced ProjectSidebar** (897 lines, down from 1210)
- Removed 313 lines of workspace item logic
- No longer manages per-workspace rename state
- Cleaner separation of concerns
## Props Reduction
WorkspaceListItem now receives **11 props instead of 18** (-7 props):
**Removed:**
- `isEditing`, `editingName`, `originalName`, `renameError` (now local
state)
- `setEditingName` (managed internally)
- `startRenaming`, `confirmRename`, `handleRenameKeyDown` (use context)
**Benefits:**
- ✅ Only edited workspace re-renders during rename (not all items)
- ✅ Better separation: global coordination in context, local state in
component
- ✅ Cleaner interfaces with fewer props
- ✅ Same UX (still only one workspace can be renamed at a time)
## Testing
All 486 tests pass.
_Generated with `cmux`_1 parent f7cfcbd commit 4a4f628
File tree
13 files changed
+895
-678
lines changed- src
- components
- contexts
- hooks
- stores
13 files changed
+895
-678
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
152 | 157 | | |
153 | 158 | | |
154 | 159 | | |
| |||
265 | 270 | | |
266 | 271 | | |
267 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
268 | 292 | | |
269 | 293 | | |
270 | 294 | | |
| |||
297 | 321 | | |
298 | 322 | | |
299 | 323 | | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
315 | 351 | | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
320 | 359 | | |
321 | 360 | | |
322 | 361 | | |
| |||
523 | 562 | | |
524 | 563 | | |
525 | 564 | | |
526 | | - | |
| 565 | + | |
527 | 566 | | |
528 | 567 | | |
529 | 568 | | |
| |||
582 | 621 | | |
583 | 622 | | |
584 | 623 | | |
585 | | - | |
586 | | - | |
587 | | - | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
588 | 627 | | |
589 | 628 | | |
590 | 629 | | |
591 | 630 | | |
592 | 631 | | |
593 | | - | |
| 632 | + | |
594 | 633 | | |
595 | 634 | | |
596 | 635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
316 | | - | |
| 316 | + | |
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | | - | |
| 391 | + | |
392 | 392 | | |
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | | - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
399 | 401 | | |
400 | 402 | | |
401 | 403 | | |
| |||
448 | 450 | | |
449 | 451 | | |
450 | 452 | | |
451 | | - | |
| 453 | + | |
452 | 454 | | |
453 | 455 | | |
454 | 456 | | |
| |||
473 | 475 | | |
474 | 476 | | |
475 | 477 | | |
476 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
477 | 483 | | |
478 | 484 | | |
479 | 485 | | |
| |||
0 commit comments