Skip to content

Commit 24ce239

Browse files
Emit SessionInfoUpdate after rename so clients can repaint inline
Previously the title was persisted to session_index.jsonl but the connected client (Zed) only saw the change on the next session/list refresh — usually after restart. Send a SessionUpdate::SessionInfoUpdate carrying the new title so the client can update its session list in place, no restart needed. Covers both rename surfaces: the session/setTitle JSON-RPC and the /rename builtin slash command both flow through handle_set_title.
1 parent 919d6f3 commit 24ce239

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

src/thread.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ use agent_client_protocol::{
1717
PlanEntryStatus, PromptRequest, RequestPermissionOutcome, RequestPermissionRequest,
1818
RequestPermissionResponse, ResourceLink, SelectedPermissionOutcome, SessionConfigId,
1919
SessionConfigOption, SessionConfigOptionCategory, SessionConfigOptionValue,
20-
SessionConfigSelectOption, SessionConfigValueId, SessionId, SessionMode, SessionModeId,
21-
SessionModeState, SessionModelState, SessionNotification, SessionUpdate, StopReason,
20+
SessionConfigSelectOption, SessionConfigValueId, SessionId, SessionInfoUpdate,
21+
SessionMode, SessionModeId, SessionModeState, SessionModelState, SessionNotification,
22+
SessionUpdate, StopReason,
2223
Terminal, TextContent, TextResourceContents, ToolCall, ToolCallContent, ToolCallId,
2324
ToolCallLocation, ToolCallStatus, ToolCallUpdate, ToolCallUpdateFields, ToolKind,
2425
UnstructuredCommandInput, UsageUpdate,
@@ -3427,6 +3428,13 @@ impl<A: Auth> ThreadActor<A> {
34273428
Error::internal_error().data(format!("failed to index thread title: {err}"))
34283429
})?;
34293430

3431+
// Tell the connected client the title changed so it can repaint the
3432+
// session list without waiting for the next session/list call.
3433+
self.client
3434+
.send_notification(SessionUpdate::SessionInfoUpdate(
3435+
SessionInfoUpdate::new().title(title),
3436+
));
3437+
34303438
Ok(())
34313439
}
34323440

@@ -4865,6 +4873,17 @@ mod tests {
48654873
Some("Renamed from ACP".to_string())
48664874
);
48674875

4876+
let notifications = client.notifications.lock().unwrap();
4877+
assert!(
4878+
notifications.iter().any(|n| matches!(
4879+
&n.update,
4880+
SessionUpdate::SessionInfoUpdate(update)
4881+
if matches!(&update.title, agent_client_protocol::schema::MaybeUndefined::Value(t) if t == "Renamed from ACP")
4882+
)),
4883+
"expected a SessionInfoUpdate carrying the new title; got: {notifications:#?}"
4884+
);
4885+
drop(notifications);
4886+
48684887
thread.shutdown().await?;
48694888
std::fs::remove_dir_all(codex_home).ok();
48704889

0 commit comments

Comments
 (0)