fix(cli): resume older working-directory sessions in /sessions and --continue - #2952
fix(cli): resume older working-directory sessions in /sessions and --continue#2952creatiVision wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 5abe837 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5abe8379c8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // alias buckets). Coalesce onto the authoritative source so `/sessions` | ||
| // (working-directory scope) and `--continue` never hide them. Unscooped | ||
| // reads stay on the projected recency column. | ||
| if (page.items.length === 0 && query.workspaceIds !== undefined) { |
There was a problem hiding this comment.
Include authoritative misses in every affected listing
When a published generation omits a legacy/v1 session, this fallback runs only if the projected workspace page is completely empty. If that workspace has even one projected session, /sessions returns the nonempty stale page and still hides the omitted sessions; moreover, --continue calls listRecent({}), so its unscoped query can never enter this branch. Thus the exact stale-generation scenario this change targets remains broken for partial workspace misses and all unscoped resume reads; merge or otherwise reconcile authoritative results rather than treating only an empty scoped page as a miss.
AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L81-L83
Useful? React with 👍 / 👎.
| // A workspace-scoped read that returns nothing can still hide sessions | ||
| // that exist on disk but were not projected into the read model (e.g. | ||
| // legacy/v1-era sessions recorded with only `workDir`, or sessions in | ||
| // alias buckets). Coalesce onto the authoritative source so `/sessions` | ||
| // (working-directory scope) and `--continue` never hide them. Unscooped |
There was a problem hiding this comment.
Move method-body narration into the file header
This newly added explanatory block sits inside listRecent and narrates the implementation, while the scoped v2 guide requires comments to live solely in the top-of-file /** */ block and describe external responsibilities. Remove the inline narration or fold the relevant responsibility-level context into the existing module header.
AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L36-L38
Useful? React with 👍 / 👎.
Problem
Since the v2 engine became the CLI default (#2627),
/sessions(working-directory scope) andkimi --continuestop surfacing the older sessions of the current working directory — most notably legacy/v1-era sessions recorded with onlyworkDir(nocwd)./sessionsshows an empty cwd list and--continuesilently starts a fresh session.Related: #2951 (report), #1650 (open, describes the same bucket-coordination gap).
What changed
Two spots covered:
v2 session index read-model miss on a workspace-scoped
listRecent(packages/agent-core-v2/src/app/sessionIndex/sessionIndexService.ts): when the minidb read model answers an empty page for aworkspaceIds-scoped query, coalesce onto the authoritative directory read so sessions that exist on disk but were not projected (legacyworkDir-only, alias buckets) are never hidden. This fixes the TUI/sessionsworking-directory scope.--continuematching (apps/kimi-code/src/cli/v2/run-v2-print.ts): normalize thecwd === workDircomparison withresolve(...)(matching the existing--sessionguard) so path variations (symlink, trailing slash, case) no longer drop the last session.Changed
packages/agent-core-v2/src/app/sessionIndex/sessionIndexService.tsapps/kimi-code/src/cli/v2/run-v2-print.tspackages/agent-core-v2/test/app/sessionIndex/sessionIndex.test.ts@moonshot-ai/kimi-codepatchOut of scope
Checklist