mirror of
https://github.com/openai/codex.git
synced 2026-12-03 00:41:03 +00:00
Hide Back to bottom when the current transcript tail is visible (#46902)
## Why Pausing transcript following can leave the current final row visible, making the “Back to bottom” control unnecessary after copying text, closing find, or enlarging the viewport. ## What changed Base control visibility on whether the current transcript tail is visible, and hide it for an empty viewport. Keep the control available when a paused view shows an older live revision with new activity. ## Testing Add regression coverage for empty viewports, copying at the bottom, closing find at the bottom, and resizing a paused view. Extend live-revision assertions and update the composer-gap snapshot to keep the gap blank in the paused detailed view at the tail. GitOrigin-RevId: d33b4279f5f5f43ae76c34466c18e89b61ad766c
This commit is contained in:
@@ -238,7 +238,8 @@ async fn owned_transcript_reserves_a_row_above_the_composer() -> Result<()> {
|
||||
let gap = Rect::new(/*x*/ 0, bottom.y - 1, width, /*height*/ 1);
|
||||
let buffer = crate::custom_terminal::test_support::last_rendered_buffer(&tui.terminal);
|
||||
let start = buffer.index_of(gap.x, gap.y);
|
||||
if app.transcript_view.is_following() {
|
||||
// Both scenarios show the current tail, including the paused detailed view.
|
||||
if matches!(label, "Latest" | "Detailed") {
|
||||
assert_eq!(
|
||||
&buffer.content()[start..start + usize::from(width)],
|
||||
Buffer::empty(gap).content(),
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
---
|
||||
source: tui/src/app/owned_transcript_tests.rs
|
||||
assertion_line: 220
|
||||
assertion_line: 227
|
||||
expression: "snapshots.join(\"\\n\\n\")"
|
||||
---
|
||||
Latest
|
||||
@@ -59,7 +59,7 @@ Detailed
|
||||
|
||||
|
||||
|
||||
↓ Back to bottom · esc
|
||||
|
||||
|
||||
› preserved draft
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ fn feedback_releases_navigation_targets_and_expiry_restores_them() {
|
||||
let mut view = TranscriptView::default();
|
||||
render(&mut view, &cells, /*width*/ 60, /*height*/ 3);
|
||||
view.scroll(&cells, /*rows*/ -2);
|
||||
render(&mut view, &cells, /*width*/ 60, /*height*/ 3);
|
||||
let area = Rect::new(
|
||||
/*x*/ 0, /*y*/ 3, /*width*/ 60, /*height*/ 1,
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
//! Return-to-latest affordance in the owned transcript's existing composer gap.
|
||||
//! The control is hidden whenever the current final transcript row is visible.
|
||||
//! Rendering owns the hit rectangle; hidden controls never intercept pointer input.
|
||||
|
||||
use super::*;
|
||||
@@ -20,7 +21,8 @@ impl TranscriptView {
|
||||
pub(crate) fn render_follow_control(&mut self, area: Option<Rect>, buf: &mut Buffer) {
|
||||
let area = area.filter(|area| {
|
||||
!area.is_empty()
|
||||
&& self.can_return_to_latest()
|
||||
&& !self.area.is_empty()
|
||||
&& !self.tail_visible
|
||||
&& self.highlight.is_none()
|
||||
&& self.selection.is_none()
|
||||
&& !self.is_search_active()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use super::*;
|
||||
use crate::history_cell::PlainHistoryCell;
|
||||
use crossterm::event::KeyCode;
|
||||
use crossterm::event::KeyModifiers;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
@@ -101,6 +102,112 @@ fn no_op_scroll_keeps_following_and_real_scroll_pauses() {
|
||||
assert!(view.is_following());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_viewport_does_not_show_back_to_bottom() {
|
||||
let cells = vec![cell("one")];
|
||||
let mut view = TranscriptView::default();
|
||||
let gap = Rect::new(
|
||||
/*x*/ 0, /*y*/ 0, /*width*/ 40, /*height*/ 1,
|
||||
);
|
||||
let mut buffer = Buffer::empty(gap);
|
||||
view.render(Rect { height: 0, ..gap }, &mut buffer, &cells);
|
||||
view.render_follow_control(Some(gap), &mut buffer);
|
||||
|
||||
assert!(view.is_following());
|
||||
assert!(view.follow_control.area.is_none());
|
||||
assert_eq!(buffer, Buffer::empty(gap));
|
||||
insta::assert_snapshot!(crate::transcript_view::tests::text(&buffer), @"");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn copying_selection_at_bottom_does_not_show_back_to_bottom() {
|
||||
let cells = vec![cell("one\ntwo\nthree\nfour\nneedle")];
|
||||
let mut view = TranscriptView::default();
|
||||
let before = paint(&mut view, &cells, /*width*/ 40);
|
||||
assert!(view.tail_visible);
|
||||
assert!(view.follow_control.area.is_none());
|
||||
|
||||
view.begin_selection(&cells, /*column*/ 0, /*row*/ 2, /*clicks*/ 2);
|
||||
view.end_drag();
|
||||
let selected = view.selected_text(&cells).expect("selected word");
|
||||
view.copy_selected_text_with(&cells, &selected, |text| {
|
||||
assert_eq!(text, "needle");
|
||||
Ok(crate::clipboard_copy::CopyStatus::Confirmed)
|
||||
})
|
||||
.expect("successful copy");
|
||||
|
||||
let after = paint(&mut view, &cells, /*width*/ 40);
|
||||
assert!(view.selected_text(&cells).is_none());
|
||||
assert!(!view.is_following());
|
||||
assert!(view.tail_visible);
|
||||
assert!(view.follow_control.area.is_none());
|
||||
assert_eq!(after, before);
|
||||
insta::assert_snapshot!(crate::transcript_view::tests::text(&after), @"
|
||||
three
|
||||
four
|
||||
needle
|
||||
");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn closing_find_at_bottom_does_not_show_back_to_bottom() {
|
||||
let cells = vec![cell("one\ntwo\nthree\nfour\nneedle")];
|
||||
let mut view = TranscriptView::default();
|
||||
let before = paint(&mut view, &cells, /*width*/ 40);
|
||||
view.begin_selection(&cells, /*column*/ 0, /*row*/ 2, /*clicks*/ 2);
|
||||
view.end_drag();
|
||||
view.begin_search();
|
||||
view.paste_search("needle");
|
||||
assert!(!view.advance_search(&cells));
|
||||
paint(&mut view, &cells, /*width*/ 40);
|
||||
|
||||
view.handle_key(KeyCode::Esc.into(), &cells);
|
||||
let after = paint(&mut view, &cells, /*width*/ 40);
|
||||
assert!(!view.is_search_active());
|
||||
assert!(!view.is_following());
|
||||
assert!(view.tail_visible);
|
||||
assert!(view.follow_control.area.is_none());
|
||||
assert_eq!(after, before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn enlarging_paused_view_hides_back_to_bottom_when_tail_fits() {
|
||||
let cells = vec![cell("one\ntwo\nthree\nfour\nfive")];
|
||||
let mut view = TranscriptView::default();
|
||||
paint(&mut view, &cells, /*width*/ 40);
|
||||
view.scroll(&cells, /*rows*/ -2);
|
||||
paint(&mut view, &cells, /*width*/ 40);
|
||||
assert!(view.follow_control.area.is_some());
|
||||
|
||||
let area = Rect::new(
|
||||
/*x*/ 0, /*y*/ 0, /*width*/ 40, /*height*/ 6,
|
||||
);
|
||||
let mut buffer = Buffer::empty(area);
|
||||
view.render(
|
||||
Rect::new(
|
||||
/*x*/ 0, /*y*/ 0, /*width*/ 40, /*height*/ 5,
|
||||
),
|
||||
&mut buffer,
|
||||
&cells,
|
||||
);
|
||||
view.render_follow_control(
|
||||
Some(Rect::new(
|
||||
/*x*/ 0, /*y*/ 5, /*width*/ 40, /*height*/ 1,
|
||||
)),
|
||||
&mut buffer,
|
||||
);
|
||||
assert!(!view.is_following());
|
||||
assert!(view.tail_visible);
|
||||
assert!(view.follow_control.area.is_none());
|
||||
insta::assert_snapshot!(crate::transcript_view::tests::text(&buffer), @"
|
||||
one
|
||||
two
|
||||
three
|
||||
four
|
||||
five
|
||||
");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn copying_live_selection_retains_the_displayed_revision() {
|
||||
let mut view = TranscriptView::default();
|
||||
@@ -120,9 +227,17 @@ fn copying_live_selection_retains_the_displayed_revision() {
|
||||
.unwrap();
|
||||
let buffer = paint(&mut view, &cells, /*width*/ 40);
|
||||
assert!(!view.is_following());
|
||||
assert!(!view.tail_visible);
|
||||
assert!(view.follow_control.area.is_some());
|
||||
assert!(format!("{buffer:?}").contains("original live text"));
|
||||
assert!(
|
||||
crate::transcript_view::tests::text(&buffer).contains("New activity · ↓ Back to bottom")
|
||||
);
|
||||
view.jump_to_latest();
|
||||
assert!(format!("{:?}", paint(&mut view, &cells, /*width*/ 40)).contains("changed live text"));
|
||||
let buffer = paint(&mut view, &cells, /*width*/ 40);
|
||||
assert!(format!("{buffer:?}").contains("changed live text"));
|
||||
assert!(view.tail_visible);
|
||||
assert!(view.follow_control.area.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user