Skip to content

Commit

Permalink
fix: integrate AI preferencex context key
Browse files Browse the repository at this point in the history
The ai-core package offers a preference context key, which can be used
in scenarios like 'when' clauses for menus. This key was not integrated,
leading to the deactivation of all dependent features. This is now fixed.
  • Loading branch information
sdirix authored and planger committed Sep 16, 2024
1 parent e1aeb7c commit beabfba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/ai-core/src/browser/ai-activation-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import { Emitter, MaybePromise, Event, } from '@theia/core';
import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-key-service';
import { PREFERENCE_NAME_ENABLE_EXPERIMENTAL } from './ai-core-preferences';

export const EXPERIMENTAL_AI_CONTEXT_KEY = 'ai.experimental.enabled';
/**
* Context key for the experimental AI feature. It is set to `true` if the feature is enabled.
*/
// We reuse the enablement preference for the context key
export const EXPERIMENTAL_AI_CONTEXT_KEY = PREFERENCE_NAME_ENABLE_EXPERIMENTAL;

@injectable()
export class AIActivationService implements FrontendApplicationContribution {
Expand All @@ -41,7 +45,7 @@ export class AIActivationService implements FrontendApplicationContribution {
}

initialize(): MaybePromise<void> {
this.isExperimentalEnabledKey = this.contextKeyService.createKey(PREFERENCE_NAME_ENABLE_EXPERIMENTAL, false);
this.isExperimentalEnabledKey = this.contextKeyService.createKey(EXPERIMENTAL_AI_CONTEXT_KEY, false);
this.preferenceService.onPreferenceChanged(e => {
if (e.preferenceName === PREFERENCE_NAME_ENABLE_EXPERIMENTAL) {
this.isExperimentalEnabledKey.set(e.newValue);
Expand Down

0 comments on commit beabfba

Please sign in to comment.