mirror of
https://github.com/openai/codex.git
synced 2026-05-01 03:42:05 +03:00
Add total (non-partial) TextElement placeholder accessors (#9545)
## Summary - Make `TextElement` placeholders private and add a text-backed accessor to avoid assuming `Some`. - Since they are optional in the protocol, we want to make sure any accessors properly handle the None case (getting the placeholder using the byte range in the text) - Preserve placeholders during protocol/app-server conversions using the accessor fallback. - Update TUI composer/remap logic and tests to use the new constructor/accessor.
This commit is contained in:
@@ -97,13 +97,14 @@ impl UserMessageItem {
|
||||
// Text element ranges are relative to each text chunk; offset them so they align
|
||||
// with the concatenated message returned by `message()`.
|
||||
for elem in text_elements {
|
||||
out.push(TextElement {
|
||||
byte_range: ByteRange {
|
||||
start: offset + elem.byte_range.start,
|
||||
end: offset + elem.byte_range.end,
|
||||
},
|
||||
placeholder: elem.placeholder.clone(),
|
||||
});
|
||||
let byte_range = ByteRange {
|
||||
start: offset + elem.byte_range.start,
|
||||
end: offset + elem.byte_range.end,
|
||||
};
|
||||
out.push(TextElement::new(
|
||||
byte_range,
|
||||
elem.placeholder(text).map(str::to_string),
|
||||
));
|
||||
}
|
||||
offset += text.len();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user