Generate descriptive TUI thread titles (#40492)

## What changed

- Give unnamed TUI threads an immediate provisional title from the first user message, then replace it asynchronously with a normalized generated title.
- Preserve manual renames by applying a generated title only while the provisional title is still current, and keep automatic rename notifications out of the transcript.
- Run title generation in a bounded ephemeral structured request that preserves custom permission profiles, otherwise uses read-only access, and disables tools and MCP servers.

## Testing

- Cover prompt and response bounds, Unicode-safe truncation, title normalization, manual-rename races, silent automatic updates, permission preservation, and structured-response failures.

GitOrigin-RevId: 7ed73522f4f6c65a005f65f3a903974d8419e312
This commit is contained in:
Felipe Coury authored and copyberry committed 2026-08-24 23:06:06 +00:00
1 parent c941572917
commit b3c7e1a47f
18 files changed
+1032 -12

No files matched your search

@@ -31,6 +31,7 @@ const RETRY_PROMPT: &str = "Handle the safety-buffered request";
const COMMITTED_STEER: &str = "Keep the accepted steer";
const UNSENT_DRAFT: &str = "Keep this unsent draft";
const RETRY_GOAL: &str = "Preserve this goal across the retry";
const SAFETY_RETRY_THREAD_NAME: &str = "Safety retry source";
#[derive(Clone, Copy, PartialEq, Eq)]
enum SafetyRetryScenario {
@@ -420,8 +421,13 @@ goals = true
let mut tui = crate::tui::test_support::make_test_tui()?;
let mut app_server = Box::pin(crate::start_embedded_app_server_for_picker(&app.config)).await?;
let started = app_server.start_thread(&app.config).await?;
let mut started = app_server.start_thread(&app.config).await?;
let source_thread_id = started.session.thread_id;
// Keep ordered response fixtures focused on safety retries, not background naming.
app_server
.thread_set_name(source_thread_id, SAFETY_RETRY_THREAD_NAME.to_string())
.await?;
started.session.thread_name = Some(SAFETY_RETRY_THREAD_NAME.to_string());
app.replace_chat_widget_with_app_server_thread(
&mut tui,
started,