MoonshotAI / MoonshotAI/kimi-code
v2 engine (default): `/sessions` and `--continue` no longer show/up into old sessions of the current working directory
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
Summary (main complaint)
With the v2 engine as the CLI default (#2627), the interactive /sessions picker (working-directory scope) and kimi --continue stop listing/resuming the older sessions of the current working directory. /sessions silently shows an empty/filtered list for the cwd, and --continue falls back to a fresh session (No sessions to continue under "<workDir>"; starting a fresh session.).
kimi --session <id> (resume directly by id) still works, and a fresh v2 session in the same dir is listed — this is why it is easy to miss.
Repro
- Have older sessions under a workdir whose
state.jsonrecords onlyworkDir(legacy/v1-era) and nocwd, or that live in a legacy/alias bucket. cdinto that workdir.- Run
/sessions(orkimi --continue). - Observed: old sessions are not listed / not resumed. Expected: they appear under the cwd scope.
Root cause
The v2 listing path filters by workspace-id set derived from the workdir, not by the physical session bucket like v1 did:
/sessionspicker (cwd):fetchSessions('cwd')→listSessionsPage({ workDir })(apps/kimi-code/src/tui/kimi-tui.ts) → SDKworkspaceIdsFor(workDir)(packages/node-sdk/src/sdk-rpc-client-v2.ts:1080) →klient.global.sessions.list({ workspaceIds, … })(v2 index).workspaceIdsFormatches a workspace only whennormalizeWorkDir(workspace.root) === workDir; legacy/alias buckets that don't resolve to the requested id-set are not returned.
kimi --continue(print mode):index.listRecent({})then a client-side exact stringsummary.cwd === workDir(apps/kimi/src/cli/v2/run-v2-print.ts:362) — fails on path variations (symlink, trailing slash) and on sessions lacking an exactcwd.
Both converge on the same underlying gap: the v2 index/directory mapping does not fully reconcile v1-era buckets and sessions for "sessions of this working directory".
Suggested fix
Two levels, prefer the robust one:
- Recommended (server-side): make
klient.global.sessions.list/ the v2 session-index list accept aworkDir(or resolve the full alias bucket set for a workDir, including legacy buckets) instead of requiring an exact workspace-id set. This restores/sessionsand--continuetogether and scales (no client-side scan of every session). - Minimal (client-side): in
run-v2-print.ts(--continue), normalize the comparison toresolve(summary.cwd) === resolve(workDir)— but this only fixes print mode, not the TUI/sessionspicker.
Related upstream work
- #2627 — v2 engine became the CLI default (behavioral change introducing this).
- #1659 ("preserve legacy buckets and coordinate queries", open) explicitly describes the sibling gap: "The v1
SessionStore.listWorkDirpath still reads only the canonical bucket for legacy alias sessions; fixing that requires a separate indexed query change." The/sessionspicker regression is the user-visible face of the same missing reconciliation. - #1390 (merged) — rebuilds the session index on boot; covers missing index lines, not this workdir-scoped listing.
Happy to open a PR with the client-side normalization first and help shape the server-side workdir-scoped query.
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
Trace the /sessions path from apps/kimi-code/src/tui/kimi-tui.ts through packages/node-sdk/src/sdk-rpc-client-v2.ts, then compare it with apps/kimi/src/cli/v2/run-v2-print.ts. Inspect how workspaceIdsFor(workDir) and the client-side summary.cwd === workDir filter handle legacy or alias buckets. Done means older sessions for the current working directory appear in /sessions and can be resumed with --continue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend-api-design, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100