MoonshotAI / MoonshotAI/kimi-code
[Bug] 会话标题在 state.json 被更新后,/sessions 选择器仍显示旧标题(query-store 缓存不同步)
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
问题描述
会话标题存在两处存储:state.json 和 $KIMI_CODE_HOME/cache/query-store/ 缓存库。当标题在 state.json 层面发生变更后(例如会话结束后的外部工具修正、或直接验证过的合法改写),TUI 的 /sessions 选择器永远显示旧标题,而终端 Tab 标题、kimi session list 命令均显示新标题——两处数据不一致。
复现步骤
- 开一个会话,发一句"你好",退出(自动标题 = "你好")
- 退出后修改该会话
state.json的title字段(如改为"蒙自考勤表生成",同时titleKind: "custom") - 重新 resume 该会话:
- 终端 Tab 标题显示新标题 ✅
kimi session list显示新标题 ✅
- 在会话中打开
/sessions选择器:该会话仍显示旧标题"你好" ❌
根因分析(已定位)
/sessions选择器与kimi session list的数据源是cache/query-store/(16 分片 + WAL + generations 的私有 KV 格式),而非直接读 state.json- 检查 WAL 记录发现:CLI 每轮都会重写该会话的缓存记录,
lastPrompt字段每次都刷新,但title字段始终保留缓存中的旧值——title 只在 CLI 自身触发标题变更(首轮自动命名、/title命令)时才写入缓存 - resume 会话时,缓存记录中的 title 不会与 state.json 同步
附带发现
- 删除
cache/query-store/后,kimi session list直接返回 "No sessions found"——CLI 没有从 state.json 重建缓存的机制,用户一旦缓存损坏将丢失整个会话列表索引(会话文件本身还在)。这也算是一个隐患
期望
- resume 会话或写入缓存记录时,title 应以 state.json 为准同步(缓存记录每轮都在重写,顺带同步 title 成本很低)
- 提供 query-store 缓存损坏后的重建/修复手段(如
kimi doctor --fix或启动时校验重建)
环境
- Kimi Code CLI(Windows 原生单文件版)
- 复现时间:2026-09-15
相关 issue
- #1544(AI 自动总结标题)——如果官方实现自动标题/标题后改,这个缓存同步问题会更突出:标题在首轮之后被更新是自动标题的天然场景,缓存不同步会导致选择器永远显示第一句话
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the /sessions selector and kimi session list through cache/query-store/, then compare their cached title with the session state.json during resume and cache-record rewrites. Done means the selector reflects the current state.json title and the reported cache-loss recovery concern has a defined, tested outcome.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100