Skip to content

Commit a67d64a

Browse files
committed
fix the settings render
1 parent b321e10 commit a67d64a

File tree

11 files changed

+145
-133
lines changed

11 files changed

+145
-133
lines changed

front_end/panels/ai_chat/ui/SettingsDialog.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { createLogger } from '../core/Logger.js';
77
import { LLMClient } from '../LLM/LLMClient.js';
88

99
// Import settings utilities
10-
import { i18nString } from './settings/i18n-strings.js';
10+
import { i18nString, UIStrings } from './settings/i18n-strings.js';
1111
import { PROVIDER_SELECTION_KEY, MINI_MODEL_STORAGE_KEY, NANO_MODEL_STORAGE_KEY, ADVANCED_SETTINGS_ENABLED_KEY } from './settings/constants.js';
1212
import { applySettingsStyles } from './settings/utils/styles.js';
1313
import { isVectorDBEnabled } from './settings/utils/storage.js';
@@ -65,7 +65,7 @@ export class SettingsDialog {
6565

6666
const title = document.createElement('h2');
6767
title.className = 'settings-title';
68-
title.textContent = i18nString('settings');
68+
title.textContent = i18nString(UIStrings.settings);
6969
headerDiv.appendChild(title);
7070

7171
const closeButton = document.createElement('button');
@@ -82,12 +82,12 @@ export class SettingsDialog {
8282

8383
const providerLabel = document.createElement('div');
8484
providerLabel.className = 'settings-label';
85-
providerLabel.textContent = i18nString('providerLabel');
85+
providerLabel.textContent = i18nString(UIStrings.providerLabel);
8686
providerSection.appendChild(providerLabel);
8787

8888
const providerHint = document.createElement('div');
8989
providerHint.className = 'settings-hint';
90-
providerHint.textContent = i18nString('providerHint');
90+
providerHint.textContent = i18nString(UIStrings.providerHint);
9191
providerSection.appendChild(providerHint);
9292

9393
// Use the stored provider from localStorage
@@ -101,25 +101,25 @@ export class SettingsDialog {
101101
// Add options to the dropdown
102102
const openaiOption = document.createElement('option');
103103
openaiOption.value = 'openai';
104-
openaiOption.textContent = i18nString('openaiProvider');
104+
openaiOption.textContent = i18nString(UIStrings.openaiProvider);
105105
openaiOption.selected = currentProvider === 'openai';
106106
providerSelect.appendChild(openaiOption);
107107

108108
const litellmOption = document.createElement('option');
109109
litellmOption.value = 'litellm';
110-
litellmOption.textContent = i18nString('litellmProvider');
110+
litellmOption.textContent = i18nString(UIStrings.litellmProvider);
111111
litellmOption.selected = currentProvider === 'litellm';
112112
providerSelect.appendChild(litellmOption);
113113

114114
const groqOption = document.createElement('option');
115115
groqOption.value = 'groq';
116-
groqOption.textContent = i18nString('groqProvider');
116+
groqOption.textContent = i18nString(UIStrings.groqProvider);
117117
groqOption.selected = currentProvider === 'groq';
118118
providerSelect.appendChild(groqOption);
119119

120120
const openrouterOption = document.createElement('option');
121121
openrouterOption.value = 'openrouter';
122-
openrouterOption.textContent = i18nString('openrouterProvider');
122+
openrouterOption.textContent = i18nString(UIStrings.openrouterProvider);
123123
openrouterOption.selected = currentProvider === 'openrouter';
124124
providerSelect.appendChild(openrouterOption);
125125

@@ -361,7 +361,7 @@ export class SettingsDialog {
361361
// Create disclaimer
362362
const disclaimer = document.createElement('div');
363363
disclaimer.className = 'settings-disclaimer';
364-
disclaimer.textContent = i18nString('disclaimer');
364+
disclaimer.textContent = i18nString(UIStrings.disclaimer);
365365
contentDiv.appendChild(disclaimer);
366366

367367
// Create footer with buttons
@@ -379,14 +379,14 @@ export class SettingsDialog {
379379
buttonContainer.appendChild(saveStatusMessage);
380380

381381
const cancelButton = document.createElement('button');
382-
cancelButton.textContent = i18nString('cancelButton');
382+
cancelButton.textContent = i18nString(UIStrings.cancelButton);
383383
cancelButton.className = 'settings-button cancel-button';
384384
cancelButton.setAttribute('type', 'button');
385385
cancelButton.addEventListener('click', () => dialog.hide());
386386
buttonContainer.appendChild(cancelButton);
387387

388388
const saveButton = document.createElement('button');
389-
saveButton.textContent = i18nString('saveButton');
389+
saveButton.textContent = i18nString(UIStrings.saveButton);
390390
saveButton.className = 'settings-button save-button';
391391
saveButton.setAttribute('type', 'button');
392392
buttonContainer.appendChild(saveButton);

front_end/panels/ai_chat/ui/settings/advanced/BrowsingHistorySettings.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import { i18nString } from '../i18n-strings.js';
5+
import { i18nString, UIStrings } from '../i18n-strings.js';
66
import * as Common from '../../../../../core/common/common.js';
77

88
const logger = Common.Console.Console.instance();
@@ -28,25 +28,25 @@ export class BrowsingHistorySettings {
2828
// Title
2929
const historyTitle = document.createElement('h3');
3030
historyTitle.className = 'settings-subtitle';
31-
historyTitle.textContent = i18nString('browsingHistoryTitle');
31+
historyTitle.textContent = i18nString(UIStrings.browsingHistoryTitle);
3232
this.container.appendChild(historyTitle);
3333

3434
// Description
3535
const historyDescription = document.createElement('p');
3636
historyDescription.className = 'settings-description';
37-
historyDescription.textContent = i18nString('browsingHistoryDescription');
37+
historyDescription.textContent = i18nString(UIStrings.browsingHistoryDescription);
3838
this.container.appendChild(historyDescription);
3939

4040
// Status message element (initially hidden)
4141
this.statusMessage = document.createElement('div');
4242
this.statusMessage.className = 'settings-status history-status';
4343
this.statusMessage.style.display = 'none';
44-
this.statusMessage.textContent = i18nString('historyCleared');
44+
this.statusMessage.textContent = i18nString(UIStrings.historyCleared);
4545
this.container.appendChild(this.statusMessage);
4646

4747
// Clear history button
4848
const clearHistoryButton = document.createElement('button');
49-
clearHistoryButton.textContent = i18nString('clearHistoryButton');
49+
clearHistoryButton.textContent = i18nString(UIStrings.clearHistoryButton);
5050
clearHistoryButton.className = 'settings-button clear-button';
5151
clearHistoryButton.setAttribute('type', 'button');
5252
this.container.appendChild(clearHistoryButton);

front_end/panels/ai_chat/ui/settings/advanced/EvaluationSettings.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import { i18nString } from '../i18n-strings.js';
5+
import { i18nString, UIStrings } from '../i18n-strings.js';
66
import {
77
getEvaluationConfig,
88
setEvaluationConfig,
@@ -40,7 +40,7 @@ export class EvaluationSettings {
4040
// Title
4141
const evaluationSectionTitle = document.createElement('h3');
4242
evaluationSectionTitle.className = 'settings-subtitle';
43-
evaluationSectionTitle.textContent = i18nString('evaluationSection');
43+
evaluationSectionTitle.textContent = i18nString(UIStrings.evaluationSection);
4444
this.container.appendChild(evaluationSectionTitle);
4545

4646
// Get current evaluation configuration
@@ -61,12 +61,12 @@ export class EvaluationSettings {
6161
const evaluationEnabledLabel = document.createElement('label');
6262
evaluationEnabledLabel.htmlFor = 'evaluation-enabled';
6363
evaluationEnabledLabel.className = 'evaluation-label';
64-
evaluationEnabledLabel.textContent = i18nString('evaluationEnabled');
64+
evaluationEnabledLabel.textContent = i18nString(UIStrings.evaluationEnabled);
6565
evaluationEnabledContainer.appendChild(evaluationEnabledLabel);
6666

6767
const evaluationEnabledHint = document.createElement('div');
6868
evaluationEnabledHint.className = 'settings-hint';
69-
evaluationEnabledHint.textContent = i18nString('evaluationEnabledHint');
69+
evaluationEnabledHint.textContent = i18nString(UIStrings.evaluationEnabledHint);
7070
this.container.appendChild(evaluationEnabledHint);
7171

7272
// Connection status indicator
@@ -143,12 +143,12 @@ export class EvaluationSettings {
143143
// Evaluation endpoint
144144
const evaluationEndpointLabel = document.createElement('div');
145145
evaluationEndpointLabel.className = 'settings-label';
146-
evaluationEndpointLabel.textContent = i18nString('evaluationEndpoint');
146+
evaluationEndpointLabel.textContent = i18nString(UIStrings.evaluationEndpoint);
147147
evaluationConfigContainer.appendChild(evaluationEndpointLabel);
148148

149149
const evaluationEndpointHint = document.createElement('div');
150150
evaluationEndpointHint.className = 'settings-hint';
151-
evaluationEndpointHint.textContent = i18nString('evaluationEndpointHint');
151+
evaluationEndpointHint.textContent = i18nString(UIStrings.evaluationEndpointHint);
152152
evaluationConfigContainer.appendChild(evaluationEndpointHint);
153153

154154
this.evaluationEndpointInput = document.createElement('input');
@@ -161,12 +161,12 @@ export class EvaluationSettings {
161161
// Evaluation secret key
162162
const evaluationSecretKeyLabel = document.createElement('div');
163163
evaluationSecretKeyLabel.className = 'settings-label';
164-
evaluationSecretKeyLabel.textContent = i18nString('evaluationSecretKey');
164+
evaluationSecretKeyLabel.textContent = i18nString(UIStrings.evaluationSecretKey);
165165
evaluationConfigContainer.appendChild(evaluationSecretKeyLabel);
166166

167167
const evaluationSecretKeyHint = document.createElement('div');
168168
evaluationSecretKeyHint.className = 'settings-hint';
169-
evaluationSecretKeyHint.textContent = i18nString('evaluationSecretKeyHint');
169+
evaluationSecretKeyHint.textContent = i18nString(UIStrings.evaluationSecretKeyHint);
170170
evaluationConfigContainer.appendChild(evaluationSecretKeyHint);
171171

172172
this.evaluationSecretKeyInput = document.createElement('input');

front_end/panels/ai_chat/ui/settings/advanced/MCPSettings.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import { i18nString } from '../i18n-strings.js';
5+
import { i18nString, UIStrings } from '../i18n-strings.js';
66
import {
77
getMCPConfig,
88
setMCPConfig,
@@ -61,7 +61,7 @@ export class MCPSettings {
6161
// Title
6262
const mcpSectionTitle = document.createElement('h3');
6363
mcpSectionTitle.className = 'settings-subtitle';
64-
mcpSectionTitle.textContent = i18nString('mcpSection');
64+
mcpSectionTitle.textContent = i18nString(UIStrings.mcpSection);
6565
this.container.appendChild(mcpSectionTitle);
6666
}
6767

@@ -189,12 +189,12 @@ export class MCPSettings {
189189
// Connections management
190190
const mcpConnectionsLabel = document.createElement('div');
191191
mcpConnectionsLabel.className = 'settings-label';
192-
mcpConnectionsLabel.textContent = i18nString('mcpConnectionsHeader');
192+
mcpConnectionsLabel.textContent = i18nString(UIStrings.mcpConnectionsHeader);
193193
this.container.appendChild(mcpConnectionsLabel);
194194

195195
const mcpConnectionsHint = document.createElement('div');
196196
mcpConnectionsHint.className = 'settings-hint';
197-
mcpConnectionsHint.textContent = i18nString('mcpConnectionsHint');
197+
mcpConnectionsHint.textContent = i18nString(UIStrings.mcpConnectionsHint);
198198
this.container.appendChild(mcpConnectionsHint);
199199

200200
const mcpConnectionsActions = document.createElement('div');
@@ -206,7 +206,7 @@ export class MCPSettings {
206206

207207
const manageConnectionsButton = document.createElement('button');
208208
manageConnectionsButton.className = 'settings-button';
209-
manageConnectionsButton.textContent = i18nString('mcpManageConnections');
209+
manageConnectionsButton.textContent = i18nString(UIStrings.mcpManageConnections);
210210
manageConnectionsButton.addEventListener('click', () => {
211211
MCPConnectionsDialog.show({
212212
onSave: async () => {
@@ -227,7 +227,7 @@ export class MCPSettings {
227227

228228
const refreshConnectionsButton = document.createElement('button');
229229
refreshConnectionsButton.className = 'settings-button';
230-
refreshConnectionsButton.textContent = i18nString('mcpRefreshConnections');
230+
refreshConnectionsButton.textContent = i18nString(UIStrings.mcpRefreshConnections);
231231
refreshConnectionsButton.addEventListener('click', async () => {
232232
try {
233233
await MCPRegistry.init(true);
@@ -254,12 +254,12 @@ export class MCPSettings {
254254
// Tool mode selection
255255
const mcpToolModeLabel = document.createElement('div');
256256
mcpToolModeLabel.className = 'settings-label';
257-
mcpToolModeLabel.textContent = i18nString('mcpToolMode');
257+
mcpToolModeLabel.textContent = i18nString(UIStrings.mcpToolMode);
258258
mcpConfigContainer.appendChild(mcpToolModeLabel);
259259

260260
const mcpToolModeHint = document.createElement('div');
261261
mcpToolModeHint.className = 'settings-hint';
262-
mcpToolModeHint.textContent = i18nString('mcpToolModeHint');
262+
mcpToolModeHint.textContent = i18nString(UIStrings.mcpToolModeHint);
263263
mcpConfigContainer.appendChild(mcpToolModeHint);
264264

265265
const mcpToolModeSelect = document.createElement('select');
@@ -268,9 +268,9 @@ export class MCPSettings {
268268

269269
// Tool mode options
270270
const toolModeOptions = [
271-
{ value: 'all', text: i18nString('mcpToolModeAll') },
272-
{ value: 'router', text: i18nString('mcpToolModeRouter') },
273-
{ value: 'meta', text: i18nString('mcpToolModeMeta') },
271+
{ value: 'all', text: i18nString(UIStrings.mcpToolModeAll) },
272+
{ value: 'router', text: i18nString(UIStrings.mcpToolModeRouter) },
273+
{ value: 'meta', text: i18nString(UIStrings.mcpToolModeMeta) },
274274
];
275275

276276
toolModeOptions.forEach(option => {
@@ -295,12 +295,12 @@ export class MCPSettings {
295295
// Advanced budget controls
296296
const mcpMaxToolsLabel = document.createElement('div');
297297
mcpMaxToolsLabel.className = 'settings-label';
298-
mcpMaxToolsLabel.textContent = i18nString('mcpMaxToolsPerTurn');
298+
mcpMaxToolsLabel.textContent = i18nString(UIStrings.mcpMaxToolsPerTurn);
299299
mcpConfigContainer.appendChild(mcpMaxToolsLabel);
300300

301301
const mcpMaxToolsHint = document.createElement('div');
302302
mcpMaxToolsHint.className = 'settings-hint';
303-
mcpMaxToolsHint.textContent = i18nString('mcpMaxToolsPerTurnHint');
303+
mcpMaxToolsHint.textContent = i18nString(UIStrings.mcpMaxToolsPerTurnHint);
304304
mcpConfigContainer.appendChild(mcpMaxToolsHint);
305305

306306
const mcpMaxToolsInput = document.createElement('input');
@@ -313,12 +313,12 @@ export class MCPSettings {
313313

314314
const mcpMaxMcpLabel = document.createElement('div');
315315
mcpMaxMcpLabel.className = 'settings-label';
316-
mcpMaxMcpLabel.textContent = i18nString('mcpMaxMcpPerTurn');
316+
mcpMaxMcpLabel.textContent = i18nString(UIStrings.mcpMaxMcpPerTurn);
317317
mcpConfigContainer.appendChild(mcpMaxMcpLabel);
318318

319319
const mcpMaxMcpHint = document.createElement('div');
320320
mcpMaxMcpHint.className = 'settings-hint';
321-
mcpMaxMcpHint.textContent = i18nString('mcpMaxMcpPerTurnHint');
321+
mcpMaxMcpHint.textContent = i18nString(UIStrings.mcpMaxMcpPerTurnHint);
322322
mcpConfigContainer.appendChild(mcpMaxMcpHint);
323323

324324
const mcpMaxMcpInput = document.createElement('input');
@@ -468,17 +468,17 @@ export class MCPSettings {
468468
reconnectButton.className = 'settings-button';
469469
reconnectButton.style.padding = '2px 8px';
470470
reconnectButton.style.fontSize = '12px';
471-
reconnectButton.textContent = i18nString('mcpReconnectButton');
471+
reconnectButton.textContent = i18nString(UIStrings.mcpReconnectButton);
472472
reconnectButton.addEventListener('click', async () => {
473473
reconnectButton.disabled = true;
474-
reconnectButton.textContent = i18nString('mcpReconnectInProgress');
474+
reconnectButton.textContent = i18nString(UIStrings.mcpReconnectInProgress);
475475
try {
476476
await MCPRegistry.reconnect(server.id);
477477
clearStoredAuthError(server.id);
478478
} catch (err) {
479479
logger.error('Failed to reconnect MCP server', { serverId: server.id, error: err });
480480
reconnectButton.disabled = false;
481-
reconnectButton.textContent = i18nString('mcpReconnectRetry');
481+
reconnectButton.textContent = i18nString(UIStrings.mcpReconnectRetry);
482482
return;
483483
} finally {
484484
this.updateMCPStatus();

0 commit comments

Comments
 (0)