Files
codex/codex-rs/tui/src/app/empty_state_policy.rs
T
Felipe Coury a97fb78085 Keep transcript Find results readable after closing the query (#50039)
## Why

Closing Find previously restored the pre-search view, making it difficult to read a match and its surrounding transcript context.

## What changed

- Make `Esc` with a nonempty query close query editing while preserving the query, highlighted match, and expanded output. A second `Esc` returns to the latest output; `Ctrl+C` cancels Find and restores the pre-search presentation.
- Allow paging through surrounding context and loading older history without losing the query. Keep `Ctrl+N` and `Ctrl+P` available for match navigation, and reopen Find to edit the retained query.
- Show context above matches when space permits, preserve match layouts across resizing, and display navigation and history status while reading results.

## Testing

Add regression tests and snapshots for retained results, surrounding context, resizing, paging around live output, older-history loading, and footer status. Update interaction tests for the additional `Esc` transition.

GitOrigin-RevId: d822956d3c6ffab88fc1665ebdf0c86ccf110899
2026-10-01 17:22:19 +00:00

50 lines
1.8 KiB
Rust

//! Allow fresh-thread decoration only on the ordinary compact conversation surface.
//! View changes hide it temporarily; non-startup content dismisses it until a new thread.
use super::*;
use crate::empty_state_animation::ComposerState;
use crate::empty_state_animation::is_startup_cell;
use crate::history_cell::HistoryRenderMode;
impl App {
pub(super) fn first_screen_composer(&self) -> Option<ComposerState> {
if !self
.transcript_cells
.iter()
.all(|cell| is_startup_cell(cell.as_ref()))
{
self.chat_widget
.empty_state_animation
.borrow_mut()
.dismiss();
}
// Evaluate live content even while a different view temporarily owns the screen.
let composer = self.chat_widget.empty_state_composer();
let view = &self.transcript_view;
match self.chat_widget.history_render_mode() {
HistoryRenderMode::Raw => None,
HistoryRenderMode::Rich => match (
self.overlay.as_ref(),
view.is_detailed(),
view.is_search_editing(),
view.is_activity_focused(),
view.has_selection_range(),
) {
// A refocus click without selected text remains an ordinary conversation.
(None, false, false, false, false)
if (view.is_following() || view.has_pending_latest_selection())
&& self.local_settings.tui.effects.welcome
&& self
.chat_widget
.empty_state_animation
.borrow()
.is_eligible() =>
{
composer
}
_ => None,
},
}
}
}