Skip to content

Conversation

@charley-oai
Copy link
Collaborator

@charley-oai charley-oai commented Jan 15, 2026

The second part of breaking up PR #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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the protocol, app-server, and core to support text element metadata (UI-defined spans with placeholders) in user inputs and message events, enabling rich text features while keeping model history clean.

Changes:

  • Added TextElement and ByteRange structures to protocol user inputs and events with backward-compatible defaults
  • Threaded text_elements through app-server v1/v2 request handling and history rebuild logic
  • Modified core to preserve UI metadata in user events while excluding it from model history

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
codex-rs/protocol/src/items.rs Added methods to extract and rebase text elements and local image paths from UserMessageItem
codex-rs/core/src/codex.rs Split user message recording to preserve text_elements in emitted events while keeping model history clean
codex-rs/app-server/tests/suite/*.rs Updated test cases to include empty text_elements vectors in InputItem::Text
codex-rs/app-server/src/codex_message_processor.rs Updated input mapping to thread text_elements through v1/v2 request handling
codex-rs/app-server-test-client/src/main.rs Added empty text_elements to test client InputItem::Text
codex-rs/app-server-protocol/src/protocol/v2.rs Added From implementations for ByteRange and TextElement conversions
codex-rs/app-server-protocol/src/protocol/v1.rs Defined V1TextElement and V1ByteRange with camelCase serialization and conversions
codex-rs/app-server-protocol/src/protocol/thread_history.rs Updated history builder to preserve text_elements and local_images from events

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@aibrahim-oai aibrahim-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clean! Let's add integration tests testing that we send turn item and event msgs and also we keep them on resume.

Copy link
Collaborator

@aibrahim-oai aibrahim-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I'd also add tests in app-server

@charley-oai charley-oai merged commit 1fa8350 into main Jan 16, 2026
32 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2026
@charley-oai charley-oai deleted the text-elements-core branch January 16, 2026 01:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants