Repository navigation
sessions: Add Git credential forwarding for Dev Containers - #340467
Christof Marti (chrmarti) wants to merge 4 commits into
Conversation
Defer shared-container consent until the first HTTPS credential lookup. Gate host credential reads on connection-scoped approvals, keep decisions in memory, and support off, prompt, and on. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Helper initialization and cancellation handling can block container use or fail otherwise valid concurrent credential requests.
5 open findings
Git helper setup failure aborts container connection · New Relay cancellation leaves readiness promise pending · New Canceled lookup leaves response promise and timeout unsettled · New First canceled credential waiter rejects shared consent · New Nested round-trip test is not independently registered · New
What changed in this PR
Adds host-backed HTTPS Git credential forwarding for Dev Container Agent Hosts across local, SSH, Tunnel, and WSL workspaces.
Changes:
- Adds deferred, container-wide consent with
off,prompt, andonmodes. - Introduces credential relays, permission messages, and capability negotiation.
- Adds documentation and regression coverage.
| File | Description |
|---|---|
| src/vs/sessions/contrib/providers/remoteAgentHost/test/electron-browser/devContainerAgentHostConnector.test.ts | Tests connector consent integration. |
| src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/devContainerGitCredentialForwarding.test.ts | Tests consent and revocation. |
| src/vs/sessions/contrib/providers/remoteAgentHost/REMOTE_AGENT_HOST_SESSIONS_PROVIDER.md | Documents forwarding behavior. |
| src/vs/sessions/contrib/providers/remoteAgentHost/electron-browser/devContainerAgentHostConnector.contribution.ts | Registers settings and connects forwarding. |
| src/vs/sessions/contrib/providers/remoteAgentHost/browser/devContainerGitCredentialForwarding.ts | Manages consent decisions. |
| src/vs/sessions/common/devContainerAgentHostService.ts | Defines the setting identifier. |
| src/vs/platform/agentHost/test/node/devContainerGitCredentialRelay.test.ts | Tests helper subprocess behavior. |
| src/vs/platform/agentHost/test/node/devContainerAgentHostService.test.ts | Tests permission-gated credential reads. |
| src/vs/platform/agentHost/test/node/devContainerAgentHostProtocol.test.ts | Adds protocol ownership checks. |
| src/vs/platform/agentHost/test/common/mockDevContainerService.ts | Extends forwarding mocks. |
| src/vs/platform/agentHost/node/devContainerGitCredentialRelay.ts | Implements the credential relay. |
| src/vs/platform/agentHost/node/devContainerAgentHostService.ts | Manages relays and host lookups. |
| src/vs/platform/agentHost/node/devContainerAgentHostProtocol.ts | Handles forwarding requests. |
| src/vs/platform/agentHost/common/meta/vscode/agentHostDevContainersMeta.ts | Defines capability detection. |
| src/vs/platform/agentHost/common/meta/agentHostDevContainersMeta.ts | Exports capability helpers. |
| src/vs/platform/agentHost/common/devContainerAgentHostProtocolClient.ts | Routes permission messages. |
| src/vs/platform/agentHost/common/devContainerAgentHost.ts | Extends service contracts. |
| src/vs/platform/agentHost/common/agentHostExtensionProtocol.ts | Defines protocol messages and validators. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Replace the modal with a connection-scoped chat input notice and preserve shared approvals while other lookups remain live. Handle optional helper setup failures without blocking sessions, release canceled startup and permission waits, and fix protocol, hygiene, and remote smoke expectations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use an informational approval notice. Remove only recognized inactive forwarding helpers on reconnect, retry Git config mutations during lock contention, and tolerate helpers whose temporary script or relay has gone away. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Show pending container consent as Needs Input and prevent idle shutdown without an approval deadline. Propagate credential-client cancellation and prioritize informational approvals over ordinary chat warnings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Hi Christof Marti (@chrmarti), I came across this PR while following up on microsoft/vscode-remote-release#11899, which was closed as a duplicate of #340566. Unfortunately, the issue is still reproducible in VS Code 1.143.0, specifically when using the Copilot Agent Host in Agents Window with a Dev Container (macOS ARM64, sandbox disabled). I've verified the same Git HTTPS command in both windows, using the same Dev Container:
The affected repository is hosted on Azure DevOps over HTTPS. I noticed this PR introduces a dedicated Git credential forwarding mechanism for Dev Container Agent Host sessions. Is this PR intended to address the scenario described in #11899, including Agents Window and non-GitHub HTTPS repositories such as Azure DevOps? Thanks for your work on this! |



Adds HTTPS Git credential forwarding from the workspace host to the Agent Host and its harnesses inside a Dev Container.
chat.agentHost.devContainer.gitCredentialForwardingwithoff,prompt(default), andon.offrevokes live relays. Helper startup and actual host credential reads remain bounded.vscode.devContainers.gitCredentialscapability for SSH, Tunnel, and WSL source hosts. Older hosts remain usable with forwardingoff.The approval notice explicitly explains that credentials are available to all sessions and processes in the shared container, not isolated per chat session. Container recreation, restarting VS Code, or changing the setting requires a new decision on the next lookup.
Review and CI fixes
How to test
prompt, start a container session. No credential approval should appear until an operation requests credentials.onto enable forwarding without an approval notice; switch tooffto revoke it.Validation
npm run typecheck-client- passed.npm run valid-layers-check- passed.git diff --check- passed.Incremental client transpilation using the existing
build/next/transpile.tshelper - passed.Scoped hygiene (including formatting and lint) - passed, 20 changed TypeScript files:
Targeted regression suites - 430 passed, 1 platform-specific test skipped:
Tests use Electron 43.7.7 and include real Git/helper subprocess round trips, approval-before-host-read checks, waits exceeding six minutes under virtual time, inactivity protection and a fresh grace period after consent, preserved host status, main/peer/archived chat presentation, informational approval priority over warnings, relay client cancellation, independent waiters, denial/revocation, optional setup failures, and remote protocol ownership/capabilities.
Real Windows Code OSS dev build and existing Docker container - passed: a synthetic HTTPS request for
example.invalidshowed a visible informational approval with Allow/Don't Allow actions above the matching chat input despite the active sandbox warning; the session displayed Attention Needed. Canceling the synthetic lookup restored Completed without reading host credentials. The same isolated authenticated profile was preserved.Earlier core compilation (
npm run gulp compile-client), smoke-test compilation (npm --prefix test\smoke run compile), and four dark/light, normal/narrow approval fixtures - passed before these lifecycle fixes. The full smoke suite was not rerun locally.No linked issue was supplied; this change was requested in the development session.