-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat(ai): rework AI configuration into a unified view #17820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ndoschek
wants to merge
3
commits into
master
Choose a base branch
from
GH-17649
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...s/api-samples/src/browser/ai-configuration/sample-chat-toolbar-configuration-category.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| // ***************************************************************************** | ||
| // Copyright (C) 2026 EclipseSource and others. | ||
| // | ||
| // This program and the accompanying materials are made available under the | ||
| // terms of the Eclipse Public License v. 2.0 which is available at | ||
| // http://www.eclipse.org/legal/epl-2.0. | ||
| // | ||
| // This Source Code may also be made available under the following Secondary | ||
| // Licenses when the conditions for such availability set forth in the Eclipse | ||
| // Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
| // with the GNU Classpath Exception which is available at | ||
| // https://www.gnu.org/software/classpath/license.html. | ||
| // | ||
| // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
| // ***************************************************************************** | ||
|
|
||
| import { Emitter, Event, nls } from '@theia/core'; | ||
| import { codicon } from '@theia/core/lib/browser'; | ||
| import { DisposableCollection } from '@theia/core/lib/common'; | ||
| import { inject, injectable, interfaces, postConstruct } from '@theia/core/shared/inversify'; | ||
| import * as React from '@theia/core/shared/react'; | ||
| import { | ||
| AiConfigurationCategory, | ||
| AiConfigurationRenderContext, | ||
| AiConfigurationSearchItem, | ||
| AiConfigurationSearchProvider | ||
| } from '@theia/ai-core-ui/lib/browser/ai-configuration/ai-configuration-category'; | ||
| import { SinglePageCategoryRenderer } from '@theia/ai-core-ui/lib/browser/ai-configuration/renderers/single-page-category-renderer'; | ||
| import { AiConfigurationSection } from '@theia/ai-core-ui/lib/browser/ai-configuration/components/ai-configuration-primitives'; | ||
| import { AiSettingsRow } from '@theia/ai-core-ui/lib/browser/ai-configuration/components/ai-settings-row'; | ||
| import { AiSettingsRowService } from '@theia/ai-core-ui/lib/browser/ai-configuration/components/ai-settings-row-service'; | ||
| import { SAMPLE_CHAT_NODE_TOOLBAR_ENABLED_PREF } from '../chat/sample-chat-node-toolbar-preferences'; | ||
|
|
||
| /** | ||
| * Sample `single-page` AI configuration category contributed by `@theia/api-samples`. It sets | ||
| * `contributed: true`, so it appears under "Contributed by extensions" in the AI Configuration view, and it | ||
| * surfaces the {@link SAMPLE_CHAT_NODE_TOOLBAR_ENABLED_PREF} setting that gates the sample chat-response | ||
| * action button — so toggling it here has a real, observable effect on the chat UI. It uses only the public | ||
| * {@link AiConfigurationCategory} contribution point and the shared primitives, proving an extension can add a | ||
| * category with no privileged access, render like the built-ins, and participate in deep search. | ||
| */ | ||
| @injectable() | ||
| export class SampleChatToolbarConfigurationCategory extends SinglePageCategoryRenderer implements AiConfigurationCategory, AiConfigurationSearchProvider { | ||
|
|
||
| readonly id = 'sample-extension'; | ||
| readonly label = nls.localize('theia/api-samples/sampleExtension/label', 'API Samples'); | ||
| readonly description = nls.localize('theia/api-samples/sampleExtension/description', | ||
| 'Example settings contributed by the @theia/api-samples extension.'); | ||
| readonly iconClass = codicon('lightbulb'); | ||
| readonly kind = 'single-page' as const; | ||
| readonly contributed = true; | ||
|
|
||
| @inject(AiSettingsRowService) | ||
| protected readonly settingsRowService: AiSettingsRowService; | ||
|
|
||
| protected readonly onDidChangeEmitter = new Emitter<void>(); | ||
| readonly onDidChange: Event<void> = this.onDidChangeEmitter.event; | ||
| protected readonly toDispose = new DisposableCollection(this.onDidChangeEmitter); | ||
|
|
||
| get renderer(): this { | ||
| return this; | ||
| } | ||
|
|
||
| get search(): AiConfigurationSearchProvider { | ||
| return this; | ||
| } | ||
|
|
||
| @postConstruct() | ||
| protected init(): void { | ||
| this.toDispose.push(this.settingsRowService.onPreferenceChanged(() => this.onDidChangeEmitter.fire())); | ||
| } | ||
|
|
||
| dispose(): void { | ||
| this.toDispose.dispose(); | ||
| } | ||
|
|
||
| protected renderSections(ctx: AiConfigurationRenderContext): React.ReactNode { | ||
| return <AiConfigurationSection title={nls.localizeByDefault('Chat')}> | ||
| <AiSettingsRow | ||
| service={this.settingsRowService} | ||
| preferenceId={SAMPLE_CHAT_NODE_TOOLBAR_ENABLED_PREF} | ||
| scope={ctx.scope} | ||
| control={{ type: 'boolean' }} | ||
| onDidChange={ctx.update} | ||
| /> | ||
| </AiConfigurationSection>; | ||
| } | ||
|
|
||
| getSearchItems(): AiConfigurationSearchItem[] { | ||
| const described = this.settingsRowService.describe(SAMPLE_CHAT_NODE_TOOLBAR_ENABLED_PREF); | ||
| return [{ | ||
| label: described.label ?? SAMPLE_CHAT_NODE_TOOLBAR_ENABLED_PREF, | ||
| typeLabel: nls.localizeByDefault('Setting'), | ||
| categoryId: this.id, | ||
| target: { categoryId: this.id, highlight: { rowId: SAMPLE_CHAT_NODE_TOOLBAR_ENABLED_PREF } }, | ||
| keywords: SAMPLE_CHAT_NODE_TOOLBAR_ENABLED_PREF | ||
| }]; | ||
| } | ||
| } | ||
|
|
||
| export function bindSampleChatToolbarConfigurationCategory(bind: interfaces.Bind): void { | ||
| bind(SampleChatToolbarConfigurationCategory).toSelf().inSingletonScope(); | ||
| bind(AiConfigurationCategory).toService(SampleChatToolbarConfigurationCategory); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
examples/api-samples/src/browser/chat/sample-chat-node-toolbar-preferences.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // ***************************************************************************** | ||
| // Copyright (C) 2026 EclipseSource and others. | ||
| // | ||
| // This program and the accompanying materials are made available under the | ||
| // terms of the Eclipse Public License v. 2.0 which is available at | ||
| // http://www.eclipse.org/legal/epl-2.0. | ||
| // | ||
| // This Source Code may also be made available under the following Secondary | ||
| // Licenses when the conditions for such availability set forth in the Eclipse | ||
| // Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
| // with the GNU Classpath Exception which is available at | ||
| // https://www.gnu.org/software/classpath/license.html. | ||
| // | ||
| // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
| // ***************************************************************************** | ||
|
|
||
| import { nls, PreferenceContribution } from '@theia/core'; | ||
| import { interfaces } from '@theia/core/shared/inversify'; | ||
| import { PreferenceSchema } from '@theia/core/lib/common/preferences/preference-schema'; | ||
|
|
||
| /** | ||
| * Whether the API Samples extension shows its example action button on chat response nodes | ||
| * (see {@link bindChatNodeToolbarActionContribution}). Surfaced as a contributed setting in the AI | ||
| * Configuration view so toggling it has a real, observable effect on the chat UI. | ||
| */ | ||
| export const SAMPLE_CHAT_NODE_TOOLBAR_ENABLED_PREF = 'sampleChatNodeToolbar.enabled'; | ||
|
|
||
| export const sampleChatNodeToolbarPreferenceSchema: PreferenceSchema = { | ||
| properties: { | ||
| [SAMPLE_CHAT_NODE_TOOLBAR_ENABLED_PREF]: { | ||
| type: 'boolean', | ||
| title: nls.localize('theia/api-samples/sampleChatNodeToolbar/enabled/title', 'Show Sample Chat Response Action'), | ||
| markdownDescription: nls.localize('theia/api-samples/sampleChatNodeToolbar/enabled/description', | ||
| 'When enabled, the `@theia/api-samples` extension adds an example action button to each chat response. ' | ||
| + 'Turn it off to hide that sample action.'), | ||
| default: true | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| export function bindSampleChatNodeToolbarPreferences(bind: interfaces.Bind): void { | ||
| bind(PreferenceContribution).toConstantValue({ schema: sampleChatNodeToolbarPreferenceSchema }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.