Agent host: Claude sessions can't be pre-created in multi-root workspaces with a virtual folder (Approvals selection reverts, Folder picker missing)
Does this issue occur when all extensions are disabled?: N/A (the scenario requires an extension to provide virtual filesystem folders)
Disclosure: I analyzed this issue with the help of an AI coding agent (Claude Code), using VS Code's logs, the shipped 1.146.0 and 1.145.3 bundles, and the source at
main(36e8c02).
Environment
- VS Code: 1.146.0 (69047191fc427f2f92828279aae1d90d8eeda7ab),
.deb, Linux x64 - Last version without the problem: 1.145.3
- Agent: Claude in the local agent host
Steps to reproduce
- Open a multi-root workspace with a local folder first and one or more folders from a
FileSystemProviderextension. In my case they come from ABAP FS (abap:scheme):{ "folders": [ { "path": "abap-work" }, { "name": "SYSTEM_A", "uri": "abap:/repotree-v1/SYSTEM_A" }, { "name": "SYSTEM_B", "uri": "abap:/repotree-v1/SYSTEM_B" } ] } - Open a new chat with the Claude agent (agent host).
- Before sending anything, pick another option in the Approvals picker of the chat input (for example, Edit Automatically).
- Send the first message.
Expected
- The selected Approvals option is applied, as it is in a workspace with only local folders.
- The Folder picker is shown, as it was in 1.145.3.
Actual
- The picker accepts the click, but the selection goes back to the previous option.
- The Folder picker is not shown.
- After the first message is sent, the Approvals picker disappears for a few seconds and comes back. From then on, it works.
Agent host log (agenthost.log):
[error] [ProtocolServer] Request 'createSession' id=749 failed Agent 'claude' does not support virtual workspaces.
[error] [ProtocolServer] Request 'subscribe' id=751 failed Session not found on backend: claude:/98a26c3c-...
[error] [AgentService] async dispatchAction failed: Working directory must be a file URI: abap:/repotree-v1/SYSTEM_A
[error] [AgentService] async dispatchAction failed: Working directory must be a file URI: abap:/repotree-v1/SYSTEM_B
... (the last two lines repeat 150–290 times per window session)
Analysis
#346117 lets local Copilot sessions use virtual workspaces and keeps other agents out of them:
- The agent host now rejects non-
file:working directories increateSessionfor providers withoutsupportsVirtualWorkspaces(agentService.ts#L6514). Only Copilot declares it. - The workbench drops those directories for non-Copilot providers in
AgentHostSessionHandler._hostAddressableWorkingDirectories(agentHostSessionHandler.ts#L8112).
That filter only runs on the send path (_resolveRequestedWorkingDirectories). Two other places still build working-directory sets from all workspace folders, including the virtual ones:
AgentHostUntitledProvisionalSessionService(_computeWorkingDirectories/_computeEntryWorkingDirectories, L441–L456). Claude advertisesmultipleWorkingDirectories, so the pre-warmedcreateSession(L800) receives[abap-work, abap:/…, …]and is rejected. Because there is no provisional session:applyConfigChangehas nothing to apply the Approvals selection (permissionMode) to, so the selection is lost.- The session state has no
folderPickerDecision, soresolveFolderPickerDecisionUpdatehides the Folder picker. That logic is the same in 1.145.3; it only changed because the session is no longer created. - The first send creates the session through the handler, whose filter keeps only
abap-work. That explains why the picker disappears and comes back, and why it works afterwards.
AgentHostSessionWorkingDirectorySynchronizer._reconcile(L294). After the session starts, it dispatchesSessionWorkingDirectorySetfor the virtual folders. The host rejects each one (sessionWorkingDirectories.ts#L74), which produces the repeated errors above.
Proposed fix
Decide in a single place which workspace folders a provider can use as working directories, and apply that decision everywhere a working-directory set is built:
- Move the check that
_hostAddressableWorkingDirectoriesdoes today into a shared helper, next tocomputeWorkingDirectoriesinagentHostNewSessionFolderService.ts. The rule stays the same: the directory must have the host's scheme, and only the local Copilot provider (outside the Agents window) also accepts virtual directories. The send path keeps its current behaviour, now through the helper. - In
AgentHostUntitledProvisionalSessionServiceand inAgentHostSessionWorkingDirectorySynchronizer, filter the workspace folders with that helper before computing the working-directory set, not after. This wayusesWorkspaceRootSetis also computed from the folders the provider can actually use. In my workspace, Claude would get onlyabap-work, so the provisional session would be created, the Approvals selection would stick, and the Folder picker would come back. - Keep the node-side guard as the authoritative backstop.
This shouldn't change anything else:
- Copilot on a virtual workspace: still allowed, because
LocalAgentHostService.clientConnectionKindisLocal. - Single-folder or local-only workspaces, the Agents window and remote hosts: they get the same rules the send path already applies.
- A virtual folder explicitly chosen as the primary for Claude: still fails, as intended.
Possible follow-ups, out of scope here:
- The Folder picker still lists virtual folders for providers that can't use them.
- Longer term, agents could advertise virtual workspace support in their
capabilitiesinstead of the client comparing againstCOPILOT_CLI_AGENT_PROVIDER_ID.
Tests to add:
- In
agentHostUntitledProvisionalSessionService.test.ts: a workspace with onefile:folder and one virtual folder, using the Claude provider withmultipleWorkingDirectories. Assert that the provisionalcreateSessionreceives only thefile:folder. - The same case for
agentHostSessionWorkingDirectorySynchronizer.test.ts.