mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Refresh animated terminal titles without redrawing the TUI (#40618)
## Why Terminal title animations only need to update the title, but each animation tick previously requested a full TUI frame. ## What changed - Track the next terminal title refresh deadline on `ChatWidget`. - Have the foreground event loop refresh the title when that deadline expires. - Clear the deadline when title animations are disabled or the configured title is empty. ## Testing - Verify spinner and action-required animations set the expected refresh deadlines. - Verify refreshing an animated title does not enqueue a TUI draw request. GitOrigin-RevId: 269347cd48de4ad9ba9a0aef9ed105c25d1a7dae
This commit is contained in:
1 parent
ed42068c45
commit
6525b95dae
5 files changed
+56
-12
No files matched your search
@@ -244,11 +244,15 @@ impl ChatWidget {
|
||||
/// Empty selections clear the managed title. Non-empty selections render the
|
||||
/// current values in configured order, skip unavailable segments, and cache
|
||||
/// the last successfully written title so redundant OSC writes are avoided.
|
||||
/// When the `activity` item is present in an animated running state, this also
|
||||
/// schedules the next frame so the title animation keeps advancing.
|
||||
/// Animated titles record their next refresh for the foreground loop, independently
|
||||
/// of full TUI redraws.
|
||||
fn refresh_terminal_title_from_selections(&mut self, selections: &StatusSurfaceSelections) {
|
||||
self.last_terminal_title_requires_action =
|
||||
self.terminal_title_shows_action_required_with_selections(selections);
|
||||
let now = Instant::now();
|
||||
self.terminal_title_next_refresh = self
|
||||
.terminal_title_animation_interval_with_selections(selections)
|
||||
.map(|interval| now + interval);
|
||||
if selections.terminal_title_items.is_empty() {
|
||||
if let Err(err) = self.clear_managed_terminal_title() {
|
||||
tracing::debug!(error = %err, "failed to clear terminal title");
|
||||
@@ -256,13 +260,8 @@ impl ChatWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
let now = Instant::now();
|
||||
let title = self.terminal_title_text_for_selections(selections, now);
|
||||
let animation_interval = self.terminal_title_animation_interval_with_selections(selections);
|
||||
if self.last_terminal_title == title {
|
||||
if let Some(interval) = animation_interval {
|
||||
self.frame_requester.schedule_frame_in(interval);
|
||||
}
|
||||
return;
|
||||
}
|
||||
match title {
|
||||
@@ -285,10 +284,6 @@ impl ChatWidget {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(interval) = animation_interval {
|
||||
self.frame_requester.schedule_frame_in(interval);
|
||||
}
|
||||
}
|
||||
|
||||
/// Recomputes both status surfaces from one shared config snapshot.
|
||||
|
||||
Reference in new issue
Block a user