Repository navigation
fix(kimi-code): load workspace directories before session - #4515
Conversation
🦋 Changeset detectedLatest commit: d5baaa6 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.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c7a0d7919d
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: af9bf58da2
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: af95992793
ℹ️ 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".
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
Port of the mention-provider half of upstream MoonshotAI/kimi-code df7efe9 (MoonshotAI#4515). The filesystem fallback scanned one root to exhaustion before the next, so a project directory holding more than the 2,000-entry cap starved the source folders entirely: `@target-needle` found nothing even though the file sat in a registered folder. The scan now interleaves the roots, one entry at a time, so unused capacity on one root is spent on others. `~` and `~/…` entries now resolve against the home directory instead of being treated as relative paths, and a root equal to the working directory is dropped instead of scanned twice. The added case uses the existing 2,000-entry fixture and fails when the scan is narrowed to the primary root. The working-directory case pins the deduplication. Also completes the MoonshotAI#4638 SDK half: `node-sdk` keeps its own error-code table, so `wire.version_too_low` had to be added there as well; the engine registry alone was not enough and the app typecheck caught it.
d48f64d interleaves the mention fallback across roots, expands `~` and dedupes a root equal to the working directory. The SDK's getWorkspaceAdditionalDirs and the TUI's pre-session directory load were already in the tree, so only the provider needed porting. Ledger: closed 44 -> 45, remaining 54.
Requirement or Bug
TUI
@file mentions miss files from additional workspace directories before the first session is created.Bug Reproduction Steps
.kimi-code/local.tomlor the workspace registry. Place a uniquely named file in B.@followed by the file name before sending the first message. The B file is not suggested, even though it becomes available after a session is created.Root Cause
Sessionless startup seeded the mention provider only with CLI
--add-dirvalues. Persisted directories were copied fromsession.summary.additionalDirsonly after a session existed, so the existing pi-tui multi-root search never received them. This PR fixes the lifecycle gap by reading the workspace directory service before autocomplete is mounted, rather than creating a session early or reimplementing search.The fallback also exhausted one shared 2,000-entry scan budget in traversal order. It now round-robins individual entries across active roots under the same global cap, so a large primary directory cannot starve additional roots and an idle root leaves capacity for the others.
Review follow-up separates the autocomplete-only startup snapshot from session-creation overrides. Initial create/resume passes only explicit CLI
--add-dirvalues; the engine re-reads persisted directories at creation, so directories removed before the first prompt are not reintroduced. Missing Git Bash preserves sessionless startup with a notice, while genuine configuration errors still fail. Terminal cleanup after the trust prompt runs exactly once, and home-directory expansion matches the engine resolver.Code Changes
SDKRpcClientBaseadds a non-abstractgetWorkspaceAdditionalDirscapability. Its default implementation throwsnot_implemented;SDKRpcClientV2returns the merged legacy-project, registry, and ephemeral directory set after awaiting readiness. It never silently substitutes an empty directory list./newand current-session deletion replacements preserve liveappState.additionalDirs; the first/newbefore any session still uses startup values.~/~/values expand consistently with the engine. Fallback roots are deduplicated by normalized absolute path before round-robin scanning, preserving the primary-root classification.Behavior Changes and Affected Users
@mention search--add-dironlylocal.tomlor registry-managed source folders/add-dir listand CLI pending paths/add-dirappState.additionalDirswhile first creation still uses startup values/newbehaviorgetWorkspaceAdditionalDirs; unsupported backends reject explicitlyExisting sessions, single-root projects, fd-backed ranking, mention insertion, slash commands, inline skills, and quoted mentions are covered by the unchanged existing test suites. No prompt text, wire schema, CLI flag, session format, or old configuration key was changed.
Verification:
/add-dir listshowed the additional directory, selecting its file inserted an absolute path, selecting a main-root file inserted a relative path, and shutdown exited with code 0.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.