fix(chat): reveal the home page once after a two-phase bootstrap

The loading screen now owns every wait: starter questions, today's
starlanguage and the rectification entry summary are fetched in a prepare
phase before reveal (4s budget, static fallbacks), the rectification chunk is
warmed, recent sessions are prefetched, and no component spinner remains
after the page appears. BUG-479.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0193vBv6w5MV2cifdTUu9H5P
This commit is contained in:
Jesse_Chen
2026-09-02 04:39:04 +00:00
parent 7557e0d2ed
commit 482796fc52
10 changed files with 305 additions and 39 deletions
+16
View File
@@ -7362,3 +7362,19 @@
- 相关记录:BUG-477
- 复发自:无
- 修复版本:待发布
## BUG-479 | 首页揭幕后仍有组件级加载:外层加载屏只等三样,推荐问题、今日星语、校正摘要各自转圈
- 状态:resolved
- 首次发现:2026-09-02
- 最近更新:2026-09-02
- 影响面:`page.tsx` 启动 effect 与揭幕条件、`starter-home.tsx``globals.css``.starter-loading`)、`lib/home-bootstrap.ts`(新增)、`DESIGN.md` §9
- 用户现象:登录后先看一次整页加载屏,进入界面后推荐问题位置再转一次(`starter-loading`)、今日星语卡 `aria-busy` 并显示「正在写下今天的星语。」、切会话消息区出现 spinner;用户感受是"进来了又在等"。
- 触发条件:任何一次进入首页;切换到消息尚未缓存的会话。
- 根因:`setHydrated(true)` 只等账户、模型目录、会话列表;推荐问题、今日星语、校正入口摘要三个 effect 都以 `hydrated` 为门槛,只能在揭幕之后才发请求,于是各自带一套等待表现。这些请求彼此无数据依赖,串行体验是历史堆出来的。
- 修复:启动分两阶段(`bootstrapPhase: "account" → "prepare"`)。账户阶段完成后不揭幕,改进入 prepare:三个 effect 改以 `bootstrapPhase` 为门槛在揭幕前并行发起,并预热校正分包 `import()`;揭幕 effect 在全部适用项就绪(`bootstrapPrepareSettled`)或 4 秒预算(`BOOTSTRAP_PREPARE_TIMEOUT_MS`,从进入 prepare 起算)到期时 `setHydrated(true)`。加载屏文案按阶段切换(`bootstrapLoadingCopy`)。揭幕后删除 `starter-loading` 分支、今日星语 `aria-busy` 与「正在写下」文案(pending 显示静态「今天的星语还没写出来。」,到达后静默替换)、会话切换的 `InlineSpinner`(保留 `sr-only` 文案)。揭幕后按侧栏顺序后台预取最近 5 条会话消息(`sessionIdsToPrefetch`)。账户阶段失败仍直接揭幕到错误屏;8 秒 bootstrap 超时不变。
- 验证:`home-bootstrap-reveal.test.ts`(纯函数 + 源码合同:prepare 门槛 ×3、揭幕延时、预热、预取、揭幕后无 spinner、加载屏 DOM 合同);`daily-starlanguage.test.ts` / `starter-questions.test.ts` 按例外条款改读新门槛;`tsc``eslint` 0 error、`next build` `/` Static、首屏 gzip-9 513570 → 513889 B+0.06%)。
- 防复发:任何首页数据拉取不得以 `hydrated` 为门槛再在揭幕后展示等待态;新增的揭幕前依赖加入 `bootstrapPrepareSettled` 的输入,而不是各自转圈。`main.app-loading[aria-busy="true"]` / `main.app-loading-error` 选择器被 `stale-client-recovery` 依赖,不得改。
- 相关记录:BUG-464(消息按需加载引入的首屏消息等待,流式轮已把当前会话消息前移到揭幕前)、BUG-470effect 内 setState 规则)
- 复发自:无
- 修复版本:待发布