Skip to content

Module Overview — Conversation Runtime And Provider Boundary

1. conversation thực tế đang chia thành 4 lớp

LớpThành phầnVai trò
Workspace shellConversationDetail, Conversation, ConversationList, ConversationMessagesUI list/detail/message cơ bản
Provider runtimeStringee wrapper, Twilio overlay, conference componentsToken, connect/join room, media tracks
Store/read-model layeruseConversationStore, conversation_current, search functionsCache list/messages, unread/search surfaces
Action layertwilioToken, stringeeToken, createConference, stringeeCallEventSinh token, tạo conference, bridge vendor

Điểm quan trọng là 4 lớp này chưa được một composition trung tâm điều phối; useConversation.ts hiện rỗng (diva-admin/src/modules/conversation/compositions/useConversation.ts:1).

2. Surface map

FE routes

Route/configVai trò
/conversationRoot module, redirect nội bộ
/conversation/:idDetail workspace
/conversation/:id/conferenceCó constant/config name nhưng không có route record thật
/conversation/stringeeChỉ là config constant, không có route record riêng

Runtime backend

RuntimeVai trò
Hasura CRUD conversation*Membership, messages, mentions, unread/read state
Function search_conversation_currentFeed runtime denormalized của conversation list
Function search_unread_conversation_messagesFeed unread riêng
conversation-api actionsToken cho Twilio/Stringee, create conference, Stringee call event

3. Route shell có drift thật

module.ts chỉ mount đúng một child route:

  • ROUTE_CONVERSATION_DETAIL -> ConversationDetail (module.ts:17)

Nhưng ConversationDetail lại push sang:

  • ROUTE_CONVERSATION_CONFERENCE (ConversationDetail.tsx:13)

Trong repo hiện tại, constant này không được mount thành route record nào cả; search toàn bộ src/router và module conversation chỉ thấy nó xuất hiện ở types, module configsrouter.push call. Đây là drift có thể làm conference route vỡ ngay khi người dùng bấm video.

4. Workspace realtime vẫn là shell một phần

Những gì đã có

SurfaceTrạng thái
Conversation listCó infinite scroll, unread badge, update read state intent
Message viewCó render stream + reverse scroll + composer UI
StoreCó merge conversations/messages, giữ cursor và currentConversation

Những gì còn thiếu hoặc đang scaffold

SurfaceDấu hiệu
Video action trong headerQBtn chưa gắn onClick emit video (Conversation/index.tsx:23)
Update read_at khi click listmutation helper cuối file throw new Error("Function not implemented.") (ConversationList.tsx:188)
Composer send messagehandleChatEnter() return sớm, không gọi mutation nào (ConversationMessages.tsx:92)
Composition orchestrationuseConversation.ts rỗng (useConversation.ts:1)

5. Provider runtime

Stringee

Thành phầnVai trò
StringeeProviderWrapperQuery token rồi mount StringeeProvider
StringeeProviderConnect client, reconnect khi requestnewtoken, emit chat events
StringeeConferenceDialogRequest room token và mount StringeeConference
StringeeConferencePreview -> join -> room runtime + sidebar chat/participants

Twilio

Thành phầnVai trò
TwilioVideo/index.tsxFull-screen overlay khi currentConversation.video_room_id có giá trị
TwilioVideoPreviewPreview trước khi join
TwilioVideoConnect room, attach/detach local-remote tracks

6. Provider/backend contract đang lệch

createConference

Backend action này:

  1. parse type = meet | stringee,
  2. tạo Google Meet hoặc Stringee room,
  3. nếu có conversation_id, cố update conversation.external_call_id = conference_url (conversation.go:60).

Drift

DriftVì sao quan trọng
FE Twilio overlay đọc conversation.video_room_id (TwilioVideo/index.tsx:14)nhưng createConference không update video_room_id
Metadata permission chỉ expose video_room_id/video_room_provider, không thấy external_call_id trong conversation user/admin permissions (public_conversation.yaml:62, public_conversation_admin.yaml:43)nên mutate external_call_id có thể fail theo role contract
createConference log lỗi update conversation nhưng vẫn return success (conference.go:79)FE có thể nghĩ conference đã gắn vào conversation dù DB không đổi

7. Findings nổi bật

IDFinding
MO-F01ROUTE_CONVERSATION_CONFERENCE không có route record thật, dù detail page đang push sang route này.
MO-F02Nút video ở Conversation chưa emit event, nên kể cả route có tồn tại thì header shell hiện vẫn không khởi động conference từ component này.
MO-F03ConversationList click item sẽ chạm mutation stub và có nguy cơ throw runtime error ngay tại UI.
MO-F04Twilio preview emit audioEnabled, nhưng parent đọc microphoneEnabled; preview choices có thể không được chuyển đúng sang room runtime.
MO-F05createConference update sai field contract (external_call_id) và swallow lỗi mutation conversation, nên conference create có thể “thành công giả”.
MO-F06Nhánh createConference -> stringee không guard ctx.Stringee == nil, khác hẳn stringeeToken, tạo ra một điểm có thể panic hoặc nil dereference khi provider config thiếu.