mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Improve automatic thread naming in the TUI (#42749)
## 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
This commit is contained in:
1 parent
8e85265c39
commit
a1294e57f1
32 files changed
+642
-181
No files matched your search
@@ -1,4 +1,7 @@
|
||||
//! Structured-output schema and normalization for generated TUI thread titles.
|
||||
//!
|
||||
//! Automatic titles are persisted only after generation, including for inactive threads;
|
||||
//! the originating thread's saved name takes precedence over an automatic result.
|
||||
|
||||
use super::App;
|
||||
use super::thread_events::ThreadBufferedEvent;
|
||||
@@ -31,6 +34,25 @@ struct GeneratedThreadTitle {
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub(super) fn sync_thread_title_progress(&mut self) {
|
||||
let pending = self.chat_widget.thread_id().is_some_and(|thread_id| {
|
||||
self.pending_thread_titles
|
||||
.iter()
|
||||
.any(|(id, _)| *id == thread_id)
|
||||
});
|
||||
self.chat_widget
|
||||
.set_thread_title_generation_pending(pending);
|
||||
}
|
||||
|
||||
pub(super) fn finish_thread_title_generation(
|
||||
&mut self,
|
||||
thread_id: ThreadId,
|
||||
destination: ThreadTitleDestination,
|
||||
) {
|
||||
self.pending_thread_titles.remove(&(thread_id, destination));
|
||||
self.sync_thread_title_progress();
|
||||
}
|
||||
|
||||
/// Start a hidden title-generation thread without blocking the UI loop.
|
||||
pub(super) fn generate_thread_title(
|
||||
&mut self,
|
||||
@@ -39,6 +61,10 @@ impl App {
|
||||
destination: ThreadTitleDestination,
|
||||
prompt: String,
|
||||
) {
|
||||
if !self.pending_thread_titles.insert((thread_id, destination)) {
|
||||
return;
|
||||
}
|
||||
self.sync_thread_title_progress();
|
||||
let request_handle = app_server.request_handle();
|
||||
let model = if self.chat_widget.config_ref().model_provider_id == "openai"
|
||||
&& self.chat_widget.has_chatgpt_account()
|
||||
@@ -96,6 +122,7 @@ impl App {
|
||||
Ok(thread_id) => thread_id,
|
||||
Err(error) => {
|
||||
tracing::debug!(%error, "failed to start title-generation thread");
|
||||
self.finish_thread_title_generation(thread_id, destination);
|
||||
if let ThreadTitleDestination::RenameSuggestion { request_id } = destination {
|
||||
self.chat_widget.apply_thread_name_suggestion(
|
||||
thread_id, request_id, /*suggestion*/ None,
|
||||
@@ -106,6 +133,7 @@ impl App {
|
||||
};
|
||||
|
||||
let Ok(temporary_thread_id) = ThreadId::from_string(&temporary_thread_id_text) else {
|
||||
self.finish_thread_title_generation(thread_id, destination);
|
||||
if let ThreadTitleDestination::RenameSuggestion { request_id } = destination {
|
||||
self.chat_widget
|
||||
.apply_thread_name_suggestion(thread_id, request_id, /*suggestion*/ None);
|
||||
|
||||
Reference in new issue
Block a user