mirror of
https://github.com/openai/codex.git
synced 2026-04-24 22:54:54 +00:00
Add text element metadata to protocol, app server, and core (#9331)
The second part of breaking up PR https://github.com/openai/codex/pull/9116 Summary: - Add `TextElement` / `ByteRange` to protocol user inputs and user message events with defaults. - Thread `text_elements` through app-server v1/v2 request handling and history rebuild. - Preserve UI metadata only in user input/events (not `ContentItem`) while keeping local image attachments in user events for rehydration. Details: - Protocol: `UserInput::Text` carries `text_elements`; `UserMessageEvent` carries `text_elements` + `local_images`. Serialization includes empty vectors for backward compatibility. - app-server-protocol: v1 defines `V1TextElement` / `V1ByteRange` in camelCase with conversions; v2 uses its own camelCase wrapper. - app-server: v1/v2 input mapping includes `text_elements`; thread history rebuilds include them. - Core: user event emission preserves UI metadata while model history stays clean; history replay round-trips the metadata.
This commit is contained in:
@@ -3125,10 +3125,12 @@ impl CodexMessageProcessor {
|
||||
let mapped_items: Vec<CoreInputItem> = items
|
||||
.into_iter()
|
||||
.map(|item| match item {
|
||||
WireInputItem::Text { text } => CoreInputItem::Text {
|
||||
WireInputItem::Text {
|
||||
text,
|
||||
// TODO: Thread text element ranges into v1 input handling.
|
||||
text_elements: Vec::new(),
|
||||
text_elements,
|
||||
} => CoreInputItem::Text {
|
||||
text,
|
||||
text_elements: text_elements.into_iter().map(Into::into).collect(),
|
||||
},
|
||||
WireInputItem::Image { image_url } => CoreInputItem::Image { image_url },
|
||||
WireInputItem::LocalImage { path } => CoreInputItem::LocalImage { path },
|
||||
@@ -3175,10 +3177,12 @@ impl CodexMessageProcessor {
|
||||
let mapped_items: Vec<CoreInputItem> = items
|
||||
.into_iter()
|
||||
.map(|item| match item {
|
||||
WireInputItem::Text { text } => CoreInputItem::Text {
|
||||
WireInputItem::Text {
|
||||
text,
|
||||
// TODO: Thread text element ranges into v1 input handling.
|
||||
text_elements: Vec::new(),
|
||||
text_elements,
|
||||
} => CoreInputItem::Text {
|
||||
text,
|
||||
text_elements: text_elements.into_iter().map(Into::into).collect(),
|
||||
},
|
||||
WireInputItem::Image { image_url } => CoreInputItem::Image { image_url },
|
||||
WireInputItem::LocalImage { path } => CoreInputItem::LocalImage { path },
|
||||
@@ -3341,6 +3345,7 @@ impl CodexMessageProcessor {
|
||||
id: turn_id.clone(),
|
||||
content: vec![V2UserInput::Text {
|
||||
text: display_text.to_string(),
|
||||
// Review prompt display text is synthesized; no UI element ranges to preserve.
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
}]
|
||||
|
||||
Reference in New Issue
Block a user