File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/cortex-tui/src/runner/event_loop Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -391,6 +391,24 @@ impl EventLoop {
391391 self . handle_history ( ) ;
392392 }
393393 "models:fetch-and-pick" => {
394+ // First, fetch models from the backend to populate the cache
395+ if let Some ( pm) = & self . provider_manager {
396+ // Need to acquire write lock to call fetch_models()
397+ match pm. try_write ( ) {
398+ Ok ( mut manager) => {
399+ if let Err ( e) = manager. fetch_models ( ) . await {
400+ tracing:: warn!( "Failed to fetch models: {}" , e) ;
401+ self . app_state
402+ . toasts
403+ . warning ( "Could not fetch models, showing cached list" ) ;
404+ }
405+ }
406+ Err ( _) => {
407+ tracing:: warn!( "Could not acquire write lock for provider manager" ) ;
408+ }
409+ }
410+ }
411+ // Now open the modal with freshly fetched (or cached) models
394412 self . handle_open_modal ( ModalType :: ModelPicker ) . await ;
395413 }
396414 _ => {
You can’t perform that action at this time.
0 commit comments