# Dispatch for worker_chat_m2_2

## 2026-10-01T02:19:05Z

You are worker_chat_m2_2 (replacement for worker_chat_m2_1 which encountered RESOURCE_EXHAUSTED).
Your working directory is: c:\Projects\FreeExile\.agents\teamwork\worker_chat_m2_2

## Mandatory Inputs to Read First
1. `c:\Projects\FreeExile\.agents\teamwork\ORIGINAL_REQUEST.md` (specifically section `## 2026-10-01T00:42:05Z`)
2. `c:\Projects\FreeExile\.agents\teamwork\orchestrator_5\plan.md`
3. `c:\Projects\FreeExile\.agents\teamwork\explorer_chat_client_bench_1\handoff.md`
4. `TEST_READY.md` at project root
5. `c:\Projects\FreeExile\.agents\teamwork\worker_chat_m2_1\progress.md`

## MANDATORY INTEGRITY WARNING
DO NOT CHEAT. All implementations must be genuine. DO NOT hardcode test results, create dummy/facade implementations, or circumvent the intended task. A teamwork_preview_auditor will independently verify your work. Integrity violations WILL be detected and your work WILL be rejected.

## File Ownership
You own EXCLUSIVELY:
- `client/src/chat/ChatManager.ts`
- `client/webapp/js/ui/chat_ui.js`
- `client/webapp/index.html`
- `client/webapp/js/main.js`
- `tests/unit/test_webapp_chat_ui.py`

Do NOT touch any files in `server/chat/` or `tools/stress/`.

## Mission: Milestone M2 — Client Chat Engine & WebApp UI Integration
1. In `client/src/chat/ChatManager.ts`:
   - Extend `ClientItemSnapshot` to include `itemLevel: number`, `createdAtMs: number`, and `affixes: Array<{affixId: string, statName: string, statValue: number, isImplicit: boolean}>` matching `proto/chat.proto`.
   - Update `formatItemTag` and `onTappedItemLink` to handle complete snapshot fields.
   - Run `cd client; npm run build` to verify clean TypeScript compilation (`tsc` exits 0).
2. Create `client/webapp/js/ui/chat_ui.js`:
   - Implement Native ES Module adhering strictly to soft cap <= 350 lines.
   - Implement multi-channel tabs: `Thế Giới` (1), `Khu Vực` (2), `Bang Hội` (3), `Đội Ngũ` (4), `Mật Thư` (5), `Hệ Thống` (6), `Chiêu Mộ` (7), `Góp Ý` (8).
   - Maintain 100-message FIFO ring buffer per channel (`MAX_RING_BUFFER = 100`).
   - Implement auto-scroll locking (locks when scrolled up, auto-scrolls when at bottom).
   - Implement client-side anti-spam cooldown display (disables send button, shows remaining seconds).
   - Parse rich item tags `[item:{uuid}:{sig}:{name}:{rarity}]` and bind click handlers to open `#modal-item-link-tooltip`.
3. In `client/webapp/index.html` & `client/webapp/js/main.js`:
   - Mount chat dock and `#modal-item-link-tooltip` in `client/webapp/index.html`.
   - Style `#modal-item-link-tooltip` with 2.5D Cổ Võ styling: item icon, name, rarity border, quality, ilvl, crafter name, affixes, and the green `[✓ HMAC Xác Thực]` badge.
   - Wire initialization in `main.js`: ensure pressing `Enter` focuses chat input / sends chat, and `Escape` closes chat or tooltip, without breaking existing game movement or interactions.
4. Unit Tests:
   - Create `tests/unit/test_webapp_chat_ui.py` testing DOM elements, channel keys, ring buffer logic, item tag parsing, and localization.
   - Run `python -m unittest tests/unit/test_webapp_chat_ui.py`.
5. Code Hygiene:
   - Run `python tools/lint/check_code_and_doc_hygiene.py --strict` to verify 0 hard cap violations.

Deliver your report in `c:\Projects\FreeExile\.agents\teamwork\worker_chat_m2_2\handoff.md`.
