3.2 KiB
3.2 KiB
IM chat history frontend
Changes
admin/src/views/tcm/diagnosis/components/ImChatRecordPanel.vuenow displays archived messages immediately, starts synchronization automatically, displays real progress, and distinguishes empty history from read errors, sync failures, and incomplete synchronization. Existing rows remain visible during refresh and after failures. Success notifications occur only after a manually requested sync completes and the archive reload succeeds.admin/src/utils/im-chat-history.tsowns the asynchronous lifecycle. It continues withsync_tokenuntilcompleted, reloads the archive every three completed pages or after a page takes the elapsed refresh interval past two seconds, and always performs a fresh archive read after completion. The next automatic sync starts 30 seconds after the current run ends. Requests within one active diagnosis are coalesced; diagnosis identity plus generation checks reject stale responses. Unmount, page hiding, and keep-alive deactivation cancel the timer and invalidate pending work.admin/src/api/tcm.tsexposes typed archive/progress results and the optionalscope: 'current'sync request. Both history endpoints use a 30-second timeout, disabled retries, and disabled duplicate-request cancellation. They read the raw response envelope and preserve backend error messages instead of losing them through the default response transform; successful automatic requests do not trigger global success toasts.admin/tests/im-chat-history.test.cjsexecutes the actual controller and actual compiled component setup with controlled asynchronous API responses and clocks.
Verification
Executed from D:/web/zyt/admin:
node --test tests/im-chat-history.test.cjs
15 tests passed; 0 failures
Coverage includes initial archive display while cloud sync is pending, fresh read after sync completes before the initial read, continuation tokens, intermediate refresh by pages/time, patient switching, unmount invalidation, preservation of rows on read/sync failure, partial failures, missing progress tokens, manual-only success notifications, duplicate clicks, one non-overlapping 30-second timer, visibility/deactivation, raw API errors/options, SFC compilation, and real panel lifecycle wiring.
git diff --check passed for the frontend files. No business database, Tencent IM, or live API requests were used. Repository-wide build/type checks and browser verification remain with the parent task.
Integration details
- Archive reads always send
{ diagnosis_id, only_archived: 1 }. - Panel synchronization starts with
{ diagnosis_id }; subsequent requests add the returnedsync_token. The panel intentionally uses the patient-wide scope;scope: 'current'is available for the parent's chat-dialog caller. - The panel treats
completed: truewitherrororerrorsas a completed but incomplete sync, refreshes successful messages, and displays the accumulated errors. - Existing callers unmount the panel when switching away from the chat tab; additional hooks cover browser hiding and keep-alive route deactivation.
- All prior appointment-mode changes were preserved. No other existing files were changed by this subtask.
.trellis/is absent in this checkout.