Skip to content

Commit

Permalink
Remove enable setting
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Helming <[email protected]>
  • Loading branch information
JonasHelming committed Nov 3, 2024
1 parent 38b7477 commit a790c00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ export const PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS = 'ai-features.codeCo
export const AICodeCompletionPreferencesSchema: PreferenceSchema = {
type: 'object',
properties: {
[PREF_AI_INLINE_COMPLETION_ENABLE]: {
title: AI_CORE_PREFERENCES_TITLE,
type: 'boolean',
description: 'Enable AI completions inline within any (Monaco) editor.',
default: false
},
[PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE]: {
title: AI_CORE_PREFERENCES_TITLE,
type: 'boolean',
description: 'Automatically trigger AI completions inline within any (Monaco) editor while editing.',
description: 'Automatically trigger AI completions inline within any (Monaco) editor while editing.\
\n\
Alternativly, you can manually trigger the code via the command "Trigger Inline Suggestion" and the default shortcut "SHIFT+Space".',
default: true
},
[PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import * as monaco from '@theia/monaco-editor-core';

import { FrontendApplicationContribution, KeybindingContribution, KeybindingRegistry, PreferenceService } from '@theia/core/lib/browser';
import { inject, injectable } from '@theia/core/shared/inversify';
import { AIActivationService } from '@theia/ai-core/lib/browser';
import { AIActivationService, PREFERENCE_NAME_ENABLE_EXPERIMENTAL } from '@theia/ai-core/lib/browser';

Check failure on line 21 in packages/ai-code-completion/src/browser/ai-code-frontend-application-contribution.ts

View workflow job for this annotation

GitHub Actions / Playwright Tests (ubuntu-22.04, Node.js 18.x)

'PREFERENCE_NAME_ENABLE_EXPERIMENTAL' is declared but its value is never read.

Check failure on line 21 in packages/ai-code-completion/src/browser/ai-code-frontend-application-contribution.ts

View workflow job for this annotation

GitHub Actions / Smoke Test for Browser Example Production Build on ubuntu-22.04 with Node.js 18.x

'PREFERENCE_NAME_ENABLE_EXPERIMENTAL' is declared but its value is never read.

Check failure on line 21 in packages/ai-code-completion/src/browser/ai-code-frontend-application-contribution.ts

View workflow job for this annotation

GitHub Actions / Build and Test (windows-2019, node-18.x)

'PREFERENCE_NAME_ENABLE_EXPERIMENTAL' is declared but its value is never read.

Check failure on line 21 in packages/ai-code-completion/src/browser/ai-code-frontend-application-contribution.ts

View workflow job for this annotation

GitHub Actions / Lint

'PREFERENCE_NAME_ENABLE_EXPERIMENTAL' is declared but its value is never read.

Check failure on line 21 in packages/ai-code-completion/src/browser/ai-code-frontend-application-contribution.ts

View workflow job for this annotation

GitHub Actions / Build and Test (windows-2019, node-20.x)

'PREFERENCE_NAME_ENABLE_EXPERIMENTAL' is declared but its value is never read.

Check failure on line 21 in packages/ai-code-completion/src/browser/ai-code-frontend-application-contribution.ts

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu-22.04, node-18.x)

'PREFERENCE_NAME_ENABLE_EXPERIMENTAL' is declared but its value is never read.

Check failure on line 21 in packages/ai-code-completion/src/browser/ai-code-frontend-application-contribution.ts

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu-22.04, node-20.x)

'PREFERENCE_NAME_ENABLE_EXPERIMENTAL' is declared but its value is never read.

Check failure on line 21 in packages/ai-code-completion/src/browser/ai-code-frontend-application-contribution.ts

View workflow job for this annotation

GitHub Actions / Build and Test (macos-14, node-18.x)

'PREFERENCE_NAME_ENABLE_EXPERIMENTAL' is declared but its value is never read.

Check failure on line 21 in packages/ai-code-completion/src/browser/ai-code-frontend-application-contribution.ts

View workflow job for this annotation

GitHub Actions / Build and Test (macos-14, node-20.x)

'PREFERENCE_NAME_ENABLE_EXPERIMENTAL' is declared but its value is never read.
import { Disposable } from '@theia/core';
import { AICodeInlineCompletionsProvider } from './ai-code-inline-completion-provider';
import { PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE, PREF_AI_INLINE_COMPLETION_ENABLE, PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS } from './ai-code-completion-preference';
import { PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE, PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS } from './ai-code-completion-preference';
import { InlineCompletionTriggerKind } from '@theia/monaco-editor-core/esm/vs/editor/common/languages';

@injectable()
Expand Down Expand Up @@ -49,8 +49,7 @@ export class AIFrontendApplicationContribution implements FrontendApplicationCon
this.toDispose.set('inlineCompletions', handler());

this.preferenceService.onPreferenceChanged(event => {
if (event.preferenceName === PREF_AI_INLINE_COMPLETION_ENABLE
|| event.preferenceName === PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE
if (event.preferenceName === PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE
|| event.preferenceName === PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS) {
this.toDispose.get('inlineCompletions')?.dispose();
this.toDispose.set('inlineCompletions', handler());
Expand All @@ -66,18 +65,15 @@ export class AIFrontendApplicationContribution implements FrontendApplicationCon
registerKeybindings(keybindings: KeybindingRegistry): void {
keybindings.registerKeybinding({
command: 'editor.action.inlineSuggest.trigger',
keybinding: 'Ctrl+Shift+Space',
keybinding: 'Shift+Space',
when: '!editorReadonly && editorTextFocus'
});
}

protected handleInlineCompletions(): Disposable {
const enable = this.preferenceService.get<boolean>(PREF_AI_INLINE_COMPLETION_ENABLE, false) && this.activationService.isActive;

if (!enable) {
if (!this.activationService.isActive) {
return Disposable.NULL;
}

const automatic = this.preferenceService.get<boolean>(PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE, true);
const excludedExtensions = this.preferenceService.get<string[]>(PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS, []);

Expand Down

0 comments on commit a790c00

Please sign in to comment.