Skip to content

feat(ai-core): add AiConfigurationService for AI preferences - #319

Closed
AlexandraBuzila wants to merge 4 commits into
masterfrom
feat/ai-preferences-service
Closed

feat(ai-core): add AiConfigurationService for AI preferences#319
AlexandraBuzila wants to merge 4 commits into
masterfrom
feat/ai-preferences-service

Conversation

@AlexandraBuzila

@AlexandraBuzila AlexandraBuzila commented Jul 7, 2026

Copy link
Copy Markdown
Member

What it does

Introduces a framework API wrapping PreferenceService for ai-features.* preferences, as the intended extension point for reading/writing AI configuration.

Closes #310

How to test

Follow-ups

Breaking changes

  • This PR introduces breaking changes and requires careful review. If yes, the breaking changes section in the changelog has been updated.

Attribution

Review checklist

Reminder for reviewers

Introduces a framework API wrapping PreferenceService for
`ai-features.*` preferences, as the intended extension point for
reading/writing AI configuration.
@AlexandraBuzila
AlexandraBuzila requested a review from ndoschek July 7, 2026 08:08

@ndoschek ndoschek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @AlexandraBuzila, code looks great to me, I just added a few minor inline comments. Could you have a quick look? TIA!

const newPatterns = validated.filter(p => !currentPatterns.includes(p));
if (newPatterns.length > 0) {
this.preferenceService.updateValue(
this.aiConfigurationService.update(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This write is fire-and-forget, so a rejected update() is silently swallowed and can surface as an unhandled rejection. Returning the promise from addPatternsToList/removePatternFromList (and the public add*/remove* methods) would let callers observe write failures. Same applies to the update() call in removePatternFromList below.

protected readonly onDidChangeEmitter = new Emitter<AiConfigurationChange>();
readonly onDidChange: Event<AiConfigurationChange> = this.onDidChangeEmitter.event;

protected _ready: Promise<void>;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ready stays undefined until init() runs, so ready can be read before it is assigned. The sibling TrustAwarePreferenceReader avoids this by creating a Deferred eagerly; doing the same here keeps the two consistent and robust against ordering surprises.

this.trustAwareReader.onDidChangeTrust(() => this.onDidChangeEmitter.fire({
preferenceName: undefined,
affects: () => true,
affectsPreference: () => true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a trust transition this sentinel returns true for every key, including non-ai-features.* ones, so a consumer that checks an unrelated key like editor.fontSize gets a false positive. The interface doc says a trust transition affects every trust-gated key, so gating this on the ai-features. prefix would match the documented semantics.


bind(TrustAwarePreferenceReader).toSelf().inSingletonScope();

bind(AiConfigurationServiceImpl).toSelf().inSingletonScope();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TrustAwarePreferenceReader is still bound and still injected directly in frontend-language-model-service.ts and ai-ide/.../workspace-functions.ts. So after this PR there are two services that do the same trust-aware ai-features.* read. Since AiConfigurationService is meant to be the place to do this, it would be cleaner to move those two consumers over too and make TrustAwarePreferenceReader internal. Otherwise the same logic lives in two spots (TrustAwarePreferenceReader.get and AiConfigurationServiceImpl.enrichInspection) and they can easily fall out of sync.

…ervice

Move FrontendLanguageModelService and WorkspaceFunctionScope off
TrustAwarePreferenceReader onto AiConfigurationService, make the reader
internal, and centralize the trust-suppression rule in one place.
@AlexandraBuzila

Copy link
Copy Markdown
Member Author

Thank you, Nina! I addressed your comments in the last commits and also made the TrustAwarePreferenceReader internal to the new configuration service, since it was used only by the AI features for now.

@AlexandraBuzila
AlexandraBuzila requested a review from ndoschek July 7, 2026 15:39
@AlexandraBuzila

AlexandraBuzila commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

Closing in favor of eclipse-theia#17768

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AI Config] AiConfigurationService for AI preferences

2 participants