mirror of
https://github.com/openai/codex.git
synced 2026-11-30 00:10:49 +00:00
## What changed - Add `EnvironmentManager::from_accepted_websocket` so embedding hosts can construct a remote environment from an already accepted and authenticated Axum WebSocket. - Add `replace_accepted_websocket` to retire the current transport and resume the same exec-server session on a host-supplied replacement connection. - Serialize replacement handoffs, reject overlapping replacements, and release the handoff claim when a replacement attempt is cancelled or fails. ## Testing - Cover initial connection validation and immediate environment readiness. - Verify replacement retry behavior and recovery of a running process and its output after reconnecting. GitOrigin-RevId: 1f2ab7bcf7b5abbbece5c101801432dc84a8058d
35 lines
1.1 KiB
Rust
35 lines
1.1 KiB
Rust
use tokio::sync::oneshot;
|
|
|
|
use super::AcceptedConnectionSource;
|
|
use crate::ExecServerClientConnectOptions;
|
|
|
|
#[tokio::test]
|
|
async fn replacement_claim_is_released_when_handoff_is_cancelled() {
|
|
let source = AcceptedConnectionSource::new(ExecServerClientConnectOptions::default());
|
|
let (claimed_tx, claimed_rx) = oneshot::channel();
|
|
let (_release_tx, release_rx) = oneshot::channel::<()>();
|
|
|
|
let handoff = tokio::spawn({
|
|
let source = source.clone();
|
|
async move {
|
|
let _submission = source
|
|
.begin_replacement()
|
|
.expect("the first replacement should claim the handoff");
|
|
claimed_tx
|
|
.send(())
|
|
.expect("the test should wait for the claim");
|
|
let _ = release_rx.await;
|
|
}
|
|
});
|
|
|
|
claimed_rx.await.expect("the handoff should be claimed");
|
|
assert!(source.begin_replacement().is_err());
|
|
|
|
handoff.abort();
|
|
let _ = handoff.await;
|
|
|
|
source
|
|
.begin_replacement()
|
|
.expect("a new replacement should be accepted after cancellation");
|
|
}
|