mirror of
https://github.com/openai/codex.git
synced 2026-11-29 00:00:54 +00:00
Cover remote code mode runtime behavior
This commit is contained in:
@@ -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()),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user