Skip to content

chat: allow cloud sandbox creation from the editor window - #340817

Merged
Osvaldo Ortega (osortega) merged 10 commits into
mainfrom
osortega/editor-cloud-sandbox-creation
Oct 14, 2026
Merged

Osvaldo Ortega (osortega) merged 10 commits into
mainfrom
osortega/editor-cloud-sandbox-creation

Conversation

@osortega

@osortega Osvaldo Ortega (osortega) commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Today the editor window can only discover and resume existing cloud sandbox sessions; creating a new one requires the Agents window. This PR lets users create a cloud sandbox session directly from the editor's chat session picker, with the same draft experience the Agents window offers (repository, model, mode, approvals).

Design

A sandbox environment does not exist until it is provisioned, so a new session cannot be drafted under an environment's session type. Instead:

  1. The editor registers a single "Cloud" creation type (SessionType.CloudSandbox). New chats are drafted under it.
  2. On first send, newChatSessionItem provisions the sandbox (Mission Control task → connect), confirms the draft's picks with the host, and returns an item under the environment's session type; the chat infrastructure rebinds the untitled draft to it.
  3. Because the draft has no backend, everything the chat input normally reads from a live Agent Host connection is supplied for the draft itself — mirroring the Agents window's own draft layer.

While the sandbox type is registered it replaces the extension's cloud agent in the editor picker, so there is always exactly one "Cloud" entry whose backend follows chat.agentHost.cloudSandbox.enabled (as in the Agents window).

What changed

Shared (workbench/contrib/chat/browser/remoteAgentHost)

  • CloudSandboxSessionContribution — lifts _provisionSandbox() / trackSessionCreationProgress() out of the Agents-window subclass so both windows share one provision → seed → connect path; populates the connection customization with resolveInitialSessionConfig and modelIdentifierAliases.
  • cloudSandboxSessionConfig.ts — moved here from vs/sessions so both windows share the draft vocabulary; adds resolveCloudSandboxSessionConfig (host confirmation), createCloudSandboxDraftOptionGroups, readCloudSandboxDraftConfig.
  • CloudSandboxSessionListController — tracks provisional repositories and draft config per session; resolves the working directory to the chosen repository, or explicitly leaves it to the host (null) for an empty sandbox.
  • EditorCloudSandboxSessionContribution — the creation type, its option groups (repository / mode / approvals), a CloudSandboxModels pool fed by the cloud catalog, "Search Repositories…" (delegates to the extension's picker), and newChatSessionItem with a cancellable progress notification.

Chat infrastructure

  • AgentHostSessionHandler — new config hooks resolveInitialSessionConfig and modelIdentifierAliases; RequestedWorkingDirectory lets a type say "host chooses" without local fallbacks.
  • chatServiceImpl — re-keys the carried intended model when a draft materializes under a different session type.
  • constants.ts — isVisibleEditorChatSessionType hides copilot-cloud-agent while cloud-sandbox is registered.
  • chatViewPane — when an empty draft's session type is withdrawn (feature turned off), starts a fresh default draft instead of leaving the picker on a dead type.

Agents window

  • Host group, creation provider, and workspace icon now use "Cloud" / $(cloud) to match; CloudSandboxSessionsProvider reuses the shared config validation. No behavior change otherwise.

Repository picker rules (same as the cloud agent's)

  • Single tracked repository (origin first, else first GitHub remote) → no picker.
  • Multi-root → one entry per root, in workspace order.
  • Empty window / no GitHub remote → "Select Repository" placeholder + "Search Repositories…"; leaving the placeholder starts an empty sandbox.

How to test

  1. Sign in with an account that has cloud sandbox access; enable chat.agentHost.cloudSandbox.enabled and chat.remoteAgentHostsEnabled.
  2. Editor window, chat session picker → Cloud. Check the pickers: model (from the cloud catalog), Agent Mode, Approvals, and Repository per the rules above.
  3. Send a first message: progress shows "Setting up cloud container" / "Connecting to cloud container"; the draft becomes a live sandbox session running the picked model/mode/approvals.
  4. Disable the sandbox setting with an empty Cloud draft open: the picker flips to the extension's Cloud entry.
  5. Verify the Agents window still creates sandboxes as before.

Validation

  • npm run typecheck-client, npm run eslint -- <changed files>, npm run valid-layers-check — passed
  • Browser unit runner (node test/unit/browser/index.js --browser chromium --run …):
    • editorCloudSandboxContribution.test.ts — 88 passing
    • cloudSandboxAgentHostContribution.test.ts + constants.test.ts — 146 passing
    • chatService.test.ts (rekeyIntendedModel, backfillTransferredModel) — 8 passing
    • agentHostFilterService.test.ts — 30 passing
  • The Electron unit runner (scripts/test.sh) was not usable in my container due to a pre-existing module-fetch flake that reproduces on main; the browser runner was used instead. copilotChatSessionsProvider.test.ts could not be loaded by either runner here (import updated for the moved module; typecheck covers it).
  • Not covered by unit tests: the chat view pane's draft recovery on feature disable, and end-to-end model/config carry against a live sandbox — please exercise steps 2–4 manually.

The editor window could only discover and resume existing cloud sandbox
sessions; creating one required the Agents window. Lift provisioning and
creation-progress tracking into the shared CloudSandboxSessionContribution
so both windows use the same provision -> seed -> connect path, and expose
a "GitHub Sandbox" creation target in the editor's chat session picker.

- Base contribution gains _provisionSandbox() and
  trackSessionCreationProgress(); the Agents-window subclass delegates to
  them.
- CloudSandboxSessionListController tracks provisional sessions and
  resolves the working directory to the chosen repository (or the host
  default when no repository is selected).
- EditorCloudSandboxSessionContribution registers a visible picker type
  with a repository option group, implements newChatSessionItem with a
  cancellable progress notification, and rebinds the untitled draft to the
  per-environment session type once the sandbox is connected.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 23:00

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.

🟡 Changes recommended

Repository-less sessions can incorrectly inherit a local workspace path, provisional state lacks production cleanup, and the owning specification remains outdated.

3 open findings
What changed in this PR

Enables cloud sandbox creation from the editor chat session picker while sharing provisioning logic with the Agents window.

Changes:

  • Adds repository-aware sandbox creation and progress reporting.
  • Tracks provisional sessions and working directories.
  • Refactors shared sandbox provisioning and adds editor tests.
File Description
editorCloudSandboxContribution.test.ts Tests editor sandbox creation flows.
editorCloudSandboxContribution.ts Adds the picker target and creation workflow.
cloudSandboxSessionListController.ts Tracks provisional repositories and directories.
cloudSandboxSessionContribution.ts Centralizes provisioning and progress logic.
cloudSandboxAgentHostContribution.ts Delegates Agents-window provisioning to the shared implementation.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

- Wire remote Agent Host session materialization through
  IChatSessionsService.notifySessionMaterialized so provisional repository
  state is released once the first turn is accepted, matching the local
  contribution.
- Let a session type signal that the host must choose the working
  directory: the resolver service and handler config accept an explicit
  null, which short-circuits the local new-session/workspace fallbacks.
  "No Repository" sandbox sessions use it instead of relying on the host
  advertising a default directory.
- Update the provider specification to describe cross-window sandbox
  creation.

Co-authored-by: Copilot <[email protected]>
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: c03d2e4a Current: 459d41fd

Changed (1)

sessions/chatCompositeBar/OverflowingTabs/Light
Before After
before after

Rename the sandbox host group, creation provider, editor session types and
models vendor from "GitHub Sandbox(es)" to "Cloud" so both windows use the
same name as the environment they already fold into. Replace the package
workspace type icon with the cloud glyph and give the host group a cloud icon.
Identity stays on ids, so existing sessions, stored picks and filters are
unaffected.

Co-authored-by: Copilot <[email protected]>
…type

The repository picker collapses its default item to an icon, so the "No
Repository" default rendered as a second cloud glyph beside the Cloud session
type. Use the circle-slash glyph for it instead.

Co-authored-by: Copilot <[email protected]>
Offer one repository per workspace root (origin first) instead of every
remote, drop the picker when a single repository is implied, list only the
roots for multi-root windows, and keep "No Repository" to empty windows,
where a "Search Repositories..." command delegates to the extension's picker
and records the choice on the draft. A folder without a GitHub remote now
asks for a repository instead of silently starting empty.

While the sandbox Cloud type is registered it replaces the extension's cloud
agent in the editor picker, so there is a single Cloud entry whose backend
follows the sandbox setting, as in the Agents window.

Co-authored-by: Copilot <[email protected]>
…draft type

The repository picker no longer lists "No Repository": leaving the "Select
Repository" placeholder in place simply starts an empty sandbox, and a folder
without a GitHub remote does the same instead of demanding a pick.

When the sandbox setting is turned off the chat view's empty draft stayed bound
to the now unregistered type, so the picker could neither show Cloud nor leave
it. Start a fresh default draft when the current empty draft's type is
withdrawn, as is already done when the displayed session is archived.

Co-authored-by: Copilot <[email protected]>
A sandbox draft has no backend until its first send, so everything the chat
input normally reads from a live Agent Host connection has to be supplied for
the draft itself. Mirror what the Agents window does for its drafts:

- Models: register a CloudSandboxModels pool under the creation type, fed by
  the shared cloud catalog, and mark the type as owning its models. The
  environment's handler accepts the creation type's identifiers as aliases, and
  the chat service re-keys the carried intended model into the environment's
  type so the picker reclaims the choice once that pool publishes.
- Mode and approvals: move the draft vocabulary (createCloudSandboxSessionConfig)
  into the shared remoteAgentHost folder, present it as option groups on the
  draft, confirm the picks with the provisioned host, and hand them to the
  handler through a new resolveInitialSessionConfig hook on the connection
  customization. The Agents window provider reuses the shared validation.
- Repository: pre-select a "Select Repository" placeholder when no workspace
  repository is known so the picker renders with only the search command; the
  placeholder is never offered as a choice and leaves the sandbox empty.

Co-authored-by: Copilot <[email protected]>
Use one label for the placeholder and the command that opens the picker, and
keep the group hover on what the repository is for.

Co-authored-by: Copilot <[email protected]>
…-sandbox-creation

# Conflicts:
#	src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts
…-sandbox-creation

# Conflicts:
#	src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionListController.ts
#	src/vs/workbench/contrib/chat/test/browser/remoteAgentHost/editorCloudSandboxContribution.test.ts
@osortega
Osvaldo Ortega (osortega) marked this pull request as ready for review October 14, 2026 05:07

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.

Comment on lines +901 to +905
const created = await this._apiService.createSession(request, token);
const name = request.repoNwo ?? created.taskId;
const address = cloudSandboxAddress(created.environmentId);
if (!this._isEnabled() || token.isCancellationRequested || enabledToken.isCancellationRequested) {
throw new CancellationError();
Comment on lines +156 to +160
seedProvisionalSession(metadata: IAgentSessionMetadata): void {
const rawId = AgentSession.id(metadata.session);
const project = metadata.project ? getGitHubRepositoryFromRemoteUrl(metadata.project.uri.toString(), ['github.com']) : undefined;
this._provisionalRepositories.set(rawId, project ? `${project.owner}/${project.repo}` : undefined);
this._sessionListStore.addPendingNewSession(CLOUD_SANDBOX_AGENT_PROVIDER, URI.from({ scheme: this.sessionType, path: `/${rawId}` }));
Agent discovery is dynamic. Changes to a host's advertised agents update the provider's session types without recreating the provider.

Both windows use [CloudSandboxSessionContribution](../../../../workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionContribution.ts) for sandbox discovery, connection-on-open, and offline history. Each supplies its own session-list adapter. Discovery remains account-wide; the Editor adapter scopes its list to the workspace's GitHub repositories, or all projects in an empty window, and groups its filters under Cloud. Repository scope applies to cached and connected sessions without changing their routing; opening one preserves its host and session identity and does not provision a replacement. Sandbox creation remains an Agents Window operation. The Editor keeps the discovery and environment providers registered for existing conversations but excludes them from the harness picker and automatic new-chat selection.
Both windows use [CloudSandboxSessionContribution](../../../../workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionContribution.ts) for sandbox discovery, connection-on-open, and offline history. Each supplies its own session-list adapter. Discovery remains account-wide; the Editor adapter scopes its list to the workspace's GitHub repositories, or all projects in an empty window, and groups its filters under Cloud. Repository scope applies to cached and connected sessions without changing their routing; opening one preserves its host and session identity and does not provision a replacement. Both windows create sandboxes through the shared contribution's provisioning path, which seeds the created task like a discovered one before connecting. The Editor offers a single `cloud-sandbox` creation target in the harness picker with a repository option group derived from the workspace's GitHub repositories plus "No Repository"; discovered environment providers stay registered for existing conversations but remain excluded from the picker and automatic new-chat selection. On the first send, the Editor provisions the sandbox, reports progress through a cancellable notification, and returns the item under the environment's own session type so the untitled draft rebinds to it. A selected repository resolves the new session's working directory to its GitHub URL for session preparation; "No Repository" explicitly leaves the working directory to the host rather than substituting a local workspace folder.
@osortega
Osvaldo Ortega (osortega) merged commit 65b5fd7 into main Oct 14, 2026
75 of 78 checks passed
@osortega
Osvaldo Ortega (osortega) deleted the osortega/editor-cloud-sandbox-creation branch October 14, 2026 10:04
@vs-code-engineering vs-code-engineering Bot added this to the 1.143.0 milestone Oct 14, 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.

4 participants