mirror of
https://github.com/openai/codex.git
synced 2026-05-01 09:56:37 +00:00
fix more leaks
This commit is contained in:
@@ -747,7 +747,12 @@ async fn turn_start_accepts_local_image_input() -> Result<()> {
|
|||||||
let TurnStartResponse { turn } = to_response::<TurnStartResponse>(turn_resp)?;
|
let TurnStartResponse { turn } = to_response::<TurnStartResponse>(turn_resp)?;
|
||||||
assert!(!turn.id.is_empty());
|
assert!(!turn.id.is_empty());
|
||||||
|
|
||||||
// This test only validates that turn/start responds and returns a turn.
|
timeout(
|
||||||
|
DEFAULT_READ_TIMEOUT,
|
||||||
|
mcp.read_stream_until_notification_message("turn/completed"),
|
||||||
|
)
|
||||||
|
.await??;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ use codex_app_server_protocol::ThreadItem;
|
|||||||
use codex_app_server_protocol::ThreadStartParams;
|
use codex_app_server_protocol::ThreadStartParams;
|
||||||
use codex_app_server_protocol::ThreadStartResponse;
|
use codex_app_server_protocol::ThreadStartResponse;
|
||||||
use codex_app_server_protocol::TurnCompletedNotification;
|
use codex_app_server_protocol::TurnCompletedNotification;
|
||||||
|
use codex_app_server_protocol::TurnInterruptParams;
|
||||||
|
use codex_app_server_protocol::TurnInterruptResponse;
|
||||||
use codex_app_server_protocol::TurnStartParams;
|
use codex_app_server_protocol::TurnStartParams;
|
||||||
|
use codex_app_server_protocol::TurnStartResponse;
|
||||||
use codex_app_server_protocol::TurnStatus;
|
use codex_app_server_protocol::TurnStatus;
|
||||||
use codex_app_server_protocol::UserInput as V2UserInput;
|
use codex_app_server_protocol::UserInput as V2UserInput;
|
||||||
use codex_core::features::FEATURES;
|
use codex_core::features::FEATURES;
|
||||||
@@ -100,7 +103,7 @@ async fn turn_start_shell_zsh_fork_executes_command_v2() -> Result<()> {
|
|||||||
|
|
||||||
let turn_id = mcp
|
let turn_id = mcp
|
||||||
.send_turn_start_request(TurnStartParams {
|
.send_turn_start_request(TurnStartParams {
|
||||||
thread_id: thread.id,
|
thread_id: thread.id.clone(),
|
||||||
input: vec![V2UserInput::Text {
|
input: vec![V2UserInput::Text {
|
||||||
text: "run echo hi".to_string(),
|
text: "run echo hi".to_string(),
|
||||||
text_elements: Vec::new(),
|
text_elements: Vec::new(),
|
||||||
@@ -114,11 +117,12 @@ async fn turn_start_shell_zsh_fork_executes_command_v2() -> Result<()> {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
timeout(
|
let turn_resp: JSONRPCResponse = timeout(
|
||||||
DEFAULT_READ_TIMEOUT,
|
DEFAULT_READ_TIMEOUT,
|
||||||
mcp.read_stream_until_response_message(RequestId::Integer(turn_id)),
|
mcp.read_stream_until_response_message(RequestId::Integer(turn_id)),
|
||||||
)
|
)
|
||||||
.await??;
|
.await??;
|
||||||
|
let TurnStartResponse { turn } = to_response::<TurnStartResponse>(turn_resp)?;
|
||||||
|
|
||||||
let started_command_execution = timeout(DEFAULT_READ_TIMEOUT, async {
|
let started_command_execution = timeout(DEFAULT_READ_TIMEOUT, async {
|
||||||
loop {
|
loop {
|
||||||
@@ -149,6 +153,25 @@ async fn turn_start_shell_zsh_fork_executes_command_v2() -> Result<()> {
|
|||||||
assert!(command.contains(" -lc 'echo hi'"));
|
assert!(command.contains(" -lc 'echo hi'"));
|
||||||
assert_eq!(cwd, workspace);
|
assert_eq!(cwd, workspace);
|
||||||
|
|
||||||
|
let turn_interrupt_request_id = mcp
|
||||||
|
.send_turn_interrupt_request(TurnInterruptParams {
|
||||||
|
thread_id: thread.id,
|
||||||
|
turn_id: turn.id,
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
let _: TurnInterruptResponse = to_response(
|
||||||
|
timeout(
|
||||||
|
DEFAULT_READ_TIMEOUT,
|
||||||
|
mcp.read_stream_until_response_message(RequestId::Integer(turn_interrupt_request_id)),
|
||||||
|
)
|
||||||
|
.await??,
|
||||||
|
)?;
|
||||||
|
timeout(
|
||||||
|
DEFAULT_READ_TIMEOUT,
|
||||||
|
mcp.read_stream_until_notification_message("codex/event/turn_aborted"),
|
||||||
|
)
|
||||||
|
.await??;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,11 +527,12 @@ async fn turn_start_shell_zsh_fork_subcommand_decline_marks_parent_declined_v2()
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
timeout(
|
let turn_resp: JSONRPCResponse = timeout(
|
||||||
DEFAULT_READ_TIMEOUT,
|
DEFAULT_READ_TIMEOUT,
|
||||||
mcp.read_stream_until_response_message(RequestId::Integer(turn_id)),
|
mcp.read_stream_until_response_message(RequestId::Integer(turn_id)),
|
||||||
)
|
)
|
||||||
.await??;
|
.await??;
|
||||||
|
let TurnStartResponse { turn } = to_response::<TurnStartResponse>(turn_resp)?;
|
||||||
|
|
||||||
let mut approval_ids = Vec::new();
|
let mut approval_ids = Vec::new();
|
||||||
for decision in [
|
for decision in [
|
||||||
@@ -577,6 +601,25 @@ async fn turn_start_shell_zsh_fork_subcommand_decline_marks_parent_declined_v2()
|
|||||||
assert_eq!(approval_ids.len(), 2);
|
assert_eq!(approval_ids.len(), 2);
|
||||||
assert_ne!(approval_ids[0], approval_ids[1]);
|
assert_ne!(approval_ids[0], approval_ids[1]);
|
||||||
|
|
||||||
|
let turn_interrupt_request_id = mcp
|
||||||
|
.send_turn_interrupt_request(TurnInterruptParams {
|
||||||
|
thread_id: thread.id,
|
||||||
|
turn_id: turn.id,
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
let _: TurnInterruptResponse = to_response(
|
||||||
|
timeout(
|
||||||
|
DEFAULT_READ_TIMEOUT,
|
||||||
|
mcp.read_stream_until_response_message(RequestId::Integer(turn_interrupt_request_id)),
|
||||||
|
)
|
||||||
|
.await??,
|
||||||
|
)?;
|
||||||
|
timeout(
|
||||||
|
DEFAULT_READ_TIMEOUT,
|
||||||
|
mcp.read_stream_until_notification_message("codex/event/turn_aborted"),
|
||||||
|
)
|
||||||
|
.await??;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ use codex_app_server_protocol::JSONRPCResponse;
|
|||||||
use codex_app_server_protocol::RequestId;
|
use codex_app_server_protocol::RequestId;
|
||||||
use codex_app_server_protocol::ThreadStartParams;
|
use codex_app_server_protocol::ThreadStartParams;
|
||||||
use codex_app_server_protocol::ThreadStartResponse;
|
use codex_app_server_protocol::ThreadStartResponse;
|
||||||
|
use codex_app_server_protocol::TurnInterruptParams;
|
||||||
|
use codex_app_server_protocol::TurnInterruptResponse;
|
||||||
use codex_app_server_protocol::TurnStartParams;
|
use codex_app_server_protocol::TurnStartParams;
|
||||||
use codex_app_server_protocol::TurnStartResponse;
|
use codex_app_server_protocol::TurnStartResponse;
|
||||||
use codex_app_server_protocol::TurnSteerParams;
|
use codex_app_server_protocol::TurnSteerParams;
|
||||||
@@ -136,7 +138,7 @@ async fn turn_steer_returns_active_turn_id() -> Result<()> {
|
|||||||
|
|
||||||
let steer_req = mcp
|
let steer_req = mcp
|
||||||
.send_turn_steer_request(TurnSteerParams {
|
.send_turn_steer_request(TurnSteerParams {
|
||||||
thread_id: thread.id,
|
thread_id: thread.id.clone(),
|
||||||
input: vec![V2UserInput::Text {
|
input: vec![V2UserInput::Text {
|
||||||
text: "steer".to_string(),
|
text: "steer".to_string(),
|
||||||
text_elements: Vec::new(),
|
text_elements: Vec::new(),
|
||||||
@@ -152,6 +154,25 @@ async fn turn_steer_returns_active_turn_id() -> Result<()> {
|
|||||||
let steer: TurnSteerResponse = to_response::<TurnSteerResponse>(steer_resp)?;
|
let steer: TurnSteerResponse = to_response::<TurnSteerResponse>(steer_resp)?;
|
||||||
assert_eq!(steer.turn_id, turn.id);
|
assert_eq!(steer.turn_id, turn.id);
|
||||||
|
|
||||||
|
let interrupt_req = mcp
|
||||||
|
.send_turn_interrupt_request(TurnInterruptParams {
|
||||||
|
thread_id: thread.id,
|
||||||
|
turn_id: steer.turn_id,
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
let _: TurnInterruptResponse = to_response::<TurnInterruptResponse>(
|
||||||
|
timeout(
|
||||||
|
DEFAULT_READ_TIMEOUT,
|
||||||
|
mcp.read_stream_until_response_message(RequestId::Integer(interrupt_req)),
|
||||||
|
)
|
||||||
|
.await??,
|
||||||
|
)?;
|
||||||
|
timeout(
|
||||||
|
DEFAULT_READ_TIMEOUT,
|
||||||
|
mcp.read_stream_until_notification_message("codex/event/turn_aborted"),
|
||||||
|
)
|
||||||
|
.await??;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user