Repository navigation
chat: automatically move policy-blocked Local chats to Copilot - #340585
Conversation
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]>
There was a problem hiding this comment.
🟡 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.
Connor Peet (connor4312)
left a comment
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
[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
<!-- 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.*
<!-- 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.*

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).