mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
Render bidirectional text in full-screen transcripts (#63845)
## Why The terminal's bidirectional layout was already used for scrollback, but full-screen transcripts could still show mixed right-to-left and left-to-right text in source order. ## What changed Use the terminal's bidirectional layout setting in the live transcript, history pager, and resume picker previews. Reorder each wrapped row for display and map its screen columns back to the source graphemes. This keeps hyperlink hit targets and search highlights aligned with the displayed text. Mouse selection follows the displayed glyphs, while copying preserves source order. ## Testing Add regression coverage for mixed Arabic, Hebrew, and Latin text across terminal widths, including link hit targets, highlights, and logical text order. Exercise mouse and keyboard selection and verify right-to-left rendering in the resume picker preview. GitOrigin-RevId: ea0518ea8791d0fcc031dd0ebf306775918f373b
This commit is contained in:
@@ -26,6 +26,7 @@ mod text;
|
||||
mod turn_details;
|
||||
mod turn_tip;
|
||||
|
||||
use crate::terminal_hyperlinks::bidi;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::chatwidget::ActiveCellTranscriptKey;
|
||||
@@ -95,6 +96,7 @@ struct VisibleRow {
|
||||
/// Shared scrolling and interaction state for compact and detailed transcript presentations.
|
||||
pub(crate) struct TranscriptView {
|
||||
pub(crate) image_protocol: Option<crate::pets::ImageProtocol>,
|
||||
pub(crate) bidi_layout: bool,
|
||||
pub(crate) agent_links: Option<crate::backend_id::BackendId>,
|
||||
pub(crate) document_links: bool,
|
||||
pub(crate) mouse_scroll_speed: f64,
|
||||
@@ -140,6 +142,7 @@ impl Default for TranscriptView {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
image_protocol: None,
|
||||
bidi_layout: false,
|
||||
agent_links: None,
|
||||
document_links: false,
|
||||
mouse_scroll_speed: 1.0,
|
||||
@@ -523,8 +526,10 @@ impl TranscriptView {
|
||||
if self.detailed {
|
||||
self.sync_live_tail(width, /*key*/ None, lines);
|
||||
} else if let Some(row) = summary {
|
||||
let bidi_layout = self.bidi_layout;
|
||||
self.sync_live_layout(width, /*key*/ None, |width| {
|
||||
Some(row.layout(width, expanded, auxiliary.to_vec()))
|
||||
let lines = bidi::session_lines(auxiliary.to_vec(), bidi_layout);
|
||||
Some(row.layout(width, expanded, lines))
|
||||
});
|
||||
} else {
|
||||
self.sync_live_activity_tail(width, /*key*/ None, expanded && disclose, |width| {
|
||||
@@ -569,8 +574,10 @@ impl TranscriptView {
|
||||
key: Option<ActiveCellTranscriptKey>,
|
||||
lines: impl FnOnce(u16) -> Option<Vec<HyperlinkLine>>,
|
||||
) -> bool {
|
||||
let bidi_layout = self.bidi_layout;
|
||||
self.sync_live_layout(width, key, |width| {
|
||||
lines(width).map(|lines| TextLayout::new(lines, width))
|
||||
lines(width)
|
||||
.map(|lines| TextLayout::new(bidi::session_lines(lines, bidi_layout), width))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -585,8 +592,10 @@ impl TranscriptView {
|
||||
.disclosure
|
||||
.keymap
|
||||
.primary_hint(crate::keymap::KeymapContext::Global, "open_transcript");
|
||||
let bidi_layout = self.bidi_layout;
|
||||
self.sync_live_layout(width, key, |width| {
|
||||
lines(width).map(|lines| layout::activity_layout(lines, width, expanded, shortcut))
|
||||
lines(width)
|
||||
.map(|lines| layout::activity_layout(lines, width, expanded, bidi_layout, shortcut))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user