disable-copilot.patch 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 f425d24..ef3ba1f 100644
  3. --- a/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts
  4. +++ b/src/vs/workbench/contrib/chat/browser/actions/chatActions.ts
  5. @@ -181,3 +181,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. @@ -1416,3 +1417,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. @@ -1629,3 +1630,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. @@ -1646,3 +1648,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. @@ -1663,3 +1666,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. @@ -1804,3 +1808,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. @@ -1837,3 +1842,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 bfcab77..f0013a4 100644
  47. --- a/src/vs/workbench/contrib/chat/browser/chat.contribution.ts
  48. +++ b/src/vs/workbench/contrib/chat/browser/chat.contribution.ts
  49. @@ -179,3 +179,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. @@ -701,3 +701,3 @@ configurationRegistry.registerConfiguration({
  55. description: nls.localize('chat.disableAIFeatures', "Disable and hide built-in AI features provided by GitHub Copilot, including chat and inline 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 a1c2acb..e41068d 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 1053f71..586705d 100644
  80. --- a/src/vs/workbench/contrib/chat/browser/chatSetup.ts
  81. +++ b/src/vs/workbench/contrib/chat/browser/chatSetup.ts
  82. @@ -1020,7 +1020,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. @@ -1136,3 +1138,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. @@ -1163,2 +1165,3 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
  103. ChatContextKeys.Setup.hidden.negate(),
  104. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate(),
  105. ContextKeyExpr.or(
  106. @@ -1219,2 +1222,3 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
  107. ChatContextKeys.Setup.hidden.negate(),
  108. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate(),
  109. ContextKeyExpr.or(
  110. @@ -1435,3 +1439,3 @@ export class ChatTeardownContribution extends Disposable implements IWorkbenchCo
  111. order: 1,
  112. - when: ChatContextKeys.Setup.installed.negate()
  113. + when: ContextKeyExpr.has('config.chat.disableAIFeatures').negate()
  114. }
  115. diff --git a/src/vs/workbench/contrib/chat/browser/chatStatus.ts b/src/vs/workbench/contrib/chat/browser/chatStatus.ts
  116. index 1a4419a..eaa7466 100644
  117. --- a/src/vs/workbench/contrib/chat/browser/chatStatus.ts
  118. +++ b/src/vs/workbench/contrib/chat/browser/chatStatus.ts
  119. @@ -49,2 +49,3 @@ import { MarkdownString } from '../../../../base/common/htmlContent.js';
  120. import { AGENT_SESSIONS_VIEWLET_ID } from '../common/constants.js';
  121. +import { ContextKeyExpr, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
  122. @@ -129,2 +130,3 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
  123. @IChatSessionsService private readonly chatSessionsService: IChatSessionsService,
  124. + @IContextKeyService private readonly contextKeyService: IContextKeyService,
  125. ) {
  126. @@ -132,2 +134,7 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
  127. + const rule = ContextKeyExpr.has('config.chat.disableAIFeatures');
  128. + if (this.contextKeyService.contextMatchesRules(rule)) {
  129. + return; // disabled
  130. + }
  131. +
  132. this.update();
  133. diff --git a/src/vs/workbench/contrib/chat/common/chatContextKeys.ts b/src/vs/workbench/contrib/chat/common/chatContextKeys.ts
  134. index f51121a..db21afb 100644
  135. --- a/src/vs/workbench/contrib/chat/common/chatContextKeys.ts
  136. +++ b/src/vs/workbench/contrib/chat/common/chatContextKeys.ts
  137. @@ -108,4 +108,4 @@ export namespace ChatContextKeyExprs {
  138. */
  139. - export const chatSetupTriggerContext = ContextKeyExpr.or(
  140. - ChatContextKeys.Setup.installed.negate(),
  141. + export const chatSetupTriggerContext = ContextKeyExpr.and(
  142. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate(),
  143. ChatContextKeys.Entitlement.canSignUp
  144. diff --git a/src/vs/workbench/contrib/mcp/browser/mcpServersView.ts b/src/vs/workbench/contrib/mcp/browser/mcpServersView.ts
  145. index 7eb3689..be00ca2 100644
  146. --- a/src/vs/workbench/contrib/mcp/browser/mcpServersView.ts
  147. +++ b/src/vs/workbench/contrib/mcp/browser/mcpServersView.ts
  148. @@ -540,3 +540,3 @@ export class McpServersViewsContribution extends Disposable implements IWorkbenc
  149. ctorDescriptor: new SyncDescriptor(DefaultBrowseMcpServersView, [{}]),
  150. - 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}`))),
  151. + 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}`))),
  152. weight: 40,
  153. @@ -555,3 +555,3 @@ export class McpServersViewsContribution extends Disposable implements IWorkbenc
  154. ctorDescriptor: new SyncDescriptor(DefaultBrowseMcpServersView, [{ showWelcome: true }]),
  155. - 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()),
  156. + 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()),
  157. weight: 40,
  158. diff --git a/src/vs/workbench/contrib/scm/browser/scm.contribution.ts b/src/vs/workbench/contrib/scm/browser/scm.contribution.ts
  159. index 606bda0..191df32 100644
  160. --- a/src/vs/workbench/contrib/scm/browser/scm.contribution.ts
  161. +++ b/src/vs/workbench/contrib/scm/browser/scm.contribution.ts
  162. @@ -685,3 +685,3 @@ registerAction2(class extends Action2 {
  163. ChatContextKeys.Setup.disabled.negate(),
  164. - ChatContextKeys.Setup.installed.negate(),
  165. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate(),
  166. ContextKeyExpr.equals('git.activeResourceHasMergeConflicts', true)
  167. diff --git a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts
  168. index 4d8907e..7df25af 100644
  169. --- a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts
  170. +++ b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts
  171. @@ -1361,3 +1361,3 @@ registerAction2(class extends Action2 {
  172. ChatContextKeys.Setup.disabled.negate(),
  173. - ChatContextKeys.Setup.installed.negate(),
  174. + ContextKeyExpr.has('config.chat.disableAIFeatures').negate(),
  175. ContextKeyExpr.equals('scmProvider', 'git')