[Feature:Forum] Unique anonymous names#12459
Conversation
…uffix - Add chatroom_anonymous_names table for persistent anonymous IDs - Generate truly random names instead of hashing - Format: Anonymous [Adjective] [Noun] #XXXX - Persist across leave/rejoin, logout, cookie clear - Add Shuffle Names button for instructors
|
Hi @williamschen23, could you please approve the workflows for this PR when you have a moment so the CI checks can initiate? Thank you! |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #12459 +/- ##
============================================
- Coverage 21.35% 21.33% -0.02%
- Complexity 9990 9992 +2
============================================
Files 275 275
Lines 37317 37346 +29
Branches 505 505
============================================
Hits 7969 7969
- Misses 28847 28876 +29
Partials 501 501
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Hi @GarvitKhandelwal31, it looks like you're missing a closing curly-bracket on line 200 of chatroom.js, which is causing most of the CI tests to fail. If you fix this I will re-approve the CI workflows to run. |
|
@Eli-J-Schwartz I have added the bracket in the latest commit. Can you please re-run workflows now? |
…ith persistent storage - Merge changes from upstream/main for read-only chat feature (PR Submitty#12428) - Resolve Chatroom.php conflict: combine anonymous name functions with read-only methods - Fix JavaScript lint errors: remove line continuation after else clause, add parentheses to arrow function - Fix migration idempotency: check for table/column existence before creating - All migrations complete successfully - Ready for PR review
|
@Eli-J-Schwartz Can you please re-run workflows. It should pass now. |
|
I've fixed all the failing workflows: Database Migrations:
Schema Dump Mismatch:
PHP (PHPCS):
JavaScript Linting:
Cypress Test Failure:
Can you please re-run? |
There was a problem hiding this comment.
Pull request overview
Implements improved anonymous naming for Live Chat by switching from deterministic/predictable name generation to persistent, randomly generated anonymous display names stored in the course database, plus an instructor action to reshuffle names.
Changes:
- Adds a
chatroom_anonymous_namestable (and Doctrine entity) to persist per-(chatroom,user) anonymous display names. - Updates chatroom anonymous name generation to read/write the persisted name and include a
#XXXXsuffix. - Adds an instructor-only “Shuffle Names” UI action and socket event handling to regenerate names for a chatroom.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| site/public/templates/chat/ChatroomRow.twig | Adds “Shuffle Names” button for active anonymous-enabled chatrooms. |
| site/app/templates/chat/ChatroomRow.twig | Same “Shuffle Names” button addition for server-side twig template. |
| site/public/js/chatroom.js | Adds AJAX call for reshuffling and client handling of the anon_names_regenerated socket event. |
| site/app/views/ChatroomView.php | Uses the new calcAnonName(..., EntityManager) signature so names can persist via DB. |
| site/app/entities/chat/ChatroomAnonymousName.php | New Doctrine entity for persisted anonymous display names. |
| site/app/entities/chat/Chatroom.php | Reworks anonymous name generation to persist and adds bulk regeneration helper. |
| site/app/controllers/ChatroomController.php | Adds instructor-only endpoint to regenerate names and broadcasts socket message. |
| migration/migrator/migrations/course/20250222150000_chatroom_anonymous_names.py | Creates chatroom_anonymous_names table and supporting index. |
| migration/migrator/migrations/course/20250222150100_chatroom_anonymous_names_display_name.py | Migration path for legacy schema to new display_name column. |
| migration/migrator/data/course_tables.sql | Adds chatroom_anonymous_names table + PK + index to baseline schema. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… varchar length, and double route
JManion32
left a comment
There was a problem hiding this comment.
This must've been a lot of work, great job! Please include screenshots of user interface changes, specifically the dashboard where the Shuffle Names button is now located:

A few things regarding the functionality here:
- If the chat allows users to join anonymously, the
Shuffle Namesbutton should be visible, rather than only being visible when the session has started. - The dashboard for chatrooms is starting to become cluttered. How can we improve the user interface without obscuring features? A solid solution to this should probably be a separate PR, but for now, I think we should start by keeping the
Shuffle Namesbutton on the same row as the rest of the buttons on the table - The
Shuffle Namesbutton should be white and blue, like all other utility buttons on Submitty. - When a session has started and I click the
Shuffle Namesbutton, the functionality works as intended. Any subsequent attempts to click the button does not shuffle the names.
Some other thoughts:
- Please add documentation to your description for the different "join messages" that can occur for the user when the instructor clicks
Shuffle Names. I noticed it in the code, but if I hadn't, it would've gone untested. - Can we add a basic Cypress test to support this change? I can't imagine it would be too much work especially since
live_chat.spec.jsis already pretty thorough. - There should be a follow-up to this that allows instructors to more easily view the real names of anonymous chatters.
Overall, great work here! I will likely conduct a more thorough review later, but I think this is a good starting point. Feel free to ping me here if you have any questions.
|
@JManion32 Addressed requested changes and updated this PR for re-review. Shuffle Names is now visible whenever anonymous mode is enabled. |
dagemcn
left a comment
There was a problem hiding this comment.
Looks good! Functionality remains the same after removing the shuffle button, tested light and dark mode along with joining multiple chats, clearing cookies and refreshing the page.
dagemcn
left a comment
There was a problem hiding this comment.
Functionality remains the same after the changes. Name still persists through clearing cookies, joining other chats, logging into other accounts and through browsers. I can't speak much to the code, I'm not familiar with many of the functions used here but from what I know the code looks good.
cjreed121
left a comment
There was a problem hiding this comment.
The algorithm to determine randomized names seems quite solid here and would be extraordinarily difficult to reverse. Few more comments and this should be good after that.
|
Sorry, we should probably wait to get this merged. I just encountered some error on running submitty_install, will fix that soon. |
Why is this Change Important & Necessary?
Fixes #11999
Live Chat anonymous names were previously deterministic but generated using a simple and easily reverse-engineered formula. Also the names were not persistent.
This PR completely overhauls the anonymous naming system to be secure, fast, and completely stateless.
What is the New Behavior?
What steps should a reviewer take to reproduce or test the bug or new feature?
Ensure live chat is enabled in course settings.
Automated Testing & Documentation
Other Information
Please run migrations before reviewing