Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
A removed chat message can be restored from /admin, and it reappears for everyone live #294
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
A chat line removed by the owner or a moderator is now kept, marked with who removed it, and can be restored from /admin or over /live. A restored line reappears for everyone live and is logged. The new tests and the existing chat, lobby, moderator and admin tests pass (70 tests).
shipped merged
1 earlier comment · 1 event
A chat line removed by the owner or a moderator is now kept, marked with who removed it, and can be restored from /admin or over /live. A restored line reappears for everyone live and is logged. The new tests and the existing chat, lobby, moderator and admin tests pass (70 tests). I did not run the full bun --cwd Software/so101 test, and forge.json is untouched.
- Storage:
Chat.delete(id, by)moves the line into a newremovedlist (newest first, last 200 kept, saved in the same chat file).Chat.unremove(id)puts it back in id order. - Restoring:
Lobby.restoreLinefirst looks in the removed list, then in the AI moderator's hidden log. It logsrestored chat line Nand re-sends the chat to all clients. The existingrestoremessage on/livenow goes through it, and it stays owner-only. /admin: the Moderation section has a "Removed lines" list showing who removed each line and its text. The owner gets a Restore button on each; a moderator sees the list without the button. A restore posted to/adminfor a line that isn't in the log returns a 400.- Tests: one new test removes a line over
/live, then restores it once over/liveand once through the/adminform. It checks that two clients both see it come back, that the log records it, and that a plain user's restore on/admingets 404. A second new test insrc/chat.test.tscovers persistence across a restart and re-insertion in order.
bun x tsc --noEmit reports one error, at src/lobby.ts:357 ('span' is possibly 'undefined'). It is also there without my changes, so I left it.
🤖 Generated with Claude Code
The logic is sound: removals are kept with who and when, they survive a restart, and restoring re-inserts by id, logs, and re-broadcasts. The restore form on /admin is owner-only, the output is escaped, and the tests cover both the /live and /admin paths. Two list items are missed, so I am requesting changes.
- The README says nothing about it (fix first). Software/README.md around line 452 documents restore only for the AI moderator's hidden lines. Add a short note that any removed chat line is kept, listed under Removed lines on /admin, and restorable by the owner there or with {"type":"restore","id":N} over /live, and that it is logged.
- Both doors. src/tty.ts has no way to see or restore removed lines. Add an owner-only command that lists removals and restores one by id. It should go through Lobby.restoreLine so web viewers see the line live, and a guest or non-owner should get nothing. If you think the terminal should stay without moderation, say so in the README and the pull so the gap is a recorded decision. tty.ts has no delete, ban or mute either, so this is a gap that was already there.
Smaller points:
- The type error at lobby.ts:357 is not yours, but the pull should still go through
bun x tsc --noEmit, and the fullbun testwas not run. - The Removed lines heading in admin-page.ts has no id and is not tied to its list by aria-labelledby. Give it an id, like the other sections have.
- Each Restore button's aria-label is "Restore line 12", which says nothing about the content. Use the text, for example: Restore line 12: <first words>.
A chat line the owner or a moderator removes is now kept with who removed it and when. The owner can see removed lines and restore them from /admin, over /live, or from the terminal, and every restore is logged. The full bun test passes (508 tests, run twice). bun x tsc --noEmit still reports the lobby.ts:358 'span' is possibly 'undefined' error. It was already there without these changes, so I left it.
- Storage:
Chat.delete(id, by)moves the line into aremovedlist (newest first, last 200, saved in the chat file).Chat.unremove(id)puts it back in id order. - Restoring: every route goes through
Lobby.restoreLine. It logsrestored chat line Nand re-sends the chat to every open page. The owner can use:
- the Restore button under Removed lines on /admin;
- {"type":"restore","id":N} over /live;
- /restore #N in the terminal.
- Terminal:
/removedlists the latest removals with their numbers and who removed them, using a new owner-only{"type":"removed"}request on/live. A non-owner gets "only the owner can do that" from both/removedand/restore. The terminal test covers an owner restore reaching a web viewer and a non-owner's refusal. - Review points: the Removed lines heading now has an id and sits in its own section tied to it by
aria-labelledby. Each Restore button'saria-labelis now "Restore line N: <first 40 characters>". The README has a Removed lines note and the two terminal commands. - Test race: the
/adminrestore test could miss the broadcast because it started listening after the POST returned. I fixed the test; the code was fine.
One correction to the review: src/terminal.ts already has /delete and /mute, so the terminal had moderation before this change. /removed and /restore extend that.
🤖 Generated with Claude Code
Removed lines are kept with who and when, persist across restarts, and come back in id order. Every door (/admin form, /live restore, terminal /removed and /restore) goes through Lobby.restoreLine, is owner-gated (lobby.ts:329 for /live, 404 for non-owners on /admin), and is logged. Tests cover chat persistence, lobby live restore plus the admin form, and the terminal. The README is updated. /admin answers 404 to a guest in the preview, as it should. Next two things: (1) the Restore button has an aria-label but there is no confirmation or focus handling after the redirect, so say where focus lands. (2) Fix the pre-existing tsc error at lobby.ts:358 in its own small pull.
A chat line removed by the owner or a moderator is now kept, marked with who removed it, and can be restored from
/adminor over/live. A restored line reappears for everyone live and is logged. The new tests and the existing chat, lobby, moderator and admin tests pass (70 tests). I did not run the fullbun --cwd Software/so101 test, andforge.jsonis untouched.Chat.delete(id, by)moves the line into a newremovedlist (newest first, last 200 kept, saved in the same chat file).Chat.unremove(id)puts it back in id order.Lobby.restoreLinefirst looks in the removed list, then in the AI moderator's hidden log. It logsrestored chat line Nand re-sends the chat to all clients. The existingrestoremessage on/livenow goes through it, and it stays owner-only./admin: the Moderation section has a "Removed lines" list showing who removed each line and its text. The owner gets a Restore button on each; a moderator sees the list without the button. A restore posted to/adminfor a line that isn't in the log returns a 400./live, then restores it once over/liveand once through the/adminform. It checks that two clients both see it come back, that the log records it, and that a plain user's restore on/admingets 404. A second new test insrc/chat.test.tscovers persistence across a restart and re-insertion in order.bun x tsc --noEmitreports one error, atsrc/lobby.ts:357('span' is possibly 'undefined'). It is also there without my changes, so I left it.🤖 Generated with Claude Code
Closes #197