Skip to content

Shared Rules — Conversation Runtime And Provider Boundary

1. Thuật ngữ chuẩn

Thuật ngữTên kỹ thuậtÝ nghĩa
Hội thoạiconversationHeader conversation
Thành viên hội thoạiconversation_memberMembership + read/mute/in_call state
Tin nhắnconversation_messageMessage body và metadata
Mentionconversation_message_mentionMapping message -> người được nhắc + read_at
Feed runtimeconversation_currentRead model denormalized cho list
Unread searchsearch_unread_conversation_messagesFunction lấy unread feed
Overlay callTwilioVideoFull-screen call runtime dựa vào store
Conference dialogStringeeConferenceDialogModal conference runtime Stringee

2. Runtime matrix

LớpSource of truthGhi chú
Conversation listconversation_current + store conversationsFE list nên đọc từ read model, không từ raw tables
Message listconversation_message + store messages[cid]merge bằng mergeSortedConversationMessages()
Read stateconversation_member.read_atFE intent có, nhưng mutation đang stub
Stringee authaction stringeeTokenprovider optional, có guard unsupported
Twilio authaction twilioTokenprovider optional, có guard unsupported
Conference createaction createConferencecontract update conversation hiện đang drift

3. Invariants hệ thống đang ngầm dùng

  1. User chỉ đọc được conversation nếu là member (public_conversation.yaml:36).
  2. User chỉ tự update conversation_member.read_at, mute_until, in_call của chính mình (public_conversation_member.yaml:72).
  3. User chỉ insert message khi conversation chưa closed và có member record (public_conversation_message.yaml:33).
  4. Twilio overlay chỉ bật khi conversationStore.currentConversation.video_room_id có giá trị (TwilioVideo/index.tsx:14).
  5. ConversationList kỳ vọng có mutation update membership, nhưng implementation thực hiện tại chưa tồn tại (ConversationList.tsx:54, :188).

4. Provider matrix

| Provider | Action backend | FE entrypoint | Rủi ro | |---|---|---| | Stringee user token | stringeeToken | StringeeProviderWrapper | provider có thể unsupported nếu env thiếu | | Stringee room token | stringeeToken(data.room, record) | StringeeConferenceDialog | phụ thuộc room id và action GraphQL sống | | Twilio room token | twilioToken(data.room) | useTwilio / TwilioVideo | preview payload mismatch làm lệch audio state | | Conference create | createConference(type) | bất kỳ surface gọi action này | đang update contract field không khớp FE/runtime list |

  1. conversation_current chứa sẵn last_message_*, unread_messages_count, read_at, video_room_id, video_room_provider (public_conversation_current.yaml:23).
  2. search_conversation_currentsearch_unread_conversation_messages đều nhận hasura_session làm session argument, nên kết quả là user-scoped read model (public_search_conversation_current.yaml:1, public_search_unread_conversation_messages.yaml:1).
  3. FE store merge conversations theo id và sort giảm dần theo last_message_created_at (useConversationStore.ts:23).
  4. Message merge không append mù; utility cố merge theo created_atid để tránh duplicate (utils.ts:1).

6. Findings ưu tiên cao

IDMức độMô tả
SR-F01CaoConversationList click item sẽ gọi mutation stub và có thể throw ngay trong UI (ConversationList.tsx:188).
SR-F02CaoConversationMessages có composer nhưng không gửi message thật (ConversationMessages.tsx:92).
SR-F03CaoROUTE_CONVERSATION_CONFERENCE không có route record mounted, dù được push từ detail page (ConversationDetail.tsx:13, module.ts:12).
SR-F04Rất caocreateConference update external_call_id thay vì video_room_id/video_room_provider, rất dễ lệch hẳn với FE Twilio overlay contract (conference.go:60, TwilioVideo/index.tsx:14).
SR-F05CaocreateConference nuốt lỗi update conversation bằng log-only path, nên FE có thể nhận success dù DB không cập nhật (conference.go:79).
SR-F06Trung bìnhuseConversation.tsConversationProvider đều gần như pass-through, cho thấy orchestration layer của module chưa tồn tại (useConversation.ts:1, ConversationProvider.tsx:12).

7. QA checklist tối thiểu

  • Click vào 1 item trong conversation list, xác nhận app có throw vì mutation stub hay không.
  • Bấm icon video từ detail workspace, xác nhận route conference có thật hay fail router.
  • Tạo conference type stringee và kiểm tra conversation record có update field nào hữu ích cho FE hay không.
  • Chạy Twilio preview với mic tắt, xác nhận room runtime có nhận đúng trạng thái microphone không.
  • Insert message / mention / reaction bằng role user, xác nhận Hasura permission chặn đúng ngoài scope member/owner.