Hide chat messages for student if teacher flags#72264
Hide chat messages for student if teacher flags#72264fisher-alice wants to merge 14 commits intostagingfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds client-side hiding of teacher-flagged chat messages for students by deriving a teacherFlaggedHidden state from teacher feedback and using it to alter message display, styling, and UI chrome.
Changes:
- Compute
teacherFlaggedHiddeninChatEventViewbased onteacherFeedback === CLEAN_DISAGREEand!isTeacherView, and pass it through to message rendering. - Update
ChatMessageViewto acceptisTeacherView+teacherFlaggedHidden, hide assets/footers when hidden, and adjust message style accordingly. - Refactor footer selection logic into a helper (
getFooter) and extendgetChatMessageDisplayText/getMessageStyleto account for hidden messages.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| apps/src/aichat/views/ChatMessageView.tsx | Uses teacherFlaggedHidden to suppress visibility-dependent UI and change the rendered message text/style; refactors footer logic. |
| apps/src/aichat/views/ChatEventView.tsx | Derives teacherFlaggedHidden from teacher feedback and supplies it to aria-label + ChatMessageView. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (status === Status.PROFANITY_VIOLATION && !showProfaneUserMessage) { | ||
| return commonI18n.aiChatInappropriateUserMessage(); | ||
| } | ||
| if (teacherFlaggedHidden) { |
There was a problem hiding this comment.
Would it make more sense to put this at the beginning of the function so we don't need to duplicate it in both branches of logic?
There was a problem hiding this comment.
I put it at the end so that other errors would be displayed. but teacherFlaggedHidden can only be true if the message was considered 'clean'. So yes! I think putting at the beginning makes sense to de-dup. I'll add a comment explaining why also.
| displayText === intendedDisplayText && | ||
| chatMessage.status !== Status.PROFANITY_VIOLATION; | ||
| chatMessage.status !== Status.PROFANITY_VIOLATION && | ||
| !teacherFlaggedHidden; |
There was a problem hiding this comment.
I think displayText === intendedDisplayText would already give us the right messageVisible value without adding the extra !teacherFlaggedHidden check; is my thinking correct here? Since getChatMessageDisplayText will override displayText?
There was a problem hiding this comment.
Yes! related to comment above and below. Will remove unnecessary check.
| chatMessage.role === Role.USER && | ||
| chatMessage.status === Status.PROFANITY_VIOLATION; | ||
| chatMessage.status === Status.PROFANITY_VIOLATION && | ||
| !teacherFlaggedHidden; |
There was a problem hiding this comment.
I have a similar question here- do we need to add the extra clause here at all? because it won't ever be teacherFlaggedHidden unless it was clean and the teacher disagreed?
| const teacherFlagged = isCompletedChatMessage(event) | ||
| ? event.teacherFeedback === TeacherFeedback.CLEAN_DISAGREE | ||
| : false; |
There was a problem hiding this comment.
nit: remove ternary? isCompletedChatMessage(event) && event.teacherFeedback === TeacherFeedback.CLEAN_DISAGREE
| teacherFlaggedHidden: boolean; | ||
| } | ||
|
|
||
| function getHeader({ |
There was a problem hiding this comment.
Might as well make this (and the footer) functional components?
There was a problem hiding this comment.
Makes sense - this file is getting pretty long.
The feature to allow teachers to flag messages in the teacher view of their student's chat history was added in #62797.
This PR updates student view of the the student chat history so that if a message is flagged by the teacher, the message is hidden from the student.
There were 5,561,438 chat events from the last 90 days (as of April 21), and only 47 of them included teacher feedback spreadsheet. Here's a graph of the breakdown of teacher feedback of these events:
For both user and assistant messages that are flagged with 'clean_disagree', the following is now displayed: 'This message has been flagged as inappropriate by the teacher.' Note that if a message is text + image or just an image, the same message is displayed.
This PR includes computing
teacherFlaggedHiddento determine the display and corresponding UI for teacher-flagged message. I added a couple helper functions (getHeaderandgetFooter) inChatMessageViewto help readability.Links
Testing story
Tested locally on a teacher account and a student account who's in the teacher's section.
Screencast of teacher flagging/unflagging messages in Web Lab 2's AI Tutor:
weblab2.mp4
Screencast of teacher flagging/unflagging messages in AI
aichat.mp4
Chat Lab:
Deployment notes
Privacy and security