Skip to content

perf(flow-chat): stabilize historical session rendering#1077

Merged
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/perf-startup-visible-ready
Jun 5, 2026
Merged

perf(flow-chat): stabilize historical session rendering#1077
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/perf-startup-visible-ready

Conversation

@limityan
Copy link
Copy Markdown
Collaborator

@limityan limityan commented Jun 5, 2026

修改前后对比

Refs #949

测试口径:Windows desktop release-fast 性能 E2E,结论以用户场景端到端结果为准。下面的“可比对比样本”和“质量防护样本”不是同一个 fixture,不能横向比较数值。

可比对比样本

这组数据用于判断 issue 关键场景的端到端变化,修改前 使用 issue 创建期或最早可追溯的问题基线。

用户场景 修改前 修改后 变化 结论
冷启动到聊天主界面可操作 1538.9 ms 1167.6 ms -371.3 ms (-24.1%) 较 issue 创建期有下降,但冷启动仍需继续优化
首次打开大历史 session,到最新正文可读 965.1 ms 396.3 ms -568.8 ms (-58.9%) 有明确改善
首次打开大历史 session,到完整历史补齐 1118.1 ms 765.1 ms -353.0 ms (-31.6%) 有改善,后台补齐仍可继续优化
再次打开大历史 session,到最新正文可读 457.7 ms 320.5 ms -137.2 ms (-30.0%) 有改善

质量防护样本

这组数据来自更重的 120-turn dense fixture,只用于验证 loading 回闪、裸白和滚动回跳防护,不作为上表的性能 delta 依据。

防护场景 最新样本
首次打开,到最新正文可用 1115.2 ms
首次打开,到完整历史补齐 2882.8 ms
再次打开,到最新正文可用 1202.3 ms
loading toggle 0
滚动跳动 0
交互后裸白采样点 0

变更范围

  • 历史 session 打开时先给出轻量点击反馈,避免从当前内容直接切到整页 loading 或空白状态。
  • 本地大历史 session 先恢复可读尾部内容,最新正文可见后释放完整历史补齐,并在投影切换期间保留可见内容,降低白屏和滚动跳动风险。
  • 收紧最新轮次锚定、虚拟列表估高和完成态 tool item 过渡,避免后台补齐引发二次布局跳变。
  • Deferred IDE/MCP/ACP 和 main after-render 初始化现在等待 startup overlay 完成移交后再启动,避免和首屏移交窗口竞争。
  • 虚拟列表文本估高改为基于 length 计算,避免为长文本估高额外分配重复字符串。
  • 删除 session 或关闭 workspace 时同步取消 pending full-hydrate、清理 deferred projection 和 apply request,避免完整历史在内存中滞留。
  • Windows 启动展示等待由固定 150 ms 改成最多 150 ms 的 maximize 状态等待;不改变关闭按钮默认语义。

风险与功能影响

  • 历史 session 打开会增加最多两帧的可见反馈等待,用于让点击反馈先完成绘制。
  • 完整历史内容仍可能晚于最新内容可读;搜索、滚动和明确需要完整历史的交互会触发完整投影。
  • Deferred systems 更晚启动,可能让 IDE/MCP/ACP 的第一次使用更接近按需成本;这是为了避免抢占 startup overlay 移交和历史 session 首屏窗口。
  • 冷启动仍未达到可关闭问题的程度,后续仍需要继续拆解 interactive_shell_ready 相关耗时。

验证

  • pnpm run lint:web
  • pnpm run type-check:web
  • pnpm --dir src/web-ui run test:run src/app/startup/startupPerformanceContract.test.ts src/app/startup/deferredStartupSystems.test.ts src/flow_chat/components/modern/ModernFlowChatContainer.history-state.test.tsx src/flow_chat/store/FlowChatStore.test.ts
  • pnpm --dir src/web-ui run test:run src/app/startup/deferredStartupSystems.test.ts src/app/startup/startupPerformanceContract.test.ts src/flow_chat/components/modern/VirtualMessageList.layout.test.ts
  • pnpm --dir src/web-ui run test:run src/flow_chat/services/flow-chat-manager/SessionModule.test.ts src/flow_chat/components/modern/ModernFlowChatContainer.history-state.test.tsx src/flow_chat/store/FlowChatStore.test.ts src/flow_chat/components/modern/VirtualMessageList.layout.test.ts src/flow_chat/components/modern/modelRoundItemGrouping.test.ts src/app/startup/startupPerformanceContract.test.ts
  • cargo check -p bitfun-desktop
  • git diff --check
  • git diff --cached --check
  • pnpm run desktop:build:release-fast
  • BITFUN_E2E_PERF_SESSION_ID=perf-flicker-debug-000 pnpm run e2e:test:perf:release-fast

@limityan limityan force-pushed the yanzhn/perf-startup-visible-ready branch 2 times, most recently from 9268a69 to da196ac Compare June 5, 2026 09:45
@limityan limityan force-pushed the yanzhn/perf-startup-visible-ready branch from da196ac to 871be3d Compare June 5, 2026 10:03
@limityan limityan marked this pull request as ready for review June 5, 2026 10:16
@limityan limityan merged commit 5610477 into GCWing:main Jun 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant