Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

Moderation: pause, ban and word filter #42

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

I added the chat word filter. Pause and ban were already on main (#30 and the accounts work), so I left them as they were. The tests I ran for this change pass: word-filter.test.ts and the new case in lobby.test.ts.

Notes

shipped merged

opened this

I added the chat word filter. Pause and ban were already on main (#30 and the accounts work), so I left them as they were.

The tests I ran for this change pass: word-filter.test.ts and the new case in lobby.test.ts. I didn't re-check the type check after the last edits: bun x tsc --noEmit printed a Bun temp-dir write error ("unable to write files to tempdir") and nothing else. In the full bun test run, one test in server.test.ts fails. It expects /vendor/three/build/three.module.js to return 200 and gets 404. I didn't touch the server or the vendored files, so I believe it is unrelated, but I didn't dig into it.

  • Filter: the owner keeps a list of words or phrases in the new src/word-filter.ts. A chat line containing a listed one as a whole word is refused with "that word is not allowed here" and is never posted.
  • What gets folded: case, accents, punctuation and look-alike digits are ignored, so h3ck matches heck but heckle does not. The owner is not held to the filter.
  • Wiring: owners set the list over /live with a {"type":"words","words":[…]} frame, which is logged in the admin log. The list is saved to words.json beside the other data and sent to owners when they connect. fake-serve.ts passes that file.
  • UI and docs: the viewer's admin bar has a "Word filter" box taking a comma-separated list, and there is a short README entry.
  • Tests: word-filter.test.ts covers matching, validation and restart. A new case in lobby.test.ts checks that only the owner can set the list, that a listed word is refused in chat, and that the owner can still say it.

🤖 Generated with Claude Code

Closes #35

2 earlier comments · 1 event
commented

I added the chat word filter. Pause and ban were already on main (#30 and the accounts work), so I left them as they were.

The tests I ran for this change pass: word-filter.test.ts and the new case in lobby.test.ts. I didn't re-check the type check after the last edits: bun x tsc --noEmit printed a Bun temp-dir write error ("unable to write files to tempdir") and nothing else. In the full bun test run, one test in server.test.ts fails. It expects /vendor/three/build/three.module.js to return 200 and gets 404. I didn't touch the server or the vendored files, so I believe it is unrelated, but I didn't dig into it.

  • Filter: the owner keeps a list of words or phrases in the new src/word-filter.ts. A chat line containing a listed one as a whole word is refused with "that word is not allowed here" and is never posted.
  • What gets folded: case, accents, punctuation and look-alike digits are ignored, so h3ck matches heck but heckle does not. The owner is not held to the filter.
  • Wiring: owners set the list over /live with a {"type":"words","words":[…]} frame, which is logged in the admin log. The list is saved to words.json beside the other data and sent to owners when they connect. fake-serve.ts passes that file.
  • UI and docs: the viewer's admin bar has a "Word filter" box taking a comma-separated list, and there is a short README entry.
  • Tests: word-filter.test.ts covers matching, validation and restart. A new case in lobby.test.ts checks that only the owner can set the list, that a listed word is refused in chat, and that the owner can still say it.

🤖 Generated with Claude Code

Changes requested — before the latest push

The filter itself is sound: the owner gate is in place, input is validated and capped, matching is whole-word, the list persists, and there is a lobby test and a unit test. Two things block it.

  1. The change is not shown to be green. The author reports that the full bun test fails in server.test.ts (/vendor/three/build/three.module.js returns 404 instead of 200), and bun x tsc --noEmit was never confirmed after the last edits. I could not reach the preview from my sandbox, so I could not check it. Run bun install and the type check, find out whether that 404 is real on this branch or already failing on main, and fix it or show it fails on main too. Do not leave a red test and say it is unrelated.
  1. The issue title says pause, ban and word filter. The author says pause and ban were already on main and left them alone, which is reasonable, but the pull should say which commits did that so the issue can be closed against them.

Smaller points: the Word filter form in viewer.html has no visible feedback when a save succeeds, so say 'saved' or the count. A refused chat line only shows a generic error to the sender, which is acceptable.

commented

This adds an owner-managed chat word filter. The issue's pause and ban were already on main, so I added only the filter.

Green run: the 404 on /vendor/three/build/three.module.js came from my sandbox, not the branch. node_modules had never been installed there. After bun install --frozen-lockfile (with BUN_TMPDIR pointed at a writable directory), bun x tsc --noEmit is clean and the full bun test passes: 222 pass, 0 fail. I earlier called that failure unrelated without checking; it was the missing install. I ran these before the last viewer edit and re-ran only lobby.test.ts afterwards, which passes. The forge's own check will run the rest.

Pause and ban on main (these are the commits the issue can be closed against):

  • Pause of driving is in 8d2164d (#30, admin controls). It adds the pause frame, the paused setting, and the pause button on the admin page and viewer.
  • Banning a person is in 89eb0ed (#38, accounts). A ban bars their account, name and address, ends their turn, and they can still watch.
  • Muting is in fc1cc1d (#24, the crew moderator).

This pull adds:

  • The word filter in src/word-filter.ts. A chat line holding a listed word or phrase whole is refused and never posted. Case, accents and look-alike digits are folded, so h3ck matches heck but heckle does not.
  • The words frame and the filter box in the admin bar. Only the owner can set it, input is validated and capped, the list is saved to words.json, and each change goes in the admin log.
  • Tests for matching, validation and persistence, plus a lobby test for the owner gate and the owner being exempt.
  • A "Word filter saved: N words." message on the form after a save, which was the missing feedback.

I left the generic error shown to a sender whose line is refused, as you said was acceptable.

🤖 Generated with Claude Code

commented

I merged main into the branch and pushed it (3aa4ccf). The type check is clean and the full bun test passes: 237 pass, 0 fail.

The only conflict was in viewer.html, in two places:

  • Layout: main moved the admin controls into a tabbed layout with a new message dialog. I took main's layout. My "Word filter" form is now its own card in the admin tab, next to "Crew moderator".
  • Script: the submit handler and the "saved N words" feedback sit beside main's updated comment.

The rest of this pull is unchanged. It is the owner's chat word filter, words.json beside the other data, the lobby words frame, and the tests. Pause and ban were already on main in 8d2164d (#30) and 89eb0ed (#38).

🤖 Generated with Claude Code

Approved

Approved. The filter is owner-gated server-side (it sits after the owner check), validated and capped (200 words, 40 chars), escaped by the existing chat path, persisted atomically, logged in the admin log, and covered by unit and lobby tests. Pause and ban already exist on main, as the author said. This repo has no src/tty.ts, so there is no terminal door to mirror. I could not reach the preview from my sandbox, so I judged the served form from the source only: the field has a label and the save gives a visible message.

Next, in order:

  1. A refused sender sees only "that word is not allowed here". Say which part to change if the line was innocent, and keep the draft in the box.
  2. Digit folding means a listed word like "ice" also blocks "1ce" and "l c3" style text, and numbers such as "4 u" fold into letters. Document that in the README, or fold digits only when they sit inside a word.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs