Skip to content

Commit 19a118a

Browse files
committed
Enhance PromptField tooltips by supporting localized labels and adding detailed information to invocation count and voice input controls
- on submit tooltip, we're showing 'Send with...'. The issue is that model and reasoning effort are shown in parenthesis. Expected appearance is showing them dimmed. - rename last_choice_button_title to 'last choice tooltip'{name, details?}, keep this convention also in the application layer. - use css class for [Fragment] - to prompt field pass translations: {invocation_count} and use it for the 'title' attribute - put 'invocation count' into a tooltip, not title attribute - place it as dimmed details [Pasted text] - 'tootlip details' should be an integral part of the Tooltip component - 'invocation count' translation should be in `apps/editor/src/views/panel/frontend/i18n/translations/prompt-field.ts` - place 'voice input' in translations, display it in a tooltip - display 'voice input' (currently in title attribute) in a tooltip
1 parent 7a7549b commit 19a118a

8 files changed

Lines changed: 216 additions & 54 deletions

File tree

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { ApiPromptType, WebPromptType } from '@shared/types/prompt-types'
1111
import { Scrollable as UiScrollable } from '@ui/components/editor/panel/Scrollable'
1212
import { BrowserExtensionMessage as UiBrowserExtensionMessage } from '@ui/components/editor/panel/BrowserExtensionMessage'
1313
import { ApiConfiguration } from '@/views/panel/types/messages'
14-
import { use_last_choice_button_title } from './hooks/use-last-choice-button-title'
14+
import { use_last_choice_tooltip } from './hooks/use-last-choice-tooltip'
1515
import { ContextUtilisation as UiContextUtilisation } from '@ui/components/editor/panel/ContextUtilisation'
1616
import { Header } from './components/Header'
1717
import { use_invocation_counts } from './hooks/use-invocation-counts'
@@ -243,7 +243,7 @@ export const MainView: React.FC<Props> = (props) => {
243243
}
244244
}
245245

246-
const last_choice_button_title = use_last_choice_button_title({
246+
const last_choice_tooltip = use_last_choice_tooltip({
247247
mode: props.mode,
248248
selected_web_configuration_or_group_name:
249249
props.selected_web_configuration_name,
@@ -397,7 +397,7 @@ export const MainView: React.FC<Props> = (props) => {
397397
on_caret_position_set={props.on_caret_position_set}
398398
focus_and_select_key={props.chat_input_focus_and_select_key}
399399
focus_key={props.chat_input_focus_key}
400-
last_choice_button_title={last_choice_button_title}
400+
last_choice_tooltip={last_choice_tooltip}
401401
show_edit_format_selector={show_edit_format_selector}
402402
edit_format={
403403
props.mode == MODE.WEB
@@ -432,6 +432,11 @@ export const MainView: React.FC<Props> = (props) => {
432432
warning={warning}
433433
voice_input_push_to_talk={props.voice_input_push_to_talk}
434434
token_count={props.token_count}
435+
translations={{
436+
invocation_count: t('prompt-field.invocation-count'),
437+
voice_input: t('prompt-field.voice-input'),
438+
exit_voice_input: t('prompt-field.exit-voice-input')
439+
}}
435440
/>
436441
<UiContextUtilisation
437442
current_context_size={props.token_count}

apps/editor/src/views/panel/frontend/Main/MainView/hooks/use-last-choice-button-title.ts renamed to apps/editor/src/views/panel/frontend/Main/MainView/hooks/use-last-choice-tooltip.ts

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,65 @@ import { ApiConfiguration } from '@/views/panel/types/messages'
44
import { CHATBOTS } from '@shared/constants/chatbots'
55
import { WebConfiguration } from '@shared/types/web-configuration'
66

7-
export const use_last_choice_button_title = (params: {
7+
export const use_last_choice_tooltip = (params: {
88
mode: Mode
99
selected_web_configuration_or_group_name?: string
1010
web_configurations: WebConfiguration[]
1111
selected_api_configuration_id?: string
1212
api_configurations: ApiConfiguration[]
13-
}): string | undefined => {
13+
}): { name: string; details?: string } | undefined => {
1414
return useMemo(() => {
1515
if (params.mode == MODE.WEB) {
1616
if (params.selected_web_configuration_or_group_name) {
1717
if (params.selected_web_configuration_or_group_name == 'Ungrouped') {
18-
return 'Ungrouped'
18+
return { name: 'Ungrouped' }
1919
} else {
2020
const web_configuration = params.web_configurations.find(
2121
(p) => p.name == params.selected_web_configuration_or_group_name
2222
)
2323
if (web_configuration) {
2424
const is_unnamed =
25-
!web_configuration.name || /^\(\d+\)$/.test(web_configuration.name.trim())
25+
!web_configuration.name ||
26+
/^\(\d+\)$/.test(web_configuration.name.trim())
2627
let display_name: string
2728
if (web_configuration.chatbot) {
28-
display_name = is_unnamed ? web_configuration.chatbot : web_configuration.name!
29+
display_name = is_unnamed
30+
? web_configuration.chatbot
31+
: web_configuration.name!
2932
} else {
30-
display_name = is_unnamed ? 'Unnamed group' : web_configuration.name!
33+
display_name = is_unnamed
34+
? 'Unnamed group'
35+
: web_configuration.name!
3136
}
3237

33-
const get_subtitle = (): string => {
34-
const { chatbot, model } = web_configuration
38+
const get_details = (): string => {
39+
const { chatbot, model, reasoning_effort } = web_configuration
40+
let base: string
3541
if (!chatbot) {
36-
return model || ''
42+
base = model || ''
43+
} else {
44+
const model_display_name = model
45+
? CHATBOTS[chatbot].models?.[model]?.label || model
46+
: null
47+
if (is_unnamed) {
48+
base = model_display_name || ''
49+
} else if (model_display_name) {
50+
base = `${chatbot} · ${model_display_name}`
51+
} else {
52+
base = chatbot
53+
}
3754
}
38-
const model_display_name = model
39-
? CHATBOTS[chatbot].models?.[model]?.label || model
40-
: null
41-
if (is_unnamed) {
42-
return model_display_name || ''
55+
if (reasoning_effort) {
56+
base = base ? `${base} · ${reasoning_effort}` : reasoning_effort
4357
}
44-
if (model_display_name) {
45-
return `${chatbot} · ${model_display_name}`
46-
}
47-
return chatbot
58+
return base
4859
}
4960

50-
const subtitle = get_subtitle()
51-
if (subtitle) {
52-
return `${display_name} (${subtitle})`
61+
const details = get_details()
62+
if (details) {
63+
return { name: display_name, details }
5364
} else {
54-
return display_name
65+
return { name: display_name }
5566
}
5667
}
5768
}
@@ -68,7 +79,7 @@ export const use_last_choice_button_title = (params: {
6879
description_parts.push(`${configuration.reasoning_effort}`)
6980
}
7081
const description = description_parts.join(' · ')
71-
return `${configuration.model} (${description})`
82+
return { name: configuration.model, details: description }
7283
}
7384
}
7485
}
@@ -81,4 +92,3 @@ export const use_last_choice_button_title = (params: {
8192
params.api_configurations
8293
])
8394
}
84-

‎apps/editor/src/views/panel/frontend/i18n/translations/index.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { home } from './home'
33
import { checkpoints } from './checkpoints'
44
import { configurations } from './configurations'
55
import { actions } from './actions'
6+
import { prompt_field } from './prompt-field'
67

78
export const translations = {
89
...header,
910
...home,
1011
...checkpoints,
1112
...configurations,
12-
...actions
13+
...actions,
14+
...prompt_field
1315
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
export const prompt_field = {
2+
'prompt-field.invocation-count': {
3+
en: 'Invocation count',
4+
pl: 'Liczba wywołań',
5+
'zh-cn': '调用次数',
6+
ja: '呼び出し回数',
7+
'zh-tw': '呼叫次數',
8+
de: 'Aufrufanzahl',
9+
es: 'Conteo de invocaciones',
10+
fr: "Nombre d'appels",
11+
'pt-br': 'Contagem de invocações',
12+
ru: 'Количество вызовов',
13+
ko: '호출 횟수',
14+
it: 'Conteggio chiamate',
15+
tr: 'Çağrı sayısı',
16+
cs: 'Počet volání',
17+
hu: 'Hívások száma',
18+
bg: 'Брой извиквания'
19+
},
20+
'prompt-field.voice-input': {
21+
en: 'Voice input',
22+
pl: 'Wprowadzanie głosowe',
23+
'zh-cn': '语音输入',
24+
ja: '音声入力',
25+
'zh-tw': '語音輸入',
26+
de: 'Spracheingabe',
27+
es: 'Entrada de voz',
28+
fr: 'Saisie vocale',
29+
'pt-br': 'Entrada de voz',
30+
ru: 'Голосовой ввод',
31+
ko: '음성 입력',
32+
it: 'Input vocale',
33+
tr: 'Sesli giriş',
34+
cs: 'Hlasový vstup',
35+
hu: 'Hangbemenet',
36+
bg: 'Гласово въвеждане'
37+
},
38+
'prompt-field.exit-voice-input': {
39+
en: 'Exit voice input',
40+
pl: 'Zakończ wprowadzanie głosowe',
41+
'zh-cn': '退出语音输入',
42+
ja: '音声入力を終了',
43+
'zh-tw': '退出語音輸入',
44+
de: 'Spracheingabe beenden',
45+
es: 'Salir de entrada de voz',
46+
fr: 'Quitter la saisie vocale',
47+
'pt-br': 'Sair da entrada de voz',
48+
ru: 'Завершить голосовой ввод',
49+
ko: '음성 입력 종료',
50+
it: 'Esci da input vocale',
51+
tr: 'Sesli girişi sonlandır',
52+
cs: 'Ukončit hlasový vstup',
53+
hu: 'Hangbemenet befejezése',
54+
bg: 'Изход от гласово въвеждане'
55+
}
56+
} as const

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export const Empty = () => (
4949
on_new_tab={() => {}}
5050
on_tab_delete={() => {}}
5151
token_count={0}
52+
translations={{
53+
invocation_count: 'Invocation count',
54+
voice_input: 'Voice input',
55+
exit_voice_input: 'Exit voice input'
56+
}}
5257
/>
5358
)
5459

@@ -96,6 +101,11 @@ export const WithText = () => (
96101
on_new_tab={() => {}}
97102
on_tab_delete={() => {}}
98103
token_count={0}
104+
translations={{
105+
invocation_count: 'Invocation count',
106+
voice_input: 'Voice input',
107+
exit_voice_input: 'Exit voice input'
108+
}}
99109
/>
100110
)
101111

@@ -143,6 +153,11 @@ export const LongText = () => (
143153
on_new_tab={() => {}}
144154
on_tab_delete={() => {}}
145155
token_count={0}
156+
translations={{
157+
invocation_count: 'Invocation count',
158+
voice_input: 'Voice input',
159+
exit_voice_input: 'Exit voice input'
160+
}}
146161
/>
147162
)
148163

@@ -190,6 +205,11 @@ export const WithPlaceholderSavedContext = () => (
190205
on_new_tab={() => {}}
191206
on_tab_delete={() => {}}
192207
token_count={0}
208+
translations={{
209+
invocation_count: 'Invocation count',
210+
voice_input: 'Voice input',
211+
exit_voice_input: 'Exit voice input'
212+
}}
193213
/>
194214
)
195215

@@ -243,6 +263,11 @@ export const WithPlaceholderSelection = () => (
243263
on_new_tab={() => {}}
244264
on_tab_delete={() => {}}
245265
token_count={0}
266+
translations={{
267+
invocation_count: 'Invocation count',
268+
voice_input: 'Voice input',
269+
exit_voice_input: 'Exit voice input'
270+
}}
246271
/>
247272
)
248273

@@ -290,6 +315,11 @@ export const WithCommit = () => (
290315
on_new_tab={() => {}}
291316
on_tab_delete={() => {}}
292317
token_count={0}
318+
translations={{
319+
invocation_count: 'Invocation count',
320+
voice_input: 'Voice input',
321+
exit_voice_input: 'Exit voice input'
322+
}}
293323
/>
294324
)
295325

@@ -337,6 +367,11 @@ export const WithCommitWithQuotes = () => (
337367
on_new_tab={() => {}}
338368
on_tab_delete={() => {}}
339369
token_count={0}
370+
translations={{
371+
invocation_count: 'Invocation count',
372+
voice_input: 'Voice input',
373+
exit_voice_input: 'Exit voice input'
374+
}}
340375
/>
341376
)
342377
export const WithContextAtCommit = () => (
@@ -383,6 +418,11 @@ export const WithContextAtCommit = () => (
383418
on_new_tab={() => {}}
384419
on_tab_delete={() => {}}
385420
token_count={0}
421+
translations={{
422+
invocation_count: 'Invocation count',
423+
voice_input: 'Voice input',
424+
exit_voice_input: 'Exit voice input'
425+
}}
386426
/>
387427
)
388428

@@ -434,6 +474,11 @@ export const WithEditFormatSelector = () => {
434474
on_new_tab={() => {}}
435475
on_tab_delete={() => {}}
436476
token_count={0}
477+
translations={{
478+
invocation_count: 'Invocation count',
479+
voice_input: 'Voice input',
480+
exit_voice_input: 'Exit voice input'
481+
}}
437482
/>
438483
)
439484
}
@@ -482,6 +527,11 @@ export const WithFilePaths = () => (
482527
on_new_tab={() => {}}
483528
on_tab_delete={() => {}}
484529
token_count={0}
530+
translations={{
531+
invocation_count: 'Invocation count',
532+
voice_input: 'Voice input',
533+
exit_voice_input: 'Exit voice input'
534+
}}
485535
/>
486536
)
487537

@@ -557,6 +607,11 @@ export const WithTabs = () => {
557607
on_new_tab={handle_new_tab}
558608
on_tab_delete={handle_tab_delete}
559609
token_count={0}
610+
translations={{
611+
invocation_count: 'Invocation count',
612+
voice_input: 'Voice input',
613+
exit_voice_input: 'Exit voice input'
614+
}}
560615
/>
561616
)
562617
}
@@ -601,6 +656,11 @@ export const WithWarning = () => (
601656
on_new_tab={() => {}}
602657
on_tab_delete={() => {}}
603658
token_count={0}
659+
translations={{
660+
invocation_count: 'Invocation count',
661+
voice_input: 'Voice input',
662+
exit_voice_input: 'Exit voice input'
663+
}}
604664
warning="Add a configuration"
605665
/>
606666
)

0 commit comments

Comments
 (0)