# Project Memory - Issues & Resolutions

## Last Updated: 2026-05-29

---

## Resolved Issues

### 1. Livewire MultipleRootElementsDetectedException
- **Date**: 2026-05-29
- **Symptom**: Livewire error when blade template had multiple root elements
- **Root Cause**: `chat-workspace.blade.php` had multiple root HTML elements
- **Fix**: Wrapped entire blade in single `<div>` root element
- **File**: `resources/views/filament/pages/chat-workspace.blade.php`

### 2. Duplicate customer conversations
- **Date**: 2026-05-29
- **Symptom**: New conversation created for every incoming message from same contact
- **Root Cause**: `ProcessIncomingMessageJob` only searched for open conversations
- **Fix**: Search for ANY existing conversation by contact_id; reopen if closed
- **File**: `app/Jobs/ProcessIncomingMessageJob.php`

### 3. CSS massive duplication in chat-workspace.css
- **Date**: 2026-05-29
- **Symptom**: File grew from ~1200 to 1517 lines with 4 duplicate textarea style blocks
- **Root Cause**: Repeated edit tool calls created duplicate CSS blocks instead of replacing existing ones
- **Fix**: Manually identified and removed all 4 duplicate blocks; file reduced to 1239 lines
- **File**: `public/css/chat-workspace.css`
- **Lesson**: Always verify edit results before making additional edits; use larger context strings for unique matches

### 4. Missing Firefox scrollbar support for textarea
- **Date**: 2026-05-29
- **Symptom**: `scrollbar-width: thin` and `scrollbar-color` properties missing after CSS cleanup
- **Root Cause**: Properties only existed in duplicate blocks that were removed
- **Fix**: Re-added Firefox-specific scrollbar properties to main textarea block
- **File**: `public/css/chat-workspace.css`

### 5. Sidebar navigation routing broken
- **Date**: 2026-05-29
- **Symptom**: Clicking sidebar items didn't navigate to correct pages
- **Root Cause**: `selectView()` function had incomplete route mapping
- **Fix**: Updated route mapping for all 9 NAV_ITEMS with correct paths
- **File**: `resources/views/filament/pages/chat-workspace.blade.php`

### 6. Role mismatch between frontend and backend
- **Date**: 2026-05-29
- **Symptom**: Permission checks failing; buttons showing incorrectly
- **Root Cause**: Frontend used `manager/support` while backend used `admin/supervisor/agent`
- **Fix**: Updated PERMISSIONS object to use `admin/supervisor/agent` matching Spatie
- **File**: `resources/views/filament/pages/chat-workspace.blade.php`

---

## Open Issues

| # | Issue | Status | Priority |
|---|-------|--------|----------|
| 1 | WHATSAPP_APP_SECRET not configured | Open | High |
| 2 | No auto_replies page | Open | Medium |
| 3 | No reports dashboard | Open | Medium |
| 4 | File upload incomplete | Open | Medium |
| 5 | WebSocket not configured | Open | Medium |
