MoonshotAI / MoonshotAI/kimi-code

v2 engine (default): `/sessions` and `--continue` no longer show/up into old sessions of the current working directory

Open
#2,951 2 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

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.json records only workDir (legacy/v1-era) and no cwd, or that live in a legacy/alias bucket.
  • cd into that workdir.
  • Run /sessions (or kimi --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:

  • /sessions picker (cwd): fetchSessions('cwd')listSessionsPage({ workDir }) (apps/kimi-code/src/tui/kimi-tui.ts) → SDK workspaceIdsFor(workDir) (packages/node-sdk/src/sdk-rpc-client-v2.ts:1080) → klient.global.sessions.list({ workspaceIds, … }) (v2 index).
    • workspaceIdsFor matches a workspace only when normalizeWorkDir(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 string summary.cwd === workDir (apps/kimi/src/cli/v2/run-v2-print.ts:362) — fails on path variations (symlink, trailing slash) and on sessions lacking an exact cwd.

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:

  1. Recommended (server-side): make klient.global.sessions.list / the v2 session-index list accept a workDir (or resolve the full alias bucket set for a workDir, including legacy buckets) instead of requiring an exact workspace-id set. This restores /sessions and --continue together and scales (no client-side scan of every session).
  2. Minimal (client-side): in run-v2-print.ts (--continue), normalize the comparison to resolve(summary.cwd) === resolve(workDir) — but this only fixes print mode, not the TUI /sessions picker.

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.listWorkDir path still reads only the canonical bucket for legacy alias sessions; fixing that requires a separate indexed query change." The /sessions picker 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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.