Enable automatic titles for Cloud conversations (#61600)

## Why

Cloud conversations previously skipped TUI title generation, leaving them without automatically saved names.

## What changed

- Generate structured titles using the selected Cloud account and its backend routing, without agent tools or a temporary conversation.
- Read and save names outside the conversation command queue without replacing the active attachment. Preserve an existing name if it no longer matches the expected value.
- Fall back to the first-message title when generation is unavailable, and allow up to three seconds for pending saves during shutdown.
- Report a retryable error when a manual rename encounters an automatic save in progress, keeping the UI responsive.

## Testing

Add coverage for selected-account title generation, saved-name reads without attachment, first-message fallback persistence, and manual rename retries after automatic saves.

GitOrigin-RevId: 48030cc0b75e790a2004af018f54e5751665b760
This commit is contained in:
Benjamin Carlsson
2026-11-15 03:17:50 +00:00
committed by copyberry
parent 8e30237f64
commit b016cd1847
22 changed files with 670 additions and 68 deletions
+19
View File
@@ -159,6 +159,25 @@ async fn rename_sends_the_thread_and_title_and_requires_acknowledgment() {
assert!(fixture.requests.try_recv().is_err());
}
#[tokio::test]
async fn reads_a_saved_name_without_attaching_to_the_thread() {
let mut fixture = fixture_responses(vec![
response(
vec![frame(b"\x0a\x09\x72\x01t\x8a\x01\x03New")],
tonic::Status::ok(""),
),
response(vec![frame(b"\x0a\x03\x72\x01u")], tonic::Status::ok("")),
])
.await;
assert_eq!(
fixture.client.read_thread_name("t").await.unwrap(),
Some("New".to_string())
);
assert_request(&mut fixture, "ReadThread", b"\x0a\x01t").await;
assert_eq!(fixture.client.read_thread_name("u").await.unwrap(), None);
assert_request(&mut fixture, "ReadThread", b"\x0a\x01u").await;
}
#[tokio::test]
async fn activation_preserves_native_settings_and_thread_metadata() {
// Native Thread fields encoded independently of the client's wire types.
+18
View File
@@ -298,6 +298,24 @@ impl Client {
Ok(())
}
/// Reads the saved name without opening or replacing an attachment.
pub async fn read_thread_name(&self, thread_id: &str) -> Result<Option<String>, Error> {
let payload = self
.raw_unary(
wire::ThreadIdRequest {
thread_id: thread_id.to_owned(),
},
"/oaiproto.codex_app_server_backend.ThreadService/ReadThread",
)
.await?;
let thread = wire::ReadThreadResponse::decode(payload)
.map_err(|_| Error::InvalidResponse)?
.thread
.filter(|thread| thread.id.as_deref() == Some(thread_id))
.ok_or(Error::InvalidResponse)?;
Ok(thread.name)
}
/// Saves a conversation name without opening an attachment.
pub async fn set_thread_name(&self, thread_id: &str, name: &str) -> Result<(), MutationError> {
if thread_id.trim().is_empty() || name.trim().is_empty() {
+21
View File
@@ -24,6 +24,27 @@ pub(crate) struct SetThreadNameRequest {
pub name: String,
}
#[derive(Clone, prost::Message)]
pub(crate) struct ReadThreadResponse {
#[prost(message, optional, tag = "1")]
pub thread: Option<ThreadName>,
}
#[derive(Clone, prost::Message)]
#[prost(skip_debug)]
pub(crate) struct ThreadName {
#[prost(string, optional, tag = "14")]
pub id: Option<String>,
#[prost(string, optional, tag = "17")]
pub name: Option<String>,
}
impl std::fmt::Debug for ThreadName {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("ThreadName([redacted])")
}
}
#[derive(Clone, prost::Message)]
pub(crate) struct UnarchiveResponse {
#[prost(bytes = "bytes", optional, tag = "1")]