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

Migrated from github.com/Trevato/SO-ARM100

Slow mode refuses a second chat line within slowModeSeconds with 'slow mode: wait Ns'; the owner and moderators are exempt - lobby and test only #408

Merged opened this

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

Merged

Slow mode is now enforced in the lobby's post case: a second line inside slowModeSeconds is refused with slow mode: wait Ns (N rounded up), sent to that socket only. The new test and the rest of src/lobby.test.ts pass (46 pass, 0 fail).

Notes

shipped merged

opened this

Slow mode is now enforced in the lobby's post case: a second line inside slowModeSeconds is refused with slow mode: wait Ns (N rounded up), sent to that socket only. The new test and the rest of src/lobby.test.ts pass (46 pass, 0 fail). I could not run bun x tsc --noEmit: bun fails with unable to write files to tempdir: ReadOnlyFileSystem in this sandbox, so the type check is unconfirmed here and left to the forge's check.

  • Timer: each person's last accepted line is tracked by id, using the lobby's now clock. A refused line does not reset the timer, and 0 turns slow mode off.
  • Exemption: the owner and verified moderators are never held. A guest who types a moderator's name is still held.
  • Test: the new test uses an injected clock and slow mode set to 5.

- A second line at 4 s is refused with slow mode: wait 1s. - A line at 5 s is accepted. - The moderator and the owner post 3 s apart, under the 5 s limit, and are never held. - After setting slow mode to 0, alice posts freely.

  • Test spacing: the test spaces the exempt and slow-mode-off posts 3 s apart because Chat already has its own 2 s rate limit, which would otherwise refuse them.
  • Scope: only lobby.ts and lobby.test.ts changed.

Closes #381

commented

Slow mode is now enforced in the lobby's post case: a second line inside slowModeSeconds is refused with slow mode: wait Ns (N rounded up), sent to that socket only. The new test and the rest of src/lobby.test.ts pass (46 pass, 0 fail). I could not run bun x tsc --noEmit: bun fails with unable to write files to tempdir: ReadOnlyFileSystem in this sandbox, so the type check is unconfirmed here and left to the forge's check.

  • Timer: each person's last accepted line is tracked by id, using the lobby's now clock. A refused line does not reset the timer, and 0 turns slow mode off.
  • Exemption: the owner and verified moderators are never held. A guest who types a moderator's name is still held.
  • Test: the new test uses an injected clock and slow mode set to 5.

- A second line at 4 s is refused with slow mode: wait 1s. - A line at 5 s is accepted. - The moderator and the owner post 3 s apart, under the 5 s limit, and are never held. - After setting slow mode to 0, alice posts freely.

  • Test spacing: the test spaces the exempt and slow-mode-off posts 3 s apart because Chat already has its own 2 s rate limit, which would otherwise refuse them.
  • Scope: only lobby.ts and lobby.test.ts changed.
Approved

Slow mode is enforced in the lobby post path, which the page and terminal both use. The owner and verified moderators are exempt, a refused line does not reset the timer, and 0 turns it off. The injected-clock test covers each of those and would fail without the change. The change is small and in scope. I read the diff and code only; I did not open the preview or the screenshots, and the type check was not run here. Two things to do next: (1) lastPosted never drops entries, so delete a person's entry on disconnect or prune old ones. (2) Add a test that the refusal reaches only the sender, which the bob.heard check mostly covers, and show the wait time in the chat input so people see it instead of a bare error.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs