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

Migrated from github.com/Trevato/SO-ARM100

A moderator can delete a chat line over /live - the first moderator action, server-checked and logged #240

Merged opened this

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

Merged

A verified moderator can now delete a chat line over /live. The preview deploy has failed twice for a reason outside this change, and I can't fix that from here. Both failures were npm registry 429 (rate-limit) errors while installing @serialport/ and other packages.

Notes

shipped merged

opened this

A verified moderator can now delete a chat line over /live. The preview deploy has failed twice for a reason outside this change, and I can't fix that from here. Both failures were npm registry 429 (rate-limit) errors while installing @serialport/* and other packages. This change touches no dependencies.

I merged current main into the branch and pushed, so the deploy runs again. forge.json was not changed on this branch; the merge only brings in main's own edit to it. I re-ran src/lobby.test.ts after the merge: 30 pass. I could not type-check, because bun x tsc and bun install fail in this sandbox with a read-only temp dir error.

  • Who counts as a moderator: a seat qualifies only if the forge signed its identity and admin.isModerator(name) is true. A guest who picks a moderator's name is refused.
  • Other actions: a plain user, and a moderator's settings or pause, still get "only the owner can do that".
  • Delete path: the owner and moderators now share one deleteLine in src/lobby.ts. It validates the id, deletes the line, and records deleted chat line N in the admin log under the actor. It then broadcasts unsaid and refreshes the owners' admin view. The owner's deletes are now logged too, which they weren't before.
  • Tests, in src/lobby.test.ts:

- A moderator deletes a line, the others receive unsaid, and the log names the moderator. - A plain user is refused. - A moderator's settings and pause are refused. - A guest using a moderator's name is refused.

If the install still hits a 429, the failure is still in the registry or the deploy environment, not this code.

🤖 Generated with Claude Code

Continues #240

6 earlier comments · 1 event
commented

A verified moderator can now delete a chat line over /live. The preview deploy has failed twice for a reason outside this change, and I can't fix that from here. Both failures were npm registry 429 (rate-limit) errors while installing @serialport/* and other packages. This change touches no dependencies.

I merged current main into the branch and pushed, so the deploy runs again. forge.json was not changed on this branch; the merge only brings in main's own edit to it. I re-ran src/lobby.test.ts after the merge: 30 pass. I could not type-check, because bun x tsc and bun install fail in this sandbox with a read-only temp dir error.

  • Who counts as a moderator: a seat qualifies only if the forge signed its identity and admin.isModerator(name) is true. A guest who picks a moderator's name is refused.
  • Other actions: a plain user, and a moderator's settings or pause, still get "only the owner can do that".
  • Delete path: the owner and moderators now share one deleteLine in src/lobby.ts. It validates the id, deletes the line, and records deleted chat line N in the admin log under the actor. It then broadcasts unsaid and refreshes the owners' admin view. The owner's deletes are now logged too, which they weren't before.
  • Tests, in src/lobby.test.ts:

- A moderator deletes a line, the others receive unsaid, and the log names the moderator. - A plain user is refused. - A moderator's settings and pause are refused. - A guest using a moderator's name is refused.

If the install still hits a 429, the failure is still in the registry or the deploy environment, not this code.

🤖 Generated with Claude Code

commented

Issue #225 is done and pushed on smith/225-a-moderator-can-delete-a-chat-line-over. I haven't seen a preview deploy for it yet, and I couldn't type-check here.

The earlier preview failure was the deploy's bun install getting HTTP 429 (rate limited) from the npm registry. My change touches no dependencies. I merged current main into the branch (a619c0a) and pushed, which should start a fresh deploy. I ran src/lobby.test.ts after the merge and all 30 tests pass. One run directly after an earlier rebase had one failure, which I didn't identify. It passed on two reruns, so it may be a flaky test.

I did not run bun x tsc --noEmit, because bun x and bun install fail in this sandbox with a read-only temp dir error. The forge's check will be the first type check. I also ran only lobby.test.ts, not the full suite.

  • Moderator delete: a moderator whose identity the forge has signed can send delete over /live. A guest who picks a moderator's name is refused.
  • Everything else: other owner actions, including a moderator's settings and pause, are still owner-only, and a plain user gets the same "only the owner can do that" error.
  • Logging: each deletion is recorded in the admin log as deleted chat line N under whoever did it, owner or moderator. Owner deletions weren't logged before.
  • Tests: four new cases in src/lobby.test.ts cover a moderator delete, a plain user, settings/pause and a guest with a moderator's name.
  • Diff vs main: only src/lobby.ts and src/lobby.test.ts. forge.json is not touched by this branch.

If the deploy hits the registry limit again, someone will need to re-run it, since pull #239 is closed and a person has to reopen or recreate it.

🤖 Generated with Claude Code

commented

A verified moderator can now delete a chat line over /live, and the deletion is logged with their name. I changed nothing this run. Pull #240 is open on this branch and already up to date with main (b8ef3fd). I re-ran only src/lobby.test.ts after merging main (30 pass), not the full suite. I couldn't type-check here, so the forge's check is the first.

The two earlier preview failures were npm registry 429 (rate-limit) errors during install, not this code. No dependencies changed, so there is nothing to fix on this side. If #240's preview still fails the same way, someone needs to re-run it.

  • Who counts as a moderator: a seat qualifies only if the forge signed its identity and admin.isModerator(name) is true. A guest who picks a moderator's name is refused.
  • Other actions: a plain user, and a moderator's settings or pause, still get "only the owner can do that".
  • Delete path: the owner and moderators share one deleteLine in src/lobby.ts. It validates the id and deletes the line. It records deleted chat line N in the admin log under whoever did it, then broadcasts unsaid and refreshes the owners' admin view. The owner's deletes are now logged too, which they weren't before.
  • Tests, in src/lobby.test.ts:

- A moderator deletes a line, the others receive unsaid, and the log names the moderator. - A plain user is refused. - A moderator's settings and pause are refused. - A guest using a moderator's name is refused.

  • forge.json is not touched by this branch.

🤖 Generated with Claude Code

Changes requested — before the latest push

The server rule is right: delete needs a forge-verified identity plus isModerator, guests and plain users are refused, and settings and pause stay owner-only. But a moderator cannot use it from either door, and nothing in the change shows how.

Fix first: the page only offers delete to the owner. src/ui/lobby-panel.js:35 defines isOwner() as hello.you.owner, and viewer.html uses it to gate the Mod tab (line 595) and the long-press delete dialog. A moderator never sees a Delete control, so only a hand-written websocket frame reaches the new server path. Let the hello tell the client the seat may moderate, for example you.moderator = seat.verified && admin.isModerator(name). Then show the chat-line delete dialog on that flag, and leave mute, ban and the rest owner-only.

Also required:

  • Terminal: src/tty.ts has no chat-delete path at all. Add one, gated by the same verified-moderator-or-owner rule, so a delete there reaches web viewers as unsaid.
  • README: say that moderators can delete chat lines, and how, in the page and in the terminal.
  • Tests: the pause assertion in lobby.test.ts uses a convoluted predicate (m !== bob.heard.find(...)). Make it simple and clear. Add a test that the owner's delete is logged, since that behaviour is new. Add a test for a non-integer id.

Small points: the 'verified' computation in upgrade() is correct. A failed deleteLine id check relies on the throw being caught as ChatError at line 275, which is fine.

I did not check the preview deploy. It was reported failing on registry 429s, and the missing UI means it would show nothing for a moderator anyway.

commented

Moderators can now delete chat lines from the page and from the terminal, as well as over /live. Tests pass for src/lobby.test.ts and src/terminal.test.ts (50), but I did not run the type check or the page code in a browser. The preview deploy for this push is still unseen. The earlier failure was an npm registry 429 during install.

  • Hello flag: the hello frame now carries moderator. It is true only for a forge-verified, non-owner seat named in admin.isModerator. I put it at the top level of hello, not under you.moderator as you suggested, so the existing you equality checks keep working. If you'd rather have you.moderator, it's a one-line move plus the two readers. When the owner changes the moderators list, connected non-owners get a fresh hello.
  • Page: src/ui/lobby-panel.js has a canDelete() (owner or hello.moderator) that gates the line focus, long-press, right-click, Enter and the dialog. Mute and Ban are hidden for moderators and mute/ban frames stay owner-only on the server. The Mod tab is still owner-only.
  • Terminal: src/terminal.ts adds /delete <name> for that person's latest line and /delete #12 for a specific line. The owner and moderators see #id before each chat line, and the hello line says (moderator). The server decides who may delete, so a plain user's /delete comes back as "only the owner can do that". The deleted line then reaches web viewers as unsaid, and it is covered in src/terminal.test.ts.
  • README: a paragraph under the owner's bullet says how a moderator deletes, in the page and in the terminal.
  • Tests: the pause assertion now clears bob.heard and waits for the next error, with no predicate. New tests:

- the owner's delete is logged under the owner; - ids "3", 1.5 and null are refused with "delete which line?"; - hello.moderator is true for the moderator and false for a plain user.

While I worked, the working tree was reset under me by something that wasn't my session, so I redid the changes in one pass and committed at once (aa2d743, f2833a5). I haven't seen the other writer's edits to terminal.ts, terminal.test.ts or the README, so check those files for leftovers.

🤖 Generated with Claude Code

commented

A moderator can now delete a chat line from both the page and the terminal, and the server still checks every delete. I couldn't type-check here (bun x tsc fails in this sandbox), so the forge's check is the first one. src/lobby.test.ts and src/terminal.test.ts pass (the terminal file has 20 tests). I did not look at the preview deploy.

The full bun test run had one failure: "serves the model, its meshes and the vendored libraries…". It fails the same way on the unmodified branch, so this change didn't cause it.

Some of these changes were already on the branch when I got to them. Another writer pushed aa2d743 and f2833a5 while I worked. They cover the page, hello, the terminal /delete and most of the tests. I dropped my overlapping copies and added only what was missing. If those commits weren't yours, it's worth a look.

  • Page:

- hello now carries a top-level moderator flag, true only for a forge-verified seat that isModerator accepts. I kept it top-level rather than the suggested you.moderator. - The chat-line delete dialog opens for the owner or a moderator. Mute and ban show only for the owner, and the Mod tab stays owner-only. - Adding or removing a moderator re-sends hello to connected seats, so the control appears without a reload.

  • Terminal:

- /delete <name> removes that person's latest line, and /delete #12 removes a numbered line. - Owners and moderators see #id before each chat line, and a moderator's login shows (moderator). - The server applies the same verified-moderator-or-owner rule, so web viewers get unsaid.

  • README: documents moderators and /delete, with the page and terminal steps.
  • Tests:

- The pause assertion is now a plain check on the errors bob received. - The owner's delete being logged is a new test. - A non-integer id is refused with "delete which line?". - The new end-to-end terminal test (07c30c3) checks that a moderator's /delete reaches a web viewer as unsaid, is logged under the moderator, and is refused for a plain user.

🤖 Generated with Claude Code

commented

A verified moderator can now delete a chat line over /live, and the page and the terminal both offer it. lobby.test.ts and terminal.test.ts pass (51 tests), but I haven't run the type check or seen the preview deploy. The type check can't run in this sandbox (bun x and bun install fail with a read-only temp dir). The preview deploy failed earlier on npm registry 429 errors, which were not caused by this code.

A full bun test run showed one failure, "the safe zone, the jam watch, and the model routes > serves the model, its meshes and the vendored libraries, and nothing outside them". It also fails with this work stashed, so it is not from this change.

Commits aa2d743, f2833a5 and 07c30c3 appeared on this branch while I was working, and I did not write them. I dropped my own overlapping edits and reviewed what they contain; it covers each review point below.

  • Server: a seat is a moderator only if the forge signed its identity and admin.isModerator(name) is true. A guest who picks a listed name is refused. The hello frame carries moderator as a top-level field, not you.moderator as the review suggested, and it is re-sent when the owner changes the moderator list. Every other owner action, including settings and pause, stays owner-only.
  • Logging: deleteLine in src/lobby.ts serves both the owner and moderators. It records deleted chat line N in the admin log under whoever did it, then broadcasts unsaid. The owner's deletes are now logged too.
  • Page: the chat-line delete dialog (long-press, right-click or Enter) opens for the owner or a moderator. Mute and ban in that dialog, and the Mod tab, stay owner-only.
  • Terminal: /delete <name> removes that person's latest line, and /delete #12 removes that line number. Both go through the same server check. Moderators and the owner see line numbers before each chat line. /delete with no argument prints a usage message, because the other writer implemented it differently from my version. An end-to-end test in terminal.test.ts shows a moderator's terminal delete reaching web viewers as unsaid and being logged under their name.
  • README: Software/README.md now says moderators can delete chat lines, and how, in the page and in the terminal.
  • Tests: the pause assertion is now a plain check. New tests cover the owner's delete being logged and a non-integer id being refused. The earlier duplicate copies of the moderator tests were dropped.
  • forge.json is untouched by this branch.

🤖 Generated with Claude Code

commented

Nothing has changed on this branch since my last run. It is in sync with origin at 07c30c3, with no new pushes and no new review comments. I changed nothing and pushed nothing.

A moderator can delete a chat line over /live on the page and in the terminal. I haven't type-checked it (bun x and bun install fail in this sandbox with a read-only temp dir error) or seen the preview deploy. The earlier deploy failures were npm registry 429 errors, not this code. If it still fails the same way, someone will need to re-run it.

  • Server: a seat is a moderator only if the forge signed its identity and admin.isModerator(name) is true. A guest who picks a listed name is refused. A plain user, and a moderator's settings or pause, still get "only the owner can do that".
  • Logging: the owner and moderators share one deleteLine in src/lobby.ts. It records deleted chat line N in the admin log under whoever did it, then broadcasts unsaid. The owner's deletes are now logged too.
  • Page: the hello frame carries moderator, so a moderator gets the chat-line delete dialog. Mute, ban and the Mod tab stay owner-only.
  • Terminal: /delete <name> and /delete #12 go through the same server check, and web viewers receive unsaid.
  • README: it says how a moderator deletes lines, in the page and in the terminal.
  • Tests: new tests cover:

- a moderator's delete and the resulting log entry; - a plain user being refused; - the owner's delete being logged; - a non-integer id being refused; - a guest using a moderator's name being refused; - the terminal delete reaching web viewers.

  • forge.json is not touched.

The full bun test run has one failure, in the model routes test ("serves the model, its meshes and the vendored libraries, and nothing outside them"). It fails the same way on the base branch.

🤖 Generated with Claude Code

Approved

Approved. The server decides who may delete: a seat counts as a moderator only if the forge signed its identity and the name is listed, and a guest using a listed name is refused. The owner and moderators share one deleteLine, which validates the id, logs who deleted the line, and broadcasts unsaid. Mute, ban, settings, pause and the Mod tab stay owner-only. Both doors are covered: the page (long-press, right-click or Enter) and the terminal (/delete <name> and /delete #id), with tests for each and a README paragraph. The preview answers 200 on /; I did not open the page in a browser. Next: (1) In src/ui/lobby-panel.js, give the delete dialog a visible Delete button of at least 44px for thumb use, and keep the long-press as a shortcut only. Also confirm the focusable chat lines have an accessible name that says they open moderation. (2) In src/terminal.ts, drop the entry from room.latest when an unsaid frame arrives. Otherwise /delete <name> silently does nothing after that line is already gone, and the map grows with every author seen.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs