@@ -234,12 +234,23 @@ const ROTATING_TIPS: [&str; 14] = [
234
234
235
235
const GREETING_BREAK_POINT : usize = 80 ;
236
236
237
- const MODEL_OPTIONS : [ ( & str , & str ) ; 3 ] = [
238
- ( "Auto" , "" ) ,
239
- ( "Claude Sonnet 3.7" , "CLAUDE_3_7_SONNET_20250219_V1_0" ) ,
240
- ( "Claude Sonnet 3.5" , "CLAUDE_3_5_SONNET_20241022_V2_0" ) ,
237
+ pub const MODEL_OPTIONS : [ ( & str , & str , & str ) ; 3 ] = [
238
+ // ("Auto", ""),
239
+ (
240
+ "Claude Sonnet 3.5" ,
241
+ "claude-3.5-sonnet" ,
242
+ "CLAUDE_3_5_SONNET_20241022_V2_0" ,
243
+ ) ,
244
+ (
245
+ "Claude Sonnet 3.7" ,
246
+ "claude-3.7-sonnet" ,
247
+ "CLAUDE_3_7_SONNET_20250219_V1_0" ,
248
+ ) ,
249
+ ( "Claude Sonnet 4.0" , "claude-4-sonnet" , "CLAUDE_SONNET_4_20250514_V1_0" ) ,
241
250
] ;
242
251
252
+ pub const DEFAULT_MODEL_ID : & str = "CLAUDE_3_7_SONNET_20250219_V1_0" ;
253
+
243
254
const POPULAR_SHORTCUTS : & str = color_print:: cstr! { "<black!><green!>/help</green!> all commands <em>•</em> <green!>ctrl + j</green!> new lines <em>•</em> <green!>ctrl + s</green!> fuzzy search</black!>" } ;
244
255
const SMALL_SCREEN_POPULAR_SHORTCUTS : & str = color_print:: cstr! { "<black!><green!>/help</green!> all commands
245
256
<green!>ctrl + j</green!> new lines
@@ -421,16 +432,10 @@ pub async fn chat(
421
432
422
433
// If modelId is specified, verify it exists before starting the chat
423
434
let model_id: Option < String > = if let Some ( model_name) = model_name {
424
- match MODEL_OPTIONS . iter ( ) . find ( |( name, _) | * name == model_name) {
425
- Some ( ( name, id) ) => {
426
- if * name == "Auto" {
427
- None // Auto maps to None
428
- } else {
429
- Some ( id. to_string ( ) )
430
- }
431
- } ,
435
+ match MODEL_OPTIONS . iter ( ) . find ( |( _, name, _) | * name == model_name) {
436
+ Some ( ( _, _, id) ) => Some ( id. to_string ( ) ) ,
432
437
None => {
433
- let available_names: Vec < & str > = MODEL_OPTIONS . iter ( ) . map ( |( name, _) | * name) . collect ( ) ;
438
+ let available_names: Vec < & str > = MODEL_OPTIONS . iter ( ) . map ( |( _ , name, _) | * name) . collect ( ) ;
434
439
bail ! (
435
440
"Model '{}' does not exist. Available models: {}" ,
436
441
model_name,
@@ -442,6 +447,9 @@ pub async fn chat(
442
447
None
443
448
} ;
444
449
450
+ // if let Some(ref id) = model_id {
451
+ // database.set_last_used_model_id(id.clone())?;
452
+ // }
445
453
let conversation_id = Alphanumeric . sample_string ( & mut rand:: rng ( ) , 9 ) ;
446
454
info ! ( ?conversation_id, "Generated new conversation id" ) ;
447
455
let ( prompt_request_sender, prompt_request_receiver) = std:: sync:: mpsc:: channel :: < Option < String > > ( ) ;
@@ -598,10 +606,16 @@ impl ChatContext {
598
606
let mut existing_conversation = false ;
599
607
let valid_model_id = match model_id {
600
608
Some ( id) => Some ( id) ,
601
- None => match database. get_last_used_model_id ( ) {
602
- Ok ( Some ( id) ) => Some ( id) ,
603
- Ok ( None ) | Err ( _) => database. settings . get_string ( Setting :: UserDefaultModel ) ,
604
- } ,
609
+ None => database
610
+ . settings
611
+ . get_string ( Setting :: ChatDefaultModel )
612
+ . and_then ( |model_name| {
613
+ MODEL_OPTIONS
614
+ . iter ( )
615
+ . find ( |( _, name, _) | * name == model_name)
616
+ . map ( |( _, _, id) | id. to_string ( ) )
617
+ } )
618
+ . or_else ( || Some ( DEFAULT_MODEL_ID . to_string ( ) ) ) ,
605
619
} ;
606
620
let conversation_state = if resume_conversation {
607
621
let prior = std:: env:: current_dir ( )
@@ -3080,7 +3094,7 @@ impl ChatContext {
3080
3094
let active_model_id = self . conversation_state . current_model_id . as_deref ( ) ;
3081
3095
let labels: Vec < String > = MODEL_OPTIONS
3082
3096
. iter ( )
3083
- . map ( |( label, model_id) | {
3097
+ . map ( |( label, _ , model_id) | {
3084
3098
if ( model_id. is_empty ( ) && active_model_id. is_none ( ) ) || Some ( * model_id) == active_model_id {
3085
3099
format ! ( "{} (active)" , label)
3086
3100
} else {
@@ -3090,7 +3104,7 @@ impl ChatContext {
3090
3104
. collect ( ) ;
3091
3105
let default_index = MODEL_OPTIONS
3092
3106
. iter ( )
3093
- . position ( |( _, model_id) | Some ( * model_id) == active_model_id)
3107
+ . position ( |( _, _ , model_id) | Some ( * model_id) == active_model_id)
3094
3108
. unwrap_or ( 0 ) ;
3095
3109
let selection: Option < _ > = match Select :: with_theme ( & crate :: util:: dialoguer_theme ( ) )
3096
3110
. with_prompt ( "Select a model for this chat session" )
@@ -3113,17 +3127,17 @@ impl ChatContext {
3113
3127
queue ! ( self . output, style:: ResetColor ) ?;
3114
3128
3115
3129
if let Some ( index) = selection {
3116
- let ( label, model_id) = MODEL_OPTIONS [ index] ;
3130
+ let ( label, _ , model_id) = MODEL_OPTIONS [ index] ;
3117
3131
let model_id_str = model_id. to_string ( ) ;
3118
3132
3119
3133
if model_id == "" {
3120
3134
self . conversation_state . current_model_id = None ;
3121
3135
telemetry. update_model_id ( None ) ;
3122
- let _ = database. unset_last_used_model_id ( ) ;
3136
+ // let _ = database.unset_last_used_model_id();
3123
3137
} else {
3124
3138
self . conversation_state . current_model_id = Some ( model_id_str. clone ( ) ) ;
3125
3139
telemetry. update_model_id ( Some ( model_id_str. clone ( ) ) ) ;
3126
- let _ = database. set_last_used_model_id ( model_id_str) ;
3140
+ // let _ = database.set_last_used_model_id(model_id_str);
3127
3141
}
3128
3142
3129
3143
queue ! (
0 commit comments