Skip to content

Fix ACARS contact + filtering, Fix Chat persistence + custom slur only filter#64

Merged
1ceit merged 7 commits intomainfrom
FIxChat
Oct 29, 2025
Merged

Fix ACARS contact + filtering, Fix Chat persistence + custom slur only filter#64
1ceit merged 7 commits intomainfrom
FIxChat

Conversation

@1ceit
Copy link
Copy Markdown
Collaborator

@1ceit 1ceit commented Oct 28, 2025

This pull request introduces significant improvements to the chat system, focusing on enhanced hate speech detection and automoderation, improved mention handling, and better user experience in the chat UI. The main changes include replacing the basic profanity filter with a custom hate speech filter, updating how mentions are processed and stored, providing clearer automod feedback to users, and improving chat message loading and UI responsiveness.

Chat moderation and hate speech detection:

  • Replaced the bad-words profanity filter with a custom hate speech filter (hateSpeechFilter.ts) that uses regular expressions to detect racial slurs and extremist content, and provides a specific reason for automoderation. The automod reason is now returned and displayed to the user. [1] [2] [3] [4] [5] [6]

Chat mention and active user handling:

  • Mentions are now resolved to user IDs (not just usernames), and the backend stores and processes mentions as user IDs for accuracy. The chat system emits chatOpened and chatClosed events to more accurately track active users in a session, improving the active user indicator. [1] [2] [3] [4]

Chat UI and user experience improvements:

  • The chat sidebar now tracks and displays specific automod reasons for flagged messages with a tooltip, improves error handling and feedback when loading messages, and implements smart auto-scroll behavior. Chat messages are loaded only once per session open, and the socket connection persists across chat UI open/close events for better performance. [1] [2] [3] [4] [5]

Flights websocket (controller contact):

  • The contactMe event in the flights websocket now supports optional station and position fields, which are sanitized and included in both the request and emitted events, providing more context for controller/flight interactions. [1] [2] [3]

Other:

  • Added some ASCII art comments for flavor in certain files. [1] [2]

These changes collectively enhance moderation accuracy, chat reliability, and the clarity of feedback provided to users.


References:

@dokploy-pfcontrol
Copy link
Copy Markdown

dokploy-pfcontrol Bot commented Oct 28, 2025

Dokploy Preview Deployment

Name Status Preview Updated (UTC)
app ✅ Done Preview URL 2025-10-29T04:42:50.496Z

@1ceit 1ceit requested review from Copilot and dev-banane October 29, 2025 03:26
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a custom hate speech and profanity filter system to replace the bad-words library, adding client-side and server-side validation for ACARS messages and chat. It also includes improvements to chat user presence tracking and message handling.

  • Replaced bad-words library with custom hate speech/profanity filtering using regex patterns
  • Added validation to ACARS contact messages with UI feedback when content violates guidelines
  • Enhanced chat sidebar with better presence tracking, automod reason display, and improved mention suggestions UI

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/utils/hateSpeechFilter.ts New custom filter with regex patterns for hate speech and profanity detection
server/utils/hateSpeechFilter.ts Server-side implementation of the same filtering logic
src/components/tools/ContactAcarsSidebar.tsx Adds content validation to ACARS messages with UI feedback
src/components/tools/ChatSidebar.tsx Improves chat presence tracking and automod notifications
src/pages/Flights.tsx Updates to pass station/position parameters for ACARS contact
src/pages/ACARS.tsx Updates to receive and display station/position from contact requests
server/websockets/flightsWebsocket.ts Adds station/position parameter handling to contact messages
server/websockets/chatWebsocket.ts Improves chat presence tracking with chatOpened/chatClosed events
server/db/chats.ts Replaces bad-words with custom hate speech filter and adds reason tracking
src/main.tsx Adds console branding/version display
src/components/modals/AtisReminderModal.tsx Adds ASCII art comment
eslint.config.js Excludes hate speech filter from linting

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/tools/ContactAcarsSidebar.tsx Outdated
Comment on lines +37 to +47
const getDefaultMessage = () => {
const freq = frequencies.find((f) => f.type === selectedPosition);
if (freq) {
return `CONTACT ME ON ${airportIcao}_${selectedPosition} ${freq.freq}`;
}
return 'CONTACT ME ON FREQUENCY';
};

// Use useMemo to ensure consistent message evaluation
const currentMessage = useMemo(() => {
return customMessage.trim() || getDefaultMessage();
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The useMemo hook calls getDefaultMessage() which is a function that depends on frequencies, selectedPosition, and airportIcao, but getDefaultMessage itself is not stable (it's redefined on every render). This defeats the purpose of useMemo. Either include getDefaultMessage in the dependency array or inline the logic, or move getDefaultMessage outside the component or wrap it in useCallback.

Suggested change
const getDefaultMessage = () => {
const freq = frequencies.find((f) => f.type === selectedPosition);
if (freq) {
return `CONTACT ME ON ${airportIcao}_${selectedPosition} ${freq.freq}`;
}
return 'CONTACT ME ON FREQUENCY';
};
// Use useMemo to ensure consistent message evaluation
const currentMessage = useMemo(() => {
return customMessage.trim() || getDefaultMessage();
// Use useMemo to ensure consistent message evaluation
const currentMessage = useMemo(() => {
if (customMessage.trim()) {
return customMessage.trim();
}
const freq = frequencies.find((f) => f.type === selectedPosition);
if (freq) {
return `CONTACT ME ON ${airportIcao}_${selectedPosition} ${freq.freq}`;
}
return 'CONTACT ME ON FREQUENCY';

Copilot uses AI. Check for mistakes.
Comment thread src/components/modals/AtisReminderModal.tsx Outdated
Comment thread src/utils/hateSpeechFilter.ts Outdated
Comment thread server/utils/hateSpeechFilter.ts Outdated
Comment thread src/utils/hateSpeechFilter.ts
Comment thread server/utils/hateSpeechFilter.ts
Comment thread server/db/chats.ts
Comment thread src/main.tsx
Comment thread src/components/tools/ContactAcarsSidebar.tsx Outdated
1ceit and others added 5 commits October 29, 2025 00:35
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@1ceit 1ceit merged commit 5ff7f05 into main Oct 29, 2025
1 check passed
@dev-banane dev-banane deleted the FIxChat branch November 22, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants