From 0d684d4b8dcc9dbbb0dd3ea52baf8d3b5b64fbea Mon Sep 17 00:00:00 2001 From: Florian Richter Date: Tue, 25 Feb 2025 16:15:43 +0100 Subject: [PATCH] Initialize AIActivationService from preferences In our Theia-derived IDE, the AI feature sometimes is not enabled properly, even though the setting is enabled. We traced this down to the AIActivationServer depending on a signal from the PreferenceService. Fixes #15043 Signed-off-by: Florian Richter --- packages/ai-core/src/browser/ai-activation-service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/ai-core/src/browser/ai-activation-service.ts b/packages/ai-core/src/browser/ai-activation-service.ts index a914604306995..f28b1dceeac04 100644 --- a/packages/ai-core/src/browser/ai-activation-service.ts +++ b/packages/ai-core/src/browser/ai-activation-service.ts @@ -45,7 +45,8 @@ export class AIActivationService implements FrontendApplicationContribution { } initialize(): MaybePromise { - this.isAiEnabledKey = this.contextKeyService.createKey(ENABLE_AI_CONTEXT_KEY, false); + const value = this.preferenceService.get(ENABLE_AI_CONTEXT_KEY); + this.isAiEnabledKey = this.contextKeyService.createKey(ENABLE_AI_CONTEXT_KEY, value); this.preferenceService.onPreferenceChanged(e => { if (e.preferenceName === PREFERENCE_NAME_ENABLE_AI) { this.isAiEnabledKey.set(e.newValue);