chore(chat): refactor chat init into separate quota and history actors

Split `chatInitActor` into `loadQuotaActor` (guest quota fetch) and `loadHistoryActor` (local → network → save sync), and add `quotaLoaded` / `historyLoaded` state flags so the UI can display loading status during the new local-first history hydration flow. Also drop the now-unused `ChatInit` event and pipe Next.js stdout/stderr to a persistent log file in the post-receive hook for easier troubleshooting.
This commit is contained in:
2026-06-15 16:21:40 +08:00
parent cfc6de5a8c
commit 1f3980d461
8 changed files with 296 additions and 152 deletions
+12
View File
@@ -39,6 +39,16 @@ export interface ChatState {
isLoadingMore: boolean;
hasMore: boolean;
historyOffset: number;
/** 游客配额加载完成标**志****仅** guestSession 期间) —— default false
* - guestSession.initializing **走** always barrier`quotaLoaded && historyLoaded` **才**进** ready
* - userSession **永不为** true**不**调 loadQuota)—— OK**不**影响 barrier
*/
quotaLoaded: boolean;
/** history 加**载**完成标**志**initial load —— local → network → save 跑**完**
* - guestSession.initializing / userSession.initializing 走 always barrier
* - **不**被 `loadMoreHistoryActor` 设**置****翻**页**是**另**一**码**事**
*/
historyLoaded: boolean;
}
export const initialState: ChatState = {
@@ -51,4 +61,6 @@ export const initialState: ChatState = {
isLoadingMore: false,
hasMore: true,
historyOffset: 0,
quotaLoaded: false,
historyLoaded: false,
};