Skip to content

Commit fed0121

Browse files
committed
Add missing provider warnings and management options to the API prompt view
- main view should show warning 'missing provider' as well - when showing 'missing provider', should not show 'missing model' (aslo hide 'models' section from settings) - because we have 'on manage models', should also add 'on manage providers' └── apps └── editor └── src ├── utils │ └── show-no-configurations-warning.ts └── views ├── prompt │ ├── backend │ │ └── prompt-view-provider.ts │ ├── frontend │ │ ├── Main │ │ │ ├── Main.tsx │ │ │ └── MainView │ │ │ └── MainView.tsx │ │ ├── Prompt.tsx │ │ ├── hooks │ │ │ └── use-prompt │ │ │ └── use-prompt.ts │ │ └── i18n │ │ └── translations │ │ └── configurations.ts │ └── types │ └── messages.ts └── settings ├── frontend │ ├── App.tsx │ ├── Home │ │ ├── Home.tsx │ │ ├── hooks │ │ │ └── use-scroll-to.ts │ │ ├── index.ts │ │ └── sections │ │ ├── ApiSection.tsx │ │ ├── GeneralSection.tsx │ │ └── WebSection.tsx │ ├── Settings.tsx │ ├── forms │ │ ├── EditProviderForm │ │ │ ├── EditProviderForm.module.scss │ │ │ ├── EditProviderForm.tsx │ │ │ └── index.ts │ │ └── EditTemplateForm │ │ ├── EditTemplateForm.module.scss │ │ ├── EditTemplateForm.tsx │ │ └── index.ts │ ├── hooks │ │ ├── use-api-configuration-editing.ts │ │ ├── use-provider-editing.ts │ │ ├── use-settings.ts │ │ └── use-web-configuration-editing.ts │ ├── i18n │ │ ├── translations │ │ │ ├── actions.ts │ │ │ ├── api.ts │ │ │ ├── common.ts │ │ │ ├── edit-provider-form.ts │ │ │ ├── edit-template-form.ts │ │ │ ├── general.ts │ │ │ ├── index.ts │ │ │ ├── sections.ts │ │ │ └── web.ts │ │ └── use-translation.tsx │ └── utils │ └── post-message.ts └── helpers └── open-settings.ts
1 parent 1b3fcfe commit fed0121

10 files changed

Lines changed: 203 additions & 121 deletions

File tree

‎apps/editor/src/views/prompt/backend/prompt-view-provider.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,8 @@ export class PromptViewProvider implements vscode.WebviewViewProvider {
768768
prompt_view_provider: this,
769769
web_configuration_name: message.web_configuration_name
770770
})
771+
} else if (message.command == 'MANAGE_PROVIDERS') {
772+
open_settings.api.providers()
771773
} else if (message.command == 'MANAGE_MODELS') {
772774
open_settings.api.models()
773775
} else if (message.command == 'MANAGE_CHATBOTS') {

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
BackendMessage,
99
WebConfigurationsMessage,
1010
FrontendMessage,
11-
SelectionState
11+
SelectionState,
12+
SetupProgress
1213
} from '@/views/prompt/types/messages'
1314
import { ApiConfiguration } from '@/views/prompt/types/messages'
1415
import { post_message } from '../utils/post-message'
@@ -61,6 +62,7 @@ type Props = {
6162
on_recording_started: () => void
6263
on_recording_finished: () => void
6364
is_setup_complete: boolean
65+
setup_progress?: SetupProgress
6466
tabs_count: number
6567
active_tab_index: number
6668
on_tab_change: (index: number) => void
@@ -317,6 +319,12 @@ export const Main: React.FC<Props> = (props) => {
317319
})
318320
}
319321

322+
const handle_manage_providers = () => {
323+
post_message(props.vscode, {
324+
command: 'MANAGE_PROVIDERS'
325+
})
326+
}
327+
320328
const handle_manage_chatbots = () => {
321329
post_message(props.vscode, {
322330
command: 'MANAGE_CHATBOTS'
@@ -497,6 +505,7 @@ export const Main: React.FC<Props> = (props) => {
497505
on_delete_api_configuration={handle_delete_api_configuration}
498506
on_create_api_configuration={handle_create_api_configuration}
499507
on_manage_models={handle_manage_models}
508+
on_manage_providers={handle_manage_providers}
500509
on_manage_chatbots={handle_manage_chatbots}
501510
on_at_sign_click={handle_at_sign_click}
502511
on_hash_sign_click={handle_hash_sign_click}
@@ -559,6 +568,7 @@ export const Main: React.FC<Props> = (props) => {
559568
on_recording_started={props.on_recording_started}
560569
on_recording_finished={props.on_recording_finished}
561570
is_setup_complete={props.is_setup_complete}
571+
setup_progress={props.setup_progress}
562572
tabs_count={props.tabs_count}
563573
active_tab_index={props.active_tab_index}
564574
on_tab_change={props.on_tab_change}

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

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { TARGET, Target } from '@shared/types/mode'
1212
import { ApiPromptType, WebPromptType } from '@shared/types/prompt-types'
1313
import { Scrollable as UiScrollable } from '@ui/components/editor/common/Scrollable'
1414
import { BrowserConnectionStatus } from './components/BrowserConnectionStatus'
15-
import { ApiConfiguration } from '@/views/prompt/types/messages'
15+
import { ApiConfiguration, SetupProgress } from '@/views/prompt/types/messages'
1616
import { use_last_choice_tooltip } from './hooks/use-last-choice-tooltip'
1717
import { use_keyboard_shortcuts } from './hooks/use-keyboard-shortcuts'
1818
import { Header } from './components/Header'
@@ -52,6 +52,7 @@ type Props = {
5252
exact_insertion?: boolean
5353
}) => void
5454
on_manage_models: () => void
55+
on_manage_providers: () => void
5556
on_manage_chatbots: () => void
5657
currently_open_file_path?: string
5758
current_selection?: SelectionState | null
@@ -105,6 +106,7 @@ type Props = {
105106
on_recording_started: () => void
106107
on_recording_finished: () => void
107108
is_setup_complete: boolean
109+
setup_progress?: SetupProgress
108110
tabs_count: number
109111
active_tab_index: number
110112
on_tab_change: (index: number) => void
@@ -304,25 +306,49 @@ export const MainView: React.FC<Props> = (props) => {
304306
</>
305307
)}
306308

307-
{props.target == TARGET.API && props.api_configurations.length == 0 && (
308-
<>
309-
<UiStatusBar
310-
theme="warning"
311-
icon="codicon-warning"
312-
label={t('configurations.missing-model')}
313-
actions={[
314-
{
315-
id: 'settings',
316-
icon: 'codicon-gear',
317-
label: t('action.settings'),
318-
title: t('action.settings'),
319-
on_click: props.on_manage_models
320-
}
321-
]}
322-
/>
323-
<UiSeparator height={4} />
324-
</>
325-
)}
309+
{props.target == TARGET.API &&
310+
props.setup_progress &&
311+
!props.setup_progress.has_provider && (
312+
<>
313+
<UiStatusBar
314+
theme="warning"
315+
icon="codicon-warning"
316+
label={t('providers.missing-provider')}
317+
actions={[
318+
{
319+
id: 'settings',
320+
icon: 'codicon-gear',
321+
label: t('action.settings'),
322+
title: t('action.settings'),
323+
on_click: props.on_manage_providers
324+
}
325+
]}
326+
/>
327+
<UiSeparator height={4} />
328+
</>
329+
)}
330+
331+
{props.target == TARGET.API &&
332+
props.setup_progress?.has_provider &&
333+
props.api_configurations.length == 0 && (
334+
<>
335+
<UiStatusBar
336+
theme="warning"
337+
icon="codicon-warning"
338+
label={t('configurations.missing-model')}
339+
actions={[
340+
{
341+
id: 'settings',
342+
icon: 'codicon-gear',
343+
label: t('action.settings'),
344+
title: t('action.settings'),
345+
on_click: props.on_manage_models
346+
}
347+
]}
348+
/>
349+
<UiSeparator height={4} />
350+
</>
351+
)}
326352

327353
<UiSeparator height={2} />
328354

‎apps/editor/src/views/prompt/frontend/Prompt.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export const Prompt = () => {
6767
is_recording,
6868
handle_set_recording_state,
6969
is_setup_complete,
70+
setup_progress,
7071
handle_tab_change,
7172
handle_new_tab,
7273
handle_tab_delete,
@@ -352,6 +353,7 @@ export const Prompt = () => {
352353
on_recording_started={() => handle_set_recording_state(true)}
353354
on_recording_finished={() => handle_set_recording_state(false)}
354355
is_setup_complete={is_setup_complete}
356+
setup_progress={setup_progress}
355357
tabs_count={current_state?.instructions.length ?? 0}
356358
active_tab_index={current_state?.active_index ?? 0}
357359
on_tab_change={handle_tab_change}

‎apps/editor/src/views/prompt/frontend/hooks/use-prompt/use-prompt.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ export const use_prompt = (vscode: any) => {
294294
is_recording,
295295
handle_set_recording_state,
296296
is_setup_complete,
297+
setup_progress,
297298
handle_tab_change,
298299
handle_new_tab,
299300
handle_tab_delete,

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
export const configurations = {
2+
'providers.missing-provider': {
3+
en: 'Missing provider',
4+
pl: 'Brak dostawcy',
5+
'zh-cn': '缺少提供商',
6+
ja: 'プロバイダーが不足しています',
7+
'zh-tw': '缺少供應商',
8+
de: 'Fehlender Anbieter',
9+
es: 'Falta proveedor',
10+
fr: 'Fournisseur manquant',
11+
'pt-br': 'Provedor ausente',
12+
ru: 'Отсутствует провайдер',
13+
ko: '제공자가 누락되었습니다',
14+
it: 'Fornitore mancante',
15+
tr: 'Eksik sağlayıcı',
16+
cs: 'Chybějící poskytovatel',
17+
hu: 'Hiányzó szolgáltató',
18+
bg: 'Липсващ доставчик'
19+
},
220
'configurations.missing-model': {
321
en: 'Missing model',
422
pl: 'Brak modelu',

‎apps/editor/src/views/prompt/types/messages.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,10 @@ export interface ManageModelsMessage extends BaseMessage {
345345
command: 'MANAGE_MODELS'
346346
}
347347

348+
export interface ManageProvidersMessage extends BaseMessage {
349+
command: 'MANAGE_PROVIDERS'
350+
}
351+
348352
export interface ManageChatbotsMessage extends BaseMessage {
349353
command: 'MANAGE_CHATBOTS'
350354
}
@@ -607,6 +611,7 @@ export type FrontendMessage =
607611
| UpdateLastUsedWebConfigurationMessage
608612
| FixAllFailedFilesMessage
609613
| ManageModelsMessage
614+
| ManageProvidersMessage
610615
| ManageChatbotsMessage
611616
| UndoMessage
612617
| ApplyResponseFromHistoryMessage

‎apps/editor/src/views/settings/frontend/Home/Home.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ export const Home: React.FC<Props> = (props) => {
214214
) {
215215
continue
216216
}
217+
if (
218+
item.id === 'section:api:group:models' &&
219+
props.providers.length === 0
220+
) {
221+
continue
222+
}
217223
if (
218224
item.id.startsWith('section:') &&
219225
!item.id.includes(':group:')

‎apps/editor/src/views/settings/frontend/Home/hooks/use-scroll-to.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ export const use_scroll_to = (params: {
4444
) {
4545
continue
4646
}
47+
if (item.id === 'section:api:group:models' && providers_length === 0) {
48+
continue
49+
}
4750
last_id = item.id
4851
}
4952
return last_id
@@ -126,6 +129,9 @@ export const use_scroll_to = (params: {
126129
) {
127130
continue
128131
}
132+
if (item.id === 'section:api:group:models' && providers_length === 0) {
133+
continue
134+
}
129135
const el = section_refs.current[item.id]
130136
if (el) {
131137
const rect = el.getBoundingClientRect()

0 commit comments

Comments
 (0)