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

Migrated from github.com/Trevato/SO-ARM100

workbenchthis machine

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

smith/arm:smith/225-a-moderator-can-delete-a-chat-line-over → main 6 commits fork

  • Merged. smith/225-a-moderator-can-delete-a-chat-line-over was merged into main as ec60765.

Review

Sign in to review this change.
6 files changed +148 −27
Software/README.md +7
@@ -421,6 +421,13 @@ its live pose and the cameras. Driving needs a name and a turn.
421421 any time (this skips the queue), end anyone's turn, take people out of
422422 the queue, delete messages, mute people and ban them (long-press or
423423 right-click a chat line).
424 - Moderators (names the owner lists under `moderators` on `/admin`) can delete
425 chat lines and do nothing else of the owner's. They must be signed in through
426 the forge: a guest who picked a listed name is not one. In the page, long-press
427 or right-click a chat line and choose **Delete message**. In the terminal, chat
428 lines show their number (`#12 bob: …`) to moderators and the owner: `/delete
429 <name>` removes that person's latest line, `/delete #12` that line. Everyone
430 watching sees it go, and the admin log records who deleted it.
424431 The owner can also press **Stop** during anyone's turn.
425432 - The red **STOP** button (or Esc) is the emergency stop.
426433 The driver and the owner can press it. Only the owner can clear it, and
Software/so101/src/lobby.test.ts +58
@@ -278,6 +278,64 @@ describe("lobby", () => {
278278 expect((await late.first((m) => m.type === "chat")).messages).toEqual([]);
279279 });
280280
281 test("a moderator deletes a chat line and it is logged; a plain user is refused; settings and pause stay the owner's", async () => {
282 const admin = new Admin();
283 admin.set({ id: "u-owner", name: "trevato", owner: true }, { moderators: ["bob"] });
284 const port = await start(undefined, undefined, admin);
285 const alice = await join(port, ALICE);
286 const bob = await join(port, BOB);
287 const owner = await join(port, OWNER);
288 expect((await bob.first((m) => m.type === "hello")).moderator).toBe(true);
289 expect((await alice.first((m) => m.type === "hello")).moderator).toBe(false);
290 alice.send({ type: "post", text: "hello" });
291 const said = await bob.next((m) => m.type === "said");
292
293 alice.send({ type: "delete", id: said.message.id });
294 expect((await alice.next((m) => m.type === "error")).error).toBe("only the owner can do that");
295 bob.send({ type: "settings", set: { paused: true } });
296 expect((await bob.next((m) => m.type === "error")).error).toBe("only the owner can do that");
297 bob.heard.length = 0;
298 bob.send({ type: "pause", on: true });
299 expect((await bob.next((m) => m.type === "error")).error).toBe("only the owner can do that");
300 expect(admin.settings.paused).toBe(false);
301
302 bob.send({ type: "delete", id: said.message.id });
303 expect((await alice.next((m) => m.type === "unsaid")).id).toBe(said.message.id);
304 expect(admin.log.at(-1)).toMatchObject({ by: { id: "u-bob", name: "bob" }, what: `deleted chat line ${said.message.id}` });
305 expect((await owner.next((m) => m.type === "admin" && m.log.at(-1).by.name === "bob")).log.at(-1).what).toContain("deleted chat line");
306 });
307
308 test("the owner's delete is logged with the owner as who did it, and a delete without an integer id is refused", async () => {
309 const admin = new Admin();
310 const port = await start(undefined, undefined, admin);
311 const alice = await join(port, ALICE);
312 const owner = await join(port, OWNER);
313 alice.send({ type: "post", text: "hello" });
314 const said = await owner.next((m) => m.type === "said");
315 owner.send({ type: "delete", id: said.message.id });
316 await alice.next((m) => m.type === "unsaid");
317 expect(admin.log.at(-1)).toMatchObject({ by: { id: "u-owner", name: "trevato" }, what: `deleted chat line ${said.message.id}` });
318 for (const id of ["3", 1.5, null]) {
319 owner.heard.length = 0;
320 owner.send({ type: "delete", id });
321 expect((await owner.next((m) => m.type === "error")).error).toBe("delete which line?");
322 }
323 expect(admin.log.length).toBe(1);
324 });
325
326 test("a guest who picked a moderator's name is not a moderator", async () => {
327 const admin = new Admin();
328 admin.set({ id: "u-owner", name: "trevato", owner: true }, { moderators: ["zed"] });
329 const port = await start(undefined, undefined, admin);
330 const alice = await join(port, ALICE);
331 alice.send({ type: "post", text: "hi" });
332 const said = await alice.next((m) => m.type === "said");
333 const guest = await join(port);
334 guest.send({ type: "delete", id: said.message.id });
335 expect((await guest.next((m) => m.type === "error")).error).toBeTruthy();
336 expect(admin.log.length).toBe(1);
337 });
338
281339 test("chat history is lazy: a new page gets the last lines, anyone asks for older pages, oldest first", async () => {
282340 const chat = new Chat();
283341 for (let i = 0; i < 100; i++) chat.system(`line ${i}`);
Software/so101/src/lobby.ts +21 −9
@@ -11,7 +11,7 @@
1111 * {"type": "leave"} hand back the turn, or leave the line
1212 * {"type": "post", "text": "…"} say something
1313 * {"type": "end", "id": "<user id>"} owner: end that turn, or take them out of the line
14 * {"type": "delete", "id": 12} owner: delete a chat line
14 * {"type": "delete", "id": 12} owner or a moderator: delete a chat line
1515 * {"type": "mute", "id": "<user id>", "on": true|false} owner
1616 * {"type": "pause", "on": true|false} owner: maintenance; nobody new gets a turn
1717 * {"type": "settings", "set": {…}} owner: any of src/admin.ts's settings
@@ -22,7 +22,7 @@
2222 * {"type": "words", "words": ["…"]} owner: the chat's word filter; a line with a listed word is refused
2323 * {"type": "pong"} the answer to {"type": "ping"}
2424 * {"type": "history", "before": 12} anyone: up to HISTORY_PAGE lines older than that one
25 * Server → client: hello (who you are), state (the turn, the line, pause, the announcement and the speed cap),
25 * Server → client: hello (who you are, and whether you may moderate: delete a line), state (the turn, the line, pause, the announcement and the speed cap),
2626 * chat (the last CHAT_FIRST lines of the log, and whether there are more), history (an older page, the same way),
2727 * said, unsaid, muted, admin (owners only: the settings and the admin log), crew (owners only:
2828 * settings, hidden lines, mute suggestions), banned and words (owners only), ping, error; and whatever the relay
@@ -69,6 +69,8 @@ interface Seat {
6969 ws: WebSocket;
7070 who: Who;
7171 from: Visitor;
72 /** The forge signed this identity (a guest's chosen name never counts as a moderator). */
73 verified: boolean;
7274 heard: number;
7375 }
7476
@@ -188,6 +190,7 @@ export class Lobby {
188190 }
189191 this.broadcastState();
190192 this.broadcastAdmin();
193 if (changed.includes("moderators")) for (const s of this.seats) if (s.who && !s.who.owner) this.send(s, this.hello(s));
191194 if (changed.length) for (const listener of this.changeListeners) listener();
192195 }
193196
@@ -232,7 +235,8 @@ export class Lobby {
232235 upgrade(req: IncomingMessage, socket: Duplex, head: Buffer): void {
233236 const who = this.who(req);
234237 const from = visitor(req);
235 this.wss.handleUpgrade(req, socket, head, (ws) => this.seat(ws, who, from));
238 const verified = Boolean(who) && this.verified(req)?.id === who?.id;
239 this.wss.handleUpgrade(req, socket, head, (ws) => this.seat(ws, who, from, verified));
236240 }
237241
238242 close(): void {
@@ -244,8 +248,8 @@ export class Lobby {
244248 }
245249
246250 // ------------------------------------------------------------------ sockets
247 private seat(ws: WebSocket, who: Who, from: Visitor): void {
248 const seat: Seat = { ws, who, from, heard: Date.now() };
251 private seat(ws: WebSocket, who: Who, from: Visitor, verified: boolean): void {
252 const seat: Seat = { ws, who, from, verified, heard: Date.now() };
249253 this.seats.add(seat);
250254 if (who) this.turns.connect(who.id);
251255 this.send(seat, this.hello(seat));
@@ -314,6 +318,7 @@ export class Lobby {
314318 return;
315319 }
316320 }
321 if (!who.owner && m.type === "delete" && seat.verified && this.admin.isModerator(who.name)) return this.deleteLine(who, m.id);
317322 if (!who.owner) return this.send(seat, { type: "error", error: "only the owner can do that" });
318323 switch (m.type) {
319324 case "end":
@@ -328,9 +333,7 @@ export class Lobby {
328333 case "settings":
329334 return this.configure(who, m.set);
330335 case "delete":
331 if (!Number.isSafeInteger(m.id)) return this.send(seat, { type: "error", error: "delete which line?" });
332 if (this.chat.delete(m.id as number)) this.broadcast({ type: "unsaid", id: m.id });
333 return;
336 return this.deleteLine(who, m.id);
334337 case "words": {
335338 const words = this.filter.set(m.words);
336339 this.admin.record(who, `word filter → ${words.length} word${words.length === 1 ? "" : "s"}`);
@@ -398,6 +401,15 @@ export class Lobby {
398401 this.send(seat, { type: "error", error: "unknown request" });
399402 }
400403
404 /** Delete a chat line as the owner or a moderator; the admin log says who. */
405 private deleteLine(who: Person, id: unknown): void {
406 if (!Number.isSafeInteger(id)) throw new ChatError("delete which line?");
407 if (!this.chat.delete(id as number)) return;
408 this.admin.record(who, `deleted chat line ${id}`);
409 this.broadcast({ type: "unsaid", id });
410 this.broadcastAdmin();
411 }
412
401413 private turnChanged(event: TurnEvent): void {
402414 if (event.kind === "turn") {
403415 const { ended, started } = event;
@@ -437,7 +449,7 @@ export class Lobby {
437449
438450 private hello(seat: Seat) {
439451 const who = seat.who;
440 return { type: "hello", you: who, signin: !this.local, muted: who ? this.chat.muted.has(who.id) : false, banned: who ? this.barred(who, seat.from) : false };
452 return { type: "hello", you: who, moderator: Boolean(who && !who.owner && seat.verified && this.admin.isModerator(who.name)), signin: !this.local, muted: who ? this.chat.muted.has(who.id) : false, banned: who ? this.barred(who, seat.from) : false };
441453 }
442454
443455 private bannedList() {
Software/so101/src/terminal.test.ts +30 −1
@@ -82,6 +82,15 @@ describe("terminal lines", () => {
8282 expect(typed(room, "/unmute u-zed")).toEqual({ send: { type: "mute", id: "u-zed", on: false } });
8383 expect(typed(room, "/mute")).toEqual({ print: "usage: /mute <name>" });
8484 expect(typed(room, "/mute a.b!")).toEqual({ print: "error: who is a.b!?" });
85 hear(room, { type: "said", message: { id: 7, from: { id: "u-alice", name: "alice" }, text: "hi" } });
86 expect(typed(room, "/delete Alice")).toEqual({ send: { type: "delete", id: 7 } });
87 expect(typed(room, "/delete #12")).toEqual({ send: { type: "delete", id: 12 } });
88 expect(typed(room, "/delete")).toEqual({ print: "usage: /delete <name> | /delete #<line number>" });
89 expect(typed(room, "/delete bob")).toEqual({ print: "error: no line from bob seen" });
90 expect(hear(emptyRoom(), { type: "said", message: { id: 7, from: { id: "u-alice", name: "alice" }, text: "hi" } })).toEqual(["alice: hi"]);
91 const mod = emptyRoom();
92 hear(mod, { type: "hello", you: { id: "u-bob", name: "bob" }, moderator: true });
93 expect(hear(mod, { type: "said", message: { id: 7, from: { id: "u-alice", name: "alice" }, text: "hi" } })).toEqual(["#7 alice: hi"]);
8594 expect(typed(room, "/who")).toEqual({ print: "alice has control · 1. bob" });
8695 expect(typed(room, "/quit")).toEqual({ quit: true });
8796 expect(typed(room, " ")).toBeNull();
@@ -218,7 +227,7 @@ describe("terminal door", () => {
218227 const port = await start();
219228 const page = await viewer(port);
220229 const alice = await terminal(port, ttyEnv("u-alice", "alice", "user"));
221 expect(alice.door.room.you).toEqual({ id: "u-alice", name: "alice", owner: false });
230 expect(alice.door.room.you).toEqual({ id: "u-alice", name: "alice", owner: false, moderator: false });
222231 alice.door.input("hi from ssh <b>bold</b>");
223232 const m = await page.heardOne((m) => m.type === "said" && m.message.from?.id === "u-alice", "terminal line on the page");
224233 expect(m.message).toMatchObject({ from: { id: "u-alice", name: "alice" }, text: "hi from ssh <b>bold</b>" });
@@ -337,6 +346,26 @@ describe("terminal door", () => {
337346 await alicePage.heardOne((m) => m.type === "said" && m.message.text === "thanks", "alice's line once unmuted");
338347 });
339348
349 test("delete: a moderator's terminal removes a line and web viewers hear unsaid; a plain user's is refused", async () => {
350 const port = await start();
351 lobby!.admin.set({ id: "u-owner", name: "trevato", owner: true }, { moderators: ["bob"] });
352 const page = await viewer(port);
353 const alicePage = await viewer(port, web("u-alice", "alice"));
354 alicePage.send({ type: "post", text: "one" });
355 const one = await page.heardOne((m) => m.type === "said" && m.message.text === "one", "the line");
356 const bob = await terminal(port, ttyEnv("u-bob", "bob", "user"));
357 const carol = await terminal(port, ttyEnv("u-carol", "carol", "user"));
358 await bob.printedLine(/^you are bob \(moderator\)$/);
359 await bob.printedLine(new RegExp(`^#${one.message.id} alice: one$`));
360 await carol.printedLine(/^alice: one$/);
361
362 carol.door.input("/delete alice");
363 await carol.printedLine(/^error: only the owner can do that$/);
364 bob.door.input("/delete alice");
365 expect((await page.heardOne((m) => m.type === "unsaid", "the line going")).id).toBe(one.message.id);
366 expect(lobby!.admin.log.at(-1)).toMatchObject({ by: { id: "u-bob", name: "bob" }, what: `deleted chat line ${one.message.id}` });
367 });
368
340369 test("end-turn: only the owner's terminal may; the page sees the turn pass on", async () => {
341370 const port = await start();
342371 const alicePage = await viewer(port, web("u-alice", "alice"));
Software/so101/src/terminal.ts +23 −10
@@ -21,6 +21,7 @@
2121 * /resume the driver or an admin: end the hold; the arm stays put until a new command
2222 * /end [who] owner: end that turn (none: whoever drives), or take them out of the line
2323 * /mute <who> /unmute <who> owner
24 * /delete <who|#id> owner or moderator: remove that person's latest chat line, or the line numbered #id (shown to those who may)
2425 * /table here admin: put the table under the arm's lowest link now (POST /settings/table-here)
2526 * /table <mm> admin: set the table offset, -100..100 mm (PUT /settings tableOffsetMm)
2627 * /machine [off] the Machine panel (/machine, src/machine-feed.ts): the joints, the link and the server as they are,
@@ -96,7 +97,7 @@ interface Someone {
9697
9798 /** What the door knows of the room, from what the server told it. */
9899 export interface Room {
99 you: (Someone & { owner: boolean }) | null;
100 you: (Someone & { owner: boolean; moderator: boolean }) | null;
100101 muted: boolean;
101102 banned: boolean;
102103 driver: Someone | null;
@@ -106,11 +107,13 @@ export interface Room {
106107 held: string | null | undefined;
107108 /** Whether the call to confirm, and the "you are next" cue, were already printed (each is said once). */
108109 told: { called: boolean; next: boolean };
110 /** The latest chat line of each author, by user id: what `/delete <who>` removes. */
111 latest: Map<string, number>;
109112 /** Everyone seen by name, most recent last: to turn a typed name into an id. */
110113 seen: Map<string, Someone>;
111114 }
112115
113 export const emptyRoom = (): Room => ({ you: null, muted: false, banned: false, driver: null, queue: [], paused: false, held: undefined, told: { called: false, next: false }, seen: new Map() });
116 export const emptyRoom = (): Room => ({ you: null, muted: false, banned: false, driver: null, queue: [], paused: false, held: undefined, told: { called: false, next: false }, seen: new Map(), latest: new Map() });
114117
115118 const someone = (x: unknown): Someone | null => {
116119 if (typeof x !== "object" || x === null) return null;
@@ -124,13 +127,17 @@ function see(room: Room, who: Someone | null): void {
124127 room.seen.set(who.name.toLowerCase(), who);
125128 }
126129
127 const said = (m: unknown): string => {
128 const message = m as { from?: unknown; text?: unknown } | null;
130 /** One chat line; those who may delete see its number, and the author's latest line is remembered for /delete. */
131 const said = (room: Room, m: unknown): string => {
132 const message = m as { id?: unknown; from?: unknown; text?: unknown } | null;
129133 const from = someone(message?.from);
130 return from ? `${plain(from.name)}: ${plain(message?.text)}` : `· ${plain(message?.text)}`;
134 const id = typeof message?.id === "number" && Number.isSafeInteger(message.id) ? message.id : null;
135 if (from && id !== null) room.latest.set(from.id, id);
136 const tag = id !== null && (room.you?.owner || room.you?.moderator) ? `#${id} ` : "";
137 return from ? `${tag}${plain(from.name)}: ${plain(message?.text)}` : `· ${plain(message?.text)}`;
131138 };
132139
133 export const HELP = "type to chat · /join /leave /ready /extend · /stop /resume (driver, owner) · /end [who] /mute <who> /unmute <who> /table here|<mm> (owner) · /machine [off] · /who · /quit";
140 export const HELP = "type to chat · /join /leave /ready /extend · /stop /resume (driver, owner) · /end [who] /mute <who> /unmute <who> /table here|<mm> (owner) · /delete <who|#id> (owner, moderator) · /machine [off] · /who · /quit";
134141
135142 /** The Machine feed's socket beside the lobby's: same app, same port. */
136143 export const machineUrl = (live: string): string => live.replace(/\/live$/, "/machine");
@@ -181,12 +188,12 @@ export function hear(room: Room, frame: Frame): string[] {
181188 case "hello": {
182189 const you = someone(frame.you);
183190 const was = { you: room.you, muted: room.muted, banned: room.banned };
184 room.you = you ? { ...you, owner: (frame.you as { owner?: unknown }).owner === true } : null;
191 room.you = you ? { ...you, owner: (frame.you as { owner?: unknown }).owner === true, moderator: frame.moderator === true } : null;
185192 room.muted = frame.muted === true;
186193 room.banned = frame.banned === true;
187194 see(room, you);
188195 const out: string[] = [];
189 if (!was.you && room.you) out.push(`you are ${plain(room.you.name)}${room.you.owner ? " (owner)" : ""}`);
196 if (!was.you && room.you) out.push(`you are ${plain(room.you.name)}${room.you.owner ? " (owner)" : room.you.moderator ? " (moderator)" : ""}`);
190197 if (!room.you && frame.signin === true) out.push("you are watching: connect with a key your forge account knows to chat and drive");
191198 if (room.muted !== was.muted && (room.muted || was.you)) out.push(room.muted ? "you are muted" : "you may chat again");
192199 if (room.banned && !was.banned) out.push("you are banned: you can still watch");
@@ -203,11 +210,11 @@ export function hear(room: Room, frame: Frame): string[] {
203210 case "chat": {
204211 const messages = Array.isArray(frame.messages) ? frame.messages : [];
205212 for (const m of messages) see(room, someone((m as { from?: unknown } | null)?.from));
206 return messages.slice(-10).map(said);
213 return messages.slice(-10).map((m) => said(room, m));
207214 }
208215 case "said":
209216 see(room, someone((frame.message as { from?: unknown } | null)?.from));
210 return [said(frame.message)];
217 return [said(room, frame.message)];
211218 case "status": {
212219 // Said when it changes, not on every push: a stop made here or on a page reaches every terminal once.
213220 const h = (frame.status as { held?: unknown } | null)?.held as { by?: unknown; at?: unknown } | null | undefined;
@@ -266,6 +273,12 @@ export function typed(room: Room, input: string): Typed {
266273 const id = target(room, arg);
267274 return id ? { send: { type: "mute", id, on: verb.toLowerCase() === "mute" } } : { print: `error: who is ${plain(arg)}?` };
268275 }
276 case "delete": {
277 if (!arg) return { print: "usage: /delete <name> | /delete #<line number>" };
278 const number = /^#(\d{1,15})$/.exec(arg);
279 const id = number ? Number(number[1]) : room.latest.get(target(room, arg) ?? "");
280 return id === undefined ? { print: `error: no line from ${plain(arg)} seen` } : { send: { type: "delete", id } };
281 }
269282 case "stop":
270283 case "resume":
271284 return { post: `/${verb.toLowerCase()}` as "/stop" | "/resume" };
Software/so101/src/ui/lobby-panel.js +9 −7
@@ -33,6 +33,8 @@ export function createRoom(page) {
3333 const lobby = { ws: null, hello: null, state: null, offset: 0, retry: 500, mutedList: [], bannedList: [], admin: null, statusSeen: false };
3434 function mayDrive() { return !relayed || (lobby.hello !== null && (!lobby.hello.signin || (lobby.hello.you !== null && lobby.state?.driver?.id === lobby.hello.you.id))); }
3535 function isOwner() { return !relayed || Boolean(lobby.hello?.you?.owner); }
36 /** The owner, or a forge-verified moderator: who may delete a chat line (the server checks again). */
37 function canDelete() { return Boolean(lobby.hello?.you?.owner || lobby.hello?.moderator); }
3638 const say = (/** @type {Record<string, unknown>} */ m) => { if (lobby.ws?.readyState === 1) lobby.ws.send(JSON.stringify(m)); };
3739 const serverNow = () => Date.now() + lobby.offset;
3840 function tickClock() {
@@ -131,7 +133,7 @@ export function createRoom(page) {
131133 renderCrew(me);
132134 $("say").hidden = !me || lobby.hello.muted || lobby.hello.banned;
133135 $("sayNote").textContent = !lobby.hello.signin ? "" : !me ? "Join (Queue tab) to chat." : lobby.hello.banned ? "You are banned: you can still watch." : lobby.hello.muted ? "The owner has muted you." : "";
134 chatBox.classList.toggle("moderated", Boolean(me?.owner));
136 chatBox.classList.toggle("moderated", canDelete());
135137 tickClock();
136138 page.applyLock();
137139 }
@@ -174,7 +176,7 @@ export function createRoom(page) {
174176 line.dataset.id = m.id;
175177 if (m.from) { line.dataset.from = m.from.id; line.dataset.name = m.from.name; line.append(el("b", { textContent: m.from.name })); }
176178 line.append(el("span", { textContent: m.text }));
177 if (m.from && me?.owner) line.tabIndex = 0;
179 if (m.from && canDelete()) line.tabIndex = 0;
178180 return line;
179181 }
180182 // A new page gets the last lines of the chat; older ones come a page at a time, when asked for.
@@ -203,31 +205,31 @@ export function createRoom(page) {
203205 if (atEnd || replace) chatBox.scrollTop = chatBox.scrollHeight;
204206 if (!replace && page.tab() !== "chat") $("unread").textContent = String(Math.min(99, Number($("unread").textContent || 0) + lines.length));
205207 }
206 // Moderation on a phone: long-press a line (or right-click it, or Enter on it) for delete and mute.
208 // Moderation on a phone: long-press a line (or right-click it, or Enter on it) for delete (and mute and ban, for the owner).
207209 {
208210 /** @type {any} */
209211 let press = null;
210212 /** @type {any} */
211213 let held = null;
212214 const open = (/** @type {any} */ line) => {
213 if (!lobby.hello?.you?.owner || !line?.dataset.from) return;
215 if (!canDelete() || !line?.dataset.from) return;
214216 held = line; line.classList.add("held");
215217 $("modTitle").textContent = `${line.dataset.name} said`;
216218 $("modText").textContent = line.querySelector("span")?.textContent ?? "";
217219 $("modMute").textContent = `Mute ${line.dataset.name}`;
218220 $("modBan").textContent = `Ban ${line.dataset.name}`;
219 $("modMute").hidden = $("modBan").hidden = line.dataset.from === lobby.hello.you.id;
221 $("modMute").hidden = $("modBan").hidden = !lobby.hello.you.owner || line.dataset.from === lobby.hello.you.id;
220222 $("modDlg").showModal();
221223 nav.vibrate?.(10);
222224 };
223225 chatBox.addEventListener("pointerdown", (/** @type {any} */ e) => {
224 const line = e.target.closest(".line"); if (!line?.dataset.from || !lobby.hello?.you?.owner) return;
226 const line = e.target.closest(".line"); if (!line?.dataset.from || !canDelete()) return;
225227 press = { x: e.clientX, y: e.clientY, timer: setTimeout(() => { press = null; open(line); }, 480) };
226228 });
227229 const cancel = () => { if (press) { clearTimeout(press.timer); press = null; } };
228230 chatBox.addEventListener("pointermove", (/** @type {any} */ e) => { if (press && Math.hypot(e.clientX - press.x, e.clientY - press.y) > 10) cancel(); });
229231 for (const ev of ["pointerup", "pointercancel", "scroll"]) chatBox.addEventListener(ev, cancel);
230 chatBox.addEventListener("contextmenu", (/** @type {any} */ e) => { const line = e.target.closest(".line"); if (line?.dataset.from && lobby.hello?.you?.owner) { e.preventDefault(); cancel(); open(line); } });
232 chatBox.addEventListener("contextmenu", (/** @type {any} */ e) => { const line = e.target.closest(".line"); if (line?.dataset.from && canDelete()) { e.preventDefault(); cancel(); open(line); } });
231233 chatBox.addEventListener("keydown", (/** @type {any} */ e) => { if (e.key === "Enter" && e.target.classList?.contains("line")) open(e.target); });
232234 $("modDlg").addEventListener("close", () => {
233235 const line = held; held = null; line?.classList.remove("held");

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs