Skip to content

Commit e094184

Browse files
committed
Standardize all user-facing warning and information messages by referencing the object
1 parent 3873187 commit e094184

23 files changed

Lines changed: 169 additions & 85 deletions

packages/vscode/src/commands/apply-chat-response-command/apply-chat-response-command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ export const apply_chat_response_command = (
368368
}) => {
369369
if (code_review_promise_resolve) {
370370
const choice = await vscode.window.showWarningMessage(
371-
'A review is currently ongoing. Would you like to discard it?',
371+
dictionary.warning_message.REVIEW_ONGOING_DISCARD,
372372
{ modal: true },
373373
'Apply Another Chat Response'
374374
)
@@ -719,7 +719,7 @@ export const apply_chat_response_command = (
719719
} else {
720720
if (!clipboard_content.files || clipboard_content.files.length == 0) {
721721
vscode.window.showWarningMessage(
722-
dictionary.NO_VALID_CODE_BLOCKS_IN_CLIPBOARD
722+
dictionary.warning_message.NO_VALID_CODE_BLOCKS_IN_CLIPBOARD
723723
)
724724
return null
725725
}

packages/vscode/src/commands/apply-chat-response-command/handlers/intelligent-update-handler.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ export const handle_intelligent_update = async (params: {
419419
data: change.filePath
420420
})
421421
vscode.window.showWarningMessage(
422-
`Skipping applying change to invalid path: ${change.filePath}`
422+
dictionary.warning_message.SKIPPING_INVALID_PATH(change.filePath)
423423
)
424424
continue
425425
}
@@ -438,7 +438,7 @@ export const handle_intelligent_update = async (params: {
438438
data: change.filePath
439439
})
440440
vscode.window.showWarningMessage(
441-
`Failed to create file: ${change.filePath}`
441+
dictionary.warning_message.FAILED_TO_CREATE_FILE(change.filePath)
442442
)
443443
}
444444
} else {
@@ -470,7 +470,9 @@ export const handle_intelligent_update = async (params: {
470470
data: { error, file_path: change.filePath }
471471
})
472472
vscode.window.showWarningMessage(
473-
`Failed to apply changes to file: ${change.filePath}`
473+
dictionary.warning_message.FAILED_TO_APPLY_CHANGES_TO_FILE(
474+
change.filePath
475+
)
474476
)
475477
}
476478
}

packages/vscode/src/commands/apply-chat-response-command/utils/file-operations.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ export const undo_files = async (params: {
358358
data: { error: err, file_path: state.file_path }
359359
})
360360
vscode.window.showWarningMessage(
361-
`Could not delete file: ${state.file_path}.`
361+
dictionary.warning_message.COULD_NOT_DELETE_FILE(state.file_path)
362362
)
363363
}
364364
}
@@ -398,7 +398,9 @@ export const undo_files = async (params: {
398398
data: { error: err, file_path: state.file_path }
399399
})
400400
vscode.window.showWarningMessage(
401-
`Could not recreate file: ${state.file_path}.`
401+
dictionary.warning_message.COULD_NOT_RECREATE_FILE(
402+
state.file_path
403+
)
402404
)
403405
}
404406
} else {
@@ -440,7 +442,9 @@ export const undo_files = async (params: {
440442
})
441443
console.error(`Error undoing file ${state.file_path}:`, err)
442444
vscode.window.showWarningMessage(
443-
`Could not undo file: ${state.file_path}. It might have been closed or deleted.`
445+
dictionary.warning_message.COULD_NOT_UNDO_FILE_MAYBE_CLOSED(
446+
state.file_path
447+
)
444448
)
445449
}
446450
}

packages/vscode/src/commands/apply-context-command.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ async function apply_saved_context(
150150

151151
if (existing_paths.length == 0) {
152152
vscode.window.showWarningMessage(
153-
`No valid paths found in context "${context.name}".`
153+
dictionary.warning_message.NO_VALID_PATHS_IN_CONTEXT(context.name)
154154
)
155155
return
156156
}
@@ -644,7 +644,9 @@ export function apply_context_command(
644644
if (event.button === delete_button) {
645645
is_showing_dialog = true
646646
const confirm_delete = await vscode.window.showWarningMessage(
647-
`Are you sure you want to delete context "${item.context.name}"?`,
647+
dictionary.warning_message.CONFIRM_DELETE_CONTEXT(
648+
item.context.name
649+
),
648650
{ modal: true },
649651
'Delete'
650652
)

packages/vscode/src/commands/code-completion-commands.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,9 @@ const perform_code_completion = async (params: {
326326
const editor = vscode.window.activeTextEditor
327327
if (editor) {
328328
if (!editor.selection.isEmpty) {
329-
vscode.window.showWarningMessage(dictionary.CODE_COMPLETIONS_NO_SELECTION)
329+
vscode.window.showWarningMessage(
330+
dictionary.warning_message.CODE_COMPLETIONS_NO_SELECTION
331+
)
330332
return
331333
}
332334
const cancel_token_source = axios.CancelToken.source()

packages/vscode/src/commands/delete-command.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export function delete_command() {
1717
const item_type = stats.type == vscode.FileType.File ? 'file' : 'folder'
1818

1919
const result = await vscode.window.showWarningMessage(
20-
`Are you sure you want to delete this ${item_type}?`,
20+
dictionary.warning_message.CONFIRM_DELETE_ITEM(
21+
item_type as 'file' | 'folder'
22+
),
2123
{ modal: true },
2224
'Delete'
2325
)

packages/vscode/src/commands/reference-in-chat-command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function reference_in_chat_command(
2424

2525
if (!workspace_root) {
2626
vscode.window.showWarningMessage(
27-
dictionary.CANNOT_REFERENCE_FILE_OUTSIDE_WORKSPACE
27+
dictionary.warning_message.CANNOT_REFERENCE_FILE_OUTSIDE_WORKSPACE
2828
)
2929
return
3030
}

packages/vscode/src/commands/save-context-command.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,22 +197,26 @@ export function save_context_command(
197197
async () => {
198198
if (!workspace_provider) {
199199
vscode.window.showErrorMessage(
200-
dictionary.WORKSPACE_PROVIDER_NOT_AVAILABLE_CANNOT_SAVE_CONTEXT
200+
dictionary.warning_message
201+
.WORKSPACE_PROVIDER_NOT_AVAILABLE_CANNOT_SAVE_CONTEXT
201202
)
202203
return
203204
}
204205

205206
const workspace_root = workspace_provider.getWorkspaceRoot()
206207
if (!workspace_root) {
207208
vscode.window.showErrorMessage(
208-
dictionary.NO_WORKSPACE_FOLDER_FOUND_CANNOT_SAVE_CONTEXT
209+
dictionary.warning_message
210+
.NO_WORKSPACE_FOLDER_FOUND_CANNOT_SAVE_CONTEXT
209211
)
210212
return
211213
}
212214

213215
const checked_files = workspace_provider.get_checked_files()
214216
if (checked_files.length == 0) {
215-
vscode.window.showWarningMessage(dictionary.NOTHING_IN_CONTEXT_TO_SAVE)
217+
vscode.window.showWarningMessage(
218+
dictionary.warning_message.NOTHING_IN_CONTEXT_TO_SAVE
219+
)
216220
return
217221
}
218222

@@ -373,7 +377,7 @@ export function save_context_command(
373377
file_contexts = JSON.parse(content)
374378
if (!Array.isArray(file_contexts)) {
375379
vscode.window.showWarningMessage(
376-
dictionary.CONTEXTS_FILE_NOT_VALID_ARRAY
380+
dictionary.warning_message.CONTEXTS_FILE_NOT_VALID_ARRAY
377381
)
378382
file_contexts = []
379383
}

packages/vscode/src/constants/dictionary.ts

Lines changed: 65 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -67,42 +67,71 @@ export const dictionary = {
6767
'No "Edit Context" configurations found. Please add one in the settings.'
6868
},
6969

70-
// Warning messages
71-
NO_VALID_CODE_BLOCKS_IN_CLIPBOARD:
72-
'Unable to find valid code blocks in the clipboard.',
73-
CODE_COMPLETIONS_NO_SELECTION:
74-
'Code completions are not supported with active text selection.',
75-
CANNOT_REFERENCE_FILE_OUTSIDE_WORKSPACE:
76-
'Cannot reference file outside of the workspace.',
77-
WORKSPACE_PROVIDER_NOT_AVAILABLE_CANNOT_SAVE_CONTEXT:
78-
'Workspace provider is not available. Cannot save context.',
79-
NO_WORKSPACE_FOLDER_FOUND_CANNOT_SAVE_CONTEXT:
80-
'No workspace folder found. Cannot save context.',
81-
NOTHING_IN_CONTEXT_TO_SAVE: 'There is nothing in your context to save.',
82-
CONTEXTS_FILE_NOT_VALID_ARRAY:
83-
'Contexts file is not a valid array. Starting with empty contexts list.',
84-
NO_FILES_OR_WEBSITES_SELECTED: 'No files or websites selected or open.',
85-
NO_OPEN_EDITORS_SELECTED: 'No open editors selected.',
86-
NO_EDITOR_OPEN: 'No editor is open.',
87-
CANNOT_COPY_PROMPT_IN_CODE_COMPLETION_WITH_SELECTION:
88-
'Cannot copy prompt in code completion mode with an active selection.',
89-
CANNOT_COPY_PROMPT_IN_EDIT_CONTEXT_WITHOUT_CONTEXT:
90-
'Cannot copy prompt in edit context mode without any context. Please add files to the context.',
91-
CANNOT_COPY_PROMPT_IN_CODE_COMPLETION_WITHOUT_EDITOR:
92-
'Cannot copy prompt in code completion mode without an active editor.',
93-
UNABLE_TO_WORK_WITH_EMPTY_CONTEXT: 'Unable to work with empty context.',
94-
CANNOT_PREVIEW_IN_CODE_COMPLETION_WITHOUT_EDITOR:
95-
'Cannot preview in code completion mode without an active editor.',
96-
BROWSER_EXTENSION_NOT_CONNECTED:
97-
'Browser extension is not connected. Please install or reload it.',
98-
TYPE_SOMETHING_TO_USE_PRESET: 'Type something to use this preset.',
99-
PRESETS_NOT_RUN_DUE_TO_MISSING_INSTRUCTIONS:
100-
'Some presets were not run due to missing instructions.',
101-
TYPE_SOMETHING_TO_USE_GROUP: 'Type something to use this group.',
102-
GROUP_HAS_NO_SELECTED_PRESETS:
103-
'The chosen group has no selected presets to run.',
104-
NO_MODEL_PROVIDERS_CONFIGURED:
105-
'No model providers configured. Please add a model provider first on the "Model Providers" page.',
70+
warning_message: {
71+
REVIEW_ONGOING_DISCARD:
72+
'A review is currently ongoing. Would you like to discard it?',
73+
SKIPPING_INVALID_PATH: (file_path: string) =>
74+
`Skipping applying change to invalid path: ${file_path}`,
75+
NO_VALID_CODE_BLOCKS_IN_CLIPBOARD:
76+
'Unable to find valid code blocks in the clipboard.',
77+
CODE_COMPLETIONS_NO_SELECTION:
78+
'Code completions are not supported with active text selection.',
79+
CANNOT_REFERENCE_FILE_OUTSIDE_WORKSPACE:
80+
'Cannot reference file outside of the workspace.',
81+
WORKSPACE_PROVIDER_NOT_AVAILABLE_CANNOT_SAVE_CONTEXT:
82+
'Workspace provider is not available. Cannot save context.',
83+
NO_WORKSPACE_FOLDER_FOUND_CANNOT_SAVE_CONTEXT:
84+
'No workspace folder found. Cannot save context.',
85+
NOTHING_IN_CONTEXT_TO_SAVE: 'There is nothing in your context to save.',
86+
CONTEXTS_FILE_NOT_VALID_ARRAY:
87+
'Contexts file is not a valid array. Starting with empty contexts list.',
88+
NO_FILES_OR_WEBSITES_SELECTED: 'No files or websites selected or open.',
89+
NO_OPEN_EDITORS_SELECTED: 'No open editors selected.',
90+
NO_EDITOR_OPEN: 'No editor is open.',
91+
CANNOT_COPY_PROMPT_IN_CODE_COMPLETION_WITH_SELECTION:
92+
'Cannot copy prompt in code completion mode with an active selection.',
93+
CANNOT_COPY_PROMPT_IN_EDIT_CONTEXT_WITHOUT_CONTEXT:
94+
'Cannot copy prompt in edit context mode without any context. Please add files to the context.',
95+
CANNOT_COPY_PROMPT_IN_CODE_COMPLETION_WITHOUT_EDITOR:
96+
'Cannot copy prompt in code completion mode without an active editor.',
97+
UNABLE_TO_WORK_WITH_EMPTY_CONTEXT: 'Unable to work with empty context.',
98+
CANNOT_PREVIEW_IN_CODE_COMPLETION_WITHOUT_EDITOR:
99+
'Cannot preview in code completion mode without an active editor.',
100+
BROWSER_EXTENSION_NOT_CONNECTED:
101+
'Browser extension is not connected. Please install or reload it.',
102+
TYPE_SOMETHING_TO_USE_PRESET: 'Type something to use this preset.',
103+
PRESETS_NOT_RUN_DUE_TO_MISSING_INSTRUCTIONS:
104+
'Some presets were not run due to missing instructions.',
105+
TYPE_SOMETHING_TO_USE_GROUP: 'Type something to use this group.',
106+
GROUP_HAS_NO_SELECTED_PRESETS:
107+
'The chosen group has no selected presets to run.',
108+
FAILED_TO_CREATE_FILE: (file_path: string) =>
109+
`Failed to create file: ${file_path}`,
110+
FAILED_TO_APPLY_CHANGES_TO_FILE: (file_path: string) =>
111+
`Failed to apply changes to file: ${file_path}`,
112+
COULD_NOT_DELETE_FILE: (file_path: string) =>
113+
`Could not delete file: ${file_path}.`,
114+
COULD_NOT_RECREATE_FILE: (file_path: string) =>
115+
`Could not recreate file: ${file_path}.`,
116+
COULD_NOT_UNDO_FILE_MAYBE_CLOSED: (file_path: string) =>
117+
`Could not undo file: ${file_path}. It might have been closed or deleted.`,
118+
NO_VALID_PATHS_IN_CONTEXT: (context_name: string) =>
119+
`No valid paths found in context "${context_name}".`,
120+
CONFIRM_DELETE_CONTEXT: (context_name: string) =>
121+
`Are you sure you want to delete context "${context_name}"?`,
122+
CONFIRM_DELETE_ITEM: (item_type: 'file' | 'folder') =>
123+
`Are you sure you want to delete this ${item_type}?`,
124+
SAVED_CONTEXT_NOT_FOUND: (name: string, source: string) =>
125+
`Saved context "${name}" from ${source} not found.`,
126+
CONFIRM_DELETE_CONFIGURATION: (model: string, provider: string) =>
127+
`Are you sure you want to delete the configuration for model "${model}" provided by ${provider}?`,
128+
CONFIRM_DELETE_MODEL_PROVIDER: (provider_name: string) =>
129+
`Are you sure you want to delete the model provider "${provider_name}"?`,
130+
NO_MODELS_FOUND_MANUAL_ENTRY: (provider_name: string) =>
131+
`No models found for ${provider_name}. You can enter model name manually.`,
132+
NO_MODEL_PROVIDERS_CONFIGURED:
133+
'No model providers configured. Please add a model provider first on the "Model Providers" page.'
134+
},
106135

107136
settings: {
108137
SETTINGS_TITLE: 'Settings',

packages/vscode/src/context/context-initialization.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export function context_initialization(context: vscode.ExtensionContext): {
135135

136136
if (context_text == '') {
137137
vscode.window.showWarningMessage(
138-
dictionary.NO_FILES_OR_WEBSITES_SELECTED
138+
dictionary.warning_message.NO_FILES_OR_WEBSITES_SELECTED
139139
)
140140
return
141141
}
@@ -153,7 +153,9 @@ export function context_initialization(context: vscode.ExtensionContext): {
153153
const checked_files = open_editors_provider.get_checked_files()
154154

155155
if (checked_files.length === 0) {
156-
vscode.window.showWarningMessage(dictionary.NO_OPEN_EDITORS_SELECTED)
156+
vscode.window.showWarningMessage(
157+
dictionary.warning_message.NO_OPEN_EDITORS_SELECTED
158+
)
157159
return
158160
}
159161

0 commit comments

Comments
 (0)