disable-copilot.patch 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts b/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts
  2. index d5aa998..ea7d567 100644
  3. --- a/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts
  4. +++ b/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts
  5. @@ -183,3 +183,4 @@ abstract class OpenChatGlobalAction extends Action2 {
  6. ChatContextKeys.Setup.hidden.negate(),
  7. - ChatContextKeys.Setup.disabled.negate()
  8. + ChatContextKeys.Setup.disabled.negate(),
  9. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate()
  10. )
  11. @@ -1458,3 +1459,3 @@ export function registerChatActions() {
  12. precondition: ContextKeyExpr.and(
  13. - ChatContextKeys.Setup.installed,
  14. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate(),
  15. ChatContextKeys.Setup.disabled.negate(),
  16. @@ -1668,3 +1669,4 @@ MenuRegistry.appendMenuItem(MenuId.CommandCenter, {
  17. ChatContextKeys.Setup.hidden.negate(),
  18. - ChatContextKeys.Setup.disabled.negate()
  19. + ChatContextKeys.Setup.disabled.negate(),
  20. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate()
  21. ),
  22. @@ -1685,3 +1687,4 @@ MenuRegistry.appendMenuItem(MenuId.TitleBar, {
  23. ChatContextKeys.Setup.hidden.negate(),
  24. - ChatContextKeys.Setup.disabled.negate()
  25. + ChatContextKeys.Setup.disabled.negate(),
  26. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate()
  27. ),
  28. @@ -1702,3 +1705,4 @@ registerAction2(class ToggleCopilotControl extends ToggleTitleBarConfigAction {
  29. ChatContextKeys.Setup.hidden.negate(),
  30. - ChatContextKeys.Setup.disabled.negate()
  31. + ChatContextKeys.Setup.disabled.negate(),
  32. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate()
  33. ),
  34. @@ -1843,3 +1847,4 @@ MenuRegistry.appendMenuItem(MenuId.EditorContext, {
  35. ChatContextKeys.Setup.hidden.negate(),
  36. - ChatContextKeys.Setup.disabled.negate()
  37. + ChatContextKeys.Setup.disabled.negate(),
  38. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate()
  39. )
  40. @@ -1876,3 +1881,3 @@ MenuRegistry.appendMenuItem(MenuId.EditorContext, {
  41. ChatContextKeys.Setup.disabled.negate(),
  42. - ChatContextKeys.Setup.installed.negate(),
  43. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate(),
  44. );
  45. diff --git a/src/vs/workbench/contrib/chat/browser/chat.contribution.ts b/src/vs/workbench/contrib/chat/browser/chat.contribution.ts
  46. index dbd2125..2f36f7b 100644
  47. --- a/src/vs/workbench/contrib/chat/browser/chat.contribution.ts
  48. +++ b/src/vs/workbench/contrib/chat/browser/chat.contribution.ts
  49. @@ -174,3 +174,3 @@ configurationRegistry.registerConfiguration({
  50. markdownDescription: nls.localize('chat.commandCenter.enabled', "Controls whether the command center shows a menu for actions to control chat (requires {0}).", '`#window.commandCenter#`'),
  51. - default: true
  52. + default: false
  53. },
  54. @@ -696,3 +696,3 @@ configurationRegistry.registerConfiguration({
  55. description: nls.localize('chat.disableAIFeatures', "Disable and hide built-in AI features provided by GitHub Copilot, including chat, code completions and next edit suggestions."),
  56. - default: false,
  57. + default: true,
  58. scope: ConfigurationScope.WINDOW
  59. diff --git a/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.ts b/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.ts
  60. index 391a4de..995590c 100644
  61. --- a/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.ts
  62. +++ b/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.ts
  63. @@ -67,9 +67,8 @@ const chatViewDescriptor: IViewDescriptor[] = [{
  64. ctorDescriptor: new SyncDescriptor(ChatViewPane, [{ location: ChatAgentLocation.Chat }]),
  65. - when: ContextKeyExpr.or(
  66. - ContextKeyExpr.or(
  67. - ChatContextKeys.Setup.hidden,
  68. - ChatContextKeys.Setup.disabled
  69. - )?.negate(),
  70. + when: ContextKeyExpr.and(
  71. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate(),
  72. + ChatContextKeys.Setup.disabled.negate(),
  73. + ChatContextKeys.Setup.hidden.negate(),
  74. ChatContextKeys.panelParticipantRegistered,
  75. - ChatContextKeys.extensionInvalid
  76. + ChatContextKeys.extensionInvalid.negate()
  77. )
  78. diff --git a/src/vs/workbench/contrib/chat/browser/chatSetup.ts b/src/vs/workbench/contrib/chat/browser/chatSetup.ts
  79. index 4325d48..53edd2c 100644
  80. --- a/src/vs/workbench/contrib/chat/browser/chatSetup.ts
  81. +++ b/src/vs/workbench/contrib/chat/browser/chatSetup.ts
  82. @@ -953,7 +953,9 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
  83. f1: true,
  84. - precondition: ContextKeyExpr.or(
  85. - ChatContextKeys.Setup.hidden,
  86. - ChatContextKeys.Setup.disabled,
  87. - ChatContextKeys.Setup.untrusted,
  88. - ChatContextKeys.Setup.installed.negate(),
  89. + precondition: ContextKeyExpr.and(
  90. + ContextKeyExpr.or(
  91. + ChatContextKeys.Setup.hidden,
  92. + ChatContextKeys.Setup.disabled,
  93. + ChatContextKeys.Setup.untrusted,
  94. + ),
  95. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate(),
  96. ChatContextKeys.Entitlement.canSignUp
  97. @@ -1069,3 +1071,3 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
  98. ChatContextKeys.Setup.hidden.negate(),
  99. - ChatContextKeys.Setup.installed.negate(),
  100. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate(),
  101. ChatContextKeys.Entitlement.signedOut
  102. @@ -1096,2 +1098,3 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
  103. ChatContextKeys.Setup.hidden.negate(),
  104. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate(),
  105. ContextKeyExpr.or(
  106. @@ -1152,2 +1155,3 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
  107. ChatContextKeys.Setup.hidden.negate(),
  108. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate(),
  109. ContextKeyExpr.or(
  110. @@ -1350,3 +1354,3 @@ export class ChatTeardownContribution extends Disposable implements IWorkbenchCo
  111. ChatContextKeys.Setup.hidden.negate(),
  112. - ChatContextKeys.Setup.installed.negate()
  113. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate()
  114. ),
  115. @@ -1356,3 +1360,3 @@ export class ChatTeardownContribution extends Disposable implements IWorkbenchCo
  116. order: 1,
  117. - when: ChatContextKeys.Setup.installed.negate()
  118. + when: ContextKeyExpr.has('config.chat.disableAIFeatures').negate()
  119. }
  120. diff --git a/src/vs/workbench/contrib/chat/browser/chatStatus.ts b/src/vs/workbench/contrib/chat/browser/chatStatus.ts
  121. index 05f6f0e..5f7a988 100644
  122. --- a/src/vs/workbench/contrib/chat/browser/chatStatus.ts
  123. +++ b/src/vs/workbench/contrib/chat/browser/chatStatus.ts
  124. @@ -48,2 +48,3 @@ import { MarkdownRenderer } from '../../../../editor/browser/widget/markdownRend
  125. import { MarkdownString } from '../../../../base/common/htmlContent.js';
  126. +import { ContextKeyExpr, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
  127. @@ -129,2 +130,3 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
  128. @IChatSessionsService private readonly chatSessionsService: IChatSessionsService,
  129. + @IContextKeyService private readonly contextKeyService: IContextKeyService,
  130. ) {
  131. @@ -132,2 +134,7 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
  132. + const rule = ContextKeyExpr.has('config.chat.disableAIFeatures');
  133. + if (this.contextKeyService.contextMatchesRules(rule)) {
  134. + return; // disabled
  135. + }
  136. +
  137. this.update();
  138. diff --git a/src/vs/workbench/contrib/chat/common/chatContextKeys.ts b/src/vs/workbench/contrib/chat/common/chatContextKeys.ts
  139. index 4877407..d11d315 100644
  140. --- a/src/vs/workbench/contrib/chat/common/chatContextKeys.ts
  141. +++ b/src/vs/workbench/contrib/chat/common/chatContextKeys.ts
  142. @@ -104,4 +104,4 @@ export namespace ChatContextKeyExprs {
  143. */
  144. - export const chatSetupTriggerContext = ContextKeyExpr.or(
  145. - ChatContextKeys.Setup.installed.negate(),
  146. + export const chatSetupTriggerContext = ContextKeyExpr.and(
  147. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate(),
  148. ChatContextKeys.Entitlement.canSignUp
  149. diff --git a/src/vs/workbench/contrib/mcp/browser/mcpServersView.ts b/src/vs/workbench/contrib/mcp/browser/mcpServersView.ts
  150. index 5a12c9d..3e1f23e 100644
  151. --- a/src/vs/workbench/contrib/mcp/browser/mcpServersView.ts
  152. +++ b/src/vs/workbench/contrib/mcp/browser/mcpServersView.ts
  153. @@ -530,3 +530,3 @@ export class McpServersViewsContribution extends Disposable implements IWorkbenc
  154. ctorDescriptor: new SyncDescriptor(DefaultBrowseMcpServersView, [{}]),
  155. - when: ContextKeyExpr.and(DefaultViewsContext, HasInstalledMcpServersContext.toNegated(), ChatContextKeys.Setup.hidden.negate(), McpServersGalleryStatusContext.isEqualTo(McpGalleryManifestStatus.Available), ContextKeyExpr.or(ContextKeyDefinedExpr.create(`config.${mcpGalleryServiceUrlConfig}`), ProductQualityContext.notEqualsTo('stable'), ContextKeyDefinedExpr.create(`config.${mcpGalleryServiceEnablementConfig}`))),
  156. + when: ContextKeyExpr.and(DefaultViewsContext, HasInstalledMcpServersContext.toNegated(), ContextKeyExpr.has('config.chat.disableAIFeatures').negate(), ChatContextKeys.Setup.hidden.negate(), McpServersGalleryStatusContext.isEqualTo(McpGalleryManifestStatus.Available), ContextKeyExpr.or(ContextKeyDefinedExpr.create(`config.${mcpGalleryServiceUrlConfig}`), ProductQualityContext.notEqualsTo('stable'), ContextKeyDefinedExpr.create(`config.${mcpGalleryServiceEnablementConfig}`))),
  157. weight: 40,
  158. @@ -545,3 +545,3 @@ export class McpServersViewsContribution extends Disposable implements IWorkbenc
  159. ctorDescriptor: new SyncDescriptor(DefaultBrowseMcpServersView, [{ showWelcome: true }]),
  160. - when: ContextKeyExpr.and(DefaultViewsContext, HasInstalledMcpServersContext.toNegated(), ChatContextKeys.Setup.hidden.negate(), McpServersGalleryStatusContext.isEqualTo(McpGalleryManifestStatus.Available), ContextKeyDefinedExpr.create(`config.${mcpGalleryServiceUrlConfig}`).negate(), ProductQualityContext.isEqualTo('stable'), ContextKeyDefinedExpr.create(`config.${mcpGalleryServiceEnablementConfig}`).negate()),
  161. + when: ContextKeyExpr.and(DefaultViewsContext, HasInstalledMcpServersContext.toNegated(), ContextKeyExpr.has('config.chat.disableAIFeatures').negate(), ChatContextKeys.Setup.hidden.negate(), McpServersGalleryStatusContext.isEqualTo(McpGalleryManifestStatus.Available), ContextKeyDefinedExpr.create(`config.${mcpGalleryServiceUrlConfig}`).negate(), ProductQualityContext.isEqualTo('stable'), ContextKeyDefinedExpr.create(`config.${mcpGalleryServiceEnablementConfig}`).negate()),
  162. weight: 40,
  163. diff --git a/src/vs/workbench/contrib/scm/browser/scm.contribution.ts b/src/vs/workbench/contrib/scm/browser/scm.contribution.ts
  164. index a2d4dc9..3f7a511 100644
  165. --- a/src/vs/workbench/contrib/scm/browser/scm.contribution.ts
  166. +++ b/src/vs/workbench/contrib/scm/browser/scm.contribution.ts
  167. @@ -659,3 +659,3 @@ registerAction2(class extends Action2 {
  168. ChatContextKeys.Setup.disabled.negate(),
  169. - ChatContextKeys.Setup.installed.negate(),
  170. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate(),
  171. ContextKeyExpr.equals('git.activeResourceHasMergeConflicts', true)
  172. diff --git a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts
  173. index d32554a..01d3cf6 100644
  174. --- a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts
  175. +++ b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts
  176. @@ -1346,3 +1346,3 @@ registerAction2(class extends Action2 {
  177. ChatContextKeys.Setup.disabled.negate(),
  178. - ChatContextKeys.Setup.installed.negate(),
  179. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate(),
  180. ContextKeyExpr.equals('scmProvider', 'git')