Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions codex-rs/protocol/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,13 @@ pub struct ContextCompactionItem {
pub id: String,
}

fn new_item_id() -> String {
uuid::Uuid::now_v7().to_string()
}

impl ContextCompactionItem {
pub fn new() -> Self {
Self {
id: uuid::Uuid::new_v4().to_string(),
}
Self { id: new_item_id() }
}
}

Expand All @@ -395,7 +397,7 @@ impl Default for ContextCompactionItem {
impl UserMessageItem {
pub fn new(content: &[UserInput]) -> Self {
Self {
id: uuid::Uuid::new_v4().to_string(),
id: new_item_id(),
client_id: None,
content: content.to_vec(),
}
Expand Down Expand Up @@ -497,9 +499,7 @@ fn trim_trailing_default_image_details(
impl HookPromptItem {
pub fn from_fragments(id: Option<&String>, fragments: Vec<HookPromptFragment>) -> Self {
Self {
id: id
.cloned()
.unwrap_or_else(|| uuid::Uuid::new_v4().to_string()),
id: id.cloned().unwrap_or_else(new_item_id),
fragments,
}
}
Expand Down Expand Up @@ -529,7 +529,7 @@ pub fn build_hook_prompt_message(fragments: &[HookPromptFragment]) -> Option<Res
}

Some(ResponseItem::Message {
id: Some(uuid::Uuid::new_v4().to_string()),
id: Some(new_item_id()),
role: "user".to_string(),
content,
phase: None,
Expand Down Expand Up @@ -582,7 +582,7 @@ fn serialize_hook_prompt_fragment(text: &str, hook_run_id: &str) -> Option<Strin
impl AgentMessageItem {
pub fn new(content: &[AgentMessageContent]) -> Self {
Self {
id: uuid::Uuid::new_v4().to_string(),
id: new_item_id(),
content: content.to_vec(),
phase: None,
memory_citation: None,
Expand Down
Loading