kimi-code
kimi-code copied to clipboard
feat: built-in session storage management (list / archive / cleanup)
Problem
Session data under ~/.kimi-code/sessions grows without bound and there is no built-in way to inspect, sort, archive, or clean it up. The documented cleanup path is manually deleting directories on disk.
Evidence (real Windows machine)
- 1.6 GB across 95 sessions / 31 workspaces; largest single session 505 MB — a research session with 30+ sub-agents, where each sub-agent writes its own
wire.jsonl(150 MB main + 97 MB + 62 MB + 46 MB sub-agent files inside one session). - 39 of the 95 sessions belonged to a single workspace (the user's home directory used as a workspace).
- Every app start reconciles the full session index. Log shows the count growing over two weeks, then dropping after manual archiving:
session index reconciliation repaired drift generation=1 sessions=82 upserted=0 removed=13 - Session files are appended constantly, so large trees also add sustained AV/Defender scan load.
Impact
- Startup cost grows with session count (index reconciliation + search-index open; measured index open grew 1.1s → 2.8s as the index grew).
- Users must hand-edit the filesystem to reclaim space, with no visibility into what is safe to remove or how much each session costs.
Proposal
A storage/session management surface (TUI panel or /sessions command) that:
- lists sessions grouped by workspace, with size, last-active date, and sub-agent breakdown
- supports archive (move out of
sessions/, restorable) and delete with confirmation - shows total and per-workspace storage usage
- warns when a single session crosses a size threshold (e.g. 50 MB) and suggests starting a fresh session