docs(plan): add chat state machine refactor design

Update implementation_plan.md with a detailed refactor plan that splits
`chatInitActor` into two independent actors (`loadQuotaActor` +
`loadHistoryActor`) and redesigns the history loading flow to follow
local → network → save semantics so the UI sees local data first,
then network data.

Key changes outlined in the plan:
- Add new events: `ChatQuotaLoaded`, `ChatHistoryLocalLoaded`,
  `ChatHistoryNetworkLoaded`, `ChatHistorySyncDone`
- Remove dead-code `ChatInit` event
- Extend `ChatState` with `quotaLoaded` and `historyLoaded` flags
- Use an `always` barrier in `guestSession.initializing` and
  `userSession.initializing` so both tasks must complete before
  transitioning to `ready`
- Guest init runs `loadQuota` + `loadHistory` in parallel; non-guest
  init runs `chatWebSocket` + `loadHistory` as independent tasks

Also adds `implementation_plan` to .gitignore.
This commit is contained in:
2026-06-15 17:05:32 +08:00
parent 9b28404673
commit fa694af723
5 changed files with 438 additions and 28 deletions
-8
View File
@@ -96,14 +96,6 @@ export function mapTotalQuotaResult(
return fallback;
}
// ============================================================
// Init 任务 1:游客配额(**纯** local)—— `loadQuotaActor` 调
// ============================================================
/**
* 读取游客配额(**仅** guestSession 有意义)
* - 游客**日**配 + 总**配** 两**项**都**从** ChatStorage 拉(**纯** local**无**网络)
* - 失**败**返 fallback 0**不**抛)—— **让** UI **还**是**能**进** ready
*/
export async function readGuestQuota(): Promise<{
remaining: number;
total: number;