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

Migrated from github.com/Trevato/SO-ARM100

The long-press moderation dialog offers Mute (with its length) and Ban to a verified moderator on a plain user's line, not only to the owner #412

Merged opened this

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

Merged

The long-press dialog now shows Mute and Ban to a verified moderator on a plain user's line, not only to the owner. I couldn't run bun x tsc --noEmit here: bun install and bun x both fail with "unable to write files to tempdir: ReadOnlyFileSystem", so the forge's check will be the first type check.

Notes

shipped merged

opened this

The long-press dialog now shows Mute and Ban to a verified moderator on a plain user's line, not only to the owner. I couldn't run bun x tsc --noEmit here: bun install and bun x both fail with "unable to write files to tempdir: ReadOnlyFileSystem", so the forge's check will be the first type check.

  • Helper: modActions(you, moderator, author) in src/ui/lobby-panel.js returns which of Delete, Mute and Ban show.

- Owner: Delete, Mute and Ban on anyone else's line. - Moderator: Delete everywhere, and Mute and Ban only on a line that isn't their own, the owner's or another moderator's. - Plain user: nothing. - Dialog: open() in the long-press code uses the helper in place of the old owner-only check.

  • Author's role: chat messages didn't carry it, so src/lobby.ts now adds from.role (owner or moderator) to lines in the chat, history and said frames. The role is taken from the moderator list and from owner ids seen this run. A line from an owner who hasn't connected since the last restart won't be marked as theirs, so a moderator would still see Mute and Ban on it. /live already refuses that, with "only the owner can ban the owner or a moderator".
  • Tests: src/ui/lobby-panel.test.ts covers the cases from the issue.

- The owner sees all three. - A moderator sees Mute and Ban on a plain user's line, but not on the owner's or another moderator's. - Nobody sees them on their own line.

  • Test run: the lobby and lobby-panel suites pass (64 tests). The full bun test had 2 failures: one is "serves the model, its meshes and the vendored libraries…", which fails the same way without my change. I didn't identify the other. I didn't check the first-visit gzip budget separately.

Closes #400

3 earlier comments · 1 event
commented

The long-press dialog now shows Mute and Ban to a verified moderator on a plain user's line, not only to the owner. I couldn't run bun x tsc --noEmit here: bun install and bun x both fail with "unable to write files to tempdir: ReadOnlyFileSystem", so the forge's check will be the first type check.

  • Helper: modActions(you, moderator, author) in src/ui/lobby-panel.js returns which of Delete, Mute and Ban show.

- Owner: Delete, Mute and Ban on anyone else's line. - Moderator: Delete everywhere, and Mute and Ban only on a line that isn't their own, the owner's or another moderator's. - Plain user: nothing. - Dialog: open() in the long-press code uses the helper in place of the old owner-only check.

  • Author's role: chat messages didn't carry it, so src/lobby.ts now adds from.role (owner or moderator) to lines in the chat, history and said frames. The role is taken from the moderator list and from owner ids seen this run. A line from an owner who hasn't connected since the last restart won't be marked as theirs, so a moderator would still see Mute and Ban on it. /live already refuses that, with "only the owner can ban the owner or a moderator".
  • Tests: src/ui/lobby-panel.test.ts covers the cases from the issue.

- The owner sees all three. - A moderator sees Mute and Ban on a plain user's line, but not on the owner's or another moderator's. - Nobody sees them on their own line.

  • Test run: the lobby and lobby-panel suites pass (64 tests). The full bun test had 2 failures: one is "serves the model, its meshes and the vendored libraries…", which fails the same way without my change. I didn't identify the other. I didn't check the first-visit gzip budget separately.
commented

The long-press dialog now offers Mute and Ban to a verified moderator on a plain user's line, not only to the owner. I merged main into the branch and pushed it. The only conflict was in the post case of src/lobby.ts, and I kept both changes there: main's slow-mode lastPosted update and this branch's role mark on the broadcast line.

I ran only the lobby and lobby-panel suites after the merge (65 pass). I didn't run the full bun test or the type check, so the forge's check on the push is the full verdict.

  • Dialog actions: modActions in src/ui/lobby-panel.js decides which of Delete, Mute and Ban show.

- Owner: all three on anyone else's line. - Moderator: Delete everywhere. Mute and Ban only on a line that isn't their own, the owner's or another moderator's. - Plain user: nothing.

  • Author's role: the lobby marks each line in the chat, history and said frames with the author's role (owner or moderator).

- Gap: owner ids are only known from owners who have connected since the last restart. A moderator would still see Mute and Ban on an owner's line until that owner reconnects; /live refuses it anyway.

  • Tests: src/ui/lobby-panel.test.ts covers the owner, moderator and own-line cases.
Changes requested — before the latest push

The client side is sound, but the server change that feeds it has no test, and two doc comments were left stranded. Fix first: add a lobby test that would fail without from.role. Connect as the owner and post, then connect as a verified moderator and a plain user. Assert that the said, history and chat frames carry role owner on the owner's line, role moderator on the moderator's, and no role on the plain user's. modActions is only tested with hand-made roles, so a broken marked() would pass every test.

Second, a moderator sees Mute and Ban on an owner's line until that owner has connected this run, because owners starts empty after a restart. The server refuses the action, so nothing is exposed, but the moderator gets a button that fails. Mark the owner from something persistent, such as the same source hello uses to set who.owner, instead of a set filled on connect. If that is not possible, say so in the README.

Third, two doc comments are now stacked on the wrong code; see the line comments. Also note the author could not run tsc, so the forge check is the first type check; Message & { from: ... } should be checked there.

commented

The long-press dialog now offers Mute and Ban to a verified moderator on a plain user's line, not only to the owner's. The branch is pushed with all three review points addressed.

  • Test for from.role: src/lobby.test.ts now has a test that connects as the owner, a moderator and a plain user, and has each post. It checks the said frame for each line. It then has the owner leave and checks that a fresh client's chat and history frames carry role owner on the owner's line, moderator on the moderator's, and no role on the plain user's. A broken marked() fails it.
  • Owner after a restart: the in-memory owners set is gone. Chat.post now stores owner: true on the line's from when the poster is the owner, using the same who.owner that hello uses. It is saved with the chat log, so it survives restarts. marked() turns it into role: "owner" and strips the raw flag from the frames.

- Gap: lines the owner posted before this change carry no flag, so a moderator still sees Mute and Ban on those. The server refuses the action, as before.

  • Doc comments: the page comment is back on page, and the mayReport comment is back on mayReport.

I still can't run tsc here (bun x fails with a read-only tempdir error), so the forge check is the first type check. That includes the Message & { from: … } return type of marked(), which Message.from now allows an optional owner.

The lobby, chat and lobby-panel suites pass (73 tests). The full bun test has one failure, "serves the model, its meshes and the vendored libraries…", which also fails on main.

commented

I merged main into the branch and pushed it. The only conflict was the import block in src/lobby.ts, where main added guest names and this branch added type Message. I kept both imports.

The full bun test shows 649 passing and 1 failing. The failure is "serves the model, its meshes and the vendored libraries…", which also fails on main. I didn't run the type check, because bun x tsc doesn't work in this sandbox, so the forge's check on the push will be the first type check.

The pull still does what #400 asked: the long-press dialog offers Mute and Ban to a verified moderator on a plain user's line.

  • modActions: this helper in src/ui/lobby-panel.js decides which of Delete, Mute and Ban show.
  • Role marks: chat lines carry from.role (owner or moderator) in the chat, history and said frames. The owner is remembered on the line itself, so it holds across restarts.
  • Gap: lines the owner posted before this change carry no flag. A moderator still sees Mute and Ban on those, and /live refuses the action.
Approved

Approved. The dialog now offers Mute and Ban to a verified moderator on a plain user's line. modActions is a small pure helper, the role mark travels in the chat/history/said frames, and the owner flag is stored on the line so it survives restarts. The server still refuses a moderator acting on the owner or another moderator (lobby.ts:493-510), so the UI is only a convenience. Tests cover the helper and the frames, including after the owner leaves. I could not exercise the moderator path in the preview because I have no moderator identity there; I judged it from the source and the tests. Two things I would do next: (1) lines the owner posted before this change carry no flag, so a moderator still sees Mute/Ban on them and gets a refusal; a follow-up could hide those or word the refusal for a phone. (2) Move the inline doc comment inside the Message.from type in chat.ts onto its own line so the type reads cleanly.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs