Skip to content

Chat tab: read a Season 3 server's in-game chat - #58

Closed
jbob06 wants to merge 1 commit into
warcon-app:mainfrom
jbob06:chat-log
Closed

jbob06 wants to merge 1 commit into
warcon-app:mainfrom
jbob06:chat-log

Conversation

@jbob06

@jbob06 jbob06 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

The problem

Season 3 (build CL-533689, live 2026-11-12) serves what players say in chat over the RCON API, and Warcon has no way to show it. Staff moderating a server still have to be in the game to see who said what.

The game gates it behind Bulkhead's terms, which an operator has to accept once per server before GET /v1/chat returns anything. Read on our live server today:

  • GET /v1/chat answers { latestSeq, messages: [{ seq, sentUtc, channel, faction, steamId, realName, hiddenName, anonymous, text, rawText, ping }], count }. channel was Team or Global; hiddenName is the anonymised name other players see.
  • ?after=N answers only the lines above N (after=5 gave 6 and 7). ?limit=n answers the oldest n. since, afterSeq, sinceSeq and fromSeq are ignored.
  • The lines are in the server's memory for the current map only: a map load empties them and seq starts again at 1.
  • GET /v1/chat/terms answers { requiredVersion: 1, acceptedVersion: 0, accepted: false, text }. POST /v1/chat/terms with { "version": 1 } answered { ok: true, pending: false, message: "OK: chat terms accepted and saved." }. Until then /v1/chat is empty and GET /v1/feed reports pausedForTerms: true. The accepted version is kept as AcceptedChatTermsVersion in the RCON block (next-restart).

The change

  • Three actions in actions.ts, run through /api/servers/:id/rcon/:action like the rest:
    • chat (Chat): GET /v1/chat?after=N, after clamped to a whole number from 0. Keeps the known fields of each line (not ping, whose meaning was not seen) and refuses an answer without a messages list as bad_response, as players does, rather than reading it as an empty map.
    • chatTerms (Chat): the terms, with accepted true only when the game says true.
    • chatTermsAccept (Config & settings, audited): posts { version }, refuses without one, and treats a 200 that says ok: false as a refusal (terms_refused), since the game answers other refusals that way.
  • A Chat tab on the server (server/[id]/chat/+page.svelte), shown to those with Chat. It lists the current map's lines, newest last: time, channel, faction (the FactionChip colours from the scoreboard), the real name linking to the dossier, and the hidden name beside it. A filter by player or text and one by channel. It reads every 5 seconds while open, with the same poll as the Server log tab. When text and rawText differ, the line's tooltip shows what was typed.
  • Map changes. The tab asks with after set to one below the last line it holds, so the answer starts with that line again. mergeChat ($lib/chat.ts) adds the new lines when it does, and when latestSeq went down or that line is not where it was, the tab reads from 0. Checking the line and not only the number also catches a new map that passed the old one's count while the tab was hidden (poll pauses in hidden tabs).
  • Terms. Until they are accepted the tab shows Bulkhead's text. Those with Config & settings get an Accept button; everyone else is told that someone who may change the server's config has to accept them. A build without the routes shows that chat came with Season 3.
  • No storage. Nothing is written to the database. Reads are not audited unless AUDIT_LOG_READS is on, and then the row carries no chat. The terms forbid storing chat beyond what moderation needs, and live-only matches what Bulkhead itself provides.
  • Demo server. mockgame.ts serves the three routes: a line every 8 seconds of the clock (picked without Math.random, so the demo's other draws are unchanged), emptied and renumbered at each map change, nothing until the terms are accepted. MOCK_LIVE_BUILD=true leaves the routes out, like the builds it imitates.
  • Docs. docs/wardogs-api.md gets the three routes in the table and a Season 3 section with the shapes, after and limit, the reset at a map load, pausedForTerms and AcceptedChatTermsVersion. The README gets a short "In-game chat" section, the Chat row of the capability table, and the actions in the Game actions table and the by-capability list.

Things worth your view

  • Which capability reads chat. I reused Chat (chat.send) rather than adding one. It already belongs to the people who talk to players in game (operator and admin by default), and reading what players say back is the other half of that job. A new capability is not trivial here: roles and API keys store their capability lists, so a new one would need a migration in the style of 0036 to give it to existing operator and admin roles, or chat would appear for nobody on upgrade. The cost of reusing it: a role cannot whisper without also reading chat, and an API key with Chat can now read chat too. If you would rather have a separate "Read chat" capability, I can add it with that migration. View alone never reads chat, since it is players' words under their real names.
  • Accepting needs Config & settings. The game saves the acceptance in the server's config, and accepting commits the operator to Bulkhead's terms, so it sits with the other config writes. The terms read needs Chat, so a custom role with Config & settings but not Chat does not see the tab; the built-in admin has both.
  • Terms are read until accepted, then not again. If Bulkhead raises requiredVersion while the tab is open, the chat goes empty and the tab only shows the new terms on the next visit. Re-reading them on every look would double the requests.
  • Request budget. An open tab costs 12 game reads a minute, out of the 120 a person may send and the game's 600 per address. A map change costs one extra read.
  • Storage as a follow-up. Keeping chat (for a ban review after the map has changed, say) would need its own retention and erasure rules, and a reading of the terms on "beyond what moderating this server requires". Left out of this PR on purpose.
  • Not used: limit (it answers the oldest lines, not the newest), the anonymous and ping flags (never seen true), and pausedForTerms from the feed report (the terms route says the same thing directly).

Tests

  • actions.test.ts: chat sends after, defaults and clamps it, keeps the known fields and fills missing ones, and refuses an answer that is not chat; chatTerms counts only accepted: true; chatTermsAccept posts the version, refuses without one before asking the game, and treats ok: false as a refusal; the capabilities are Chat, Chat and Config & settings, and the built-in viewer does not hold Chat; against the demo server, chat stays empty until the terms are accepted, and under MOCK_LIVE_BUILD it answers no_route.
  • chat.test.ts: chatAfter and mergeChat: nothing held, new lines added after the anchor, nothing new, latestSeq going down, a new map that passed the old count, and the anchor missing.
  • action-matrix.test.ts has lines for the three actions, so the permission matrix checks them for every member of the cast.

Checks

Run on Windows with Bun 1.4.2, on this branch and on untouched upstream/main (867bd15) the same way:

  • prettier --check .: clean on both.
  • bun run check: 0 errors, 0 warnings on both (2170 files here, 2167 on main).
  • bun test without TEST_DATABASE_URL (no Postgres or Docker on this machine): main 1032 pass, 967 skip, 23 fail across 186 files; this branch 1048 pass, 970 skip, 23 fail across 187 files. The 16 new passing tests are the ones above; the 3 new skips are the permission matrix lines, which need the database. The 23 failures are the same tests on both, by name: page-loads.test.ts, the route and load matrix coverage checks and the console check find or name source files by /-separated paths, which Windows writes with \.
  • The database suites, including the permission matrix for the new actions, were not run. CI on this PR will be the first run of them.
  • Verified against a live Season 3 server at the API level only (the shapes and behaviour above). The Chat tab was not exercised against a live server or in a browser.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DtMArSWCQVUG3qWgzi2Ebi

Season 3 (CL-533689) serves the current map's chat over RCON: GET /v1/chat
with ?after=<seq>, and Bulkhead's terms at GET/POST /v1/chat/terms. Three
actions read and accept them: chat and chatTerms need Chat (never View
alone, since chat is players' words under their real names), and
chatTermsAccept needs Config & settings, as the game saves the acceptance
in its config.

The server's new Chat tab polls with after, newest last, and reads the map
again from the start when the numbering goes back. Until the terms are
accepted it shows them, with Accept for those who may apply the config.
Nothing is stored. The demo server serves the three routes, and
MOCK_LIVE_BUILD leaves them out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DtMArSWCQVUG3qWgzi2Ebi
@jbob06

jbob06 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by the In-game chat work merged on main (f02dee3, 62bd4d2), which covers everything here and settles the open question the stricter way, with a separate Read chat capability that API keys never hold. Closing this one. Thanks for building it.

@jbob06 jbob06 closed this Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant