Cover remote code mode runtime behavior

This commit is contained in:
Channing Conger
2026-06-25 01:04:11 +00:00
parent 1886ad6344
commit 4cb5caac10
7 changed files with 558 additions and 25 deletions
+15 -5
View File
@@ -146,8 +146,12 @@ pub struct ProcessOwnedCodeModeSession {
impl ProcessOwnedCodeModeSession {
pub fn new() -> Self {
Self::with_delegate(Arc::new(NoopCodeModeSessionDelegate))
}
pub fn with_delegate(delegate: Arc<dyn CodeModeSessionDelegate>) -> Self {
Self::with_process_host(
Arc::new(NoopCodeModeSessionDelegate),
delegate,
Arc::new(OwnedProcessHost::new(default_host_program())),
)
}
@@ -192,13 +196,19 @@ impl ProcessOwnedCodeModeSession {
}
fn current_connection(&self) -> Result<Option<Arc<Connection>>, String> {
match &*self
let mut state = self
.state
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner)
{
.unwrap_or_else(std::sync::PoisonError::into_inner);
match &*state {
SessionState::New => Ok(None),
SessionState::Open(connection) => Ok(Some(Arc::clone(connection))),
SessionState::Open(connection) if connection.is_alive() => {
Ok(Some(Arc::clone(connection)))
}
SessionState::Open(_) => {
*state = SessionState::New;
Ok(None)
}
SessionState::Shutdown => Err("code mode session is shutting down".to_string()),
}
}