mirror of
https://github.com/openai/codex.git
synced 2026-12-04 00:51:02 +00:00
Restore composer hints after clearing selection at the transcript bottom (#47384)
## Why Selecting text can pause following while the final transcript row remains visible. Clearing that selection could leave an unnecessary `esc latest` hint in place of the composer hints. ## What changed Only show the return-to-latest footer for paused navigation when the transcript tail is out of view. At the bottom, show selection shortcuts without the earlier-history status, then restore composer hints when the selection is cleared, even if following remains paused. Preserve loading and retry hints. ## Testing Add regression coverage for selection, clicking away, and scrolling at the bottom with partial and complete history, plus selection above the bottom. Verify retry hints with selected text and update activity expectations and the composer-gap snapshot. GitOrigin-RevId: aeb2109244d6c3214c945abb51cf469087d03074
This commit is contained in:
+1
-2
@@ -1,6 +1,6 @@
|
||||
---
|
||||
source: tui/src/app/owned_transcript_tests.rs
|
||||
assertion_line: 227
|
||||
assertion_line: 350
|
||||
expression: "snapshots.join(\"\\n\\n\")"
|
||||
---
|
||||
Latest
|
||||
@@ -64,4 +64,3 @@ Detailed
|
||||
› preserved draft
|
||||
|
||||
gpt-test default · /tmp/project
|
||||
esc latest
|
||||
|
||||
@@ -33,13 +33,7 @@ fn visible_updates_and_empty_tail_cells_do_not_report_activity() {
|
||||
assert!(view.unseen_activity);
|
||||
render(&mut view, &cells, /*height*/ 8);
|
||||
assert!(!view.unseen_activity);
|
||||
assert_eq!(
|
||||
view.footer(/*width*/ 80, MotionMode::Reduced)
|
||||
.unwrap()
|
||||
.text
|
||||
.to_string(),
|
||||
"esc latest"
|
||||
);
|
||||
assert!(view.footer(/*width*/ 80, MotionMode::Reduced).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -41,18 +41,23 @@ impl TranscriptView {
|
||||
is_interactive: true,
|
||||
});
|
||||
}
|
||||
let pending = self.is_loading_history() || self.history == TranscriptHistoryState::Failed;
|
||||
if has_selected_text {
|
||||
return Some(TranscriptFooter {
|
||||
text: first_fitting_line(
|
||||
[
|
||||
self.status_line_with_navigation(
|
||||
"ctrl+c copy · enter copy & follow · esc clear",
|
||||
motion,
|
||||
),
|
||||
selection_hint(width),
|
||||
],
|
||||
width,
|
||||
)
|
||||
text: if self.tail_visible && !pending {
|
||||
selection_hint(width)
|
||||
} else {
|
||||
first_fitting_line(
|
||||
[
|
||||
self.status_line_with_navigation(
|
||||
"ctrl+c copy · enter copy & follow · esc clear",
|
||||
motion,
|
||||
),
|
||||
selection_hint(width),
|
||||
],
|
||||
width,
|
||||
)
|
||||
}
|
||||
.into(),
|
||||
cursor_column: None,
|
||||
is_interactive: true,
|
||||
@@ -61,8 +66,9 @@ impl TranscriptView {
|
||||
if self.is_activity_focused() {
|
||||
return self.disclosure_footer(width);
|
||||
}
|
||||
let pending = self.is_loading_history() || self.history == TranscriptHistoryState::Failed;
|
||||
let can_return = self.selection.is_none() && self.can_return_to_latest();
|
||||
// Selection can pause following without hiding the current final row.
|
||||
let can_return =
|
||||
self.selection.is_none() && self.can_return_to_latest() && !self.tail_visible;
|
||||
(pending || self.unseen_activity || can_return).then(|| {
|
||||
let navigation = if self.can_return_to_latest() {
|
||||
latest_navigation
|
||||
|
||||
@@ -13,6 +13,106 @@ use pretty_assertions::assert_eq;
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
#[test]
|
||||
fn selection_at_bottom_restores_footer_without_resuming_following() {
|
||||
let cells: Vec<Arc<dyn HistoryCell>> = vec![Arc::new(PlainHistoryCell::new(vec![
|
||||
"one".into(),
|
||||
"two".into(),
|
||||
"three".into(),
|
||||
"four".into(),
|
||||
"needle final".into(),
|
||||
]))];
|
||||
let mut observations = Vec::new();
|
||||
for history in [
|
||||
TranscriptHistoryState::Partial,
|
||||
TranscriptHistoryState::Complete,
|
||||
] {
|
||||
let mut view = TranscriptView {
|
||||
history,
|
||||
..TranscriptView::default()
|
||||
};
|
||||
let initial = render(&mut view, &cells);
|
||||
assert!(view.tail_visible);
|
||||
assert!(view.is_following());
|
||||
assert!(view.footer(/*width*/ 120, MotionMode::Reduced).is_none());
|
||||
|
||||
for (label, events) in [
|
||||
(
|
||||
"selected at bottom",
|
||||
vec![
|
||||
(MouseEventKind::Down(MouseButton::Left), 0, 2),
|
||||
(MouseEventKind::Drag(MouseButton::Left), 6, 2),
|
||||
(MouseEventKind::Up(MouseButton::Left), 6, 2),
|
||||
],
|
||||
),
|
||||
(
|
||||
"clicked away",
|
||||
vec![
|
||||
(MouseEventKind::Down(MouseButton::Left), 0, 1),
|
||||
(MouseEventKind::Up(MouseButton::Left), 0, 1),
|
||||
],
|
||||
),
|
||||
(
|
||||
"scrolled down at bottom",
|
||||
vec![(MouseEventKind::ScrollDown, 0, 1)],
|
||||
),
|
||||
] {
|
||||
let mut buffer = initial.clone();
|
||||
for (kind, column, row) in events {
|
||||
view.handle_mouse(
|
||||
MouseEvent {
|
||||
kind,
|
||||
column,
|
||||
row,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
},
|
||||
&cells,
|
||||
);
|
||||
buffer = render(&mut view, &cells);
|
||||
}
|
||||
assert!(view.tail_visible);
|
||||
assert_eq!(
|
||||
crate::transcript_view::tests::text(&buffer),
|
||||
crate::transcript_view::tests::text(&initial),
|
||||
);
|
||||
let selected = label == "selected at bottom";
|
||||
assert_eq!(
|
||||
view.selected_text(&cells).as_deref(),
|
||||
selected.then_some("needle"),
|
||||
);
|
||||
assert_eq!(view.is_following(), label == "scrolled down at bottom");
|
||||
let footer = view.footer(/*width*/ 120, MotionMode::Reduced);
|
||||
let hint = footer.map_or_else(
|
||||
|| "<composer hints>".to_owned(),
|
||||
|footer| footer.text.to_string(),
|
||||
);
|
||||
observations.push(format!("{history:?}, {label}: {hint}"));
|
||||
}
|
||||
view.scroll(&cells, /*rows*/ -1);
|
||||
render(&mut view, &cells);
|
||||
view.begin_selection(&cells, /*column*/ 0, /*row*/ 0, /*clicks*/ 3);
|
||||
view.end_drag();
|
||||
render(&mut view, &cells);
|
||||
assert!(!view.tail_visible);
|
||||
assert_eq!(view.selected_text(&cells).as_deref(), Some("two\n"));
|
||||
let footer = view.footer(/*width*/ 120, MotionMode::Reduced).unwrap();
|
||||
observations.push(format!(
|
||||
"{history:?}, selected above bottom: {}",
|
||||
footer.text
|
||||
));
|
||||
}
|
||||
insta::assert_snapshot!(observations.join("\n"), @"
|
||||
Partial, selected at bottom: ctrl+c copy · enter copy & follow · esc clear
|
||||
Partial, clicked away: <composer hints>
|
||||
Partial, scrolled down at bottom: <composer hints>
|
||||
Partial, selected above bottom: Earlier messages available. ctrl+c copy · enter copy & follow · esc clear
|
||||
Complete, selected at bottom: ctrl+c copy · enter copy & follow · esc clear
|
||||
Complete, clicked away: <composer hints>
|
||||
Complete, scrolled down at bottom: <composer hints>
|
||||
Complete, selected above bottom: ctrl+c copy · enter copy & follow · esc clear
|
||||
");
|
||||
}
|
||||
|
||||
fn render(view: &mut TranscriptView, cells: &[Arc<dyn HistoryCell>]) -> Buffer {
|
||||
let area = Rect::new(
|
||||
/*x*/ 0, /*y*/ 0, /*width*/ 32, /*height*/ 3,
|
||||
@@ -115,6 +215,16 @@ fn loading_preserves_selected_content_and_copy_action() {
|
||||
Some("selected words".to_string())
|
||||
);
|
||||
view.history = TranscriptHistoryState::Failed;
|
||||
assert_eq!(
|
||||
view.footer(/*width*/ 120, MotionMode::Reduced)
|
||||
.unwrap()
|
||||
.text
|
||||
.to_string(),
|
||||
format!(
|
||||
"ctrl+c copy · enter copy & follow · esc clear · Retry: {}",
|
||||
JumpTarget::Beginning.hint_label(),
|
||||
),
|
||||
);
|
||||
insta::assert_snapshot!(view.footer(/*width*/ 38, MotionMode::Reduced).unwrap().text.to_string(),
|
||||
@"enter copy & follow · esc clear");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user