@@ -35,7 +35,7 @@ const DEBUG_COMMANDS_CONTINUE: &[&str] = &["n", "f", "c", "cont", "Q"];
3535static R_INIT : once_cell:: sync:: OnceCell < ( ) > = once_cell:: sync:: OnceCell :: new ( ) ;
3636
3737/// An enum representing the different modes in which the R session can run.
38- #[ derive( PartialEq , Clone , Copy ) ]
38+ #[ derive( Debug , PartialEq , Clone , Copy ) ]
3939pub enum SessionMode {
4040 /// A session with an interactive console (REPL), such as in Positron.
4141 Console ,
@@ -192,6 +192,7 @@ pub(crate) struct KernelInfo {
192192 pub ( crate ) banner : String ,
193193 pub ( crate ) input_prompt : Option < String > ,
194194 pub ( crate ) continuation_prompt : Option < String > ,
195+ pub ( crate ) session_mode : SessionMode ,
195196}
196197
197198/// The kind of prompt we're handling in the REPL.
@@ -485,7 +486,7 @@ impl Console {
485486 log:: info!(
486487 "R has started and ark handlers have been registered, completing initialization."
487488 ) ;
488- Self :: complete_initialization ( console. banner . take ( ) , kernel_init_tx) ;
489+ Self :: complete_initialization ( console. banner . take ( ) , console . session_mode , kernel_init_tx) ;
489490
490491 // Spawn handler loop for async messages from other components (e.g., LSP).
491492 // Note that we do it after init is complete to avoid deadlocking
@@ -576,7 +577,11 @@ impl Console {
576577 /// # Safety
577578 ///
578579 /// Can only be called from the R thread, and only once.
579- fn complete_initialization ( banner : Option < String > , mut kernel_init_tx : Bus < KernelInfo > ) {
580+ fn complete_initialization (
581+ banner : Option < String > ,
582+ session_mode : SessionMode ,
583+ mut kernel_init_tx : Bus < KernelInfo > ,
584+ ) {
580585 let version = unsafe {
581586 let version = Rf_findVarInFrame ( R_BaseNamespace , r_symbol ! ( "R.version.string" ) ) ;
582587 RObject :: new ( version) . to :: < String > ( ) . unwrap ( )
@@ -591,6 +596,7 @@ impl Console {
591596 banner : banner. unwrap_or_default ( ) ,
592597 input_prompt : Some ( input_prompt) ,
593598 continuation_prompt : Some ( continuation_prompt) ,
599+ session_mode,
594600 } ;
595601
596602 // Set `R_INIT` before broadcasting so that threads unblocked by the
0 commit comments