Skip to content

Commit 1a00274

Browse files
committed
Merge branch 'dev'
2 parents f7fcc43 + bff7bc8 commit 1a00274

25 files changed

Lines changed: 926 additions & 452 deletions

File tree

‎packages/shared/src/constants/dictionary.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export const dictionary = {
110110
NO_MODELS_FOUND_MANUAL_ENTRY: (provider_name: string) =>
111111
`No models found for ${provider_name}. You can enter model name manually.`,
112112
NO_RESULTS_FOR_SEARCH_SHOWING_ALL: (search_value: string) =>
113-
`No results for "${search_value}" in the selected context. Showing all items.`,
113+
`No results for "${search_value}" in the selected context.`,
114114
NO_MODEL_PROVIDERS_CONFIGURED:
115115
'No model providers configured. Please add a model provider first on the "Model Providers" page.'
116116
},

‎packages/ui/src/components/editor/common/Input/Input.module.scss‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
border: 1px solid var(--vscode-input-border);
44
color: var(--vscode-input-foreground);
55
padding: var(--padding-4px) var(--padding-8px);
6-
border-radius: var(--border-radius);
7-
outline: none;
6+
border-radius: var(--border-radius-4px);
87
width: 100%;
8+
outline: none;
99

1010
&:focus {
11-
border-color: var(--vscode-focusBorder);
12-
}
13-
14-
&::placeholder {
15-
color: var(--vscode-input-placeholderForeground);
11+
outline: 1px solid var(--vscode-focusBorder);
12+
outline-offset: -1px;
1613
}
1714
}

‎packages/ui/src/components/editor/common/Input/Input.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import styles from './Input.module.scss'
22

33
type Props = {
4+
id?: string
45
type?: string
56
value: string
67
placeholder?: string
78
max_width?: number
89
onChange: (value: string) => void
10+
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void
911
}
1012

1113
export const Input: React.FC<Props> = (props) => {
@@ -15,9 +17,11 @@ export const Input: React.FC<Props> = (props) => {
1517

1618
return (
1719
<input
20+
id={props.id}
1821
type={props.type || 'text'}
1922
value={props.value}
2023
onChange={(e) => props.onChange(e.target.value)}
24+
onKeyDown={props.onKeyDown}
2125
className={styles.input}
2226
placeholder={props.placeholder}
2327
style={style}

‎packages/ui/src/components/editor/panel/ChatInput/ChatInput.module.scss‎

Lines changed: 70 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
padding: var(--padding-6px) var(--padding-10px) var(--padding-6px)
113113
var(--padding-6px);
114114
justify-content: space-between;
115-
overflow: hidden;
116115

117116
> div {
118117
flex-shrink: 0;
@@ -187,35 +186,85 @@
187186
}
188187
}
189188
}
190-
&__button {
189+
190+
&__submit {
191+
position: relative;
191192
display: flex;
192193
align-items: center;
193-
justify-content: center;
194-
gap: 3px;
195-
height: 20px;
196-
padding: 0 var(--padding-2px);
197-
border-radius: var(--border-radius-5px);
198194
pointer-events: all;
199195

200-
> svg {
201-
width: 10px;
202-
fill: var(--vscode-icon-foreground);
203-
}
196+
&__button {
197+
display: flex;
198+
align-items: center;
199+
justify-content: center;
200+
gap: 3px;
201+
height: 20px;
202+
border-radius: var(--border-radius-5px);
203+
pointer-events: all;
204204

205-
&.codicon::before {
206-
font-size: 16px;
207-
}
205+
> svg {
206+
width: 10px;
207+
fill: var(--vscode-icon-foreground);
208+
}
208209

209-
&:hover:enabled {
210-
background-color: var(--vscode-toolbar-hoverBackground);
210+
&.codicon::before {
211+
font-size: 16px;
212+
}
213+
214+
&:hover:enabled {
215+
background-color: var(--vscode-toolbar-hoverBackground);
216+
}
217+
218+
&:disabled {
219+
opacity: 0.5;
220+
cursor: default;
221+
222+
&:hover {
223+
background-color: none;
224+
}
225+
}
226+
227+
&--submit {
228+
padding: 0 var(--padding-2px);
229+
}
230+
231+
&--chevron.codicon::before {
232+
font-size: 11px;
233+
}
211234
}
212235

213-
&:disabled {
214-
opacity: 0.5;
215-
cursor: default;
236+
&__dropdown {
237+
position: absolute;
238+
top: calc(100% + 4px);
239+
right: 0;
240+
background-color: var(--vscode-menu-background);
241+
border: 1px solid var(--vscode-menu-border);
242+
border-radius: var(--border-radius-5px);
243+
box-shadow: 0 2px 8px var(--vscode-widget-shadow);
244+
z-index: 10;
245+
padding: var(--padding-4px) 0;
246+
width: max-content;
247+
text-align: left;
216248

217-
&:hover {
218-
background-color: none;
249+
&__item {
250+
display: flex;
251+
justify-content: space-between;
252+
gap: var(--padding-12px);
253+
align-items: center;
254+
padding: var(--padding-4px) var(--padding-8px);
255+
cursor: pointer;
256+
color: var(--vscode-menu-foreground);
257+
white-space: nowrap;
258+
259+
&:hover {
260+
background-color: var(--vscode-menu-selectionBackground);
261+
color: var(--vscode-menu-selectionForeground);
262+
}
263+
264+
&__shortcut {
265+
color: var(--vscode-descriptionForeground);
266+
font-size: var(--font-size-12px);
267+
}
219268
}
220269
}
221270
}

‎packages/ui/src/components/editor/panel/ChatInput/ChatInput.stories.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const Empty = () => (
2121
on_at_sign_click={() => console.log('@ clicked')}
2222
on_hash_sign_click={() => console.log('# clicked')}
2323
on_search_click={() => console.log('Search clicked')}
24-
on_submit_with_control={() => {}}
24+
on_submit_with_control={() => console.log('Submitted with control')}
2525
on_curly_braces_click={() => {}}
2626
/>
2727
)
@@ -42,7 +42,7 @@ export const WithText = () => (
4242
on_at_sign_click={() => console.log('@ clicked')}
4343
on_hash_sign_click={() => console.log('# clicked')}
4444
on_search_click={() => console.log('Search clicked')}
45-
on_submit_with_control={() => {}}
45+
on_submit_with_control={() => console.log('Submitted with control')}
4646
on_curly_braces_click={() => {}}
4747
/>
4848
)
@@ -63,7 +63,7 @@ export const LongText = () => (
6363
on_at_sign_click={() => console.log('@ clicked')}
6464
on_hash_sign_click={() => console.log('# clicked')}
6565
on_search_click={() => console.log('Search clicked')}
66-
on_submit_with_control={() => {}}
66+
on_submit_with_control={() => console.log('Submitted with control')}
6767
on_curly_braces_click={() => {}}
6868
/>
6969
)
@@ -84,7 +84,7 @@ export const WithPlaceholderSavedContext = () => (
8484
on_at_sign_click={() => console.log('@ clicked')}
8585
on_hash_sign_click={() => console.log('# clicked')}
8686
is_web_mode={false}
87-
on_submit_with_control={() => {}}
87+
on_submit_with_control={() => console.log('Submitted with control')}
8888
on_curly_braces_click={() => {}}
8989
/>
9090
)
@@ -105,7 +105,7 @@ export const WithPlaceholderSelection = () => (
105105
on_at_sign_click={() => console.log('@ clicked')}
106106
on_hash_sign_click={() => console.log('# clicked')}
107107
is_web_mode={false}
108-
on_submit_with_control={() => {}}
108+
on_submit_with_control={() => console.log('Submitted with control')}
109109
on_curly_braces_click={() => {}}
110110
/>
111111
)
@@ -128,7 +128,7 @@ export const WithEditFormatSelector = () => {
128128
on_at_sign_click={() => console.log('@ clicked')}
129129
on_hash_sign_click={() => console.log('# clicked')}
130130
on_search_click={() => console.log('Search clicked')}
131-
on_submit_with_control={() => {}}
131+
on_submit_with_control={() => console.log('Submitted with control')}
132132
on_curly_braces_click={() => {}}
133133
show_edit_format_selector={true}
134134
edit_format={edit_format}

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

Lines changed: 91 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { useRef, useEffect, useMemo } from 'react'
1+
import { useRef, useEffect, useMemo, useState } from 'react'
22
import styles from './ChatInput.module.scss'
33
import TextareaAutosize from 'react-textarea-autosize'
44
import cn from 'classnames'
55
import { Icon } from '../../common/Icon'
66
import { get_highlighted_text } from './utils/get-highlighted-text'
77
import { use_handlers } from './hooks/use-handlers'
8+
import { use_dropdown } from './hooks/use-dropdown'
89

910
export type EditFormat = 'whole' | 'truncated' | 'diff'
1011

@@ -40,7 +41,13 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
4041
const textarea_ref = useRef<HTMLTextAreaElement>(null)
4142
const highlight_ref = useRef<HTMLDivElement>(null)
4243
const container_ref = useRef<HTMLDivElement>(null)
43-
44+
const {
45+
is_dropdown_open,
46+
toggle_dropdown,
47+
dropdown_ref,
48+
handle_copy_click,
49+
handle_select_click
50+
} = use_dropdown(props)
4451
const {
4552
handle_select,
4653
handle_input_change,
@@ -49,6 +56,12 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
4956
is_history_enabled
5057
} = use_handlers(props)
5158

59+
const is_mac = useMemo(
60+
() => navigator.platform.toUpperCase().indexOf('MAC') >= 0,
61+
[]
62+
)
63+
const mod_key = is_mac ? 'cmd' : 'ctrl'
64+
5265
useEffect(() => {
5366
if (textarea_ref.current) {
5467
textarea_ref.current.focus()
@@ -238,7 +251,7 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
238251
]]: props.edit_format == format
239252
}
240253
)}
241-
title={props.edit_format_instructions?.[format]}
254+
title={`Attached edit format instructions: ${props.edit_format_instructions?.[format]}`}
242255
onClick={() => props.on_edit_format_change?.(format)}
243256
data-text={format}
244257
>
@@ -248,35 +261,86 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
248261
</div>
249262
)}
250263

251-
{(!props.is_web_mode ||
252-
(props.is_web_mode && props.is_connected)) && (
253-
<>
264+
<div className={styles['footer__right__submit']} ref={dropdown_ref}>
265+
{(!props.is_web_mode ||
266+
(props.is_web_mode && props.is_connected)) && (
267+
<>
268+
<button
269+
className={cn(
270+
styles['footer__right__submit__button'],
271+
styles['footer__right__submit__button--submit'],
272+
'codicon',
273+
'codicon-send'
274+
)}
275+
onClick={handle_submit}
276+
title={props.use_last_choice_button_title}
277+
/>
278+
<button
279+
className={cn(
280+
styles['footer__right__submit__button'],
281+
styles['footer__right__submit__button--chevron'],
282+
'codicon',
283+
'codicon-chevron-down'
284+
)}
285+
onClick={toggle_dropdown}
286+
title="More actions"
287+
/>
288+
{is_dropdown_open && (
289+
<div className={styles['footer__right__submit__dropdown']}>
290+
<div
291+
className={
292+
styles['footer__right__submit__dropdown__item']
293+
}
294+
onClick={handle_select_click}
295+
>
296+
Select...
297+
<span
298+
className={
299+
styles[
300+
'footer__right__submit__dropdown__item__shortcut'
301+
]
302+
}
303+
>
304+
{mod_key}+{is_mac ? 'return' : 'enter'}
305+
</span>
306+
</div>
307+
<div
308+
className={
309+
styles['footer__right__submit__dropdown__item']
310+
}
311+
onClick={handle_copy_click}
312+
>
313+
Copy
314+
<span
315+
className={
316+
styles[
317+
'footer__right__submit__dropdown__item__shortcut'
318+
]
319+
}
320+
>
321+
{mod_key}+{is_mac ? 'option' : 'alt'}+c
322+
</span>
323+
</div>
324+
</div>
325+
)}
326+
</>
327+
)}
328+
329+
{props.is_web_mode && !props.is_connected && (
254330
<button
255331
className={cn(
256-
styles.footer__right__button,
332+
styles['footer__right__submit__button'],
257333
'codicon',
258-
'codicon-send'
334+
'codicon-copy'
259335
)}
260-
onClick={handle_submit}
261-
title={props.use_last_choice_button_title}
336+
onClick={(e) => {
337+
e.stopPropagation()
338+
props.on_copy()
339+
}}
340+
title="Copy to clipboard"
262341
/>
263-
</>
264-
)}
265-
266-
{props.is_web_mode && !props.is_connected && (
267-
<button
268-
className={cn(
269-
styles.footer__right__button,
270-
'codicon',
271-
'codicon-copy'
272-
)}
273-
onClick={(e) => {
274-
e.stopPropagation()
275-
props.on_copy()
276-
}}
277-
title="Copy to clipboard"
278-
/>
279-
)}
342+
)}
343+
</div>
280344
</div>
281345
</div>
282346
</div>

0 commit comments

Comments
 (0)