Skip to content

Commit a90c266

Browse files
committed
Refactor missing configuration warnings and update prompt field logic to account for selected files
- in 'web' target, when connected, should not use 'copy' as primary action - rename `packages/ui/src/components/editor/prompt/BrowserExtensionMessage/BrowserExtensionMessage.tsx` to BrowserExtensionNotice - in `packages/ui/src/components/editor/prompt/BrowserExtensionNotice/BrowserExtensionNotice.tsx` use gradient between bg blue and bg green - [Fragment] should be disabled when in 'edit' prompt type without context files - when prompt is empty, the voice input should always be a default action, while keeping current shortcuts - use common.no-configurations-found instead of [Fragment] - add translations to [Fragment] - whenever about to show 'no configurations found' notification - show warning modal with button 'Open settings' (directing appropriately to web/api configurations). Use shared util for this. - rename 'no configurations found' to 'missing configuration'. use modal instead of notification ├── apps │ └── editor │ └── src │ ├── commands │ │ ├── code-at-cursor-command │ │ │ └── utils │ │ │ ├── get-code-at-cursor-config.ts │ │ │ └── perform-code-at-cursor.ts │ │ └── generate-commit-message-commands │ │ ├── actions │ │ │ └── run-generate-action.ts │ │ └── utils │ │ └── get-commit-message-config.ts │ ├── features │ │ └── search-files │ │ └── search-modes │ │ └── perform-intelligent-search-mode.ts │ ├── i18n │ │ └── translations │ │ └── common.ts │ ├── utils │ │ ├── ascii-tree │ │ │ ├── ascii-tree.ts │ │ │ ├── index.ts │ │ │ └── utils.ts │ │ └── show-no-configurations-warning.ts │ └── views │ ├── prompt │ │ ├── backend │ │ │ └── message-handlers │ │ │ ├── handle-autofill.ts │ │ │ └── utils │ │ │ └── intelligent-update-utils.ts │ │ └── frontend │ │ ├── Main │ │ │ └── MainView │ │ │ └── MainView.tsx │ │ └── Prompt.tsx │ └── settings │ └── helpers │ └── open-settings.ts └── packages └── ui └── src ├── components │ └── editor │ ├── common │ │ ├── TextButton │ │ │ └── TextButton.tsx │ │ └── prompts │ │ ├── PromptField │ │ │ ├── PromptField.module.scss │ │ │ ├── PromptField.stories.tsx │ │ │ ├── PromptField.tsx │ │ │ ├── hooks │ │ │ │ ├── use-drag-drop.ts │ │ │ │ ├── use-dropdown.ts │ │ │ │ ├── use-ghost-text.ts │ │ │ │ ├── use-handlers │ │ │ │ │ ├── handle-copy.ts │ │ │ │ │ ├── handle-cut.ts │ │ │ │ │ ├── handle-input-change.ts │ │ │ │ │ ├── handle-input-click.ts │ │ │ │ │ ├── handle-key-down.ts │ │ │ │ │ ├── handle-paste.ts │ │ │ │ │ ├── handle-submit.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── types.ts │ │ │ │ │ ├── use-handlers.ts │ │ │ │ │ └── utils.ts │ │ │ │ └── use-keyboard-shortcuts.ts │ │ │ └── index.ts │ │ ├── Template │ │ │ ├── Template.module.scss │ │ │ ├── Template.tsx │ │ │ └── index.ts │ │ └── shared │ │ └── symbols │ │ ├── caret.ts │ │ ├── get-highlighted-text.tsx │ │ ├── index.ts │ │ ├── position-mapping.ts │ │ ├── prompt-symbols.module.scss │ │ ├── reconstruct-raw-value.ts │ │ └── use-symbol-deletion.ts │ └── prompt │ └── BrowserExtensionNotice │ ├── BrowserExtensionNotice.module.scss │ ├── BrowserExtensionNotice.stories.tsx │ ├── BrowserExtensionNotice.tsx │ └── index.ts └── styles └── foundation └── _colors.scss
1 parent f5a9603 commit a90c266

19 files changed

Lines changed: 178 additions & 135 deletions

File tree

‎apps/editor/src/commands/code-at-cursor-command/utils/get-code-at-cursor-config.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
show_configuration_quick_pick,
1212
map_api_configuration_to_item
1313
} from '@/utils/show-configuration-quick-pick'
14-
import { open_settings } from '@/views/settings/helpers/open-settings'
14+
import { show_no_configurations_warning } from '@/utils/show-no-configurations-warning'
1515

1616
export const get_code_at_cursor_api_configuration = async (params: {
1717
model_providers_manager: ModelProvidersManager
@@ -23,8 +23,7 @@ export const get_code_at_cursor_api_configuration = async (params: {
2323
await params.model_providers_manager.get_api_configurations()
2424

2525
if (code_at_cursor_api_configurations.length == 0) {
26-
open_settings.api.api_configurations()
27-
vscode.window.showInformationMessage(t('common.no-configurations-found'))
26+
show_no_configurations_warning('api')
2827
return
2928
}
3029

‎apps/editor/src/commands/code-at-cursor-command/utils/perform-code-at-cursor.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { WebSocketManager } from '@/services/websocket-manager'
2424
import { show_configuration_quick_pick } from '@/utils/show-configuration-quick-pick'
2525
import { CHATBOTS } from '@shared/constants/chatbots'
2626
import { get_last_used_web_configuration_key } from '@/constants/state-keys'
27-
import { open_settings } from '@/views/settings/helpers/open-settings'
27+
import { show_no_configurations_warning } from '@/utils/show-no-configurations-warning'
2828

2929
export const perform_code_at_cursor = async (params: {
3030
workspace_provider: WorkspaceProvider
@@ -285,8 +285,7 @@ export const perform_code_at_cursor = async (params: {
285285
)
286286

287287
if (valid_web_configurations.length == 0) {
288-
open_settings.web.web_configurations()
289-
vscode.window.showInformationMessage('No configurations found.')
288+
show_no_configurations_warning('web')
290289
return
291290
}
292291

‎apps/editor/src/commands/generate-commit-message-commands/actions/run-generate-action.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { WebSocketManager } from '@/services/websocket-manager'
2525
import { ModelProvidersManager } from '@/services/model-providers-manager'
2626
import { get_response_preview_promise_resolve } from '@/commands/apply-response-command/utils/preview'
2727
import { normalize_path } from '@/utils/normalize-path'
28-
import { open_settings } from '@/views/settings/helpers/open-settings'
28+
import { show_no_configurations_warning } from '@/utils/show-no-configurations-warning'
2929

3030
const truncate_prompt = (text: string): string => {
3131
if (text.length <= MAX_PROMPT_CHARS_IN_COMMIT_MESSAGE) return text
@@ -280,8 +280,7 @@ export const run_generate_action = async (params: {
280280
)
281281

282282
if (valid_web_configurations.length == 0) {
283-
open_settings.web.web_configurations()
284-
vscode.window.showInformationMessage('No configurations found.')
283+
show_no_configurations_warning('web')
285284
current_action = undefined
286285
continue
287286
}

‎apps/editor/src/commands/generate-commit-message-commands/utils/get-commit-message-config.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
show_configuration_quick_pick,
88
map_api_configuration_to_item
99
} from '@/utils/show-configuration-quick-pick'
10-
import { open_settings } from '@/views/settings/helpers/open-settings'
10+
import { show_no_configurations_warning } from '@/utils/show-no-configurations-warning'
1111

1212
export interface CommitMessageApiConfiguration {
1313
model_provider_name: string
@@ -42,8 +42,7 @@ export const get_commit_message_api_configuration = async (
4242
await model_providers_manager.get_api_configurations()
4343

4444
if (api_configurations.length == 0) {
45-
open_settings.api.api_configurations()
46-
vscode.window.showInformationMessage(t('common.no-configurations-found'))
45+
show_no_configurations_warning('api')
4746
return null
4847
}
4948

‎apps/editor/src/features/search-files/search-modes/perform-intelligent-search-mode.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
intelligent_file_search_instructions,
2424
intelligent_file_search_format_for_prompt_view
2525
} from '@/constants/instructions'
26-
import { open_settings } from '@/views/settings/helpers/open-settings'
26+
import { show_no_configurations_warning } from '@/utils/show-no-configurations-warning'
2727

2828
export const perform_intelligent_search_mode = async (params: {
2929
files: string[]
@@ -301,8 +301,7 @@ export const perform_intelligent_search_mode = async (params: {
301301
)
302302

303303
if (valid_web_configurations.length == 0) {
304-
open_settings.web.web_configurations()
305-
vscode.window.showInformationMessage('No configurations found.')
304+
show_no_configurations_warning('web')
306305
go_back_to_action = true
307306
continue
308307
}

‎apps/editor/src/i18n/translations/common.ts‎

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -486,24 +486,41 @@ export const translations = {
486486
hu: 'Prompt a vágólapra másolva.',
487487
bg: 'Подканата е копирана в клипборда.'
488488
},
489-
'common.no-configurations-found': {
490-
en: 'No configurations for API calls found. Add in settings.',
491-
pl: 'Nie znaleziono konfiguracji dla wywołań API. Dodaj w ustawieniach.',
492-
'zh-cn': '未找到 API 调用的配置。请在设置中添加。',
493-
ja: 'API 呼び出しの設定が見つかりません。設定で追加してください。',
494-
'zh-tw': '未找到 API 呼叫的設定。請在設定中新增。',
495-
de: 'Keine Konfigurationen für API-Aufrufe gefunden. In den Einstellungen hinzufügen.',
496-
es: 'No se encontraron configuraciones para llamadas API. Añadir en ajustes.',
497-
fr: 'Aucune configuration pour les appels API trouvée. Ajouter dans les paramètres.',
498-
'pt-br':
499-
'Nenhuma configuração para chamadas de API encontrada. Adicione nas configurações.',
500-
ru: 'Конфигурации для вызовов API не найдены. Добавьте в настройках.',
501-
ko: 'API 호출을 위한 구성을 찾을 수 없습니다. 설정에서 추가하세요.',
502-
it: 'Nessuna configurazione per le chiamate API trovata. Aggiungi nelle impostazioni.',
503-
tr: 'API çağrıları için yapılandırma bulunamadı. Ayarlardan ekleyin.',
504-
cs: 'Nebyly nalezeny žádné konfigurace pro volání API. Přidejte v nastavení.',
505-
hu: 'Nem találhatók API hívási konfigurációk. Adja hozzá a beállításokban.',
506-
bg: 'Не са намерени конфигурации за API извиквания. Добавете в настройките.'
489+
'common.open-settings': {
490+
en: 'Open Settings',
491+
pl: 'Otwórz ustawienia',
492+
'zh-cn': '打开设置',
493+
ja: '設定を開く',
494+
'zh-tw': '打開設定',
495+
de: 'Einstellungen öffnen',
496+
es: 'Abrir configuración',
497+
fr: 'Ouvrir les paramètres',
498+
'pt-br': 'Abrir configurações',
499+
ru: 'Открыть настройки',
500+
ko: '설정 열기',
501+
it: 'Apri le impostazioni',
502+
tr: 'Ayarları Aç',
503+
cs: 'Otevřít nastavení',
504+
hu: 'Beállítások megnyitása',
505+
bg: 'Отвори настройките'
506+
},
507+
'common.missing-configuration': {
508+
en: 'Missing configuration.',
509+
pl: 'Brakująca konfiguracja.',
510+
'zh-cn': '缺少配置。',
511+
ja: '設定が不足しています。',
512+
'zh-tw': '缺少設定。',
513+
de: 'Fehlende Konfiguration.',
514+
es: 'Falta configuración.',
515+
fr: 'Configuration manquante.',
516+
'pt-br': 'Configuração ausente.',
517+
ru: 'Отсутствует конфигурация.',
518+
ko: '구성이 누락되었습니다.',
519+
it: 'Configurazione mancante.',
520+
tr: 'Yapılandırma eksik.',
521+
cs: 'Chybí konfigurace.',
522+
hu: 'Hiányzó konfiguráció.',
523+
bg: 'Липсваща конфигурация.'
507524
},
508525
'common.info.select-files-to-search': {
509526
en: 'Please select files to search.',
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as vscode from 'vscode'
2+
import { t } from '@/i18n'
3+
import { open_settings } from '@/views/settings/helpers/open-settings'
4+
5+
export const show_no_configurations_warning = async (
6+
type: 'api' | 'web'
7+
): Promise<void> => {
8+
const open_settings_label = t('common.open-settings')
9+
const result = await vscode.window.showWarningMessage(
10+
t('common.missing-configuration'),
11+
{ modal: true },
12+
open_settings_label
13+
)
14+
15+
if (result === open_settings_label) {
16+
if (type == 'api') {
17+
open_settings.api.api_configurations()
18+
} else {
19+
open_settings.web.web_configurations()
20+
}
21+
}
22+
}

‎apps/editor/src/views/prompt/backend/message-handlers/handle-at-sign-quick-pick/handle-at-sign-quick-pick.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ const at_sign_quick_pick = async (params: {
260260
}
261261

262262
const separator_item = {
263-
label: 'files in context',
263+
label: 'selected files',
264264
kind: vscode.QuickPickItemKind.Separator
265265
} as any
266266

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
import { handle_update_last_used_web_configuration } from './handle-update-last-used-web-configuration'
1717
import { show_configuration_quick_pick } from '@/utils/show-configuration-quick-pick'
1818
import { PromptBuilder } from '@/utils/prompt-builder'
19-
import { open_settings } from '@/views/settings/helpers/open-settings'
19+
import { show_no_configurations_warning } from '@/utils/show-no-configurations-warning'
2020

2121
export const handle_autofill = async (params: {
2222
prompt_view_provider: PromptViewProvider
@@ -136,8 +136,7 @@ const show_web_configuration_quick_pick = async (params: {
136136
const valid_web_configurations = web_configurations.filter((c) => c.chatbot)
137137

138138
if (valid_web_configurations.length == 0) {
139-
open_settings.web.web_configurations()
140-
vscode.window.showInformationMessage('No configurations found.')
139+
show_no_configurations_warning('web')
141140
return null
142141
}
143142

‎apps/editor/src/views/prompt/backend/message-handlers/utils/intelligent-update-utils.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
show_configuration_quick_pick,
1717
map_api_configuration_to_item
1818
} from '@/utils/show-configuration-quick-pick'
19-
import { open_settings } from '@/views/settings/helpers/open-settings'
19+
import { show_no_configurations_warning } from '@/utils/show-no-configurations-warning'
2020

2121
export const get_intelligent_update_config = async (
2222
model_providers_manager: ModelProvidersManager,
@@ -30,8 +30,7 @@ export const get_intelligent_update_config = async (
3030
await model_providers_manager.get_api_configurations()
3131

3232
if (intelligent_update_api_configurations.length == 0) {
33-
open_settings.api.api_configurations()
34-
vscode.window.showInformationMessage(t('common.no-configurations-found'))
33+
show_no_configurations_warning('api')
3534
return
3635
}
3736

0 commit comments

Comments
 (0)