Commit 2959246
authored
π€ Fix: Display workspace removal errors and auto-focus chat input (#160)
## Issues Fixed
### 1. Workspace removal errors not visible β β β
**Problem**: When workspace removal fails (e.g., due to uncommitted
changes), error was logged to console but not shown in UI.
**Root Cause**: `ProjectsList` has `overflow-y: auto` which clips
absolutely positioned children. The error container was positioned
absolutely below the workspace item, but the scroll container cut it
off.
**Example error that was hidden:**
```
Failed to remove workspace: fatal: '/path/to/workspace' contains modified or untracked files, use --force to delete it
```
**Solution**:
- Use React Portal (`createPortal()`) to render error outside the
scrolling container
- New `RemoveErrorToast` component with fixed positioning at bottom
center of viewport
- Toast automatically dismisses after 5 seconds
- High z-index (10000) ensures visibility over all other content
**Visual:**
- Fixed position at bottom center of screen
- Red background with border matching error color scheme
- Monospace font for technical error messages
- Word-wrapping for long git error messages
### 2. Chat input not auto-focusing on new workspace π β β
**Problem**: When creating a new workspace, the chat input didn't
auto-focus, requiring user to manually click before typing.
**Why it worked for workspace switching**: When using command palette to
switch workspaces, focus already in document from typing in palette, so
worked by coincidence.
**Solution**:
- Add `useEffect` that focuses input whenever `workspaceId` changes
- Small 100ms delay ensures:
- DOM is fully rendered
- Other components have settled
- React lifecycle is complete
- Uses existing `focusMessageInput()` helper which:
- Checks if element is disabled before focusing
- Positions cursor at end of text
- Auto-resizes textarea
## Testing
### Manual Testing Checklist:
**Workspace Removal Errors:**
- [ ] Try to remove workspace with uncommitted changes β error toast
appears
- [ ] Error toast is visible (not clipped by scroll container)
- [ ] Error auto-dismisses after 5 seconds
- [ ] Error message shows full git error text
- [ ] Can remove clean workspace successfully (no error)
**Chat Input Focus:**
- [ ] Create new workspace β chat input auto-focuses
- [ ] Switch workspace via command palette β chat input auto-focuses
- [ ] Switch workspace via sidebar click β chat input auto-focuses
- [ ] Type immediately after workspace change (no manual click needed)
### Static Checks:
- β
TypeScript compilation
- β
ESLint
- β
Formatting
## Technical Details
**New Components:**
```typescript
const RemoveErrorToast = styled.div`
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
max-width: 600px;
z-index: 10000;
// ... error styling
`;
```
**Portal Rendering:**
```typescript
{removeError && createPortal(
<RemoveErrorToast>
Failed to remove workspace: {removeError.error}
</RemoveErrorToast>,
document.body
)}
```
**Auto-Focus:**
```typescript
useEffect(() => {
const timer = setTimeout(() => {
focusMessageInput();
}, 100);
return () => clearTimeout(timer);
}, [workspaceId, focusMessageInput]);
```
## Impact
- **Better UX**: Users now see clear error messages when operations fail
- **Less confusion**: No more silent failures that appear successful
- **Faster workflow**: No manual clicking needed to start typing in new
workspaces
- **Better error messages**: Full git error text visible (including
suggestions like "use --force")
_Generated with `cmux`_1 parent 24d3a68 commit 2959246
2 files changed
+50
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
455 | 464 | | |
456 | 465 | | |
457 | 466 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
343 | 344 | | |
344 | 345 | | |
345 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
346 | 367 | | |
347 | 368 | | |
348 | 369 | | |
| |||
409 | 430 | | |
410 | 431 | | |
411 | 432 | | |
412 | | - | |
413 | | - | |
414 | | - | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
415 | 438 | | |
416 | 439 | | |
417 | 440 | | |
| |||
485 | 508 | | |
486 | 509 | | |
487 | 510 | | |
488 | | - | |
| 511 | + | |
489 | 512 | | |
490 | 513 | | |
| 514 | + | |
| 515 | + | |
491 | 516 | | |
492 | 517 | | |
493 | 518 | | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
494 | 523 | | |
495 | 524 | | |
496 | 525 | | |
| |||
679 | 708 | | |
680 | 709 | | |
681 | 710 | | |
682 | | - | |
| 711 | + | |
683 | 712 | | |
684 | 713 | | |
685 | 714 | | |
| |||
729 | 758 | | |
730 | 759 | | |
731 | 760 | | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | 761 | | |
738 | 762 | | |
739 | 763 | | |
| |||
763 | 787 | | |
764 | 788 | | |
765 | 789 | | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
766 | 797 | | |
767 | 798 | | |
768 | 799 | | |
| |||
0 commit comments