流式性能问题不能只靠最终 Markdown 文本复现。真实链路里的 provider SSE chunk 数量、chunk 间隔、agent/protocol 合并、renderer IPC、UI chunk batch、Markdown 渲染和动画都会影响 CPU。 只保存完整 response body 再一次性回放,会改变通信节奏,无法稳定复现 renderer 层压力。
E2ENetworkCaptureRecord 新增可选字段:
responseChunkTimeline:response body chunk 列表。responseChunkTimelineTruncated:chunk 时间线达到本地大小上限时置为 true。每个 chunk 包含:
offsetMs:从请求进入 capture proxy 到该 chunk 到达 proxy 的毫秒偏移。byteLength:原始 chunk 字节数。base64:记录到 artifact 的 chunk bytes。responseTextPreview 仍然用于人工查看和现有 usage 解析;性能回放优先使用
responseChunkTimeline。
replay fixture 的 response.chunks 存在时:
content-length,让 Node 以 chunked response 流式发送。offsetMs 后写出。offsetMs 差值等待后写出。response.body 仍保留为完整响应文本,用于报告和旧断言。没有 response.chunks 的旧 fixture 继续一次性返回 response.body。
采集真实 GLM highspeed 响应:
E2E_PROVIDER_HTTP_MODE=capture \
E2E_PROVIDER_PRESET=glmhighspeed \
GLM_HIGHSPEED_E2E_API_KEY=... \
E2E_PROVIDER_PROMPT='输出一篇很长的 Markdown,末尾包含 PERF_TRACE_DONE' \
E2E_PROVIDER_EXPECT_REPLY_TEXT=PERF_TRACE_DONE \
pnpm --filter @zcode/desktop test:e2e -- --spec ./test/e2e/upstream-provider.test.ts
glmhighspeed preset 使用 Anthropic-compatible endpoint
https://open.bigmodel.cn/api/anthropic 和模型 glm-5.1-highspeed。capture 模式在未显式指定
provider preset 时默认仍使用 DeepSeek v4 flash;只有显式设置
E2E_PROVIDER_PRESET=glmhighspeed / LLM_E2E_PROVIDER_PRESET=glmhighspeed
时才会切到 GLM highspeed。GLM highspeed preset 默认不强制选择思考深度;如需覆盖,可显式设置
E2E_PROVIDER_THOUGHT_LEVEL。
capture artifact 默认写入:
packages/desktop/.e2e-home/.zcode/e2e-network-capture/upstream-provider.json
后续回放自定义 fixture 或 capture-derived fixture:
E2E_PROVIDER_PRESET=glmhighspeed \
E2E_PROVIDER_REPLAY_FIXTURE_PATH=/absolute/path/to/replay-fixture-or-capture.json \
pnpm --filter @zcode/desktop test:e2e -- --spec ./test/e2e/upstream-provider.test.ts