11import styles from './MainView.module.scss'
22import { Configurations as UiConfigurations } from '@ui/components/editor/panel/Configurations'
3- import { Presets as UiPresets } from '@ui/components/editor/panel/Presets'
43import { PromptField as UiPromptField } from '@ui/components/editor/panel/prompts/PromptField'
54import { Separator as UiSeparator } from '@ui/components/editor/panel/Separator'
65import { Preset } from '@shared/types/preset'
@@ -19,6 +18,8 @@ import { use_invocation_counts } from './hooks/use-invocation-counts'
1918import { SelectionState } from '@/views/panel/types/messages'
2019import { use_translation } from '../../i18n/use-translation'
2120import { Checkbox as UiCheckbox } from '@ui/components/editor/common/Checkbox'
21+ import { Icon } from '@ui/components/editor/common/Icon'
22+ import { CHATBOTS } from '@shared/constants/chatbots'
2223
2324type Props = {
2425 scroll_reset_key : number
@@ -125,6 +126,29 @@ type Props = {
125126 voice_input_push_to_talk : boolean
126127}
127128
129+ const chatbot_to_icon : Record < keyof typeof CHATBOTS , Icon . Variant > = {
130+ 'AI Studio' : 'AI_STUDIO' ,
131+ ChatGPT : 'CHATGPT' ,
132+ Claude : 'CLAUDE' ,
133+ Copilot : 'COPILOT' ,
134+ DeepSeek : 'DEEPSEEK' ,
135+ Doubao : 'DOUBAO' ,
136+ Gemini : 'GEMINI' ,
137+ 'GitHub Copilot' : 'GITHUB_COPILOT' ,
138+ Grok : 'GROK' ,
139+ HuggingChat : 'HUGGING_CHAT' ,
140+ Kimi : 'KIMI' ,
141+ Mistral : 'MISTRAL' ,
142+ 'Meta AI' : 'META' ,
143+ Arena : 'ARENA' ,
144+ 'Open WebUI' : 'OPEN_WEBUI' ,
145+ OpenRouter : 'OPENROUTER' ,
146+ Qwen : 'QWEN' ,
147+ Together : 'TOGETHER' ,
148+ Yuanbao : 'YUANBAO' ,
149+ Z : 'Z_AI'
150+ }
151+
128152export const MainView : React . FC < Props > = ( props ) => {
129153 const { t } = use_translation ( )
130154
@@ -196,6 +220,51 @@ export const MainView: React.FC<Props> = (props) => {
196220 configurations : props . configurations
197221 } )
198222
223+ const web_configurations : UiConfigurations . Configuration [ ] = props . presets . map (
224+ ( preset , index ) => {
225+ const is_unnamed = ! preset . name || / ^ \( \d + \) $ / . test ( preset . name . trim ( ) )
226+ const display_name = is_unnamed
227+ ? preset . chatbot !
228+ : preset . name ! . replace ( / \( \d + \) $ / , '' )
229+
230+ const get_details = ( ) : string [ ] => {
231+ const { chatbot, model } = preset
232+ const model_display_name =
233+ model && chatbot ? CHATBOTS [ chatbot ] . models ?. [ model ] ?. label || model : null
234+
235+ if ( is_unnamed ) return model_display_name ? [ model_display_name ] : [ ]
236+ if ( model_display_name ) return [ chatbot ! , model_display_name ]
237+ return chatbot ? [ chatbot ] : [ ]
238+ }
239+
240+ return {
241+ id : preset . name ?? `unnamed-${ index } ` ,
242+ title : display_name ,
243+ details : get_details ( ) ,
244+ is_pinned : preset . is_pinned ,
245+ icon : preset . chatbot ? chatbot_to_icon [ preset . chatbot ] : undefined ,
246+ }
247+ }
248+ )
249+
250+ const api_configurations : UiConfigurations . Configuration [ ] = props . configurations . map (
251+ ( c ) => {
252+ const details = [ c . provider_name ]
253+ if ( c . reasoning_effort ) {
254+ details . push ( `${ c . reasoning_effort } ` )
255+ }
256+ if ( c . temperature != null ) {
257+ details . push ( `${ c . temperature } ` )
258+ }
259+ return {
260+ id : c . id ,
261+ title : c . model ,
262+ details,
263+ is_pinned : c . is_pinned
264+ }
265+ }
266+ )
267+
199268 return (
200269 < >
201270 < Header
@@ -331,46 +400,52 @@ export const MainView: React.FC<Props> = (props) => {
331400 { props . mode == MODE . WEB && (
332401 < >
333402 < UiSeparator height = { 8 } />
334- < UiPresets
335- web_prompt_type = { props . web_prompt_type }
336- is_connected = { props . is_connected }
337- has_instructions = { ! ! props . instructions }
338- has_context = { props . token_count > 0 }
339- is_in_code_completions_mode = {
340- props . web_prompt_type == 'code-at-cursor'
403+ < UiConfigurations
404+ configurations = { web_configurations }
405+ on_create = { ( params ) =>
406+ props . on_create_preset (
407+ params ?. create_on_top ? 'top' : 'bottom' ,
408+ params ?. insertion_index
409+ )
341410 }
342- presets = { props . presets }
343- on_create = { props . on_create_preset }
344- on_preset_click = { ( preset_name ) =>
411+ on_configuration_click = { ( id ) => {
345412 props . initialize_chats ( {
346- preset_name,
413+ preset_name : id ,
347414 show_quick_pick : false ,
348415 invocation_count : current_invocation_count
349416 } )
350- }
351- on_preset_copy = { props . copy_to_clipboard }
352- on_preset_edit = { props . on_preset_edit }
353- on_presets_reorder = { props . on_presets_reorder }
354- on_duplicate = { props . on_duplicate_preset }
355- on_delete = { props . on_delete_preset }
356- on_toggle_preset_pinned = { props . on_toggle_preset_pinned }
357- selected_preset_name = { props . selected_preset_name }
417+ } }
418+ on_edit = { ( id ) => props . on_preset_edit ( id ) }
419+ on_reorder = { ( reordered ) => {
420+ const new_presets = reordered . map ( ( c ) => {
421+ return props . presets . find (
422+ ( p , i ) => ( p . name ?? `unnamed-${ i } ` ) === c . id
423+ ) !
424+ } )
425+ props . on_presets_reorder ( new_presets )
426+ } }
427+ on_duplicate = { ( id ) => {
428+ const idx = props . presets . findIndex ( ( p , i ) => ( p . name ?? `unnamed-${ i } ` ) === id )
429+ props . on_duplicate_preset ( idx )
430+ } }
431+ on_delete = { ( id ) => {
432+ const idx = props . presets . findIndex ( ( p , i ) => ( p . name ?? `unnamed-${ i } ` ) === id )
433+ props . on_delete_preset ( idx )
434+ } }
435+ on_toggle_pinned = { ( id ) => props . on_toggle_preset_pinned ( id ) }
436+ selected_configuration_id = { props . selected_preset_name }
358437 is_collapsed = { props . presets_collapsed }
359438 on_toggle_collapsed = { props . on_presets_collapsed_change }
360439 translations = { {
361440 title : t ( 'presets.title' ) ,
362441 empty : t ( 'presets.empty' ) ,
363- preset : t ( 'presets.preset' ) ,
364- presets : t ( 'presets.presets' ) ,
365442 add_new : t ( 'action.add-new' ) ,
366- add_new_tooltip : t ( 'action.add-new' ) ,
367- copy_tooltip : t ( 'action.copy' ) ,
368- pin_tooltip : t ( 'action.pin' ) ,
369- unpin_tooltip : t ( 'action.unpin' ) ,
370- duplicate_tooltip : t ( 'action.duplicate-preset' ) ,
371- edit_tooltip : t ( 'action.edit' ) ,
372- delete_tooltip : t ( 'action.delete' ) ,
373- insert_tooltip : t ( 'action.insert-preset' )
443+ pin : t ( 'action.pin' ) ,
444+ unpin : t ( 'action.unpin' ) ,
445+ duplicate_configuration : t ( 'action.duplicate-configuration' ) ,
446+ edit : t ( 'action.edit' ) ,
447+ delete : t ( 'action.delete' ) ,
448+ insert : t ( 'action.insert-configuration' ) ,
374449 } }
375450 />
376451 </ >
@@ -380,10 +455,9 @@ export const MainView: React.FC<Props> = (props) => {
380455 < >
381456 < UiSeparator height = { 8 } />
382457 < UiConfigurations
383- api_prompt_type = { props . api_prompt_type }
384- configurations = { props . configurations }
458+ configurations = { api_configurations }
385459 on_configuration_click = { props . on_configuration_click }
386- on_reorder = { props . on_configurations_reorder }
460+ on_reorder = { ( reordered ) => props . on_configurations_reorder ( reordered ) }
387461 on_toggle_pinned = { props . on_toggle_pinned_configuration }
388462 on_edit = { props . on_edit_configuration }
389463 on_delete = { props . on_delete_configuration }
@@ -396,13 +470,12 @@ export const MainView: React.FC<Props> = (props) => {
396470 title : t ( 'configurations.title' ) ,
397471 empty : t ( 'configurations.empty' ) ,
398472 add_new : t ( 'action.add-new' ) ,
399- add_new_tooltip : t ( 'action.add-new' ) ,
400- pin_tooltip : t ( 'action.pin' ) ,
401- unpin_tooltip : t ( 'action.unpin' ) ,
402- insert_tooltip : t ( 'action.insert-configuration' ) ,
403- edit_tooltip : t ( 'action.edit' ) ,
404- delete_tooltip : t ( 'action.delete' ) ,
405- duplicate_tooltip : t ( 'action.duplicate-configuration' )
473+ pin : t ( 'action.pin' ) ,
474+ unpin : t ( 'action.unpin' ) ,
475+ insert : t ( 'action.insert-configuration' ) ,
476+ edit : t ( 'action.edit' ) ,
477+ delete : t ( 'action.delete' ) ,
478+ duplicate_configuration : t ( 'action.duplicate-configuration' )
406479 } }
407480 />
408481 </ >
0 commit comments