Enhance chat server reliability, fix crisis detection logic, and impr…#42
Open
navin-oss wants to merge 1 commit into
Open
Enhance chat server reliability, fix crisis detection logic, and impr…#42navin-oss wants to merge 1 commit into
navin-oss wants to merge 1 commit into
Conversation
…ove error handling
- Database: Added `nickname` column to `messages` table for persistent chat history.
- Backend:
- Refactored `ChatServer` to use `WebSocketServer` and fix race conditions in connection handling.
- Improved `crisisDetection` logic to correctly aggregate keywords and prioritize risk levels.
- Fixed `journal` API routes to return 404 for non-existent resources.
- Frontend:
- Updated `ChatRoom` to gracefully handle missing nicknames.
- Fixed TypeScript errors in API client.
Co-authored-by: navin-oss <181780004+navin-oss@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses several critical issues and enhances the codebase:
Chat System Improvements:
nicknamecolumn to themessagestable. This ensures that historical messages retain the sender's identity even without complex joins, which was a missing feature.WebSocketServer(fixing deprecation) and refactored connection management to use aMapbased onuserId. This prevents duplicate connections and fixes a race condition where a user reconnecting could be disconnected by their previous session closing.nicknamewith each message.Crisis Detection Enhancements:
API Reliability:
journalroutes (PUT, DELETE) to correctly identify when a resource doesn't exist (using PostgREST error codes or checking returned data) and return a 404 status instead of 500 or success.Frontend Stability:
api.tsrelated to `HeadersInit