Files
codex/codex-rs/tui/src/turn_tip.rs
T
Eric Traut 41fd60f561 Allow selecting and copying TUI turn tips (#53152)
## Why

Turn tips are visible outside transcript history, but their text could not be selected for copying.

## What changed

Register rendered working and completion tip rows for mouse selection. Keep tips in place when selection hints or copy status appear, and use the hint “Selecting text · esc cancel”.

## Testing

Extend mouse-selection tests and snapshots to cover selecting `/help` in working and completion tips with copy-on-select enabled, and clearing the selection when a working tip disappears.

GitOrigin-RevId: 25b3f02e7e93a53e777de455943d47fbab388ff1
2026-10-11 15:50:16 +00:00

34 lines
1.1 KiB
Rust

//! One expendable tip row shared by working status and completed-response presentation.
//! Drawing records exposure; measuring or clipping the row does not.
use std::cell::Cell;
use ratatui::buffer::Buffer;
use ratatui::layout::Rect;
use ratatui::style::Style;
use ratatui::widgets::Widget;
use crate::render::renderable::Renderable;
use crate::terminal_hyperlinks::HyperlinkLine;
use crate::terminal_hyperlinks::HyperlinkParagraph;
pub(crate) struct TurnTip {
pub(crate) line: HyperlinkLine,
pub(crate) rendered: Cell<Option<Rect>>,
}
impl Renderable for TurnTip {
fn render(&self, area: Rect, buf: &mut Buffer) {
if !area.is_empty() && self.line.width() <= usize::from(area.width) {
let area = Rect { height: 1, ..area }.intersection(buf.area);
HyperlinkParagraph::new(std::slice::from_ref(&self.line), Style::default())
.render(area, buf);
self.rendered.set(Some(area));
}
}
fn desired_height(&self, width: u16) -> u16 {
u16::from(self.line.width() <= usize::from(width))
}
}