Skip to content

AHP filesystem: make resolved files writable and add realpath capability - #321191

Merged
Connor Peet (connor4312) merged 1 commit into
mainfrom
connor/ahp-fs-realpath-writable
Jun 12, 2026
Merged

Connor Peet (connor4312) merged 1 commit into
mainfrom
connor/ahp-fs-realpath-writable

Conversation

@connor4312

Copy link
Copy Markdown
Member

Summary

The AHPFileSystemProvider advertises FileReadWrite and implements writeFile, but every resolved resource was stamped with FilePermission.Readonly in stat() — so real files opened read-only and editors refused edits.

Changes

  • Fix read-only files: drop the spurious FilePermission.Readonly from real resources resolved via resourceResolve. It's kept only for genuinely read-only cases (the synthetic root and the virtual session-db / git-blob schemes).
  • Add FileRealpath capability: the AHP resourceResolve already returns the canonical (symlink-resolved) URI, so the provider now advertises FileSystemProviderCapabilities.FileRealpath, implements IFileSystemProviderWithFileRealpathCapability, and exposes realpath() which re-encodes the canonical URI back into provider space. A small _resolve() helper is shared by stat and realpath.

Notes on etags

Etag-based optimistic concurrency is intentionally not wired into the provider: the file service performs its own dirty-write prevention (mtime/size-derived etag) and never forwards an etag to provider.writeFile, so there is no stateless token for the provider to replay.

Testing

Added two unit tests (resolved files are not read-only; realpath canonicalization). All 30 tests in the suite pass.

Resolved resources were always stamped with FilePermission.Readonly in
stat(), so real files opened read-only even though the provider advertises
FileReadWrite and implements writeFile. Drop the spurious flag for real
resources (keeping it only for the synthetic root and the virtual
session-db / git-blob schemes).

Also surface the canonical-path information the AHP resourceResolve already
returns by advertising the FileRealpath capability and implementing
realpath(), which re-encodes the resolved canonical URI back into provider
space.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings June 12, 2026 17:47
@connor4312
Connor Peet (connor4312) enabled auto-merge (squash) June 12, 2026 17:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes editability for real files exposed through the Agent Host filesystem provider by stopping stat() from unconditionally applying FilePermission.Readonly to resolved resources, and adds realpath support so the provider can surface canonical (symlink-resolved) paths back to the file service.

Changes:

  • Remove the spurious FilePermission.Readonly from stat() results for non-virtual resolved resources (keeping readonly only for synthetic root and virtual session-db / git-blob).
  • Advertise FileSystemProviderCapabilities.FileRealpath and implement realpath() via a shared _resolve() helper.
  • Add unit tests covering non-readonly stats for resolved files and realpath re-encoding behavior.
Show a summary per file
File Description
src/vs/platform/agentHost/common/agentHostFileSystemProvider.ts Stops marking resolved resources readonly and adds realpath() + capability advertising using a shared resolve helper.
src/vs/platform/agentHost/test/common/agentHostFileSystemProvider.test.ts Adds unit tests for editability (no readonly permission) and canonical-path re-encoding via realpath().

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@connor4312
Connor Peet (connor4312) merged commit c5039c5 into main Jun 12, 2026
40 of 41 checks passed
@connor4312
Connor Peet (connor4312) deleted the connor/ahp-fs-realpath-writable branch June 12, 2026 19:14
@vs-code-engineering vs-code-engineering Bot added this to the 1.125.0 milestone Jun 12, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jul 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants