Repository navigation
chat: don't start new chats with a harness disabled by policy - #345207
Merged
Ross Wollman (rwoll) merged 5 commits intoOct 30, 2026
Merged
Conversation
When policy disables the Claude or Codex Agent Host provider, a remembered, current or explicit choice of that harness kept winning new-chat resolution. New Chat, New Chat Editor and the restored Chat view then opened an empty read-only chat with no input. Treat a policy-disabled provider as unusable for new chats so resolution falls back to an allowed harness, without forgetting the remembered choice, and replace empty drafts of it on restore. *🤖 Authored with GitHub Copilot on behalf of @rwoll.* Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved draft-restoration issues can discard persisted unsent prompts or leave the Chat view without usable input when account policy settles late.
2 open issues
What changed in this PR
This PR updates chat session selection and restoration so organization policy disabling Claude or Codex does not leave users in an unusable new chat.
Changes:
- Rejects policy-disabled local harnesses during new-chat resolution while preserving remembered preferences.
- Adds fallback handling for restored untitled drafts in the Chat view and chat editors.
- Adds tests for policy-aware selection and draft restoration.
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/test/common/constants.test.ts |
Tests disabled-provider fallback and preference preservation. |
src/vs/workbench/contrib/chat/test/browser/widgetHosts/viewPane/chatViewPane.test.ts |
Tests which restored drafts the Chat view skips. |
src/vs/workbench/contrib/chat/test/browser/widgetHosts/editor/chatEditorInput.test.ts |
Tests editor fallback from a disabled-provider draft. |
src/vs/workbench/contrib/chat/common/constants.ts |
Adds policy checks to new-chat harness selection. |
src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewPane.ts |
Skips restored request-free drafts of disabled harnesses. |
src/vs/workbench/contrib/chat/browser/widgetHosts/editor/chatEditorInput.ts |
Redirects disabled-harness untitled drafts to the default chat. |
Review effort: Balanced
…bled drafts Replacing an empty draft of a policy-disabled harness dropped its unsent text and attachments. Carry them into the new chat in the Chat view and in chat editors, without the disabled harness's model, mode or permissions. If account policy settles after the Chat view restored such a draft, replace it once it is shown, and when availability changes, instead of waiting for account policy before showing the input. Restoring never blocks on policy or the network. *🤖 Authored with GitHub Copilot on behalf of @rwoll.* Co-authored-by: Copilot <[email protected]>
…ing disabled drafts" This reverts commit a2f0b48. Measured in a Code - OSS build on Ubuntu with Claude3PIntegration=false, the follow-up did not change what users see and regressed chat editors: - Restart with unsent drafts: the replacement chats already get the most recently typed draft from the chat input's saved empty-chat draft, with or without the follow-up. The Chat view does not reload the untitled draft. - Restarting a chat editor on a disabled draft now waited about 1.6 s for the Agent Host to load that draft, then showed an empty input. - Policy arriving while VS Code is open: the existing availability handler already replaces the read-only draft with a Local chat that keeps the prompt. *🤖 Authored with GitHub Copilot on behalf of @rwoll.* Co-authored-by: Copilot <[email protected]>
Resolve the conflict in isNewChatSessionTypeUsable with #345156, which now also rejects a remembered remote Agent Host type this window lacks. Keep that check unchanged and add the policy check for local Claude/Codex harnesses. *🤖 Authored with GitHub Copilot on behalf of @rwoll.* Co-authored-by: Copilot <[email protected]>
… Copilot is allowed Cover remembered, current and explicit Claude/Codex choices that policy disables while Local is unavailable through managed policy, the managed sandbox, chat.editor.preferCopilotHarness or chat.editor.localAgent.enabled. Each resolves to the Copilot harness. Without the fix they resolved to the disabled harness, which opens a read-only chat. *🤖 Authored with GitHub Copilot on behalf of @rwoll.* Co-authored-by: Copilot <[email protected]>
Ross Wollman (rwoll)
marked this pull request as ready for review
October 30, 2026 20:09
Ross Wollman (rwoll)
enabled auto-merge (squash)
October 30, 2026 20:09
Bhavya U (bhavyaus)
approved these changes
Oct 30, 2026
Dmitriy Vasyura (dmitrivMS)
approved these changes
Oct 30, 2026
Ross Wollman (rwoll)
deleted the
agents/repro-claude-session-issue-ubuntu
branch
October 30, 2026 20:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #345117
Problem
When org policy disables the Claude agent (
Claude3PIntegration, e.g. via the account's preview-features setting), users who had previously chosen Claude could not start a usable chat. Chat view New Chat (+), New Chat Editor, a new window and the restored Chat view all opened an empty Claude chat that only showed:There was no chat input, and Continue in Copilot did nothing because the conversation was empty.
The new-chat harness resolver treated every Agent Host session type as usable when the Agent Host was enabled. A remembered (
chat.userSelectedSessionType), current or explicit Claude/Codex type therefore kept winning even after policy disabled that provider. The resulting chat was immediately marked read-only.The same happens with Codex (
Codex3PIntegration) whenchat.editor.codex.preferAgentHostis on (experiment-controlled in stable), which looks like #344867. Reproduced on main at c6315a9 in an Ubuntu desktop; with that setting off, main falls back to Local.Fix
isNewChatSessionTypeUsablenow treats a local Agent Host provider that policy disables (Claude or Codex) as unusable, so remembered and current choices fall back to the regular default (Local or Copilot).chat.editor.preferCopilotHarness, orchat.editor.localAgent.enabledset tofalse, it resolves to the Copilot harness.Before / after
Code - OSS built from source in a fresh Ubuntu 24.04 desktop, with the policy in
/etc/vscode/policy.jsonand the user's earlier harness choice remembered. Captions come from checks of the live UI: red marks the read-only banner, green the working chat input.chat.editor.codex.preferAgentHoston), click New Chat (+)before.mp4
after.mp4
Workaround until this ships
"chat.editor.codex.preferAgentHost": falsein user settings and reload the window. The user setting overrides the experiment value.chat.editor.localAgent.enabledandchat.defaultToCopilotHarnessdon't override the remembered choice). Reset the remembered harness instead: assign a keybinding to Chat: New Local Chat (workbench.action.chat.newLocalChat, hidden from the Command Palette but listed in Keyboard Shortcuts), use it to open a Local chat, then pick Local or Copilot in the harness picker under the chat input. Later New Chat (+) clicks then open that harness. Verified on main at c6315a9.How to test
Claude3PIntegrationpolicy tofalse(Linux:/etc/vscode/policy.json; macOS dev build: adefaultsvalue for the product'sdarwinBundleIdentifier).chat.userSelectedSessionTyperemembered asagent-host-claude(for example, Claude was picked before the policy applied).Codex3PIntegrationset tofalse,chat.editor.codex.preferAgentHostset totrueandagent-host-codexremembered.Validation
Run in the Ubuntu desktop:
./scripts/test.sh --run src/vs/workbench/contrib/chat/test/common/constants.test.ts: passed (64 tests). The new "only the Copilot harness is allowed" test fails when the policy check is reverted: every case then resolves to the disabled Claude/Codex harness.npm run eslint -- src/vs/workbench/contrib/chat/test/common/constants.test.tsandnpm run typecheck-client: passed../scripts/test.sh --run src/vs/workbench/contrib/chat/test/common/constants.test.ts --run src/vs/workbench/contrib/chat/test/browser/widgetHosts/viewPane/chatViewPane.test.ts --run src/vs/workbench/contrib/chat/test/browser/widgetHosts/editor/chatEditorInput.test.ts: passed (145 tests).npm run eslint -- <the 6 changed files>: passed.🤖 Authored with GitHub Copilot on behalf of Ross Wollman (@rwoll).