@@ -643,146 +643,76 @@ async function resolve_presets(params: {
643643 // It also handles cases where a specified preset/group was not found.
644644 }
645645
646- if ( ! params . show_quick_pick ) {
647- if ( params . preset_name === undefined && params . group_name === undefined ) {
648- // Try to use last selection if "Send" button is clicked without specific preset/group
649- const last_choice =
650- params . context . workspaceState . get < string > (
651- last_group_or_preset_choice_state_key
652- ) ??
653- params . context . globalState . get < string > (
654- last_group_or_preset_choice_state_key
655- )
646+ if (
647+ ! params . show_quick_pick &&
648+ params . preset_name === undefined &&
649+ params . group_name === undefined
650+ ) {
651+ // Try to use last selection if "Send" button is clicked without specific preset/group
652+ const last_choice =
653+ params . context . workspaceState . get < string > (
654+ last_group_or_preset_choice_state_key
655+ ) ??
656+ params . context . globalState . get < string > (
657+ last_group_or_preset_choice_state_key
658+ )
656659
657- if ( last_choice == PRESET ) {
658- const last_preset_name =
659- params . context . workspaceState . get < string > ( last_selected_preset_key ) ??
660- params . context . globalState . get < string > ( last_selected_preset_key )
661- if ( last_preset_name !== undefined ) {
662- const preset = all_presets . find ( ( p ) => p . name === last_preset_name )
663- if ( preset ) {
664- if ( get_is_preset_disabled ( preset ) ) {
665- if (
666- ! is_in_code_completions_mode &&
667- ! current_instructions &&
668- ! preset . promptPrefix &&
669- ! preset . promptSuffix
670- ) {
671- vscode . window . showWarningMessage (
672- dictionary . warning_message . TYPE_SOMETHING_TO_USE_PRESET
673- )
674- }
675- return [ ]
676- } else {
677- return [ last_preset_name ]
660+ if ( last_choice == PRESET ) {
661+ const last_preset_name =
662+ params . context . workspaceState . get < string > ( last_selected_preset_key ) ??
663+ params . context . globalState . get < string > ( last_selected_preset_key )
664+ if ( last_preset_name !== undefined ) {
665+ const preset = all_presets . find ( ( p ) => p . name === last_preset_name )
666+ if ( preset ) {
667+ if ( get_is_preset_disabled ( preset ) ) {
668+ if (
669+ ! is_in_code_completions_mode &&
670+ ! current_instructions &&
671+ ! preset . promptPrefix &&
672+ ! preset . promptSuffix
673+ ) {
674+ vscode . window . showWarningMessage (
675+ dictionary . warning_message . TYPE_SOMETHING_TO_USE_PRESET
676+ )
678677 }
679- }
680- }
681- } else if ( last_choice == GROUP ) {
682- const last_group =
683- params . context . workspaceState . get < string > (
684- last_selected_group_state_key
685- ) ??
686- params . context . globalState . get < string > ( last_selected_group_state_key )
687- if ( last_group ) {
688- if ( last_group == 'Ungrouped' ) {
689- const first_group_index = all_presets . findIndex ( ( p ) => ! p . chatbot )
690- const relevant_presets =
691- first_group_index == - 1
692- ? all_presets
693- : all_presets . slice ( 0 , first_group_index )
694- const preset_names = relevant_presets
695- . filter ( ( p ) => p . isSelected && ! get_is_preset_disabled ( p ) )
696- . map ( ( p ) => p . name )
697- if ( preset_names . length > 0 ) return preset_names
678+ return [ ]
698679 } else {
699- const group_index = all_presets . findIndex (
700- ( p ) => p . name == last_group
701- )
702- const preset_names : string [ ] = [ ]
703- if ( group_index != - 1 ) {
704- for ( let i = group_index + 1 ; i < all_presets . length ; i ++ ) {
705- const preset = all_presets [ i ]
706- if ( ! preset . chatbot ) {
707- break // next group
708- }
709- if ( preset . isSelected && ! get_is_preset_disabled ( preset ) ) {
710- preset_names . push ( preset . name )
711- }
712- }
713- }
714- if ( preset_names . length > 0 ) return preset_names
680+ return [ last_preset_name ]
715681 }
716682 }
717683 }
718- } else {
719- const last_choice =
684+ } else if ( last_choice == GROUP ) {
685+ const last_group =
720686 params . context . workspaceState . get < string > (
721- last_group_or_preset_choice_state_key
687+ last_selected_group_state_key
722688 ) ??
723- params . context . globalState . get < string > (
724- last_group_or_preset_choice_state_key
725- )
726-
727- if ( last_choice == PRESET ) {
728- const last_preset_name =
729- params . context . workspaceState . get < string > ( last_selected_preset_key ) ??
730- params . context . globalState . get < string > ( last_selected_preset_key )
731- if ( last_preset_name !== undefined ) {
732- const preset = all_presets . find ( ( p ) => p . name == last_preset_name )
733- if ( preset ) {
734- if ( get_is_preset_disabled ( preset ) ) {
735- if (
736- ! is_in_code_completions_mode &&
737- ! current_instructions &&
738- ! preset . promptPrefix &&
739- ! preset . promptSuffix
740- ) {
741- vscode . window . showWarningMessage (
742- dictionary . warning_message . TYPE_SOMETHING_TO_USE_PRESET
743- )
689+ params . context . globalState . get < string > ( last_selected_group_state_key )
690+ if ( last_group ) {
691+ if ( last_group == 'Ungrouped' ) {
692+ const first_group_index = all_presets . findIndex ( ( p ) => ! p . chatbot )
693+ const relevant_presets =
694+ first_group_index == - 1
695+ ? all_presets
696+ : all_presets . slice ( 0 , first_group_index )
697+ const preset_names = relevant_presets
698+ . filter ( ( p ) => p . isSelected && ! get_is_preset_disabled ( p ) )
699+ . map ( ( p ) => p . name )
700+ if ( preset_names . length > 0 ) return preset_names
701+ } else {
702+ const group_index = all_presets . findIndex ( ( p ) => p . name == last_group )
703+ const preset_names : string [ ] = [ ]
704+ if ( group_index != - 1 ) {
705+ for ( let i = group_index + 1 ; i < all_presets . length ; i ++ ) {
706+ const preset = all_presets [ i ]
707+ if ( ! preset . chatbot ) {
708+ break // next group
744709 }
745- return [ ]
746- } else {
747- return [ last_preset_name ]
748- }
749- }
750- }
751- } else if ( last_choice == GROUP ) {
752- const last_group =
753- params . context . workspaceState . get < string > (
754- last_selected_group_state_key
755- ) ??
756- params . context . globalState . get < string > ( last_selected_group_state_key )
757- if ( last_group ) {
758- if ( last_group == 'Ungrouped' ) {
759- const first_group_index = all_presets . findIndex ( ( p ) => ! p . chatbot )
760- const relevant_presets =
761- first_group_index == - 1
762- ? all_presets
763- : all_presets . slice ( 0 , first_group_index )
764- const preset_names = relevant_presets
765- . filter ( ( p ) => p . isSelected && ! get_is_preset_disabled ( p ) )
766- . map ( ( p ) => p . name )
767- if ( preset_names . length > 0 ) return preset_names
768- } else {
769- const group_index = all_presets . findIndex (
770- ( p ) => p . name == last_group
771- )
772- const preset_names : string [ ] = [ ]
773- if ( group_index != - 1 ) {
774- for ( let i = group_index + 1 ; i < all_presets . length ; i ++ ) {
775- const preset = all_presets [ i ]
776- if ( ! preset . chatbot ) {
777- break // next group
778- }
779- if ( preset . isSelected && ! get_is_preset_disabled ( preset ) ) {
780- preset_names . push ( preset . name )
781- }
710+ if ( preset . isSelected && ! get_is_preset_disabled ( preset ) ) {
711+ preset_names . push ( preset . name )
782712 }
783713 }
784- if ( preset_names . length > 0 ) return preset_names
785714 }
715+ if ( preset_names . length > 0 ) return preset_names
786716 }
787717 }
788718 }
0 commit comments