The chat feed stays chronological (newest last) and now scrolls to the
bottom on load and on each new message while the user is already near the
bottom — scrolling up to read history no longer gets yanked back down.
Exchange moves no longer push a message into the game chat. The engine's
state.messages drains into the platform's chat as system messages, and the
per-trade lines were pure noise there — the trade already shows in the event
log. Chat is now reserved for game-over and auction wins. Engine 0.10.10.
## Summary
Render the platform's game chat inside the Outpost viewer. This is the **reference-engine implementation** of the viewer-chat protocol that was added to the platform in **boardgamers/boardgamers#510** (issue **boardgamers/boardgamers#509** — Outpost is the reference engine named there).
The viewer now owns the game chat surface: a `ChatPanel` sits beside the event log and renders the room chat, fed by the `chat:*` downlink events and posting through the `chat:send` / `chat:read` uplinks, per the merged platform contract.
## Protocol conformance (boardgamers/boardgamers#510, incl. the Fuji-author additions)
Downlink (host → viewer), handled in `store.svelte.ts`:
- `chat:messages` — full-history replace (on mount/remount)
- `chat:appended` — append new messages (own accepted posts come back this way; no optimistic echo)
- `chat:updated` — replace in place by `_id`
- `chat:deleted` — drop by `ids: string[]`
- `chat:disabled` — room kill switch, hides the composer
- `chat:state` — write-permission `{ canSend, reason? }`, gates the composer with a human-readable reason
- `chat:result` — **send-ack** `{ requestId, ok, error? }`; refused sends restore the draft and show the error so the user can retry
Uplink (viewer → host), on `ViewerBridge`:
- `chat:send` — `{ text, requestId? }`; every send carries a `requestId` so it is answered by one `chat:result`
- `chat:read` — **read receipt** `{ messageId }`; watermarks the newest shown message (real ObjectIds only) so the platform clears its unread badge while the viewer owns the chat surface
`ViewerChatMessage` supports the additive author identity fields: `authorId`, `playerIndex`, `createdAt` (author colors prefer `playerIndex`, falling back to a name match — never matching identity on the name). `editedAt` renders an "(edited)" marker; `createdAt` renders a short timestamp.
## Files
- `packages/viewer/src/lib/bgs.svelte.ts` — `ViewerChatMessage` (+ `authorId`/`playerIndex`/`createdAt`), `ViewerChatCanSend`, `ViewerChatResult`; the `chat:*` event types; `sendChat` / `readChat` uplinks.
- `packages/viewer/src/lib/store.svelte.ts` — chat state (`chatMessages` / `chatDisabled` / `chatCanSend`), `chat:result` ack handling with draft restore, `chat:read` watermark, `chatAuthorColor`.
- `packages/viewer/src/lib/ChatPanel.svelte` — feed + composer, author colors, write gating, edited/time display, send-error surface.
- `packages/viewer/src/App.svelte` — panel placed above the log in the desktop sidebar and the mobile column.
- `packages/viewer/src/dev-backend.ts`, `packages/viewer/src/dev.ts` — dev harness: seeded history, echo sends as `chat:appended` with identity fields, `chat:result` acks, and `outpostDev.chatAppend` / `chatDisable` / `chatState` console helpers.
## Verification
`pnpm build` (engine + viewer) and `svelte-check` pass with 0 errors; the chat event vocabulary and panel are present in the built `outpost-viewer.iife.js`. The dev harness (`pnpm dev`) seeds a chat history and echoes accepted sends, so the panel can be exercised locally end-to-end against the mock backend.
Closes the engine-viewer half of boardgamers/boardgamers#509.
Co-authored-by: Coyote508 (bgs-ci) <coyotte508@users.noreply.codeberg.org>
Reviewed-on: https://codeberg.org/boardgamers/outpost/pulls/1