@@ -11,23 +11,23 @@ export const handle_pick_model = async (
1111 message : PickModelMessage
1212) : Promise < void > => {
1313 try {
14- let items : vscode . QuickPickItem [ ] = [ ]
14+ let items : ( vscode . QuickPickItem & { model_id : string } ) [ ] = [ ]
1515
1616 if ( message . chatbot_name == 'OpenRouter' ) {
1717 const response = await axios . get ( 'https://openrouter.ai/api/v1/models' )
1818 const models = response . data . data
1919
2020 items = models . map ( ( model : any ) => ( {
2121 label : model . name ,
22- description : model . id ,
23- detail : model . description
22+ model_id : model . id
2423 } ) )
2524 } else {
2625 const chatbot_config =
2726 CHATBOTS [ message . chatbot_name as keyof typeof CHATBOTS ]
2827 if ( chatbot_config && chatbot_config . models ) {
2928 items = Object . entries ( chatbot_config . models ) . map ( ( [ id , data ] ) => ( {
30- label : ( data as any ) . label || id
29+ label : ( data as any ) . label || id ,
30+ model_id : id
3131 } ) )
3232 }
3333 }
@@ -36,6 +36,14 @@ export const handle_pick_model = async (
3636 quick_pick . items = items
3737 quick_pick . title = 'Models'
3838 quick_pick . placeholder = 'Choose a model'
39+
40+ if ( message . current_model_id ) {
41+ const active_item = items . find (
42+ ( i ) => i . model_id === message . current_model_id
43+ )
44+ if ( active_item ) quick_pick . activeItems = [ active_item ]
45+ }
46+
3947 quick_pick . buttons = [
4048 {
4149 iconPath : new vscode . ThemeIcon ( 'close' ) ,
@@ -51,11 +59,11 @@ export const handle_pick_model = async (
5159
5260 return new Promise < void > ( ( resolve ) => {
5361 quick_pick . onDidAccept ( ( ) => {
54- const selected = quick_pick . selectedItems [ 0 ]
62+ const selected = quick_pick . selectedItems [ 0 ] as any
5563 if ( selected ) {
5664 panel_provider . send_message ( {
5765 command : 'NEWLY_PICKED_MODEL' ,
58- model_id : selected . description !
66+ model_id : selected . model_id
5967 } )
6068 }
6169 quick_pick . hide ( )
0 commit comments