Read project customizations on the host's own filesystem - #331527
Read project customizations on the host's own filesystem#331527Ryan Ewen (RyanEwen) wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR ensures the agent host reads project customizations from the correct filesystem when the client window is connected to a remote (e.g., dev container) by translating vscode-remote://... working directory URIs into host-local file: URIs.
Changes:
- Added
toHostLocalUrihelper to reinterpretvscode-remote://...URIs asfile:URIs for host-side disk reads. - Updated
ClaudeAgentSessioncustomization discovery/scanning to use host-local working directory URIs. - Added unit tests for
toHostLocalUribehavior and invariants.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/vs/platform/agentHost/test/common/agentHostFileSystemProvider.test.ts | Adds focused tests for toHostLocalUri conversion and non-conversion cases. |
| src/vs/platform/agentHost/node/claude/claudeAgentSession.ts | Uses host-local working directory URIs for customization discovery/scans to fix “silent empty reads” in remote windows. |
| src/vs/platform/agentHost/common/agentHostUri.ts | Introduces toHostLocalUri utility and documents intended behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: TylerLeonhardtMatched files:
|
A window connected to a remote hands the session its working directory in the client's namespace, so in a dev container the primary root arrives as `vscode-remote://dev-container+<hex>/workspace/repo`. The agent host runs inside that container and its file service only answers for `file:`, so every project-scope disk scan reads a URI it cannot resolve. It fails quietly: the scan returns empty rather than erroring, so project agents, skills, commands, rules, MCP servers and hooks are all simply absent. User-scope ones keep working because `userHome` is already host-local, which makes the symptom look like `.claude/commands` specifically. Slash commands appear to recover after the first turn, but only because the SDK then supplies its own list; the disk scan never starts working. The path is what both namespaces agree on, which materialize already relies on by handing the SDK `workingDirectory.fsPath` as its cwd. This applies the same reading to the host's own reads, and only to those: anything sent back to the client keeps the namespace the client uses. Scoped to `vscode-remote:`. Stripping the authority off any other scheme would name a local file that is not there rather than the resource meant.
`URI.file` builds from the path alone, so the conversion silently dropped `query` and `fragment`. Working directories carry neither, but the helper is exported and general, and `fromAgentHostUri` returns URIs that do carry a query, so the loss would have been waiting for the first such caller. Also trims the comments this change added. The repository allows 1-2 short sentences of JSDoc and at most one line inline, and these ran to twelve and fourteen lines. The reasoning belongs in the commit and the pull request, which is where it now lives.
4bb687e to
705a508
Compare
|
Superseded by #333683. That PR now maps the roots inside AI disclosure: this comment and the related code were written with the assistance of AI. |
Fixes #331526.
In a remote window the agent host reads project-scope customizations off a URI it cannot resolve, so it finds none. The symptom users hit is that a new chat offers no workspace slash commands until a turn has run.
The window hands the session its working directory in the client's namespace. A diagnostic build of the host logged, for a fresh chat in a dev container:
The host runs inside that container and its file service only answers for
file:, andgetSessionCustomizationspasses the working directory straight to four disk scans (agents/skills/commands, rules, MCP servers, hooks). Each returns empty rather than raising, so the customizations are absent with nothing in the log.Fix
A conversion beside the other agent-host URI helpers, applied only to reads the host performs itself:
The path is the part both namespaces agree on, which materialize already relies on by handing the SDK
workingDirectory.fsPathas its cwd. This applies the same reading to the host's own disk access.Deliberately narrow:
vscode-remote:. Stripping the authority off any other scheme would name a local file that is not there rather than the resource meant. A local window comparesfile:tofile:and is untouched.workingDirectoryandworkingDirectoriesare unchanged for everything else; anything sent back to the client, or compared against client-supplied URIs, keeps the namespace the client uses.Verification
file:no-op, a non-remote scheme left alone, and that the client authority never leaks into a host read.~/.claude/commands/was offered before the first turn both before and after the fix, which isolates the failure to project scope rather than to the suggestion pipeline.file:URI shape this produces is one the client already resolves: a user-scope command, which has always been surfaced as a host-localfile:URI, resolves and runs end to end. So project entries now arrive in a shape with a working precedent rather than a new one.What is not covered
The conversion is unit-tested and the wiring is verified live, but there is no unit test asserting that
getSessionCustomizationspasses the converted form, because that needs a fully constructed session and the existing tests stub the method rather than exercise it. I would rather say so than imply coverage that is not there.The Codex customization scan takes working directories the same way and joins onto them, so it looks like the same shape. I have not reproduced it there and have left it out of this change.
AI disclosure: this description and the code it proposes were written with the assistance of AI.