Skip to content

chat: automatically move policy-blocked Local chats to Copilot - #340585

Merged
Ross Wollman (rwoll) merged 2 commits into
mainfrom
rwoll/auto-migrate-policy-local-chats
Oct 8, 2026
Merged

Ross Wollman (rwoll) merged 2 commits into
mainfrom
rwoll/auto-migrate-policy-local-chats

Conversation

@rwoll

Copy link
Copy Markdown
Member

Followup to #340529 based on user feedback.

When an organization requires Agent Host for managed sandboxing or permission
rules, opening an existing Local chat now automatically moves it to Copilot
instead of requiring the user to click Move to Copilot.

Relates #338932.

Relates https://github.com/microsoft/vscode-internalbacklog/issues/9987.

🤖 Authored with GitHub Copilot on behalf of Ross Wollman (@rwoll).

Reuse the existing migration when Local history is displayed or managed policy arrives while its chat is open. Preserve the no-send flow, retain the banner for retry, and cancel opening when the source is no longer visible.

*🤖 Authored with GitHub Copilot on behalf of @rwoll.*

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 21:38
Reviewed-head: 8c2f790
Pull-request: #340585
Approved-by: rwoll via PR Sign-Off
Requested-by: Copilot

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

Cancellation during session materialization can leave an orphaned Copilot session.

1 open finding
What changed in this PR

Automatically migrates policy-blocked Local chats to Copilot when displayed.

Changes:

  • Adds automatic migration with progress and retry states.
  • Cancels migration when the source is no longer visible.
  • Updates tests, policy guidance, and accessibility help.
File Description
chatWidget.ts Triggers automatic migration.
chatReadOnlyBanner.ts Exposes banner action execution.
chatContinueInAction.ts Adds source visibility checks.
chatAccessibilityHelp.ts Documents automatic migration.
chatWidget.test.ts Tests migration lifecycle.
chatContinueInCopilotAction.test.ts Tests visibility cancellation.
sdk-runtime-policy.md Documents policy behavior.

🧠 Review effort: Balanced


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

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 0f5a4b26 Current: 0655d346

Changed (1)

sessions/chatCompositeBar/MixedStatuses/Light
Before After
before after

@connor4312 Connor Peet (connor4312) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the complete diff and the surrounding widget, migration action, transcript import, session materialization, provisional ownership/cleanup, and tests for security and correctness. No P1 blocking issues found. One substantiated P2 cancellation-cleanup issue is noted inline (also corroborates the existing review finding). Review was read-only; no repository files or branches were modified and no tests were executed.

Written by Connor's agent running GPT-6.1 Sol

await provisional.disposeSession(untitledResource);
}
}
ensureSourceVisible();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Dispose the materialized destination when visibility cancellation fires here. If the user switches chats or hides the widget while createNewChatSessionItem is pending, that call can successfully rebind the imported backend to sessionResource before this check throws. tryRebind removes the untitled entry, so the preceding disposeSession(untitledResource) is then a no-op; the outer cleanup only clears import snapshots. The destination never opens (and thus never acquires a chat-model disposal hook), but its provisional/backend session remains and is already announced as materialized. Reopening the unarchived Local chat can repeat this and create additional copies. Clean up the real destination on cancellation before opening, including its materialized session-list state, and add a test that hides/switches the source during createNewChatSessionItem (the current tests only cover availability and provisional preparation).

Written by Connor's agent running GPT-6.1 Sol

@rwoll
Ross Wollman (rwoll) merged commit adb6bdc into main Oct 8, 2026
35 checks passed
@rwoll
Ross Wollman (rwoll) deleted the rwoll/auto-migrate-policy-local-chats branch October 8, 2026 22:06
@vs-code-engineering vs-code-engineering Bot added this to the 1.142.0 milestone Oct 8, 2026
Ross Wollman (rwoll) added a commit that referenced this pull request Oct 8, 2026
<!-- Thank you for submitting a Pull Request. Please:
* Read our Pull Request guidelines:

https://github.com/microsoft/vscode/wiki/How-to-Contribute#pull-requests
* Associate an issue with the Pull Request.
* Ensure that the code is up-to-date with the `main` branch.
* Include a description of the proposed changes and how to test them.
-->

Followup to #340585 addressing
[review
feedback](#340585 (comment)).

If the user switches away while an automatic migration is creating the
Copilot
session, delete that unopened destination before cancelling. Keep the
original
Local chat untouched and avoid publishing the cancelled destination.

Relates #338932.

Relates microsoft/vscode-internalbacklog#9987.

*🤖 Authored with GitHub Copilot on behalf of @rwoll.*
Ross Wollman (rwoll) added a commit that referenced this pull request Oct 9, 2026
<!-- Thank you for submitting a Pull Request. Please:
* Read our Pull Request guidelines:
  https://github.com/microsoft/vscode/wiki/How-to-Contribute#pull-requests
* Associate an issue with the Pull Request.
* Ensure that the code is up-to-date with the `main` branch.
* Include a description of the proposed changes and how to test them.
-->

Supersedes #340408. Builds on the automatic migration and cleanup in #340585 and #340596.

Any nonempty managed `permissions` object now requires Copilot Agent Host, including
defaults, explicit `false` / `"enable"`, and empty rule lists. This reuses the existing
Local chat migration without sending anything automatically.

Copilot's permission picker reflects runtime restrictions and defaults, allowing
admins to block Allow All while keeping Assisted available. Explicit new mode
restrictions replace the legacy blanket restriction; `defaultMode` alone does not.

Empty `permissions: {}` and legacy policy alone retain existing Local behavior.
Editor Inline Chat keeps its limited read/edit exception. Sandboxing remains independent.

## Policy behavior

**Legacy `ChatToolsAutoApprove: false` with no managed permissions still blocks
both Allow All and Assisted in Copilot Agent Host.** It does not force users off
Local. A nonempty `permissions` object determines harness eligibility; only an
explicit new mode restriction replaces the legacy blanket mode restriction.

The table shows selectable modes, not the starting selection. It assumes all
modes are supported and no additional restrictions. Legacy JSON represents policy
values, not OS-specific deployment syntax. Local does not support Assisted.

| # | Legacy policy JSON | Managed-settings JSON | Full Local chat | AH: Allow All | AH: Assisted | AH: Manual |
|---|---|---|---|:---:|:---:|:---:|
| 1 | `{}` | `{}` | Available | ✅ | ✅ | ✅ |
| 2 | `{"ChatToolsAutoApprove":false}` | `{}` | Available, legacy restrictions | ❌ | ❌ | ✅ |
| 3 | `{}` | `{"permissions":{"disableBypassPermissionsMode":"disable"}}` | Migrate to Copilot | ❌ | ✅ | ✅ |
| 4 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"disableBypassPermissionsMode":"disable"}}` | Migrate to Copilot | ❌ | ✅ | ✅ |
| 5 | `{}` | `{"permissions":{"disableAssistedPermissionsMode":true}}` | Migrate to Copilot | ✅ | ❌ | ✅ |
| 6 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"disableAssistedPermissionsMode":true}}` | Migrate to Copilot | ✅ | ❌ | ✅ |
| 7 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"disableBypassPermissionsMode":"disable","disableAssistedPermissionsMode":true}}` | Migrate to Copilot | ❌ | ❌ | ✅ |
| 8 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"disableBypassPermissionsMode":"enable"}}` | Migrate to Copilot | ✅ | ✅ | ✅ |
| 9 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"disableAssistedPermissionsMode":false}}` | Migrate to Copilot | ✅ | ✅ | ✅ |
| 10 | `{}` | `{"permissions":{"defaultMode":"assisted"}}` | Migrate to Copilot | ✅ | ✅ | ✅ |
| 11 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"defaultMode":"assisted"}}` | Migrate to Copilot | ❌ | ❌ | ✅ |
| 12 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"ask":[]}}` | Migrate to Copilot | ❌ | ❌ | ✅ |

`permissions: {}` behaves like no permissions object. Rows 6, 8, and 9 intentionally
replace the legacy restriction with the explicitly configured new mode controls.
Rows 11 and 12 require Agent Host but retain the legacy mode restriction.
In row 10, Assisted is the starting default unless an explicit or remembered
choice takes precedence; in row 11 it is unavailable, so the default falls back
to Manual.

“Migrate to Copilot” means full Local execution is unavailable: new chats use
Copilot and existing Local chats migrate when displayed. The editor-inline
exception above remains. Managed `sandbox.enabled: true` independently requires
Agent Host even when permissions are absent.

## Testing

Test with only `permissions.disableBypassPermissionsMode: "disable"`: full Local chats
should move to Copilot, Allow All should be unavailable, and Assisted should remain
selectable. Also test policy removal and an empty permissions object.

Relates #338932.

Relates microsoft/vscode-internalbacklog#9987.

*🤖 Authored with GitHub Copilot on behalf of @rwoll.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants