mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
## Why Automatic title generation used a provisional thread name and only applied the generated result while its thread remained active. Switching threads could therefore leave the originating thread without its generated name. ## What changed - Track title-generation requests by thread so results are persisted for the originating thread, while preserving any name set before generation finishes. - Show a `renaming...` spinner instead of a provisional name, including across thread switches and failure paths. - Add `thread-name` items to the status line and terminal title, and include the generated thread name in both default layouts. ## Testing - Cover automatic naming, manual-name precedence, thread switching, failed requests, deduplication, and status-surface rendering and animation. GitOrigin-RevId: a03ae4849bedec9f62f256fadad72c1685ce46e0
66 lines
2.3 KiB
Rust
66 lines
2.3 KiB
Rust
//! Title-generation progress on thread identity items in both status surfaces.
|
|
//!
|
|
//! The app owns requests across thread switches. Only the displayed thread's pending state
|
|
//! lives here; the existing terminal-title timer also redraws the footer while it is pending.
|
|
|
|
use super::ChatWidget;
|
|
use super::status_surfaces::TERMINAL_TITLE_SPINNER_FRAMES;
|
|
use crate::bottom_pane::StatusLineItem;
|
|
use std::time::Instant;
|
|
|
|
impl ChatWidget {
|
|
pub(crate) fn set_thread_title_generation_pending(&mut self, pending: bool) {
|
|
if self.status_state.thread_title_generation_pending != pending {
|
|
self.status_state.thread_title_generation_pending = pending;
|
|
self.refresh_status_surfaces();
|
|
self.request_redraw();
|
|
}
|
|
}
|
|
|
|
pub(super) fn status_line_value_for_item(&mut self, item: StatusLineItem) -> Option<String> {
|
|
let value = self.status_line_value(item);
|
|
if matches!(
|
|
item,
|
|
StatusLineItem::ThreadName | StatusLineItem::ThreadTitle | StatusLineItem::SessionId
|
|
) {
|
|
self.with_thread_title_progress(value, Instant::now())
|
|
} else {
|
|
value
|
|
}
|
|
}
|
|
|
|
pub(super) fn with_thread_title_progress(
|
|
&self,
|
|
value: Option<String>,
|
|
now: Instant,
|
|
) -> Option<String> {
|
|
if !self.status_state.thread_title_generation_pending {
|
|
return value;
|
|
}
|
|
let spinner = if self.local_settings.tui.animations {
|
|
self.terminal_title_spinner_frame_at(now)
|
|
} else {
|
|
TERMINAL_TITLE_SPINNER_FRAMES[0]
|
|
};
|
|
let value = value.unwrap_or_else(|| "renaming...".to_string());
|
|
Some(format!("{value} {spinner}"))
|
|
}
|
|
|
|
pub(crate) fn refresh_thread_title_progress_for_time_tick(&mut self) {
|
|
if self.status_state.thread_title_generation_pending
|
|
&& self.local_settings.tui.animations
|
|
&& self.configured_status_line_items().iter().any(|item| {
|
|
matches!(
|
|
item.parse::<StatusLineItem>(),
|
|
Ok(StatusLineItem::ThreadName
|
|
| StatusLineItem::ThreadTitle
|
|
| StatusLineItem::SessionId)
|
|
)
|
|
})
|
|
{
|
|
self.refresh_status_line();
|
|
self.request_redraw();
|
|
}
|
|
}
|
|
}
|