Skip to content

agentHost: support attaching virtual resources (untitled, notebook cells)#320040

Merged
connor4312 merged 2 commits into
mainfrom
connor4312/319802
Jun 5, 2026
Merged

agentHost: support attaching virtual resources (untitled, notebook cells)#320040
connor4312 merged 2 commits into
mainfrom
connor4312/319802

Conversation

@connor4312
Copy link
Copy Markdown
Member

agentHost: support attaching virtual resources (untitled, notebook cells)Consolidates the agent host's permission and virtual-resource services into a single IAgentHostResourceService that owns the gated FS surface (list/read/write/del/move/copy/resolve/mkdir), the permission policy, and an ITextModelService-backed fallback for content that isn't on disk. Both the in-process local channel and the remote protocol client's reverse-RPC handler now reduce to a thin wire adapter that dispatches frames to the same service.- Adds a single IAgentHostResourceService (platform decorator + types, workbench implementation) replacing IAgentHostPermissionService and IAgentHostVirtualResourceProvider.- read, write, and resolve (stat) transparently fall back to ITextModelService when IFileService cannot satisfy the request, so attached untitled documents and notebook cells round-trip end to end.- AgentHostClientResourceChannel (local in-process) and RemoteAgentHostProtocolClient._handleReverseRequest (remote) shrink to thin adapters that translate JSON-RPC frames into service calls and surface AgentHostResourcePermissionError as PermissionDenied frames so the host's standard resourceRequest -> retry loop still works.- Local agent host short-circuits the permission gate (sentinel address 'local'): the utility process already has the renderer's FS access, so gating it adds no security and would just produce unprompted denials.- createAgentHostClientResourceConnection now exposes resourceRequest, completing the local prompt/retry loop.- agentClientUri preserves query and fragment across the round trip and uses a ! scheme-slot marker to faithfully round-trip opaque-path URIs such as untitled:Untitled-1.Fixes #319802 message generated by Copilot)

…lls)

Consolidates the agent host's permission and virtual-resource services into a single `IAgentHostResourceService` that owns the gated FS surface (`list`/`read`/`write`/`del`/`move`/`copy`/`resolve`/`mkdir`), the permission policy, and an `ITextModelService`-backed fallback for content that isn't on disk. Both the in-process local channel and the remote protocol client's reverse-RPC handler now reduce to a thin wire adapter that dispatches frames to the same service.

- Adds a single `IAgentHostResourceService` (platform decorator + types, workbench implementation) replacing `IAgentHostPermissionService` and `IAgentHostVirtualResourceProvider`.
- `read`, `write`, and `resolve` (stat) transparently fall back to `ITextModelService` when `IFileService` cannot satisfy the request, so attached untitled documents and notebook cells round-trip end to end.
- `AgentHostClientResourceChannel` (local in-process) and `RemoteAgentHostProtocolClient._handleReverseRequest` (remote) shrink to thin adapters that translate JSON-RPC frames into service calls and surface `AgentHostResourcePermissionError` as `PermissionDenied` frames so the host's standard `resourceRequest` -> retry loop still works.
- Local agent host short-circuits the permission gate (sentinel address `'local'`): the utility process already has the renderer's FS access, so gating it adds no security and would just produce unprompted denials.
- `createAgentHostClientResourceConnection` now exposes `resourceRequest`, completing the local prompt/retry loop.
- `agentClientUri` preserves `query` and `fragment` across the round trip and uses a `!` scheme-slot marker to faithfully round-trip opaque-path URIs such as `untitled:Untitled-1`.

Fixes #319802

(Commit message generated by Copilot)
Copilot AI review requested due to automatic review settings June 5, 2026 03:11
@connor4312 connor4312 enabled auto-merge (squash) June 5, 2026 03:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 unifies agent-host-facing filesystem access and permission prompting behind a single IAgentHostResourceService, enabling attachments backed by virtual resources (e.g. untitled editors, notebook cells) to round-trip through the agent host.

Changes:

  • Introduces IAgentHostResourceService (platform) and AgentHostResourceService (workbench) to combine permission gating + FS operations, with ITextModelService fallback for non-disk resources.
  • Refactors both local (in-process) and remote (protocol) reverse-RPC handlers into thin adapters that dispatch to the shared service and translate permission denials into PermissionDenied frames.
  • Improves URI round-tripping via agentClientUri by preserving query/fragment and supporting opaque-path URIs like untitled:Untitled-1.
Show a summary per file
File Description
src/vs/workbench/workbench.common.main.ts Switches workbench bootstrap import to the unified resource service.
src/vs/workbench/services/agentHost/test/common/agentHostResourceService.test.ts Updates unit tests to construct/use AgentHostResourceService.
src/vs/workbench/services/agentHost/electron-browser/agentHostService.ts Updates comment to reflect the current remote client implementation name.
src/vs/workbench/services/agentHost/common/agentHostResourceService.ts Implements unified resource service with permission gating + virtual resource fallback.
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostPermissionUiContribution.test.ts Updates test wiring to stub IAgentHostResourceService.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts Allows non-file attachments and closes a session-state hydration race.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostPermissionUiContribution.ts Migrates UI contribution to IAgentHostResourceService.
src/vs/sessions/sessions.common.main.ts Switches sessions bootstrap import to the unified resource service.
src/vs/sessions/contrib/providers/remoteAgentHost/browser/remoteAgentHost.contribution.ts Updates setting import to new resource service module.
src/vs/platform/agentHost/test/electron-browser/remoteAgentHostProtocolClient.test.ts Reworks protocol client tests around IAgentHostResourceService and permission-denial frames.
src/vs/platform/agentHost/test/electron-browser/localAhpJsonlLogging.test.ts Removes channel-specific logging test now that channel implementation is refactored.
src/vs/platform/agentHost/test/common/agentHostClientResourceChannel.test.ts Adds focused tests for the new resource-channel adapter behavior.
src/vs/platform/agentHost/test/common/agentClientUri.test.ts Adds coverage for query/fragment and opaque-path URI round-tripping.
src/vs/platform/agentHost/node/agentService.ts Avoids masking the original error when a fallback readFile attempt fails.
src/vs/platform/agentHost/electron-browser/localAgentHostService.ts Switches local resource channel registration to DI-created channel (injecting resource service).
src/vs/platform/agentHost/common/agentHostResourceService.ts Adds the new unified platform service contract + permission error type.
src/vs/platform/agentHost/common/agentHostPermissionService.ts Removes the old permission-only service contract.
src/vs/platform/agentHost/common/agentHostClientResourceChannel.ts Refactors local reverse-RPC resource channel to delegate to IAgentHostResourceService.
src/vs/platform/agentHost/common/agentClientUri.ts Preserves query/fragment and supports opaque-path URIs using a scheme-slot marker.
src/vs/platform/agentHost/browser/remoteAgentHostProtocolClient.ts Refactors reverse-RPC handling to dispatch to IAgentHostResourceService.

Copilot's findings

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

Comment thread src/vs/platform/agentHost/browser/remoteAgentHostProtocolClient.ts
DonJayamanne
DonJayamanne previously approved these changes Jun 5, 2026
@connor4312 connor4312 merged commit c1c20ad into main Jun 5, 2026
25 checks passed
@connor4312 connor4312 deleted the connor4312/319802 branch June 5, 2026 06:52
@vs-code-engineering vs-code-engineering Bot added this to the 1.124.0 milestone Jun 5, 2026
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.

attached untitled doc does not get attached

4 participants