Skip to content

Commit 8187689

Browse files
Add descriptions to open AI config widget
1 parent cee979b commit 8187689

File tree

9 files changed

+114
-3
lines changed

9 files changed

+114
-3
lines changed

packages/ai-core/src/browser/agent-preferences.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const AgentSettingsPreferenceSchema: PreferenceSchema = {
2525
[AGENT_SETTINGS_PREF]: {
2626
type: 'object',
2727
title: nls.localize('theia/ai/agents/title', 'Agent Settings'),
28+
hidden: true,
2829
markdownDescription: nls.localize('theia/ai/agents/mdDescription', 'Configure agent settings such as enabling or disabling specific agents, configuring prompts and \
2930
selecting LLMs.'),
3031
additionalProperties: {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// *****************************************************************************
2+
// Copyright (C) 2025 EclipseSource GmbH and others.
3+
//
4+
// This program and the accompanying materials are made available under the
5+
// terms of the Eclipse Public License v. 2.0 which is available at
6+
// http://www.eclipse.org/legal/epl-2.0.
7+
//
8+
// This Source Code may also be made available under the following Secondary
9+
// Licenses when the conditions for such availability set forth in the Eclipse
10+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
11+
// with the GNU Classpath Exception which is available at
12+
// https://www.gnu.org/software/classpath/license.html.
13+
//
14+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15+
// *****************************************************************************
16+
17+
import { nls } from '@theia/core';
18+
import { PreferenceSchema } from '@theia/core/lib/browser/preferences/preference-contribution';
19+
20+
/**
21+
* These preferences are not intended to reflect real settings.
22+
* They are placeholders to redirect users to the appropriate widget
23+
* in case the user looks in the preferences editor UI to find the configuration.
24+
*/
25+
export const AiConfigurationPreferences: PreferenceSchema = {
26+
type: 'object',
27+
properties: {
28+
'ai-features.agentSettings.details': {
29+
type: 'null',
30+
markdownDescription: nls.localize('theia/ai/ide/agent-description',
31+
'Additional settings for AI agents can be configured using the [AI Configuration View]({0}).',
32+
'command:aiConfiguration:open'
33+
)
34+
},
35+
'ai-features.promptTemplates.details': {
36+
type: 'null',
37+
markdownDescription: nls.localize('theia/ai/ide/prompt-template-description',
38+
'Additional AI prompt template settings can be configured using the [AI Configuration View]({0}).',
39+
'command:aiConfiguration:open'
40+
)
41+
},
42+
'ai-features.models.details': {
43+
type: 'null',
44+
markdownDescription: nls.localize('theia/ai/ide/prompt-template-description',
45+
'Additional settings for AI models can be configured using the [AI Configuration View]({0}).',
46+
'command:aiConfiguration:open'
47+
)
48+
}
49+
}
50+
};

packages/ai-ide/src/browser/frontend-module.ts

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { AIAgentConfigurationViewContribution } from './ai-configuration/ai-conf
3838
import { AIConfigurationContainerWidget } from './ai-configuration/ai-configuration-widget';
3939
import { AIVariableConfigurationWidget } from './ai-configuration/variable-configuration-widget';
4040
import { ContextFilesVariableContribution } from '../common/context-files-variable';
41+
import {AiConfigurationPreferences} from './ai-configuration/ai-configuration-preferences';
4142

4243
export default new ContainerModule(bind => {
4344
bind(PreferenceContribution).toConstantValue({ schema: WorkspacePreferencesSchema });
@@ -105,4 +106,5 @@ export default new ContainerModule(bind => {
105106
bind(ToolProvider).to(SimpleReplaceContentInFileProvider);
106107
bind(ToolProvider).to(AddFileToChatContext);
107108
bind(AIVariableContribution).to(ContextFilesVariableContribution).inSingletonScope();
109+
bind(PreferenceContribution).toConstantValue({schema: AiConfigurationPreferences});
108110
});

packages/core/src/common/preferences/preference-schema.ts

+3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ export interface PreferenceItem extends IJSONSchema {
7373
*/
7474
defaultValue?: JSONValue;
7575
overridable?: boolean;
76+
/** If false, the preference will not be included in the schema or the UI. */
7677
included?: boolean;
78+
/** If true, this item will registered as part of the preference schema, but hidden in the preference editor UI. */
79+
hidden?: boolean;
7780
[key: string]: any;
7881
}
7982
export interface PreferenceSchemaProperty extends PreferenceItem {

packages/core/src/node/messaging/websocket-frontend-connection-service.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class WebsocketFrontendConnectionService implements FrontendConnectionSer
103103

104104
handleSocketDisconnect(socket: Socket, channel: ReconnectableSocketChannel, frontEndId: string): void {
105105
socket.on('disconnect', evt => {
106-
console.info('socked closed');
106+
console.info('socket closed');
107107
channel.disconnect();
108108

109109
const timeout = this.frontendConnectionTimeout();
@@ -183,4 +183,3 @@ class ReconnectableSocketChannel extends AbstractChannel {
183183
return writeBuffer;
184184
}
185185
}
186-

packages/preferences/src/browser/util/preference-layout.ts

+1
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ export const DEFAULT_LAYOUT: PreferenceLayout[] = [
306306
{
307307
id: 'ai-features',
308308
label: 'AI Features', // TODO localize
309+
settings: ['ai-features.*']
309310
},
310311
{
311312
id: 'extensions',

packages/preferences/src/browser/util/preference-tree-generator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class PreferenceTreeGenerator {
9292
}
9393
for (const propertyName of propertyNames) {
9494
const property = preferencesSchema.properties[propertyName];
95-
if (!this.preferenceConfigs.isSectionName(propertyName) && !OVERRIDE_PROPERTY_PATTERN.test(propertyName) && !property.deprecationMessage) {
95+
if (!property.hidden && !property.deprecationMessage && !this.preferenceConfigs.isSectionName(propertyName) && !OVERRIDE_PROPERTY_PATTERN.test(propertyName)) {
9696
if (property.owner) {
9797
this.createPluginLeafNode(propertyName, property, root, groups);
9898
} else {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// *****************************************************************************
2+
// Copyright (C) 2025 EclipseSource GmbH and others.
3+
//
4+
// This program and the accompanying materials are made available under the
5+
// terms of the Eclipse Public License v. 2.0 which is available at
6+
// http://www.eclipse.org/legal/epl-2.0.
7+
//
8+
// This Source Code may also be made available under the following Secondary
9+
// Licenses when the conditions for such availability set forth in the Eclipse
10+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
11+
// with the GNU Classpath Exception which is available at
12+
// https://www.gnu.org/software/classpath/license.html.
13+
//
14+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15+
// *****************************************************************************
16+
17+
import { injectable, interfaces } from '@theia/core/shared/inversify';
18+
import { PreferenceLeafNodeRenderer, PreferenceNodeRenderer } from './preference-node-renderer';
19+
import { Preference } from '../../util/preference-types';
20+
import { PreferenceLeafNodeRendererContribution } from './preference-node-renderer-creator';
21+
22+
@injectable()
23+
/** For rendering preference items for which the only interesting feature is the description */
24+
export class PreferenceNullInputRenderer extends PreferenceLeafNodeRenderer<null, HTMLElement> {
25+
protected override createInteractable(container: HTMLElement): void {
26+
const span = document.createElement('span');
27+
this.interactable = span;
28+
container.appendChild(span);
29+
}
30+
31+
protected override getFallbackValue(): null {
32+
// eslint-disable-next-line no-null/no-null
33+
return null;
34+
}
35+
36+
protected override doHandleValueChange(): void { }
37+
}
38+
39+
@injectable()
40+
export class PreferenceNullRendererContribution extends PreferenceLeafNodeRendererContribution {
41+
static ID = 'preference-null-renderer';
42+
id = PreferenceNullRendererContribution.ID;
43+
44+
canHandleLeafNode(node: Preference.LeafNode): number {
45+
const isOnlyNull = node.preference.data.type === 'null' || Array.isArray(node.preference.data.type) && node.preference.data.type.every(candidate => candidate === 'null');
46+
return isOnlyNull ? 5 : 0;
47+
}
48+
49+
createLeafNodeRenderer(container: interfaces.Container): PreferenceNodeRenderer {
50+
return container.get(PreferenceNullInputRenderer);
51+
}
52+
}

packages/preferences/src/browser/views/preference-widget-bindings.ts

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { PreferencesScopeTabBar } from './preference-scope-tabbar-widget';
3636
import { PreferencesSearchbarWidget } from './preference-searchbar-widget';
3737
import { PreferencesTreeWidget } from './preference-tree-widget';
3838
import { PreferencesWidget } from './preference-widget';
39+
import { PreferenceNullInputRenderer, PreferenceNullRendererContribution } from './components/preference-null-input';
3940

4041
export function bindPreferencesWidgets(bind: interfaces.Bind): void {
4142
bind(PreferenceTreeLabelProvider).toSelf().inSingletonScope();
@@ -58,6 +59,8 @@ export function bindPreferencesWidgets(bind: interfaces.Bind): void {
5859

5960
bind(PreferenceStringInputRenderer).toSelf();
6061
bind(PreferenceNodeRendererContribution).to(PreferenceStringInputRendererContribution).inSingletonScope();
62+
bind(PreferenceNullInputRenderer).toSelf();
63+
bind(PreferenceNodeRendererContribution).to(PreferenceNullRendererContribution).inSingletonScope();
6164

6265
bind(PreferenceBooleanInputRenderer).toSelf();
6366
bind(PreferenceNodeRendererContribution).to(PreferenceBooleanInputRendererContribution).inSingletonScope();

0 commit comments

Comments
 (0)