@@ -20,7 +20,6 @@ mod translate;
2020mod uninstall;
2121mod update;
2222mod user;
23-
2423use std:: io:: {
2524 Write as _,
2625 stdout,
@@ -87,7 +86,7 @@ use crate::util::desktop::{
8786} ;
8887use crate :: util:: {
8988 CliContext ,
90- assert_logged_in ,
89+ is_logged_in_check ,
9190} ;
9291
9392#[ derive( Debug , Clone , Copy , Default , PartialEq , Eq , ValueEnum ) ]
@@ -375,30 +374,23 @@ impl Cli {
375374
376375 Self :: execute_chat ( "chat" , Some ( args) , true ) . await
377376 } ,
378- CliRootCommands :: Mcp { args } => {
379- if args. iter ( ) . any ( |arg| [ "--help" , "-h" ] . contains ( & arg. as_str ( ) ) ) {
380- return Self :: execute_chat ( "mcp" , Some ( args) , false ) . await ;
381- }
382-
383- Self :: execute_chat ( "mcp" , Some ( args) , true ) . await
384- } ,
377+ CliRootCommands :: Mcp { args } => Self :: execute_chat ( "mcp" , Some ( args) , false ) . await ,
385378 CliRootCommands :: Inline ( subcommand) => subcommand. execute ( & cli_context) . await ,
386- CliRootCommands :: Agent { args } => {
387- if args. iter ( ) . any ( |arg| [ "--help" , "-h" ] . contains ( & arg. as_str ( ) ) ) {
388- return Self :: execute_chat ( "agent" , Some ( args) , false ) . await ;
389- }
390-
391- Self :: execute_chat ( "agent" , Some ( args) , true ) . await
392- } ,
379+ CliRootCommands :: Agent { args } => Self :: execute_chat ( "agent" , Some ( args) , false ) . await ,
393380 } ,
394381 // Root command
395382 None => Self :: execute_chat ( "chat" , None , true ) . await ,
396383 }
397384 }
398385
399386 pub async fn execute_chat ( subcmd : & str , args : Option < Vec < String > > , enforce_login : bool ) -> Result < ExitCode > {
400- if enforce_login {
401- assert_logged_in ( ) . await ?;
387+ if enforce_login && !is_logged_in_check ( ) . await {
388+ let options = [ "Yes" , "No" ] ;
389+ match crate :: util:: choose ( " You are not logged in. Login now?" , & options) ? {
390+ Some ( 0 ) => { } ,
391+ _ => bail ! ( "Login is required to use chat" ) ,
392+ }
393+ crate :: cli:: user:: login_interactive ( Default :: default ( ) ) . await ?;
402394 }
403395
404396 // Save credentials from the macOS keychain to sqlite.
0 commit comments