MoonshotAI / MoonshotAI/kimi-code

[Bug] 会话标题在 state.json 被更新后,/sessions 选择器仍显示旧标题(query-store 缓存不同步)

Open
#3,791 0 comments 0 reactions 0 assignees View on GitHub

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 命令均显示新标题——两处数据不一致。

复现步骤

  1. 开一个会话,发一句"你好",退出(自动标题 = "你好")
  2. 退出后修改该会话 state.jsontitle 字段(如改为"蒙自考勤表生成",同时 titleKind: "custom"
  3. 重新 resume 该会话:
    • 终端 Tab 标题显示新标题
    • kimi session list 显示新标题
  4. 在会话中打开 /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 重建缓存的机制,用户一旦缓存损坏将丢失整个会话列表索引(会话文件本身还在)。这也算是一个隐患

期望

  1. resume 会话或写入缓存记录时,title 应以 state.json 为准同步(缓存记录每轮都在重写,顺带同步 title 成本很低)
  2. 提供 query-store 缓存损坏后的重建/修复手段(如 kimi doctor --fix 或启动时校验重建)

环境

  • Kimi Code CLI(Windows 原生单文件版)
  • 复现时间:2026-09-15

相关 issue

  • #1544(AI 自动总结标题)——如果官方实现自动标题/标题后改,这个缓存同步问题会更突出:标题在首轮之后被更新是自动标题的天然场景,缓存不同步会导致选择器永远显示第一句话

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.