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
The project now lives at codeberg.org/boardgamers/outpost. The GitHub
Actions workflow is replaced by an equivalent Forgejo Actions workflow
(.forgejo/workflows/ci.yml): docker runner on a pinned node:24-bookworm
image, pnpm via corepack, checkout from data.forgejo.org — the same shape as
boardgamers-mono. AGENTS.md points at the new remote.
Rather than a waiting-banner note, the card you received in an exchange now
appears in your hand as a face-down (unknown-value) card with a dashed gold
border and a title explaining it is parked on the Wily Trader / Merchant
House until the exchange step ends. The wrapper masks the parked card's
value from everyone — owner included — while the step runs, so it genuinely
is unknown; it resolves to a real card when the step closes. The banner note
is gone. Engine 0.10.9.
The received card is parked face-down on the Wily Trader / Merchant House
for the rest of the discard phase's exchange step (phase 4), so its value is
nobody's business until then. While the step runs, the exchange log entry
shows the offered card but masks the received value as "for a higher one"
for every viewer — participants included; once the step closes (and the card
lands in the giver's hand) the participants see it, others only at game end.
Added a waiting banner note so a trader sees their card is parked, not lost.
Engine 0.10.8.
Factory buys take a count, the same way population and robots do: one
payment covers count x cost, the cards are spent once, and the overpay is
lost. A lone Mega Titanium 44 buys 4 ore factories (cost 40) in a single
step; New Chemicals needs one research card per factory. The log reads
"builds 4 ore factories (paid 44)". Replaces the earlier one-step-per-copy
splitting, which was wrong — a card can only be spent once. Engine 0.10.7.
A card pays for a single factory (its overpay is lost, not spread), so
floor(handValue / cost) was the wrong cap: a lone Mega Titanium 44 showed
4 ore factories as reachable when it only pays for one. The stepper now caps
at the number of groups the cards partition into, each reaching the cost
(descending-value greedy, matching the confirm split).
The factory payment panel now has the − / +1 stepper colonists and robots
always had, so a big card (e.g. a Mega) can pay for several factories at
once instead of wasting the overpay one factory at a time. The purchase is
split into one engine buy step per copy — the engine's endTurn already
applies repeated factory steps — with the picked cards dealt highest-value
first so each step clears the cost, and indices re-resolved per step against
the shrinking hand. New Chemicals stays one research card per factory.
Viewer-only change.
The era announcement read off entry.era, which is set on every round entry —
so "Era II begins" printed on every round of era II. The round entry now
carries eraBegan only on the round the era actually advances, and the log
text uses that. The feed renders it as a full-width era-colored band (bold,
era II orange / era III purple) instead of a subtle ruled line. Engine 0.10.6.
The exchange move now records the offered card (exchangeGiven: type + value)
alongside the returned card's value. The offered card's value needs no
masking once offered — it never re-enters the giver's hand (it goes to the
target, or bounces back from the parked cards at the same value). Both
values are still hidden from non-participants until the game ends, then
revealed to everyone. The log line reads "P1 trades Ore 5 with P2 for Ore 9"
for the two participants (and post-game), "P1 trades a card with P2 for a
higher one" for the rest. Engine 0.10.5.
The era transition was invisible in the log (only the market contents hinted
at it). The round entry's text now opens with "Era II begins — " / "Era III
begins — " on the round the era advances (era I is the opening era, so no
announcement), and the log feed renders it as a ruled delimiter above the
round line instead of plain text. The era is public and unmasked on the round
entry, so spectators and replays get the same delimiter. Engine 0.10.4.
productionRange ignored the Smelter kicker — it now adds the extra
floor(manned ore / 2) ore draws to min/max/avg. The other production kickers
(Ice Prospector / Refinery) draw-then-discard-cheapest: same card count, so
the range is unchanged by design.
PlayerPanel: while staging the operator assignment, your own panel shows the
production the STAGED factories would give — the min–max (~avg) line updates
with every toggle instead of only after the turn commits. Engine 0.10.3.
While a sealed auction collects bids, its log entries (and the game-server's
last-move summary built from them) leaked information: the opening line
showed the auctioneer their own amount, and auto-passes printed as "X passes
on the auction" the moment they happened. Now opening/bid/pass entries all
read as a neutral sealed-auction line until the resolving move is logged;
the wrapper's reveal then restores full text (amounts, passes, outcome). A
pass that resolves the auction now carries the "wins at N" outcome line too.
Engine 0.10.2.
The setting now lives entirely in fastAutoPass: a seat whose true hand value
cannot reach the list price is auto-passed (bid 0) the moment the auction
opens, recorded in info.autoPassed and applied verbatim on replay. The viewer
no longer sends anything for it — the previous client-side auto-pass raced
the host's state pushes and produced spurious "not your turn to play"
rejections. Timing may reveal that an auto-passed seat held a weak hand;
accepted (indistinguishable in the log from a public-bound or manual pass).
Engine 0.10.1.