Skip to content

fix(vscode): allow editor mentions for files outside the working directory - #1836

Merged
wbxl2000 merged 2 commits into
mainfrom
fix/vscode-editor-mention-outside-workdir
Jul 17, 2026
Merged

fix(vscode): allow editor mentions for files outside the working directory#1836
wbxl2000 merged 2 commits into
mainfrom
fix/vscode-editor-mention-outside-workdir

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — this comes from a user report; the problem is explained below.

Problem

In a multi-root workspace, the session working directory is the first workspace folder. Using Kimi Code: Insert Current File (Alt+K) on any file from another root always fails with "The active file is outside the selected working directory." Configuring workspace.additional_dir in .kimi-code/local.toml makes the session able to read/write those files, but the mention still refuses, because the extension gated mentions on the session working directory only and never consulted the session's additionalDirs. The same false rejection happened for any file outside a custom selected working directory, even inside a single-root workspace. The CLI/TUI has no such gate: @ completion covers the working directory plus additionalDirs, and any typed @path is passed through with readability decided by the session's tool layer.

What changed

  • Editor mentions no longer UI-gate on the working directory, matching the CLI/TUI: a file inside the working directory still mentions as a relative path; a file outside it (another workspace root, an additionalDir, anywhere on disk) mentions as an absolute path, and the session's tool layer decides readability.
  • Still returns null (and shows the existing warning) when no workspace folder is open, or when the active document is virtual (untitled:, git:, etc.) and therefore has no meaningful path to reference.
  • Tests: the outdated rejection case now asserts an absolute-path mention; added cases for a file outside the workspace root entirely and for a virtual (untitled) document.

No changeset: the VS Code extension is a private package released manually via chore(vscode): release commits, and no extension change has ever carried a changeset in this repo.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6d30f85

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@6d30f85
npx https://pkg.pr.new/@moonshot-ai/kimi-code@6d30f85

commit: 6d30f85

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45669b2ea7

ℹ️ 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".

Comment thread apps/vscode/src/bridge-handler.ts Outdated
Comment on lines +219 to +221
const filePath = relativeWorkspacePath(workDirUri, documentUri) ?? documentUri.fsPath;

if (selection.isEmpty) return `@${relativePath}`;
if (selection.isEmpty) return `@${filePath}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Quote editor mentions whose absolute paths contain spaces

When an outside file is under a directory containing spaces, this produces text such as @/tmp/Other Root/App.java, so the whitespace separates the mention instead of identifying the complete path. The CLI/TUI convention explicitly emits @"..." when a path contains spaces (apps/kimi-code/src/tui/components/editor/file-mention-provider.ts:417-420, also packages/pi-tui/src/autocomplete.ts:107-120); apply the same quoting here, placing any line-range suffix after the closing quote.

Useful? React with 👍 / 👎.

@wbxl2000

Copy link
Copy Markdown
Collaborator Author

Addressed the spaced-path mention review in 6d30f85: mentions whose path contains a space are now emitted as @"..." with any line range after the closing quote, matching the CLI/TUI convention in pi-tui's autocomplete. Added tests for a spaced absolute path and a quoted relative path with a line range.

@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 6d30f85e47

ℹ️ 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".

@wbxl2000
wbxl2000 merged commit 429521b into main Jul 17, 2026
14 checks passed
@wbxl2000
wbxl2000 deleted the fix/vscode-editor-mention-outside-workdir branch July 17, 2026 10:02
@wbxl2000 wbxl2000 mentioned this pull request Jul 17, 2026
5 tasks
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Jul 17, 2026
…ctory (MoonshotAI#1836)

* fix(vscode): allow editor mentions for files outside the working directory

* fix(vscode): quote editor mentions whose paths contain spaces
ywh114 pushed a commit to ywh114/kimi-code that referenced this pull request Jul 19, 2026
…ctory (MoonshotAI#1836)

* fix(vscode): allow editor mentions for files outside the working directory

* fix(vscode): quote editor mentions whose paths contain spaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant