Skip to content

Commit 4b1457e

Browse files
committed
Rename all occurrences of preset to web configuration across the editor and shared packages
- in place of [Fragment], use [Fragment]. Remove unused translations. - rename 'edit preset form' to 'edit web configuration form' - in identifiers, file names: rename 'preset' to 'web configuration'
1 parent 29be01b commit 4b1457e

43 files changed

Lines changed: 867 additions & 943 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/editor/src/constants/state-keys.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const RECENTLY_USED_INTELLIGENT_UPDATE_CONFIG_IDS_STATE_KEY =
7070
export const RECENTLY_USED_VOICE_INPUT_CONFIG_IDS_STATE_KEY =
7171
'recently-used-voice-input-config-ids'
7272

73-
export const PRESETS_COLLAPSED_STATE_KEY = 'presets-collapsed'
73+
export const WEB_CONFIGURATIONS_COLLAPSED_STATE_KEY = 'web-configurations-collapsed'
7474
export const API_CONFIGURATIONS_COLLAPSED_STATE_KEY = 'api-configurations-collapsed'
7575

7676
export const get_recently_used_presets_or_groups_key = (

‎apps/editor/src/services/websocket-manager.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { CHATBOTS } from '@shared/constants/chatbots'
1313
import { DEFAULT_PORT, SECURITY_TOKENS } from '@shared/constants/websocket'
1414
import { dictionary } from '@shared/constants/dictionary'
1515
import { Logger } from '@shared/utils/logger'
16-
import { Preset } from '@shared/types/preset'
16+
import { WebConfiguration } from '@shared/types/web-configuration'
1717
import { ConfigPresetFormat } from '@/views/panel/backend/utils/preset-format-converters'
1818
import { LAST_SELECTED_BROWSER_ID_STATE_KEY } from '@/constants/state-keys'
1919
import { ApplyChatResponseCommandArgs } from '@/commands/apply-chat-response-command/response-processor'
@@ -345,20 +345,20 @@ export class WebSocketManager {
345345
public async initialize_chats(params: {
346346
chats: Array<{
347347
text: string
348-
preset_name: string
348+
web_configuration_name: string
349349
raw_instructions?: string
350350
edit_format?: string
351351
prompt_type?: WebPromptType
352352
}>
353-
presets_config_key: string
353+
web_configurations_config_key: string
354354
}): Promise<boolean> {
355355
if (!this.has_connected_browsers) {
356356
throw new Error('Does not have connected browsers.')
357357
}
358358

359359
const config = vscode.workspace.getConfiguration('codeWebChat')
360360
const web_chat_presets =
361-
config.get<ConfigPresetFormat[]>(params.presets_config_key) ?? []
361+
config.get<ConfigPresetFormat[]>(params.web_configurations_config_key) ?? []
362362
const gemini_user_id = config.get<number | null>('geminiUserId')
363363
const ai_studio_user_id = config.get<number | null>('aiStudioUserId')
364364
const reuse_last_tab =
@@ -372,7 +372,7 @@ export class WebSocketManager {
372372
}
373373

374374
for (const chat of params.chats) {
375-
const preset = web_chat_presets.find((p) => p.name == chat.preset_name)
375+
const preset = web_chat_presets.find((p) => p.name == chat.web_configuration_name)
376376
if (!preset) {
377377
continue
378378
}
@@ -460,7 +460,7 @@ export class WebSocketManager {
460460

461461
public async preview_preset(params: {
462462
instruction: string
463-
preset: Preset
463+
preset: WebConfiguration
464464
raw_instructions: string
465465
prompt_type?: WebPromptType
466466
}): Promise<boolean> {

‎apps/editor/src/views/panel/backend/message-handlers/handle-copy-prompt.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { replace_symbols } from '@/views/panel/backend/utils/symbols/replace-sym
2020
export const handle_copy_prompt = async (params: {
2121
panel_provider: PanelProvider
2222
instructions: string
23-
preset_name?: string
23+
web_configuration_name?: string
2424
}): Promise<void> => {
2525
const files_collector = new FilesCollector({
2626
workspace_provider: params.panel_provider.workspace_provider,

apps/editor/src/views/panel/backend/message-handlers/handle-create-preset.ts renamed to apps/editor/src/views/panel/backend/message-handlers/handle-create-web-configuration.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@ import { PanelProvider } from '@/views/panel/backend/panel-provider'
33
import { dictionary } from '@shared/constants/dictionary'
44
import { CHATBOTS } from '@shared/constants/chatbots'
55
import {
6-
config_preset_to_ui_format,
7-
ConfigPresetFormat
8-
} from '@/views/panel/backend/utils/preset-format-converters'
9-
import { CreatePresetMessage } from '@/views/panel/types/messages'
6+
config_web_configuration_to_ui_format,
7+
ConfigWebConfigurationFormat
8+
} from '@/views/panel/backend/utils/web-configuration-format-converters'
9+
import { CreateWebConfigurationMessage } from '@/views/panel/types/messages'
1010

11-
const ITEM_NAME_PRESET = 'Preset'
11+
const ITEM_NAME_WEB_CONFIGURATION = 'Web Configuration'
1212

13-
const create_preset = async (params: {
13+
const create_web_configuration = async (params: {
1414
panel_provider: PanelProvider
1515
insertion_index?: number
1616
chatbot: keyof typeof CHATBOTS
1717
}) => {
1818
const config = vscode.workspace.getConfiguration('codeWebChat')
19-
const presets_config_key = params.panel_provider.get_presets_config_key()
20-
const current_presets =
21-
config.get<ConfigPresetFormat[]>(presets_config_key, []) || []
19+
const web_configurations_config_key = params.panel_provider.get_web_configurations_config_key()
20+
const current_web_configurations =
21+
config.get<ConfigWebConfigurationFormat[]>(web_configurations_config_key, []) || []
2222

2323
let copy_number = 0
2424
let new_name: string
2525
do {
2626
new_name = `(${copy_number++})`
27-
} while (current_presets.some((p) => p.name == new_name))
27+
} while (current_web_configurations.some((p) => p.name == new_name))
2828

29-
const new_preset: ConfigPresetFormat = {
29+
const new_web_configuration: ConfigWebConfigurationFormat = {
3030
name: new_name,
3131
chatbot: params.chatbot,
3232
model: Object.keys(CHATBOTS[params.chatbot].models ?? {})[0],
@@ -35,29 +35,29 @@ const create_preset = async (params: {
3535
: undefined
3636
}
3737

38-
const updated_presets = [...current_presets]
38+
const updated_web_configurations = [...current_web_configurations]
3939
if (params.insertion_index !== undefined) {
40-
updated_presets.splice(params.insertion_index, 0, new_preset)
40+
updated_web_configurations.splice(params.insertion_index, 0, new_web_configuration)
4141
} else {
42-
updated_presets.push(new_preset)
42+
updated_web_configurations.push(new_web_configuration)
4343
}
4444

4545
try {
4646
params.panel_provider.send_message({
47-
command: 'PRESET_CREATED',
48-
preset: config_preset_to_ui_format(new_preset)
47+
command: 'WEB_CONFIGURATION_CREATED',
48+
web_configuration: config_web_configuration_to_ui_format(new_web_configuration)
4949
})
50-
await config.update(presets_config_key, updated_presets, true)
50+
await config.update(web_configurations_config_key, updated_web_configurations, true)
5151
} catch (error) {
5252
vscode.window.showErrorMessage(
53-
dictionary.error_message.FAILED_TO_CREATE_ITEM(ITEM_NAME_PRESET, error)
53+
dictionary.error_message.FAILED_TO_CREATE_ITEM(ITEM_NAME_WEB_CONFIGURATION, error)
5454
)
5555
}
5656
}
5757

58-
export const handle_create_preset = async (
58+
export const handle_create_web_configuration = async (
5959
panel_provider: PanelProvider,
60-
message: CreatePresetMessage
60+
message: CreateWebConfigurationMessage
6161
): Promise<void> => {
6262
let insertion_index: number | undefined
6363

@@ -125,7 +125,7 @@ export const handle_create_preset = async (
125125
const quick_pick = vscode.window.createQuickPick()
126126
quick_pick.items = items
127127
quick_pick.title = 'Chatbots'
128-
quick_pick.placeholder = 'Choose a chatbot for the new preset'
128+
quick_pick.placeholder = 'Choose a chatbot for the new web configuration'
129129
quick_pick.buttons = [
130130
{
131131
iconPath: new vscode.ThemeIcon('close'),
@@ -144,7 +144,7 @@ export const handle_create_preset = async (
144144
?.label as keyof typeof CHATBOTS
145145
quick_pick.hide()
146146
if (selected_chatbot) {
147-
await create_preset({
147+
await create_web_configuration({
148148
panel_provider,
149149
insertion_index,
150150
chatbot: selected_chatbot

‎apps/editor/src/views/panel/backend/message-handlers/handle-delete-preset.ts‎

Lines changed: 0 additions & 57 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import * as vscode from 'vscode'
2+
import { PanelProvider } from '@/views/panel/backend/panel-provider'
3+
import { dictionary } from '@shared/constants/dictionary'
4+
import { DeleteWebConfigurationMessage } from '@/views/panel/types/messages'
5+
import { ConfigWebConfigurationFormat } from '@/views/panel/backend/utils/web-configuration-format-converters'
6+
7+
export const handle_delete_web_configuration = async (
8+
panel_provider: PanelProvider,
9+
message: DeleteWebConfigurationMessage,
10+
webview_view: vscode.WebviewView
11+
): Promise<void> => {
12+
const { index } = message
13+
const config = vscode.workspace.getConfiguration('codeWebChat')
14+
const web_configurations_config_key = panel_provider.get_web_configurations_config_key()
15+
const current_web_configurations =
16+
config.get<ConfigWebConfigurationFormat[]>(web_configurations_config_key, []) || []
17+
18+
if (index < 0 || index >= current_web_configurations.length) return
19+
20+
const item_to_delete = current_web_configurations[index]
21+
const item_name = item_to_delete.name
22+
const is_unnamed = !item_name || /^\(\d+\)$/.test(item_name?.trim() ?? '')
23+
const display_item_name = is_unnamed ? 'Unnamed' : item_name!
24+
25+
const delete_button = 'Delete'
26+
const result = await vscode.window.showWarningMessage(
27+
dictionary.warning_message.PLEASE_CONFIRM,
28+
{
29+
modal: true,
30+
detail: is_unnamed
31+
? dictionary.warning_message.CONFIRM_DELETE_ITEM('configuration')
32+
: dictionary.warning_message.CONFIRM_DELETE_NAMED_ITEM('web configuration', display_item_name)
33+
},
34+
delete_button
35+
)
36+
37+
if (result != delete_button) {
38+
return
39+
}
40+
41+
const updated_web_configurations = [...current_web_configurations]
42+
updated_web_configurations.splice(index, 1)
43+
44+
try {
45+
await config.update(
46+
web_configurations_config_key,
47+
updated_web_configurations,
48+
vscode.ConfigurationTarget.Global
49+
)
50+
51+
panel_provider.send_web_configurations_to_webview(webview_view.webview)
52+
} catch (error) {
53+
vscode.window.showErrorMessage(
54+
dictionary.error_message.FAILED_TO_DELETE_ITEM('web configuration', error)
55+
)
56+
}
57+
}

‎apps/editor/src/views/panel/backend/message-handlers/handle-duplicate-preset.ts‎

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)