Remove terminal resize reflow flag gates (#27794)

## Why

`terminal_resize_reflow` is now stable and should behave as always on.
Keeping the disabled runtime paths around made the feature look
configurable even though the rollout is complete, and old config could
still suggest there was a supported off mode.

## What Changed

- Marked `terminal_resize_reflow` as `Stage::Removed` while keeping it
default-enabled for compatibility.
- Ignored `[features].terminal_resize_reflow` config entries so stale
`false` settings no longer affect the effective feature set.
- Removed TUI branches that depended on the flag being disabled, so
draw, replay buffering, stream finalization, and resize scheduling all
assume resize reflow is active.
- Simplified resize smoke coverage to exercise the always-on behavior
only.

## Verification

- `just test -p codex-features`
- `just test -p codex-tui resize_reflow`
- `just test -p codex-tui initial_replay_buffer
thread_switch_replay_buffer`
This commit is contained in:
Eric Traut authored and GitHub committed 2026-06-15 08:23:02 -07:00
1 parent 1aa3e432cc
commit 8a6a039f26
11 files changed
+86 -272

No files matched your search

-8
View File
@@ -249,14 +249,6 @@ impl App {
self.insert_completed_token_activity_output_after_stream_shutdown(tui);
}
AppEvent::ConsolidateProposedPlan(source) => {
if !self.terminal_resize_reflow_enabled() {
if !self.transcript_reflow.history_cell_refresh_requested() {
self.transcript_reflow.clear();
}
self.chat_widget.note_stream_consolidation_completed();
self.insert_completed_token_activity_output_after_stream_shutdown(tui);
return Ok(AppRunControl::Continue);
}
let end = self.transcript_cells.len();
let start = trailing_run_start::<history_cell::ProposedPlanStreamCell>(
&self.transcript_cells,
+15 -82
View File
@@ -18,7 +18,6 @@ use std::collections::VecDeque;
use std::sync::Arc;
use std::time::Instant;
use codex_features::Feature;
use color_eyre::eyre::Result;
use ratatui::text::Line;
@@ -109,18 +108,14 @@ impl App {
}
}
pub(super) fn terminal_resize_reflow_enabled(&self) -> bool {
self.config.features.enabled(Feature::TerminalResizeReflow)
}
/// Start retaining initial resume replay rows before they are written to scrollback.
///
/// Resume replay can insert thousands of already-finalized history cells before the first draw.
/// When resize reflow is enabled, buffering here lets the same row cap used by resize rebuilds
/// apply to the startup write. Starting this buffer while an overlay owns rendering would split
/// transcript ownership, so overlay replay continues through the normal deferred-history path.
/// Buffering here lets the same row cap used by resize rebuilds apply to the startup write.
/// Starting this buffer while an overlay owns rendering would split transcript ownership, so
/// overlay replay continues through the normal deferred-history path.
pub(super) fn begin_initial_history_replay_buffer(&mut self) {
if self.terminal_resize_reflow_enabled() && self.overlay.is_none() {
if self.overlay.is_none() {
self.initial_history_replay_buffer = Some(Default::default());
}
}
@@ -131,10 +126,7 @@ impl App {
/// defer terminal writes until the replay is complete and reuse the resize-reflow tail renderer
/// so only the rows the terminal would retain are formatted and inserted.
pub(super) fn begin_thread_switch_history_replay_buffer(&mut self) {
if self.terminal_resize_reflow_enabled()
&& self.resize_reflow_max_rows().is_some()
&& self.overlay.is_none()
{
if self.resize_reflow_max_rows().is_some() && self.overlay.is_none() {
self.initial_history_replay_buffer = Some(InitialHistoryReplayBuffer {
retained_lines: VecDeque::new(),
render_from_transcript_tail: true,
@@ -233,7 +225,6 @@ impl App {
}
fn schedule_resize_reflow(&mut self, target_width: Option<u16>) -> bool {
debug_assert!(self.terminal_resize_reflow_enabled());
self.transcript_reflow.schedule_debounced(target_width)
}
@@ -263,19 +254,6 @@ impl App {
/// source-backed reflow so terminal scrollback reflects the finalized cell instead of the
/// transient stream rows.
pub(super) fn maybe_finish_stream_reflow(&mut self, tui: &mut tui::Tui) -> Result<()> {
if !self.terminal_resize_reflow_enabled() {
if self.transcript_reflow.take_stream_finish_reflow_needed() {
self.schedule_immediate_history_cell_refresh(tui);
self.maybe_run_resize_reflow(tui)?;
return Ok(());
}
if self.transcript_reflow.history_cell_refresh_requested() {
return Ok(());
}
self.transcript_reflow.clear();
return Ok(());
}
if self.transcript_reflow.take_stream_finish_reflow_needed() {
self.schedule_immediate_resize_reflow(tui);
self.maybe_run_resize_reflow(tui)?;
@@ -286,42 +264,16 @@ impl App {
}
fn schedule_immediate_resize_reflow(&mut self, tui: &mut tui::Tui) {
if !self.terminal_resize_reflow_enabled() {
self.transcript_reflow.clear();
return;
}
self.transcript_reflow.schedule_immediate();
tui.frame_requester().schedule_frame();
}
fn schedule_immediate_history_cell_refresh(&mut self, tui: &mut tui::Tui) {
self.transcript_reflow.schedule_history_cell_refresh();
tui.frame_requester().schedule_frame();
}
pub(crate) fn retry_pending_history_cell_refresh(&self, tui: &mut tui::Tui) {
if self.transcript_reflow.history_cell_refresh_requested() {
tui.frame_requester().schedule_frame();
}
}
pub(super) fn should_handle_draw_pre_render(&self) -> bool {
self.terminal_resize_reflow_enabled()
|| self.transcript_reflow.history_cell_refresh_requested()
}
/// Force stream-finalized output through the resize reflow path.
///
/// Proposed plan consolidation uses this stricter path because a completed plan is inserted or
/// replaced as one styled source-backed cell. If this reflow is skipped after a stream-time
/// resize, the visible scrollback can keep the pre-consolidation wrapping.
pub(super) fn finish_required_stream_reflow(&mut self, tui: &mut tui::Tui) -> Result<()> {
if !self.terminal_resize_reflow_enabled() {
if !self.transcript_reflow.history_cell_refresh_requested() {
self.transcript_reflow.clear();
}
return Ok(());
}
self.schedule_immediate_resize_reflow(tui);
self.maybe_run_resize_reflow(tui)?;
if !self.transcript_reflow.has_pending_reflow() {
@@ -350,37 +302,24 @@ impl App {
self.chat_widget.on_terminal_resize(size.width);
}
if should_rebuild_transcript {
if self.terminal_resize_reflow_enabled() {
if reflow_needed && self.should_mark_reflow_as_stream_time() {
self.transcript_reflow.mark_resize_requested_during_stream();
}
let target_width = reflow_needed.then_some(size.width);
if self.schedule_resize_reflow(target_width) {
frame_requester.schedule_frame();
} else {
frame_requester.schedule_frame_in(TRANSCRIPT_REFLOW_DEBOUNCE);
}
} else if !self.terminal_resize_reflow_enabled()
&& width.changed
&& !self.transcript_reflow.history_cell_refresh_requested()
{
self.transcript_reflow.clear();
if reflow_needed && self.should_mark_reflow_as_stream_time() {
self.transcript_reflow.mark_resize_requested_during_stream();
}
let target_width = reflow_needed.then_some(size.width);
if self.schedule_resize_reflow(target_width) {
frame_requester.schedule_frame();
} else {
frame_requester.schedule_frame_in(TRANSCRIPT_REFLOW_DEBOUNCE);
}
}
if size != last_known_screen_size {
self.refresh_status_line();
}
if self.terminal_resize_reflow_enabled() {
self.maybe_clear_resize_reflow_without_terminal();
}
self.maybe_clear_resize_reflow_without_terminal();
should_rebuild_transcript
}
fn maybe_clear_resize_reflow_without_terminal(&mut self) {
if !self.terminal_resize_reflow_enabled() {
self.transcript_reflow.clear();
return;
}
let Some(deadline) = self.transcript_reflow.pending_until() else {
return;
};
@@ -400,7 +339,7 @@ impl App {
tui.terminal.last_known_screen_size,
&tui.frame_requester(),
);
if should_rebuild_transcript && self.terminal_resize_reflow_enabled() {
if should_rebuild_transcript {
// Resize-sensitive history inserts queued before this frame may be wrapped for the old
// viewport or targeted at rows no longer visible. Drop them and let resize reflow
// rebuild from transcript cells.
@@ -417,12 +356,6 @@ impl App {
/// reuse terminal-wrapped output here would preserve exactly the stale wrapping this feature is
/// meant to remove.
pub(super) fn maybe_run_resize_reflow(&mut self, tui: &mut tui::Tui) -> Result<()> {
if !self.terminal_resize_reflow_enabled()
&& !self.transcript_reflow.history_cell_refresh_requested()
{
self.transcript_reflow.clear();
return Ok(());
}
let Some(deadline) = self.transcript_reflow.pending_until() else {
return Ok(());
};
-37
View File
@@ -4400,13 +4400,6 @@ fn test_thread_session(thread_id: ThreadId, cwd: PathBuf) -> ThreadSessionState
}
}
fn enable_terminal_resize_reflow(app: &mut App) {
app.config
.features
.set_enabled(Feature::TerminalResizeReflow, /*enabled*/ true)
.expect("feature should be configurable");
}
fn plain_line_cell(text: impl Into<String>) -> Arc<dyn HistoryCell> {
Arc::new(PlainHistoryCell::new(vec![Line::from(text.into())])) as Arc<dyn HistoryCell>
}
@@ -4516,7 +4509,6 @@ async fn uncapped_resize_reflow_renders_all_cells_under_row_limit() {
#[tokio::test]
async fn initial_replay_buffer_keeps_recent_rows_when_row_cap_present() {
let (mut app, _rx, _op_rx) = make_test_app_with_channels().await;
enable_terminal_resize_reflow(&mut app);
app.config.terminal_resize_reflow.max_rows = TerminalResizeReflowMaxRows::Limit(3);
app.begin_initial_history_replay_buffer();
@@ -4551,7 +4543,6 @@ async fn initial_replay_buffer_keeps_recent_rows_when_row_cap_present() {
#[tokio::test]
async fn thread_switch_replay_buffer_uses_transcript_tail_mode_when_row_cap_present() {
let (mut app, _rx, _op_rx) = make_test_app_with_channels().await;
enable_terminal_resize_reflow(&mut app);
app.config.terminal_resize_reflow.max_rows = TerminalResizeReflowMaxRows::Limit(3);
app.begin_thread_switch_history_replay_buffer();
@@ -4567,7 +4558,6 @@ async fn thread_switch_replay_buffer_uses_transcript_tail_mode_when_row_cap_pres
#[tokio::test]
async fn thread_switch_replay_buffer_is_disabled_without_row_cap() {
let (mut app, _rx, _op_rx) = make_test_app_with_channels().await;
enable_terminal_resize_reflow(&mut app);
app.config.terminal_resize_reflow.max_rows = TerminalResizeReflowMaxRows::Disabled;
app.begin_thread_switch_history_replay_buffer();
@@ -4578,7 +4568,6 @@ async fn thread_switch_replay_buffer_is_disabled_without_row_cap() {
#[tokio::test]
async fn height_shrink_schedules_resize_reflow() {
let (mut app, _rx, _op_rx) = make_test_app_with_channels().await;
enable_terminal_resize_reflow(&mut app);
let frame_requester = crate::tui::FrameRequester::test_dummy();
assert!(!app.handle_draw_size_change(
@@ -4595,32 +4584,6 @@ async fn height_shrink_schedules_resize_reflow() {
assert!(app.transcript_reflow.has_pending_reflow());
}
#[tokio::test]
async fn disabled_resize_reflow_preserves_pending_history_cell_refresh() {
let (mut app, _rx, _op_rx) = make_test_app_with_channels().await;
let frame_requester = crate::tui::FrameRequester::test_dummy();
app.config
.features
.set_enabled(Feature::TerminalResizeReflow, /*enabled*/ false)
.expect("feature should be configurable");
assert!(!app.should_handle_draw_pre_render());
app.transcript_reflow.schedule_history_cell_refresh();
assert!(app.should_handle_draw_pre_render());
assert!(!app.handle_draw_size_change(
ratatui::layout::Size::new(/*width*/ 118, /*height*/ 35),
ratatui::layout::Size::new(/*width*/ 118, /*height*/ 35),
&frame_requester,
));
assert!(app.handle_draw_size_change(
ratatui::layout::Size::new(/*width*/ 119, /*height*/ 35),
ratatui::layout::Size::new(/*width*/ 118, /*height*/ 35),
&frame_requester,
));
assert!(app.transcript_reflow.history_cell_refresh_requested());
}
fn test_turn(turn_id: &str, status: TurnStatus, items: Vec<ThreadItem>) -> Turn {
Turn {
id: turn_id.to_string(),
+2 -4
View File
@@ -1098,8 +1098,7 @@ impl App {
self.chat_widget
.set_initial_user_message_submit_suppressed(/*suppressed*/ true);
self.chat_widget.handle_thread_session(session);
let should_buffer_initial_replay =
self.terminal_resize_reflow_enabled() && !turns.is_empty();
let should_buffer_initial_replay = !turns.is_empty();
if should_buffer_initial_replay {
self.app_event_tx
.send(AppEvent::BeginInitialHistoryReplayBuffer);
@@ -1289,8 +1288,7 @@ impl App {
resume_restored_queue: bool,
) {
self.refresh_mcp_startup_expected_servers_from_config();
let should_buffer_replay = self.terminal_resize_reflow_enabled()
&& (!snapshot.turns.is_empty() || !snapshot.events.is_empty());
let should_buffer_replay = !snapshot.turns.is_empty() || !snapshot.events.is_empty();
if should_buffer_replay {
self.app_event_tx
.send(AppEvent::BeginThreadSwitchHistoryReplayBuffer);