@@ -15,6 +15,7 @@ import { show_configurations_quick_pick } from '@/utils/show-configurations-quic
1515import { PromptBuilder } from '@/utils/prompt-builder'
1616import { t } from '@/i18n'
1717import { show_incomplete_setup_warning } from '@/utils/show-missing-configuration-notification'
18+ import { CHATBOTS } from '@shared/constants/chatbots'
1819
1920export const handle_autofill = async ( params : {
2021 prompt_view_provider : PromptViewProvider
@@ -38,7 +39,6 @@ export const handle_autofill = async (params: {
3839 } )
3940
4041 if ( ! resolution . web_configuration_name ) {
41- show_incomplete_setup_warning ( 'web' )
4242 return
4343 }
4444 const resolved_web_configuration_name = resolution . web_configuration_name
@@ -130,9 +130,6 @@ const show_web_configuration_quick_pick = async (params: {
130130 extension_context : vscode . ExtensionContext
131131 prompt_type : WebPromptType
132132 prompt_view_provider : PromptViewProvider
133- get_is_web_configuration_disabled : (
134- web_configuration : ConfigWebConfigurationFormat
135- ) => boolean
136133} ) : Promise < { web_configuration_name : string | undefined } | undefined > => {
137134 const {
138135 web_configurations,
@@ -141,7 +138,9 @@ const show_web_configuration_quick_pick = async (params: {
141138 prompt_view_provider
142139 } = params
143140
144- const valid_web_configurations = web_configurations . filter ( ( c ) => c . chatbot )
141+ const valid_web_configurations = web_configurations . filter (
142+ ( c ) => c . chatbot && Object . keys ( CHATBOTS ) . includes ( c . chatbot )
143+ )
145144
146145 if ( valid_web_configurations . length == 0 ) {
147146 return
@@ -165,10 +164,6 @@ const show_web_configuration_quick_pick = async (params: {
165164
166165 const web_configuration = result . item
167166
168- if ( params . get_is_web_configuration_disabled ( web_configuration ) ) {
169- return
170- }
171-
172167 if ( web_configuration . name ) {
173168 handle_update_last_used_web_configuration ( {
174169 prompt_view_provider,
@@ -193,21 +188,21 @@ const resolve_web_configuration = async (params: {
193188 'chatbots' ,
194189 [ ]
195190 )
196- const get_is_web_configuration_disabled = (
197- web_configuration : ConfigWebConfigurationFormat
198- ) =>
199- ( web_configuration . chatbot &&
200- ! params . prompt_view_provider . websocket_server_instance . is_connected_with_browser ( ) ) ||
201- false
191+
192+ const valid_web_configurations = all_web_configurations . filter (
193+ ( c ) => c . chatbot && Object . keys ( CHATBOTS ) . includes ( c . chatbot )
194+ )
195+
196+ if ( valid_web_configurations . length == 0 ) {
197+ show_incomplete_setup_warning ( 'web' )
198+ return { web_configuration_name : undefined }
199+ }
202200
203201 if ( params . web_configuration_name !== undefined ) {
204202 const web_configuration = all_web_configurations . find (
205203 ( p ) => p . name == params . web_configuration_name
206204 )
207205 if ( web_configuration ) {
208- if ( get_is_web_configuration_disabled ( web_configuration ) ) {
209- return { web_configuration_name : undefined }
210- }
211206 return { web_configuration_name : params . web_configuration_name }
212207 }
213208 }
@@ -223,24 +218,14 @@ const resolve_web_configuration = async (params: {
223218 ( p ) => p . name == last_selected_name
224219 )
225220 if ( item ) {
226- if ( item . chatbot ) {
227- if ( get_is_web_configuration_disabled ( item ) ) {
228- return { web_configuration_name : undefined }
229- } else {
230- return { web_configuration_name : last_selected_name }
231- }
221+ if ( item . chatbot && Object . keys ( CHATBOTS ) . includes ( item . chatbot ) ) {
222+ return { web_configuration_name : last_selected_name }
232223 }
233224 }
234225 }
235226
236- const valid_web_configurations = all_web_configurations . filter (
237- ( c ) => c . chatbot
238- )
239227 if ( valid_web_configurations . length == 1 ) {
240228 const web_configuration = valid_web_configurations [ 0 ]
241- if ( get_is_web_configuration_disabled ( web_configuration ) ) {
242- return { web_configuration_name : undefined }
243- }
244229 return { web_configuration_name : web_configuration . name }
245230 }
246231 }
@@ -249,8 +234,7 @@ const resolve_web_configuration = async (params: {
249234 web_configurations : all_web_configurations ,
250235 extension_context : params . extension_context ,
251236 prompt_type : params . prompt_view_provider . web_prompt_type ,
252- prompt_view_provider : params . prompt_view_provider ,
253- get_is_web_configuration_disabled
237+ prompt_view_provider : params . prompt_view_provider
254238 } )
255239
256240 return resolution ?? { web_configuration_name : undefined }
0 commit comments