Skip to content

Commit d39ee7c

Browse files
committed
Refactor configuration items to be dimmed instead of disabled and improve autofill error handling
- on configurations, rename 'disable invocation' to 'is dimmed', keep current visuals but enable invocations - in case [Fragment] show info notification: 'Browser not connected.'. In case of [Fragment] show 'No chatbots added yet.'. (translated) - translate [Fragment] ├── apps │ └── editor │ └── src │ ├── i18n │ │ └── translations │ │ └── views │ │ └── prompt │ │ └── handlers │ │ ├── handle-autofill.ts │ │ ├── handle-make-api-call.ts │ │ └── index.ts │ └── views │ └── prompt │ ├── backend │ │ └── message-handlers │ │ └── handle-autofill.ts │ └── frontend │ └── Main │ └── MainView │ └── MainView.tsx └── packages └── ui └── src └── components └── editor └── prompt └── Configurations ├── Configurations.module.scss ├── Configurations.stories.tsx ├── Configurations.tsx └── index.ts
1 parent 3e6acfe commit d39ee7c

6 files changed

Lines changed: 39 additions & 25 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export const translations = {
2+
'views.prompt.handlers.handle-autofill.browser-not-connected': {
3+
en: 'Browser not connected.',
4+
pl: 'Brak połączenia z przeglądarką.',
5+
'zh-cn': '浏览器未连接。',
6+
ja: 'ブラウザが接続されていません。',
7+
'zh-tw': '瀏覽器未連接。',
8+
de: 'Browser nicht verbunden.',
9+
es: 'Navegador no conectado.',
10+
fr: 'Navigateur non connecté.',
11+
'pt-br': 'Navegador não conectado.',
12+
ru: 'Браузер не подключен.',
13+
ko: '브라우저가 연결되지 않았습니다.',
14+
it: 'Browser non connesso.',
15+
tr: 'Tarayıcı bağlı değil.',
16+
cs: 'Prohlížeč není připojen.',
17+
hu: 'A böngésző nincs csatlakoztatva.',
18+
bg: 'Браузърът не е свързан.'
19+
}
20+
} as const

‎apps/editor/src/i18n/translations/views/prompt/handlers/index.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { translations as utils } from './utils'
99
import { translations as handle_template_quick_pick } from './handle-template-quick-pick'
1010
import { translations as handle_patch_repair } from './handle-patch-repair'
1111
import { translations as handle_agentic_search } from './handle-agentic-search'
12+
import { translations as handle_autofill } from './handle-autofill'
1213

1314
export const translations = {
1415
...handle_delete_task,
@@ -21,5 +22,6 @@ export const translations = {
2122
...utils,
2223
...handle_template_quick_pick,
2324
...handle_patch_repair,
24-
...handle_agentic_search
25+
...handle_agentic_search,
26+
...handle_autofill
2527
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { handle_update_last_used_web_configuration } from './handle-update-last-
1414
import { show_configurations_quick_pick } from '@/utils/show-configurations-quick-pick'
1515
import { PromptBuilder } from '@/utils/prompt-builder'
1616
import { t } from '@/i18n'
17+
import { show_incomplete_setup_warning } from '@/utils/show-missing-configuration-notification'
1718

1819
export const handle_autofill = async (params: {
1920
prompt_view_provider: PromptViewProvider
@@ -23,6 +24,9 @@ export const handle_autofill = async (params: {
2324
if (
2425
!params.prompt_view_provider.websocket_server_instance.is_connected_with_browser()
2526
) {
27+
vscode.window.showInformationMessage(
28+
t('views.prompt.handlers.handle-autofill.browser-not-connected')
29+
)
2630
return
2731
}
2832

@@ -34,6 +38,7 @@ export const handle_autofill = async (params: {
3438
})
3539

3640
if (!resolution.web_configuration_name) {
41+
show_incomplete_setup_warning('web')
3742
return
3843
}
3944
const resolved_web_configuration_name = resolution.web_configuration_name

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export const MainView: React.FC<Props> = (props) => {
162162
(props.target == TARGET.WEB && props.web_prompt_type == 'edit-files') ||
163163
(props.target == TARGET.API && props.api_prompt_type == 'edit-files')
164164

165-
const context_is_empty_warning =
165+
const is_context_empty =
166166
show_edit_format_selector && props.selected_files.length == 0
167167

168168
const handle_input_change = (value: string) => {
@@ -353,7 +353,7 @@ export const MainView: React.FC<Props> = (props) => {
353353
props.target == TARGET.WEB &&
354354
(!props.is_connected || !props.web_configurations.length)
355355
}
356-
is_action_disabled={context_is_empty_warning}
356+
is_action_disabled={is_context_empty}
357357
value={props.instructions}
358358
chat_history={props.chat_history}
359359
on_change={handle_input_change}
@@ -392,7 +392,7 @@ export const MainView: React.FC<Props> = (props) => {
392392
target={props.target}
393393
on_target_change={(target) => props.on_target_change(target)}
394394
active_border_color={
395-
context_is_empty_warning
395+
is_context_empty
396396
? 'yellow'
397397
: props.target == TARGET.WEB
398398
? props.web_prompt_type == 'edit-files'
@@ -453,7 +453,7 @@ export const MainView: React.FC<Props> = (props) => {
453453
/>
454454
</div>
455455

456-
{context_is_empty_warning ? (
456+
{is_context_empty ? (
457457
<UiStatusBar
458458
placement="bottom"
459459
theme="warning"
@@ -501,7 +501,7 @@ export const MainView: React.FC<Props> = (props) => {
501501
{props.target == TARGET.WEB && (
502502
<UiConfigurations
503503
configurations={web_configurations}
504-
disable_invocation={context_is_empty_warning || !props.is_connected}
504+
is_dimmed={is_context_empty || !props.is_connected}
505505
on_create={(params) => {
506506
props.on_create_web_configuration(params)
507507
}}
@@ -542,9 +542,7 @@ export const MainView: React.FC<Props> = (props) => {
542542
{props.target == TARGET.API && (
543543
<UiConfigurations
544544
configurations={api_configurations_ui}
545-
disable_invocation={
546-
context_is_empty_warning || !props.api_configurations.length
547-
}
545+
is_dimmed={is_context_empty || !props.api_configurations.length}
548546
on_configuration_click={props.on_api_configuration_click}
549547
on_reorder={(reordered) =>
550548
props.on_api_configurations_reorder(reordered)

‎packages/ui/src/components/editor/prompt/Configurations/Configurations.module.scss‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,7 @@
3232
}
3333
}
3434

35-
&--disabled-invocation {
36-
cursor: default;
37-
38-
&:hover {
39-
background-color: unset;
40-
}
41-
35+
&--dimmed {
4236
.configurations__item__left__icon,
4337
.configurations__item__left__text {
4438
opacity: var(--dimmed-opacity);

‎packages/ui/src/components/editor/prompt/Configurations/Configurations.tsx‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export namespace Configurations {
2626
}) => void
2727
on_edit: (id: string) => void
2828
on_delete: (id: string) => void
29-
disable_invocation?: boolean
29+
is_dimmed?: boolean
3030
translations: {
3131
empty: string
3232
add_new: string
@@ -55,15 +55,10 @@ export const Configurations: React.FC<Configurations.Props> = (props) => {
5555
className={cn(styles.configurations__item, {
5656
[styles['configurations__item--highlighted']]:
5757
active_configuration_id == configuration.id,
58-
[styles['configurations__item--disabled-invocation']]:
59-
props.disable_invocation
58+
[styles['configurations__item--dimmed']]: props.is_dimmed
6059
})}
61-
onClick={
62-
props.disable_invocation
63-
? undefined
64-
: () => props.on_configuration_click(configuration.id)
65-
}
66-
role={props.disable_invocation ? undefined : 'button'}
60+
onClick={() => props.on_configuration_click(configuration.id)}
61+
role="button"
6762
>
6863
<div className={styles.configurations__item__left}>
6964
{!is_dragging_disabled && (

0 commit comments

Comments
 (0)