Skip to content

Commit 4b9f785

Browse files
committed
Move prompt preview to more actions dropdown and update selected files display
- currently 'attach selected files' and token count are detached. We want to have them together like this: '[X]K tokens in selected fiels'. When disabled should say: '[warning] Won't send selected files' - fix stories - rename 'wont send selected files' to 'disabled attaching files' - 'disabled attaching files' should be italic - move 'preview' from `packages/ui/src/components/editor/prompt/SelectedFiles/SelectedFiles.tsx` to `packages/ui/src/components/editor/common/prompts/PromptField/PromptField.tsx`, under 'copy prompt', as 'preview prompt' (without shortcut) - fix `packages/ui/src/components/editor/common/prompts/PromptField/PromptField.stories.tsx` - move 'preview prompt' below 'voice input ├── apps │ └── editor │ └── src │ └── views │ └── prompt │ └── frontend │ ├── Main │ │ └── MainView │ │ └── MainView.tsx │ └── i18n │ └── translations │ ├── main.ts │ └── prompt-field.ts └── packages └── ui └── src └── components └── editor ├── common │ └── prompts │ └── PromptField │ ├── PromptField.module.scss │ ├── PromptField.stories.tsx │ └── PromptField.tsx └── prompt └── SelectedFiles ├── SelectedFiles.module.scss ├── SelectedFiles.stories.tsx └── SelectedFiles.tsx
1 parent cdb7b94 commit 4b9f785

9 files changed

Lines changed: 112 additions & 93 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ export const MainView: React.FC<Props> = (props) => {
331331
on_paste_long_text={props.on_paste_long_text}
332332
on_open_pasted_text={props.on_open_pasted_text}
333333
on_paste_url={props.on_paste_url}
334+
on_preview_prompt={props.on_preview_prompt}
334335
is_recording={props.is_recording}
335336
on_recording_started={props.on_recording_started}
336337
on_recording_finished={props.on_recording_finished}
@@ -365,6 +366,7 @@ export const MainView: React.FC<Props> = (props) => {
365366
send_with: t('prompt-field.action.send-with'),
366367
send_with_ellipsis: t('prompt-field.action.send-with-ellipsis'),
367368
copy_prompt: t('prompt-field.action.copy-prompt'),
369+
preview_prompt: t('prompt-field.action.preview-prompt'),
368370
more_actions: t('prompt-field.action.more-actions'),
369371
send: t('prompt-field.action.send'),
370372
attach_selected_files: t('prompt-field.attach-selected-files'),
@@ -379,10 +381,10 @@ export const MainView: React.FC<Props> = (props) => {
379381
on_toggle_include_selected_files={
380382
props.on_toggle_include_selected_files
381383
}
382-
on_preview={props.on_preview_prompt}
383384
translations={{
384385
attach_selected_files: t('main.attach-selected-files'),
385-
preview: t('main.preview' as any)
386+
tokens_in_selected_files: t('main.tokens-in-selected-files' as any),
387+
disabled_attaching_files: t('main.disabled-attaching-files' as any)
386388
}}
387389
/>
388390

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

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,42 @@ export const main = {
8989
hu: ' token',
9090
bg: ' токена'
9191
},
92+
'main.tokens-in-selected-files': {
93+
en: 'tokens in selected files',
94+
pl: 'tokenów w wybranych plikach',
95+
'zh-cn': '个令牌在选定的文件中',
96+
ja: '選択したファイルのトークン',
97+
'zh-tw': '個代幣在選定的檔案中',
98+
de: 'Token in ausgewählten Dateien',
99+
es: 'tokens en archivos seleccionados',
100+
fr: 'jetons dans les fichiers sélectionnés',
101+
'pt-br': 'tokens nos arquivos selecionados',
102+
ru: 'токенов в выбранных файлах',
103+
ko: '선택한 파일의 토큰',
104+
it: 'token nei file selezionati',
105+
tr: 'seçili dosyalardaki jetonlar',
106+
cs: 'tokenů ve vybraných souborech',
107+
hu: 'token a kiválasztott fájlokban',
108+
bg: 'токена в избраните файлове'
109+
},
110+
'main.disabled-attaching-files': {
111+
en: 'Disabled attaching files',
112+
pl: 'Wyłączono dołączanie plików',
113+
'zh-cn': '已禁用附加文件',
114+
ja: 'ファイルの添付が無効になっています',
115+
'zh-tw': '已停用附加檔案',
116+
de: 'Anhängen von Dateien deaktiviert',
117+
es: 'Se deshabilitó adjuntar archivos',
118+
fr: 'Fichiers joints désactivés',
119+
'pt-br': 'Anexar arquivos desativado',
120+
ru: 'Прикрепление файлов отключено',
121+
ko: '파일 첨부 비활성화됨',
122+
it: 'Allegati disabilitati',
123+
tr: 'Dosya ekleme devre dışı',
124+
cs: 'Připojování souborů zakázáno',
125+
hu: 'Fájlok csatolása letiltva',
126+
bg: 'Прикачването на файлове е деактивирано'
127+
},
92128
'main.attach-selected-files': {
93129
en: 'Attach selected files',
94130
pl: 'Dołącz wybrane pliki',
@@ -106,23 +142,5 @@ export const main = {
106142
cs: 'Připojit vybrané soubory',
107143
hu: 'Kiválasztott fájlok csatolása',
108144
bg: 'Прикачване на избраните файлове'
109-
},
110-
'main.preview': {
111-
en: 'Preview',
112-
pl: 'Podgląd',
113-
'zh-cn': '预览',
114-
ja: 'プレビュー',
115-
'zh-tw': '預覽',
116-
de: 'Vorschau',
117-
es: 'Vista previa',
118-
fr: 'Aperçu',
119-
'pt-br': 'Pré-visualização',
120-
ru: 'Предпросмотр',
121-
ko: '미리보기',
122-
it: 'Anteprima',
123-
tr: 'Önizleme',
124-
cs: 'Náhled',
125-
hu: 'Előnézet',
126-
bg: 'Преглед'
127145
}
128146
} as const

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,24 @@ export const prompt_field = {
305305
hu: 'Prompt másolása',
306306
bg: 'Копиране на промпта'
307307
},
308+
'prompt-field.action.preview-prompt': {
309+
en: 'Preview prompt',
310+
pl: 'Podgląd promptu',
311+
'zh-cn': '预览提示',
312+
ja: 'プロンプトをプレビュー',
313+
'zh-tw': '預覽提示',
314+
de: 'Prompt-Vorschau',
315+
es: 'Vista previa del prompt',
316+
fr: 'Aperçu du prompt',
317+
'pt-br': 'Pré-visualizar prompt',
318+
ru: 'Предпросмотр промпта',
319+
ko: '프롬프트 미리보기',
320+
it: 'Anteprima prompt',
321+
tr: 'İstem önizlemesi',
322+
cs: 'Náhled promptu',
323+
hu: 'Prompt előnézete',
324+
bg: 'Преглед на промпта'
325+
},
308326
'prompt-field.action.more-actions': {
309327
en: 'More actions',
310328
pl: 'Więcej akcji',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const CHATBOTS = {
5555
supports_url_override: true,
5656
url_override_label: 'Project URL',
5757
url_override_disabled_options: ['temporary'],
58+
supported_reasoning_efforts: ['instant', 'medium', 'high'],
5859
supported_options: {
5960
temporary: 'Temporary',
6061
'think (free)': 'Think (free)'

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export const Empty = () => (
6464
send_with: 'Send with',
6565
send_with_ellipsis: 'Send with...',
6666
copy_prompt: 'Copy prompt',
67+
preview_prompt: 'Preview prompt',
6768
more_actions: 'More actions',
6869
send: 'Send',
6970
attach_selected_files: 'Attach selected files',
@@ -130,6 +131,7 @@ export const WithText = () => (
130131
send_with: 'Send with',
131132
send_with_ellipsis: 'Send with...',
132133
copy_prompt: 'Copy prompt',
134+
preview_prompt: 'Preview prompt',
133135
more_actions: 'More actions',
134136
send: 'Send',
135137
attach_selected_files: 'Attach selected files',
@@ -196,6 +198,7 @@ export const LongText = () => (
196198
send_with: 'Send with',
197199
send_with_ellipsis: 'Send with...',
198200
copy_prompt: 'Copy prompt',
201+
preview_prompt: 'Preview prompt',
199202
more_actions: 'More actions',
200203
send: 'Send',
201204
attach_selected_files: 'Attach selected files',
@@ -262,6 +265,7 @@ export const WithPlaceholderSavedContext = () => (
262265
send_with: 'Send with',
263266
send_with_ellipsis: 'Send with...',
264267
copy_prompt: 'Copy prompt',
268+
preview_prompt: 'Preview prompt',
265269
more_actions: 'More actions',
266270
send: 'Send',
267271
attach_selected_files: 'Attach selected files',
@@ -334,6 +338,7 @@ export const WithPlaceholderSelection = () => (
334338
send_with: 'Send with',
335339
send_with_ellipsis: 'Send with...',
336340
copy_prompt: 'Copy prompt',
341+
preview_prompt: 'Preview prompt',
337342
more_actions: 'More actions',
338343
send: 'Send',
339344
attach_selected_files: 'Attach selected files',
@@ -400,6 +405,7 @@ export const WithCommit = () => (
400405
send_with: 'Send with',
401406
send_with_ellipsis: 'Send with...',
402407
copy_prompt: 'Copy prompt',
408+
preview_prompt: 'Preview prompt',
403409
more_actions: 'More actions',
404410
send: 'Send',
405411
attach_selected_files: 'Attach selected files',
@@ -465,6 +471,7 @@ export const WithCommitWithQuotes = () => (
465471
send_with: 'Send with',
466472
send_with_ellipsis: 'Send with...',
467473
copy_prompt: 'Copy prompt',
474+
preview_prompt: 'Preview prompt',
468475
more_actions: 'More actions',
469476
send: 'Send',
470477
attach_selected_files: 'Attach selected files',
@@ -538,6 +545,7 @@ export const WithEditFormatSelector = () => {
538545
send_with: 'Send with',
539546
send_with_ellipsis: 'Send with...',
540547
copy_prompt: 'Copy prompt',
548+
preview_prompt: 'Preview prompt',
541549
more_actions: 'More actions',
542550
send: 'Send',
543551
attach_selected_files: 'Attach selected files',
@@ -605,6 +613,7 @@ export const WithFilePaths = () => (
605613
send_with: 'Send with',
606614
send_with_ellipsis: 'Send with...',
607615
copy_prompt: 'Copy prompt',
616+
preview_prompt: 'Preview prompt',
608617
more_actions: 'More actions',
609618
send: 'Send',
610619
attach_selected_files: 'Attach selected files',
@@ -699,6 +708,7 @@ export const WithTabs = () => {
699708
send_with: 'Send with',
700709
send_with_ellipsis: 'Send with...',
701710
copy_prompt: 'Copy prompt',
711+
preview_prompt: 'Preview prompt',
702712
more_actions: 'More actions',
703713
send: 'Send',
704714
attach_selected_files: 'Attach selected files',
@@ -764,6 +774,7 @@ export const WithWarning = () => (
764774
send_with: 'Send with',
765775
send_with_ellipsis: 'Send with...',
766776
copy_prompt: 'Copy prompt',
777+
preview_prompt: 'Preview prompt',
767778
more_actions: 'More actions',
768779
send: 'Send',
769780
attach_selected_files: 'Attach selected files',

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export type PromptFieldProps = {
6868
on_paste_long_text: (text: string) => void
6969
on_open_pasted_text: (hash: string) => void
7070
on_paste_url: (url: string) => void
71+
on_preview_prompt?: () => void
7172
is_recording: boolean
7273
on_recording_started: () => void
7374
on_recording_finished: () => void
@@ -101,6 +102,7 @@ export type PromptFieldProps = {
101102
send_with: string
102103
send_with_ellipsis: string
103104
copy_prompt: string
105+
preview_prompt: string
104106
more_actions: string
105107
send: string
106108
attach_selected_files: string
@@ -450,7 +452,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
450452
{is_edit_format_hovered && (
451453
<Tooltip
452454
message={props.translations.edit_format}
453-
details={is_mac ? '⌥(W/S/D/T)' : 'Alt+(W/S/D/T)'}
455+
details={is_mac ? '⌥' : 'Alt'}
454456
align="center"
455457
/>
456458
)}
@@ -568,7 +570,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
568570
{is_mode_switch_hovered && (
569571
<Tooltip
570572
message={props.translations.mode}
571-
details={is_mac ? '⌥Esc' : 'Alt+Esc'}
573+
details={is_mac ? '⌥' : 'Alt'}
572574
align="center"
573575
/>
574576
)}
@@ -714,7 +716,14 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
714716
}
715717
}
716718
]
717-
: [])
719+
: []),
720+
{
721+
label: props.translations.preview_prompt,
722+
on_click: () => {
723+
props.on_preview_prompt?.()
724+
close_dropdown()
725+
}
726+
}
718727
]}
719728
/>
720729
</>
@@ -800,6 +809,13 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
800809
props.on_recording_started()
801810
close_dropdown()
802811
}
812+
},
813+
{
814+
label: props.translations.preview_prompt,
815+
on_click: () => {
816+
props.on_preview_prompt?.()
817+
close_dropdown()
818+
}
803819
}
804820
]}
805821
/>

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

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@
3333
display: block;
3434
line-height: var(--height);
3535
padding-left: 6px;
36-
padding-right: 6px;
3736
}
3837
}
3938

4039
.warning {
4140
display: inline-block;
4241
color: var(--cwc-text-color-orange);
43-
margin-right: 6px;
42+
margin-right: 5px;
4443
vertical-align: middle;
4544

4645
span::before {
@@ -49,38 +48,7 @@
4948
}
5049
}
5150

52-
.count {
53-
font-size: 12px;
51+
.wont-send {
5452
color: var(--cwc-text-color-dimmed);
55-
flex-shrink: 0;
56-
57-
&--excluded {
58-
text-decoration: line-through;
59-
}
60-
}
61-
62-
.actions {
63-
display: flex;
64-
align-items: center;
65-
gap: 4px;
66-
}
67-
68-
.preview {
69-
display: flex;
70-
font-size: 12px;
71-
align-items: center;
72-
gap: 4px;
73-
cursor: pointer;
74-
white-space: nowrap;
75-
color: var(--vscode-textLink-foreground);
76-
padding: 0 6px 0 5px;
77-
height: 100%;
78-
79-
> span:first-child::before {
80-
font-size: 15px;
81-
}
82-
83-
&:hover {
84-
background-color: var(--vscode-toolbar-hoverBackground);
85-
}
53+
font-style: italic;
8654
}

‎packages/ui/src/components/editor/prompt/SelectedFiles/SelectedFiles.stories.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ export const Default = () => {
1313
selected_files_token_count={12500}
1414
include_selected_files={include}
1515
on_toggle_include_selected_files={set_include}
16-
on_preview={() => {}}
1716
translations={{
1817
attach_selected_files: 'Attach selected files',
19-
preview: 'Preview'
18+
tokens_in_selected_files: 'tokens in selected files',
19+
disabled_attaching_files: 'Disabled attaching files'
2020
}}
2121
/>
2222
)
@@ -30,10 +30,10 @@ export const ZeroTokens = () => {
3030
selected_files_token_count={0}
3131
include_selected_files={include}
3232
on_toggle_include_selected_files={set_include}
33-
on_preview={() => {}}
3433
translations={{
3534
attach_selected_files: 'Attach selected files',
36-
preview: 'Preview'
35+
tokens_in_selected_files: 'tokens in selected files',
36+
disabled_attaching_files: 'Disabled attaching files'
3737
}}
3838
/>
3939
)

0 commit comments

Comments
 (0)