Skip to content

Commit d48e2af

Browse files
committed
Improve UI text clarity by standardizing insertion option labels and adding a helpful audio understanding link
1 parent a346dc0 commit d48e2af

10 files changed

Lines changed: 92 additions & 79 deletions

File tree

‎apps/editor/src/views/panel/backend/message-handlers/handle-create-preset-group-or-separator.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ export const handle_create_preset_group_or_separator = async (
138138
(resolve) => {
139139
const quick_pick = vscode.window.createQuickPick()
140140
quick_pick.items = [
141-
{ label: 'Insert new item above' },
142-
{ label: 'Insert new item below' }
141+
{ label: 'Insert a new item above' },
142+
{ label: 'Insert a new item below' }
143143
]
144144
quick_pick.title = 'Placement'
145145
quick_pick.placeholder = 'Where to insert?'
@@ -175,7 +175,7 @@ export const handle_create_preset_group_or_separator = async (
175175
if (!position_quick_pick) return
176176

177177
insertion_index =
178-
position_quick_pick == 'Insert new item above'
178+
position_quick_pick == 'Insert a new item above'
179179
? message.reference_index
180180
: message.reference_index + 1
181181
} else if (message.placement == 'top') {

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,19 @@ export const Home: React.FC<Props> = (props) => {
652652
}
653653
>
654654
<Notice type="info">
655-
Requires a multimodal model accepting audio input.
655+
Requires a multimodal model supporting{' '}
656+
<a
657+
href="#"
658+
onClick={(e) => {
659+
e.preventDefault()
660+
props.on_open_external_url(
661+
'https://ai.google.dev/gemini-api/docs/audio'
662+
)
663+
}}
664+
>
665+
audio understanding
666+
</a>
667+
.
656668
</Notice>
657669
{props.voice_input_configs.length == 0 && (
658670
<Notice type="warning">

‎apps/editor/src/views/utils/upsert-configuration.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ export const upsert_configuration = async (params: {
7070
(resolve) => {
7171
const quick_pick = vscode.window.createQuickPick()
7272
quick_pick.items = [
73-
{ label: 'Insert new configuration above' },
74-
{ label: 'Insert new configuration below' }
73+
{ label: 'Insert a new configuration above' },
74+
{ label: 'Insert a new configuration below' }
7575
]
7676
quick_pick.title = 'Placement'
7777
quick_pick.placeholder = 'Where to insert?'
@@ -107,7 +107,7 @@ export const upsert_configuration = async (params: {
107107
if (!position_quick_pick) return
108108

109109
actual_insertion_index =
110-
position_quick_pick == 'Insert new configuration above'
110+
position_quick_pick == 'Insert a new configuration above'
111111
? params.insertion_index
112112
: params.insertion_index + 1
113113
}

‎apps/editor/src/views/utils/upsert-model-provider.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ export const upsert_model_provider = async (params: {
317317
(resolve) => {
318318
const quick_pick = vscode.window.createQuickPick()
319319
quick_pick.items = [
320-
{ label: 'Insert new provider above' },
321-
{ label: 'Insert new provider below' }
320+
{ label: 'Insert a new provider above' },
321+
{ label: 'Insert a new provider below' }
322322
]
323323
quick_pick.title = 'Placement'
324324
quick_pick.placeholder = 'Where to insert?'
@@ -354,7 +354,7 @@ export const upsert_model_provider = async (params: {
354354
if (!position_quick_pick) return
355355

356356
actual_insertion_index =
357-
position_quick_pick == 'Insert new provider above'
357+
position_quick_pick == 'Insert a new provider above'
358358
? insertion_index
359359
: insertion_index + 1
360360
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const Configurations: React.FC<Configurations.Props> = (props) => {
9797
{!is_dragging_disabled && (
9898
<IconButton
9999
codicon_icon="insert"
100-
title="Insert new configuration below/above"
100+
title="Insert a new configuration below/above"
101101
on_click={(e) => {
102102
e.stopPropagation()
103103
props.on_create({ insertion_index: index_for_insertion })

‎packages/ui/src/components/editor/panel/Presets/Presets.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ export const Presets: React.FC<Presets.Props> = (props) => {
344344
/>
345345
<IconButton
346346
codicon_icon="insert"
347-
title="Insert new item below/above"
347+
title="Insert a new item below/above"
348348
on_click={(e) => {
349349
e.stopPropagation()
350350
props.on_create(undefined, preset.original_index!)
@@ -549,7 +549,7 @@ export const Presets: React.FC<Presets.Props> = (props) => {
549549
/>
550550
<IconButton
551551
codicon_icon="insert"
552-
title="Insert new item below/above"
552+
title="Insert a new item below/above"
553553
on_click={(e) => {
554554
e.stopPropagation()
555555
props.on_create(undefined, preset.original_index!)

‎packages/ui/src/components/editor/panel/PromptField/PromptField.tsx‎

Lines changed: 12 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ import {
1616
get_caret_position_from_div,
1717
set_caret_position_for_div
1818
} from './utils/caret'
19-
import {
20-
map_display_pos_to_raw_pos,
21-
map_raw_pos_to_display_pos
22-
} from './utils/position-mapping'
2319
import { Tooltip } from './components'
2420
import { ApiPromptType, WebPromptType } from '@shared/types/prompt-types'
2521

@@ -85,7 +81,6 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
8581
useState(false)
8682
const [hovered_edit_format, set_hovered_edit_format] =
8783
useState<EditFormat | null>(null)
88-
8984
const [prune_instructions, set_prune_instructions] = useState(
9085
props.prune_context_instructions_prefix
9186
)
@@ -106,6 +101,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
106101
is_invocation_dropdown_open,
107102
on_toggle_invocation_dropdown: toggle_invocation_dropdown
108103
})
104+
109105
const {
110106
is_dropdown_open,
111107
toggle_dropdown,
@@ -114,16 +110,18 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
114110
handle_copy_click,
115111
handle_select_click
116112
} = use_dropdown(props)
113+
117114
const invocation_dropdown_ref = useRef<HTMLDivElement>(null)
115+
118116
const { ghost_text, handle_accept_ghost_text } = use_ghost_text({
119117
value: props.value,
120118
input_ref,
121119
is_focused: is_focused && should_show_ghost_text,
122120
currently_open_file_text: props.currently_open_file_text,
123121
caret_position
124122
})
123+
125124
const {
126-
handle_clear,
127125
handle_input_change,
128126
handle_submit,
129127
handle_key_down,
@@ -132,7 +130,14 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
132130
handle_cut,
133131
handle_paste,
134132
handle_input_click
135-
} = use_handlers(props, input_ref, ghost_text, handle_accept_ghost_text)
133+
} = use_handlers(
134+
props,
135+
input_ref,
136+
ghost_text,
137+
handle_accept_ghost_text,
138+
set_caret_position
139+
)
140+
136141
const { handle_drag_start, handle_drag_over, handle_drop, handle_drag_end } =
137142
use_drag_drop({
138143
input_ref,
@@ -199,28 +204,6 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
199204
}
200205
}, [highlighted_html])
201206

202-
useEffect(() => {
203-
if (input_ref.current) {
204-
if (
205-
props.caret_position_to_set !== undefined &&
206-
props.on_caret_position_set
207-
) {
208-
const display_pos = map_raw_pos_to_display_pos(
209-
props.caret_position_to_set,
210-
props.value,
211-
props.context_file_paths ?? []
212-
)
213-
set_caret_position_for_div(input_ref.current, display_pos)
214-
props.on_caret_position_set()
215-
}
216-
}
217-
}, [
218-
props.caret_position_to_set,
219-
props.on_caret_position_set,
220-
props.value,
221-
props.context_file_paths
222-
])
223-
224207
useEffect(() => {
225208
if (input_ref.current) {
226209
input_ref.current.focus()
@@ -247,37 +230,6 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
247230
}
248231
}, [is_invocation_dropdown_open])
249232

250-
useEffect(() => {
251-
if (input_ref.current) {
252-
input_ref.current.focus()
253-
const selection = window.getSelection()
254-
if (selection) {
255-
const range = document.createRange()
256-
range.selectNodeContents(input_ref.current)
257-
selection.removeAllRanges()
258-
selection.addRange(range)
259-
}
260-
}
261-
}, [props.focus_and_select_key])
262-
263-
useEffect(() => {
264-
const on_selection_change = () => {
265-
if (document.activeElement === input_ref.current && input_ref.current) {
266-
const pos = get_caret_position_from_div(input_ref.current)
267-
set_caret_position(pos)
268-
const raw_pos = map_display_pos_to_raw_pos(
269-
pos,
270-
props.value,
271-
props.context_file_paths ?? []
272-
)
273-
props.on_caret_position_change(raw_pos)
274-
}
275-
}
276-
document.addEventListener('selectionchange', on_selection_change)
277-
return () =>
278-
document.removeEventListener('selectionchange', on_selection_change)
279-
}, [props.on_caret_position_change, props.value, props.context_file_paths])
280-
281233
const placeholder = useMemo(() => {
282234
if (props.prompt_type == 'code-at-cursor') {
283235
if (props.chat_history.length > 0 && is_history_enabled) {

‎packages/ui/src/components/editor/panel/PromptField/hooks/use-handlers.ts‎

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ export const use_handlers = (
236236
props: PromptFieldProps,
237237
input_ref: RefObject<HTMLDivElement>,
238238
ghost_text: string,
239-
on_accept_ghost_text: () => void
239+
on_accept_ghost_text: () => void,
240+
set_caret_position: (pos: number) => void
240241
) => {
241242
const [history_index, set_history_index] = useState(-1)
242243
const [is_history_enabled, set_is_history_enabled] = useState(!props.value)
@@ -277,17 +278,19 @@ export const use_handlers = (
277278
if (document.activeElement === input_ref.current && input_ref.current) {
278279
const selection = window.getSelection()
279280
const pos = get_caret_position_from_div(input_ref.current)
281+
set_caret_position(pos)
282+
280283
const raw_pos = map_display_pos_to_raw_pos(
281284
pos,
282285
props.value,
283286
props.context_file_paths ?? []
284287
)
285288
raw_caret_pos_ref.current = raw_pos
289+
props.on_caret_position_change(raw_pos)
286290

287291
const is_at_end =
288292
raw_pos == props.value.length && !!selection?.isCollapsed
289293

290-
// Only enable history if at end AND haven't modified the current entry
291294
const is_history_check_enabled =
292295
is_at_end && !has_modified_current_entry_ref.current
293296
set_is_history_enabled(is_history_check_enabled)
@@ -297,7 +300,54 @@ export const use_handlers = (
297300
on_selection_change()
298301
return () =>
299302
document.removeEventListener('selectionchange', on_selection_change)
300-
}, [props.value, props.context_file_paths, input_ref])
303+
}, [
304+
props.value,
305+
props.context_file_paths,
306+
input_ref,
307+
props.on_caret_position_change,
308+
set_caret_position
309+
])
310+
311+
useEffect(() => {
312+
if (input_ref.current) {
313+
if (
314+
props.caret_position_to_set !== undefined &&
315+
props.on_caret_position_set
316+
) {
317+
const display_pos = map_raw_pos_to_display_pos(
318+
props.caret_position_to_set,
319+
props.value,
320+
props.context_file_paths ?? []
321+
)
322+
set_caret_position_for_div(input_ref.current, display_pos)
323+
props.on_caret_position_set()
324+
}
325+
}
326+
}, [
327+
props.caret_position_to_set,
328+
props.on_caret_position_set,
329+
props.value,
330+
props.context_file_paths
331+
])
332+
333+
useEffect(() => {
334+
if (input_ref.current) {
335+
input_ref.current.focus()
336+
}
337+
}, [props.focus_key])
338+
339+
useEffect(() => {
340+
if (input_ref.current) {
341+
input_ref.current.focus()
342+
const selection = window.getSelection()
343+
if (selection) {
344+
const range = document.createRange()
345+
range.selectNodeContents(input_ref.current)
346+
selection.removeAllRanges()
347+
selection.addRange(range)
348+
}
349+
}
350+
}, [props.focus_and_select_key])
301351

302352
const update_value = (new_value: string, caret_pos?: number) => {
303353
if (new_value === props.value) return
@@ -1460,7 +1510,6 @@ export const use_handlers = (
14601510
handle_submit,
14611511
handle_key_down,
14621512
is_history_enabled,
1463-
handle_clear,
14641513
handle_copy,
14651514
handle_cut,
14661515
handle_paste,

‎packages/ui/src/components/editor/settings/ConfigurationsList/ConfigurationsList.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const ConfigurationsList: React.FC<ConfigurationsList.Props> = (
6161
<div className={styles['col-actions']}>
6262
<IconButton
6363
codicon_icon="insert"
64-
title="Insert new configuration below/above"
64+
title="Insert a new configuration below/above"
6565
on_click={() => props.on_add({ insertion_index: index })}
6666
/>
6767
<IconButton

‎packages/ui/src/components/editor/settings/ModelProviders/ModelProviders.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const ModelProviders: React.FC<ModelProviders.Props> = (props) => {
4747
<div className={styles['col-actions']}>
4848
<IconButton
4949
codicon_icon="insert"
50-
title="Insert new provider below/above"
50+
title="Insert a new provider below/above"
5151
on_click={() => props.on_add_provider({ insertion_index: index })}
5252
/>
5353
{provider.type == 'custom' && (

0 commit comments

Comments
 (0)