feat(system): implement graceful shutdown and expand websocket events
Improve system reliability and real-time capabilities by implementing a robust lifecycle management system and adding new broadcast events for attachments and voice recordings. - Implement asynchronous graceful shutdown in backend to close HTTP, WebSocket, Redis, and database connections. - Add new WebSocket broadcast events: `attachment_created`, `voice_recording_started`, `voice_recording_stopped`, `voice_recording_uploaded`, and `analysis_queue_status`. - Refactor media status handling to use boolean `playing` state instead of string-based status. - Centralize `PageResult` and `VoiceRecording` types to improve consistency between frontend and backend. - Update frontend API client to include `listRecordings` and handle new WebSocket event types. - Fix type mismatches in voice command handling and media status reporting.
This commit is contained in:
@@ -11,6 +11,7 @@ export interface WsHandlers {
|
||||
onMessageUpdated?: (data: unknown) => void;
|
||||
onMessageDeleted?: (data: unknown) => void;
|
||||
onMessageAnalyzed?: (data: unknown) => void;
|
||||
onAttachmentCreated?: (data: unknown) => void;
|
||||
onAttachmentUploaded?: (data: unknown) => void;
|
||||
onUserState?: (users: unknown[]) => void;
|
||||
onUiState?: (state: unknown) => void;
|
||||
@@ -99,8 +100,7 @@ function doConnect(): WebSocket {
|
||||
h.onVoiceActiveUser?.(msg.data);
|
||||
break;
|
||||
case "attachment_created":
|
||||
// attachment_created is informational — same data shape as message_created
|
||||
h.onMessageCreated?.(msg.data);
|
||||
h.onAttachmentCreated?.(msg.data);
|
||||
break;
|
||||
case "analysis_queue_status":
|
||||
// analysis_queue_status is monitoring-only — no UI action needed
|
||||
@@ -147,6 +147,7 @@ export function useDashboardSocket(handlers: WsHandlers) {
|
||||
onMessageUpdated: (d) => handlersRef.current.onMessageUpdated?.(d),
|
||||
onMessageDeleted: (d) => handlersRef.current.onMessageDeleted?.(d),
|
||||
onMessageAnalyzed: (d) => handlersRef.current.onMessageAnalyzed?.(d),
|
||||
onAttachmentCreated: (d) => handlersRef.current.onAttachmentCreated?.(d),
|
||||
onAttachmentUploaded: (d) =>
|
||||
handlersRef.current.onAttachmentUploaded?.(d),
|
||||
onUserState: (u) => handlersRef.current.onUserState?.(u),
|
||||
|
||||
Reference in New Issue
Block a user