Files
cc-web/.trellis/tasks/08-06-fix-session-preview-cwd/research/root-cause.md
2026-08-07 10:54:08 +08:00

30 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 根因证据:大会话预览误读嵌套 cwd
## 现场
- 会话 ID:`bf88c202-711a-4f2f-b6e3-b29062f37b20`
- 文件大小:909402 bytes
- 顶层 `cwd`:`/mnt/e/华电众信/2026/上下游协同平台`
- 预览误读 `cwd`:`/mnt/e/我的项目/MCP/fineui-web-mcp`
- 第一个错误键来自 `$.messages[28].toolCalls[39].input.arguments.cwd`。
## 时序
1. 刷新触发 `sendSessionList()`。
2. `loadSessionMetaFromFile()` 因文件超过 512KB 进入预览分支。
3. `jsonStringFieldFromPreview()` 以正则命中任意层级第一个 `cwd`。
4. 前端 `session_list` 整批替换列表,显示错误项目。
5. 点击后 `handleLoadSession()` 完整解析 JSON,发送正确顶层 `cwd`。
6. 后续列表推送重复第 1—4 步,产生往返漂移。
## 推荐修复边界
只修服务端预览解析,让字段提取具备 JSON 顶层感知能力;不在前端掩盖错误数据。
## 必测预览边界
- 头部包含嵌套 `cwd`,尾部包含顶层正确 `cwd`。
- 顶层字段跨头部或尾部预览截断边界时安全降级。
- 头尾片段拼接处不能组合出不存在的顶层键值。
- 专项回归目标:`session-preview-metadata`。