### Implementation Plan **Objective:** Fix the chat rendering bug by addressing the three confirmed code issues (missing error handling, dead optimistic rendering, and no rendering tests) and mitigating the dual‑renderer divergence with a server‑side test guarantee. **Steps:** 1. **Add error handling to `renderBody` promise chain** - File: `MessagesLayout.js` (lines 339–347) - Change: Append `.catch(console.error)` to the `.then()` chain so that a single rendering failure does not silently suppress subsequent bubbles. 2. **Re‑enable optimistic rendering** - File: `MessagesLayout.js` (lines 214–227, the `appendOptimistic` block) - Change: Uncomment the body; ensure that when a WebSocket message arrives with a `uid` matching an existing optimistic bubble, the optimistic bubble is replaced (not appended). The deduplication logic at lines 229–234 already prevents duplicates from the server echo, so this fixes the double‑message problem. 3. **Add server‑renderer unit tests for parity** - File: `tests/test_rendering.py` (new or extend existing) - Change: Write 5+ test cases that call `rendering.render_content()` with edge‑case inputs: - URL inside a fenced code block (should not be embedded). - `@mention` in an email context (`email@domain.com` – should not be a mention). - Nested formatting (bold inside inline code). - Multiple line breaks (hard wrap vs soft break differences). - A complex table with inline links. - Assert that the output HTML matches expected strings (exact or structural match). This ensures the server path is correct and provides a baseline for future client‑side parity checks. 4. **Verify no new lint or test regressions** - Run both verification commands; fix any failures. **Definition of Done:** - [ ] `pip install -e '.[dev]' -q && make test-unit` exits with code 0. - [ ] `pip install -q ruff && ruff check .` exits with code 0 (no new warnings or errors). - [ ] The new `test_rendering.py` contains at least 5 passing tests covering the edge cases listed in Step 3. - [ ] Code review confirms `MessagesLayout.js` has `.catch(console.error)` on every `renderBody` promise chain. - [ ] Code review confirms `appendOptimistic` block is uncommented and correctly replaces optimistic bubbles by `uid` (dead code removed).