mirror of
https://github.com/openai/codex.git
synced 2026-11-26 23:40:43 +00:00
Highlight clickable links and controls on hover in the fullscreen TUI (#62390)
## Why The pointer shape can signal that transcript links are clickable, but the text itself does not change on hover. A foreground change makes the clickable region visible. ## What changed Change the foreground color of hovered transcript and status-line links, transcript disclosure controls, and the warning notice. Use the rendered link spans so the highlight follows the visible text, including wide characters. Recompute the highlight on redraw so it follows the content under a stationary pointer as the transcript scrolls or updates. ## Testing Add a mouse-motion regression test that checks highlight and restore behavior for transcript links, including wide characters and Markdown table links, as well as status-line links, disclosure controls, and the warning notice. The test also checks that a URL in the editable draft keeps its original styling. GitOrigin-RevId: 4c7da58705e2ad4c710ec6c55727d5a064f3cf1f
This commit is contained in:
@@ -180,28 +180,41 @@ impl TranscriptView {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn disclosure_hover_area(&self, point: ratatui::layout::Position) -> Option<Rect> {
|
||||
self.disclosure_at(point).map(|(_, area)| area)
|
||||
}
|
||||
|
||||
fn disclosure_at(&self, point: ratatui::layout::Position) -> Option<(&VisibleRow, Rect)> {
|
||||
if self.is_select_mode()
|
||||
|| self.detailed
|
||||
|| self.mode != HistoryRenderMode::Rich
|
||||
|| !self.area.contains(point)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let visible = self.visible.get(usize::from(point.y - self.area.y))?;
|
||||
if visible.layout.disclosure_row() != Some(visible.row) {
|
||||
return None;
|
||||
}
|
||||
let columns = visible.layout.disclosure_columns();
|
||||
let area = Rect::new(
|
||||
self.area.x + columns.start,
|
||||
point.y,
|
||||
columns.end - columns.start,
|
||||
/*height*/ 1,
|
||||
);
|
||||
area.contains(point).then_some((visible, area))
|
||||
}
|
||||
|
||||
pub(super) fn toggle_disclosure_at(
|
||||
&mut self,
|
||||
cells: &[Arc<dyn HistoryCell>],
|
||||
column: u16,
|
||||
row: u16,
|
||||
) -> bool {
|
||||
if self.detailed || self.mode != HistoryRenderMode::Rich {
|
||||
return false;
|
||||
}
|
||||
let Some(visible) = row
|
||||
.checked_sub(self.area.y)
|
||||
.and_then(|row| self.visible.get(usize::from(row)))
|
||||
else {
|
||||
let Some((visible, _)) = self.disclosure_at((column, row).into()) else {
|
||||
return false;
|
||||
};
|
||||
if visible.layout.disclosure_row() != Some(visible.row)
|
||||
|| column
|
||||
.checked_sub(self.area.x)
|
||||
.is_none_or(|column| !visible.layout.disclosure_columns().contains(&column))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
let Some(index) = self.canonical_activity_index(cells, &visible.activity_ids) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -608,10 +608,7 @@ impl TranscriptView {
|
||||
mode: MouseMode<'_>,
|
||||
) -> Option<ViewAction> {
|
||||
let was_following = self.is_following();
|
||||
if !self.is_select_mode()
|
||||
&& event.modifiers.is_empty()
|
||||
&& self.toggle_disclosure_at(cells, event.column, event.row)
|
||||
{
|
||||
if event.modifiers.is_empty() && self.toggle_disclosure_at(cells, event.column, event.row) {
|
||||
// Keep the patch anchored for inspection, then follow again when the prompt closes.
|
||||
if was_following && let MouseMode::Selection(Some((thread_id, id))) = mode {
|
||||
self.disclosure.resume_after_approval = Some((thread_id, id.to_owned()));
|
||||
|
||||
Reference in New Issue
Block a user