Skip to content

Commit ff6c09c

Browse files
committed
Disable voice input when API configurations are missing
- when there are no models, action buttons should be disabled as if there were no files in context - without api configurations, disable voice input - remove trailing dots [Fragment] - translate [Fragment] ├── apps │ └── editor │ └── src │ ├── i18n │ │ └── translations │ │ └── views │ │ └── shared │ │ └── actions │ │ └── api │ │ └── create │ │ └── interactions │ │ └── initial-select-provider.ts │ └── views │ └── prompt │ └── frontend │ ├── Main │ │ └── MainView │ │ └── MainView.tsx │ └── i18n │ └── translations │ └── configurations.ts └── packages └── ui └── src └── components └── editor └── common └── 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
1 parent fde8a18 commit ff6c09c

5 files changed

Lines changed: 69 additions & 57 deletions

File tree

‎apps/editor/src/i18n/translations/views/shared/actions/api/create/interactions/initial-select-provider.ts‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,21 @@ export const translations = {
7777
},
7878
'views.shared.actions.api.create.interactions.initial-select-provider.no-providers-found':
7979
{
80-
en: 'No providers found. Please add a provider first.',
81-
pl: 'Nie znaleziono dostawców. Proszę najpierw dodać dostawcę.',
82-
'zh-cn': '未找到提供商。请先添加一个提供商。',
83-
ja: 'プロバイダーが見つかりません。まずプロバイダーを追加してください。',
84-
'zh-tw': '未找到供應商。請先新增一個供應商。',
85-
de: 'Keine Anbieter gefunden. Bitte fügen Sie zuerst einen Anbieter hinzu.',
86-
es: 'No se encontraron proveedores. Por favor, añada un proveedor primero.',
87-
fr: "Aucun fournisseur trouvé. Veuillez d'abord ajouter un fournisseur.",
88-
'pt-br':
89-
'Nenhum provedor encontrado. Por favor, adicione um provedor primeiro.',
90-
ru: 'Провайдеры не найдены. Пожалуйста, сначала добавьте провайдера.',
91-
ko: '제공자를 찾을 수 없습니다. 먼저 제공자를 추가하세요.',
92-
it: 'Nessun fornitore trovato. Si prega di aggiungere prima un fornitore.',
93-
tr: 'Sağlayıcı bulunamadı. Lütfen önce bir sağlayıcı ekleyin.',
94-
cs: 'Nebyli nalezeni žádní poskytovatelé. Nejprve prosím přidejte poskytovatele.',
95-
hu: 'Nem találhatók szolgáltatók. Kérjük, először adjon hozzá egy szolgáltatót.',
96-
bg: 'Не са намерени доставчици. Моля, първо добавете доставчик.'
80+
en: 'No providers found. Please add one first.',
81+
pl: 'Nie znaleziono dostawców. Najpierw dodaj jednego.',
82+
'zh-cn': '未找到提供商。请先添加一个。',
83+
ja: 'プロバイダーが見つかりません。まず追加してください。',
84+
'zh-tw': '未找到供應商。請先新增一個。',
85+
de: 'Keine Anbieter gefunden. Bitte fügen Sie zuerst einen hinzu.',
86+
es: 'No se encontraron proveedores. Por favor, añade uno primero.',
87+
fr: "Aucun fournisseur trouvé. Veuillez d'abord en ajouter un.",
88+
'pt-br': 'Nenhum provedor encontrado. Por favor, adicione um primeiro.',
89+
ru: 'Провайдеры не найдены. Пожалуйста, сначала добавьте одного.',
90+
ko: '제공자를 찾을 수 없습니다. 먼저 추가해 주세요.',
91+
it: 'Nessun fornitore trovato. Aggiungine prima uno.',
92+
tr: 'Sağlayıcı bulunamadı. Lütfen önce bir tane ekleyin.',
93+
cs: 'Nebyli nalezeni žádní poskytovatelé. Nejprve prosím nějakého přidejte.',
94+
hu: 'Nem találhatók szolgáltatók. Kérjük, először adjon hozzá egyet.',
95+
bg: 'Не са намерени доставчици. Моля, първо добавете един.'
9796
}
9897
} as const

‎apps/editor/src/views/prompt/frontend/Main/MainView/MainView.tsx‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ export const MainView: React.FC<Props> = (props) => {
161161
const context_is_empty_warning =
162162
show_edit_format_selector && props.selected_files.length == 0
163163

164+
const has_no_api_configurations =
165+
props.target == TARGET.API && props.api_configurations.length == 0
166+
164167
const handle_input_change = (value: string) => {
165168
props.set_instructions(value)
166169
}
@@ -380,18 +383,23 @@ export const MainView: React.FC<Props> = (props) => {
380383

381384
<div className={styles['chat-input']}>
382385
<UiPromptField
383-
is_copy_only={props.target == TARGET.WEB && !props.is_connected}
386+
is_copy_only={
387+
props.target == TARGET.WEB &&
388+
(!props.is_connected || !props.web_configurations.length)
389+
}
384390
is_action_disabled={
385-
(props.target == TARGET.WEB
391+
((props.target == TARGET.WEB
386392
? props.web_prompt_type
387393
: props.api_prompt_type) == 'edit-files' &&
388-
props.selected_files.length == 0
394+
!props.selected_files.length) ||
395+
has_no_api_configurations
389396
}
397+
is_voice_input_disabled={has_no_api_configurations}
390398
is_preview_disabled={
391399
(props.target == TARGET.WEB
392400
? props.web_prompt_type
393401
: props.api_prompt_type) == 'edit-files' &&
394-
props.selected_files.length == 0
402+
!props.selected_files.length
395403
}
396404
value={props.instructions}
397405
chat_history={props.chat_history}

‎apps/editor/src/views/prompt/frontend/i18n/translations/configurations.ts‎

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,22 @@ export const configurations = {
3636
bg: 'Липсващ модел'
3737
},
3838
'configurations.empty': {
39-
en: 'No models configured yet.',
40-
pl: 'Nie ustawiono jeszcze żadnych modeli.',
41-
'zh-cn': '尚未配置模型。',
42-
ja: 'まだモデルは設定されていません。',
43-
'zh-tw': '尚未設定模型。',
44-
de: 'Noch keine Modelle konfiguriert.',
45-
es: 'Aún no se han configurado modelos.',
46-
fr: 'Aucun modèle configuré pour le moment.',
47-
'pt-br': 'Nenhum modelo configurado ainda.',
48-
ru: 'Модели еще не настроены.',
49-
ko: '아직 구성된 모델이 없습니다.',
50-
it: 'Nessun modello ancora configurato.',
51-
tr: 'Henüz hiçbir model yapılandırılmadı.',
52-
cs: 'Zatím nebyly nakonfigurovány žádné modely.',
53-
hu: 'Még nincsenek modellek konfigurálva.',
54-
bg: 'Все още няма конфигурирани модели.'
39+
en: 'No models configured yet',
40+
pl: 'Nie ustawiono jeszcze żadnych modeli',
41+
'zh-cn': '尚未配置模型',
42+
ja: 'まだモデルは設定されていません',
43+
'zh-tw': '尚未設定模型',
44+
de: 'Noch keine Modelle konfiguriert',
45+
es: 'Aún no se han configurado modelos',
46+
fr: 'Aucun modèle configuré pour le moment',
47+
'pt-br': 'Nenhum modelo configurado ainda',
48+
ru: 'Модели еще не настроены',
49+
ko: '아직 구성된 모델이 없습니다',
50+
it: 'Nessun modello ancora configurato',
51+
tr: 'Henüz hiçbir model yapılandırılmadı',
52+
cs: 'Zatím nebyly nakonfigurovány žádné modely',
53+
hu: 'Még nincsenek modellek konfigurálva',
54+
bg: 'Все още няма конфигурирани модели'
5555
},
5656
'chatbots.missing-chatbot': {
5757
en: 'Missing chatbot',
@@ -72,21 +72,21 @@ export const configurations = {
7272
bg: 'Липсващ чатбот'
7373
},
7474
'chatbots.empty': {
75-
en: 'No chatbots configured yet.',
76-
pl: 'Nie ustawiono jeszcze żadnych chatbotów.',
77-
'zh-cn': '尚未配置聊天机器人。',
78-
ja: 'まだチャットボットは設定されていません。',
79-
'zh-tw': '尚未設定聊天機器人。',
80-
de: 'Noch keine Chatbots konfiguriert.',
81-
es: 'Aún no se han configurado chatbots.',
82-
fr: 'Aucun chatbot configuré pour le moment.',
83-
'pt-br': 'Nenhum chatbot configurado ainda.',
84-
ru: 'Чат-боты еще не настроены.',
85-
ko: '아직 구성된 챗봇이 없습니다.',
86-
it: 'Nessun chatbot ancora configurato.',
87-
tr: 'Henüz hiçbir sohbet botu yapılandırılmadı.',
88-
cs: 'Zatím nebyli nakonfigurováni žádní chatboti.',
89-
hu: 'Még nincsenek chatbotok konfigurálva.',
90-
bg: 'Все още няма конфигурирани чатботове.'
75+
en: 'No chatbots configured yet',
76+
pl: 'Nie ustawiono jeszcze żadnych chatbotów',
77+
'zh-cn': '尚未配置聊天机器人',
78+
ja: 'まだチャットボットは設定されていません',
79+
'zh-tw': '尚未設定聊天機器人',
80+
de: 'Noch keine Chatbots konfiguriert',
81+
es: 'Aún no se han configurado chatbots',
82+
fr: 'Aucun chatbot configuré pour le moment',
83+
'pt-br': 'Nenhum chatbot configurado ainda',
84+
ru: 'Чат-боты еще не настроены',
85+
ko: '아직 구성된 챗봇이 없습니다',
86+
it: 'Nessun chatbot ancora configurato',
87+
tr: 'Henüz hiçbir sohbet botu yapılandırılmadı',
88+
cs: 'Zatím nebyli nakonfigurováni žádní chatboti',
89+
hu: 'Még nincsenek chatbotok konfigurálva',
90+
bg: 'Все още няма конфигурирани чатботове'
9191
}
9292
} as const

‎packages/ui/src/components/editor/common/prompts/PromptField/PromptField.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export type PromptFieldProps = {
8989
voice_input_push_to_talk?: boolean
9090
prompt_token_count: number
9191
is_copy_only?: boolean
92+
is_voice_input_disabled?: boolean
9293
target: Target
9394
on_target_change: (target: Target) => void
9495
active_border_color?: 'blue' | 'purple'
@@ -374,7 +375,8 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
374375
on_click: () => {
375376
props.on_recording_started()
376377
close_dropdown()
377-
}
378+
},
379+
is_disabled: props.is_voice_input_disabled
378380
}
379381
]
380382
: []),
@@ -410,7 +412,8 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
410412
on_click: () => {
411413
props.on_recording_started()
412414
close_dropdown()
413-
}
415+
},
416+
is_disabled: props.is_voice_input_disabled
414417
}
415418
]
416419
: []),
@@ -739,6 +742,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
739742
}}
740743
onMouseEnter={() => set_is_recording_hovered(true)}
741744
onMouseLeave={() => set_is_recording_hovered(false)}
745+
disabled={props.is_voice_input_disabled}
742746
/>
743747
) : (
744748
<button
@@ -821,6 +825,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
821825
}}
822826
onMouseEnter={() => set_is_recording_hovered(true)}
823827
onMouseLeave={() => set_is_recording_hovered(false)}
828+
disabled={props.is_voice_input_disabled}
824829
/>
825830
) : (
826831
<>

‎packages/ui/src/components/editor/common/prompts/PromptField/hooks/use-handlers/handle-key-down.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ export const create_handle_key_down = (
4949
e.preventDefault()
5050
if (props.is_recording) {
5151
props.on_recording_finished()
52-
} else {
52+
} else if (!props.is_voice_input_disabled) {
5353
props.on_recording_started()
5454
}
5555
}
5656

5757
const handle_space_key = (e: React.KeyboardEvent<HTMLDivElement>) => {
58-
if (!props.voice_input_push_to_talk) {
58+
if (!props.voice_input_push_to_talk || props.is_voice_input_disabled) {
5959
return false
6060
}
6161

0 commit comments

Comments
 (0)