Skip to content

sandbox: show last-known sandbox profile while a host is disconnected - #350008

Merged
Dileep Yavanmandha (dileepyavan) merged 2 commits into
mainfrom
DileepY/sandbox-profile-last-known
Nov 23, 2026
Merged

Dileep Yavanmandha (dileepyavan) merged 2 commits into
mainfrom
DileepY/sandbox-profile-last-known

Conversation

@dileepyavan

Copy link
Copy Markdown
Member

Fixes #349807

What

Remote Environments showed Default in the Sandbox Profile column for a disconnected host, even though the host keeps its assigned profile and new sessions still use it. That looked like the assignment had been reset.

Remote Environments now remembers the profile it last saw on each connected host. While the host is disconnected, the column shows that profile, disabled, with a hover and screen-reader label that say it's the last known profile and that you need to connect to refresh or change it.

How

  • The client remembers each host's assignment per machine (APPLICATION_SHARED, MACHINE, not synced). Remote Environments records it while it shows a connected host. Choosing Default clears the remembered value; a host that can't be read keeps it.
  • On reconnect the column shows the host's current assignment and updates the remembered value. The remembered value is display-only and is never written back to the host.
  • Deleting a sandbox profile is also blocked when a disconnected remote environment is known to use it.

Behavior with two clients

  1. Client A assigns S1 and remembers it.
  2. A disconnects, and B assigns S2 to the same host.
  3. A shows "S1 (on host)", disabled and labelled as last known.
  4. When A reconnects, it shows S2 and remembers S2. The host keeps S2.

If another client changes the assignment while A is connected but Remote Environments is closed, A updates the next time it shows the host connected.

Validation

  • Unit tests cover:
    • the profile shown while disconnected and after reopening Remote Environments;
    • reconnecting after another client changed the assignment, with nothing written back to the host;
    • deletion blocked for connected and disconnected hosts, and allowed after reconnecting to an unassigned host;
    • unreadable host state never clearing a remembered assignment.
  • Type check, formatter, oxlint and the layers check pass.

Remote Environments showed Default for a disconnected host even though the
host keeps its assigned sandbox profile, which looked like the assignment had
been reset. Remote Environments now remembers the assignment it last saw on
each connected host (per machine, not synced) and shows it, disabled and
labelled as last known, while the host is disconnected. Reconnecting shows the
host's current assignment; the remembered value is never written back.

Deleting a sandbox profile is also blocked when a disconnected remote
environment is known to use it.

Fixes #349807

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 22:29
@dileepyavan
Dileep Yavanmandha (dileepyavan) marked this pull request as ready for review November 23, 2026 22:32
@dileepyavan Dileep Yavanmandha (dileepyavan) added the ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch label Nov 23, 2026

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

Window-specific host names can cause cache notifications to repeatedly refresh and rewrite assignments, creating an unbounded cross-window storage/repaint loop.

3 open issues
What changed in this PR

This PR addresses #349807 by showing a disconnected remote host’s last-known sandbox profile instead of Default. The remembered assignment is display-only; reconnecting refreshes it from the host.

Changes:

  • Persist last-known assignments per machine and show them in a disabled picker with explanatory hover and screen-reader text.
  • Block profile deletion when a connected or remembered disconnected environment uses it.
  • Update accessibility help and tests for disconnects, reopening, reconnects, and deletion protection.
File Description
src/​vs/​workbench/​contrib/​terminalContrib/​chatAgentTools/​test/​browser/​sandboxProfiles.test.ts Tests remembered assignments and deletion protection.
src/​vs/​workbench/​contrib/​terminalContrib/​chatAgentTools/​browser/​terminal.chatAgentTools.contribution.ts Updates accessibility help for deletion restrictions.
src/​vs/​workbench/​contrib/​terminalContrib/​chatAgentTools/​browser/​sandboxProfilesInput.ts Includes remembered host assignments in deletion checks.
src/​vs/​workbench/​contrib/​terminalContrib/​chatAgentTools/​browser/​sandboxProfilesEditor.ts Clarifies deletion dialogs for disconnected environments.
src/​vs/​workbench/​contrib/​sessions/​providers/​remoteAgentHost/​test/​browser/​remotesWidget.test.ts Tests disconnected display, reopening, and host-authoritative reconnects.
src/​vs/​workbench/​contrib/​sessions/​providers/​remoteAgentHost/​browser/​remotesTable.ts Displays and remembers assignments with last-known labels.
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​electron-browser/​remotes.contribution.ts Updates Remote Environments accessibility help.
src/​vs/​platform/​agentHost/​common/​sandboxProfiles.ts Adds machine-local assignment storage and change notifications.

Review effort: Balanced

Modify watchSandboxProfileAssignments to refresh only if there is no connection by address.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Merged via the queue into main with commit 66f5c56 Nov 23, 2026
38 checks passed
@dileepyavan
Dileep Yavanmandha (dileepyavan) deleted the DileepY/sandbox-profile-last-known branch November 23, 2026 23:17
Dileep Yavanmandha (dileepyavan) added a commit that referenced this pull request Nov 24, 2026
…cherry-pick #350008) (#350019)

[release/1.148] sandbox: retain disconnected host profile (#350008)

Backport #350008 to release/1.148 from its current PR head.

(cherry picked from commit a8206ee)
(cherry picked from commit 5e1c545)

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sandbox Profile: Previously selected profile not shown while disconnected

4 participants