mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
patch-tools
This commit is contained in:
@@ -586,14 +586,7 @@ impl Session {
|
||||
self.record_conversation_items_internal(&responses, false).await;
|
||||
}
|
||||
|
||||
let mut msgs = Vec::new();
|
||||
for event in items.as_slice().get_events() {
|
||||
match event.msg {
|
||||
EventMsg::UserMessage(_) | EventMsg::AgentMessage(_) => msgs.push(event.msg),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
msgs
|
||||
items.as_slice().get_events()
|
||||
}
|
||||
|
||||
/// Sends the given event to the client and records it to the rollout (if enabled).
|
||||
|
||||
@@ -47,7 +47,7 @@ impl InitialHistory {
|
||||
}
|
||||
|
||||
/// Return all events contained in this initial history.
|
||||
pub fn get_events(&self) -> Vec<crate::protocol::Event> {
|
||||
pub fn get_events(&self) -> Vec<crate::protocol::EventMsg> {
|
||||
match self {
|
||||
InitialHistory::New => Vec::new(),
|
||||
InitialHistory::Resumed(items) => items.as_slice().get_events(),
|
||||
|
||||
@@ -8,6 +8,7 @@ use std::path::PathBuf;
|
||||
|
||||
use codex_protocol::mcp_protocol::ConversationId;
|
||||
use codex_protocol::protocol::Event;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use time::OffsetDateTime;
|
||||
@@ -133,7 +134,7 @@ impl From<Event> for RolloutItem {
|
||||
/// Convenience helpers to extract typed items from a list of rollout items.
|
||||
pub trait RolloutItemSliceExt {
|
||||
fn get_response_items(&self) -> Vec<ResponseItem>;
|
||||
fn get_events(&self) -> Vec<Event>;
|
||||
fn get_events(&self) -> Vec<EventMsg>;
|
||||
}
|
||||
|
||||
impl RolloutItemSliceExt for [RolloutItem] {
|
||||
@@ -146,10 +147,10 @@ impl RolloutItemSliceExt for [RolloutItem] {
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn get_events(&self) -> Vec<Event> {
|
||||
fn get_events(&self) -> Vec<EventMsg> {
|
||||
self.iter()
|
||||
.filter_map(|it| match it {
|
||||
RolloutItem::Event(ev) => Some(ev.clone()),
|
||||
RolloutItem::Event(ev) => Some(ev.msg.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
|
||||
@@ -100,19 +100,6 @@ async fn fork_conversation_twice_drops_to_first_message() {
|
||||
}
|
||||
out
|
||||
}
|
||||
async fn read_response_entries_with_retry(
|
||||
path: &std::path::Path,
|
||||
min_len: usize,
|
||||
) -> Vec<ResponseItem> {
|
||||
for _ in 0..50u32 {
|
||||
let entries = read_response_entries(path).await;
|
||||
if entries.len() >= min_len {
|
||||
return entries;
|
||||
}
|
||||
tokio::time::sleep(tokio::time::Duration::from_millis(10)).await;
|
||||
}
|
||||
read_response_entries(path).await
|
||||
}
|
||||
let entries_after_three: Vec<ResponseItem> = read_response_entries(&base_path).await;
|
||||
// History layout for this test:
|
||||
// [0] user instructions,
|
||||
@@ -160,8 +147,7 @@ async fn fork_conversation_twice_drops_to_first_message() {
|
||||
}) => (*conversation_id, path.clone()),
|
||||
_ => panic!("expected ConversationHistory event after first fork"),
|
||||
};
|
||||
let entries_after_first_fork: Vec<ResponseItem> =
|
||||
read_response_entries_with_retry(&fork1_path, expected_after_first.len()).await;
|
||||
let entries_after_first_fork: Vec<ResponseItem> = read_response_entries(&fork1_path).await;
|
||||
assert_eq!(entries_after_first_fork, expected_after_first);
|
||||
|
||||
// Fork again with n=1 → drops the (new) last user message, leaving only the first.
|
||||
@@ -185,7 +171,6 @@ async fn fork_conversation_twice_drops_to_first_message() {
|
||||
}) => (*conversation_id, path.clone()),
|
||||
_ => panic!("expected ConversationHistory event after second fork"),
|
||||
};
|
||||
let entries_after_second_fork: Vec<ResponseItem> =
|
||||
read_response_entries_with_retry(&fork2_path, expected_after_second.len()).await;
|
||||
let entries_after_second_fork: Vec<ResponseItem> = read_response_entries(&fork2_path).await;
|
||||
assert_eq!(entries_after_second_fork, expected_after_second);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user