@@ -38,6 +38,7 @@ use std::time::Duration;
38
38
use std:: {
39
39
env,
40
40
fs,
41
+ io,
41
42
} ;
42
43
43
44
use command:: {
@@ -65,6 +66,10 @@ use crossterm::{
65
66
style,
66
67
terminal,
67
68
} ;
69
+ use dialoguer:: {
70
+ Error as DError ,
71
+ Select ,
72
+ } ;
68
73
use eyre:: {
69
74
ErrReport ,
70
75
Result ,
@@ -223,6 +228,12 @@ const ROTATING_TIPS: [&str; 13] = [
223
228
224
229
const GREETING_BREAK_POINT : usize = 80 ;
225
230
231
+ const MODEL_OPTIONS : [ ( & str , & str ) ; 3 ] = [
232
+ ( "Auto" , "" ) ,
233
+ ( "Claude Sonnet 3.7" , "CLAUDE_3_7_SONNET_20250219_V1_0" ) ,
234
+ ( "Claude Sonnet 3.5" , "CLAUDE_3_5_SONNET_20241022_V2_0" ) ,
235
+ ] ;
236
+
226
237
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!>" } ;
227
238
const SMALL_SCREEN_POPULAR_SHORTCUTS : & str = color_print:: cstr! { "<black!><green!>/help</green!> all commands
228
239
<green!>ctrl + j</green!> new lines
@@ -2999,6 +3010,44 @@ impl ChatContext {
2999
3010
skip_printing_tools : true ,
3000
3011
}
3001
3012
} ,
3013
+ Command :: Model => {
3014
+ queue ! ( self . output, style:: Print ( "\n " ) ) ?;
3015
+ let labels: Vec < & str > = MODEL_OPTIONS . iter ( ) . map ( |( l, _) | * l) . collect ( ) ;
3016
+ let selection: Option < _ > = match Select :: with_theme ( & crate :: util:: dialoguer_theme ( ) )
3017
+ . with_prompt ( "choose your model" )
3018
+ . items ( & labels)
3019
+ . default ( 0 )
3020
+ . interact_on_opt ( & dialoguer:: console:: Term :: stdout ( ) )
3021
+ {
3022
+ Ok ( sel) => sel,
3023
+ // Ctrl‑C -> Err(Interrupted)
3024
+ Err ( DError :: IO ( ref e) ) if e. kind ( ) == io:: ErrorKind :: Interrupted => {
3025
+ queue ! (
3026
+ self . output,
3027
+ style:: Print ( "\n " ) ,
3028
+ style:: Print ( "⚠️ User cancelled selection\n \n " )
3029
+ ) ?;
3030
+ None
3031
+ } ,
3032
+ Err ( e) => return Err ( ChatError :: Custom ( format ! ( "Failed to choose model: {e}" ) . into ( ) ) ) ,
3033
+ } ;
3034
+
3035
+ if let Some ( index) = selection {
3036
+ let ( label, model_opt) = MODEL_OPTIONS [ index] ;
3037
+
3038
+ use crossterm:: {
3039
+ queue,
3040
+ style,
3041
+ } ;
3042
+ queue ! ( self . output, style:: Print ( format!( "\n ✅ change to : {}\n \n " , label) ) ) ?;
3043
+ }
3044
+
3045
+ ChatState :: PromptUser {
3046
+ tool_uses : None ,
3047
+ pending_tool_index : None ,
3048
+ skip_printing_tools : false ,
3049
+ }
3050
+ } ,
3002
3051
} )
3003
3052
}
3004
3053
0 commit comments