Skip to content

Handle session/setTitle and emit SessionInfoUpdate#286

Draft
daniel-agentee wants to merge 2 commits into
zed-industries:mainfrom
daniel-agentee:acp-set-title-handler
Draft

Handle session/setTitle and emit SessionInfoUpdate#286
daniel-agentee wants to merge 2 commits into
zed-industries:mainfrom
daniel-agentee:acp-set-title-handler

Conversation

@daniel-agentee
Copy link
Copy Markdown

@daniel-agentee daniel-agentee commented May 14, 2026

Summary

Implements the agent side of the new ACP session/setTitle method so ACP clients (e.g. Zed) can persist a session rename through codex-acp. After a successful rename, codex-acp emits a SessionInfoUpdate notification so the client can repaint its session list inline — no restart, no session/list round-trip required.

Why

Zed's agent panel already has a title editor for ACP sessions (zed#54689), but it can't persist anything for ACP threads because there was no protocol method to push the new title down. With the protocol method now defined upstream, codex-acp needs a handler that:

  1. Updates the SQLite state index (so session/list returns the new title even after a fresh process)
  2. Writes a custom-title entry to the JSONL rollout (so find_thread_name_by_id returns the new value)
  3. Notifies the client so the title in the sidebar updates immediately

session/list also needs to consult the rollout's custom-title entries when assembling each session's title, otherwise the rename is invisible until the next codex restart.

What's in this PR

  • codex_agent.rs — registers a SetSessionTitleRequest handler that dispatches to Thread::set_title. Adjusts listSessions to consult find_thread_name_by_id first and fall back to the formatted first user message.
  • thread.rs — adds Thread::set_title + ThreadMessage::SetTitle + ThreadActor::handle_set_title, which calls append_thread_name(codex_home, thread_id, title) to persist the rename. Then emits SessionUpdate::SessionInfoUpdate { title } so the client knows.
  • New unit test test_set_session_title_renames_underlying_thread covering both the JSONL persistence and the SessionInfoUpdate emit.

Tests

cargo build --locked
cargo test --locked --lib

21 lib tests pass on the rebuilt branch (24ce239).

Upstream dependency chain

This PR sits on top of two upstream PRs that must merge first. To keep the build green here in the meantime, Cargo.toml carries a temporary [patch.crates-io] block pointing at branch revs on my fork — see the inline comment in Cargo.toml for removal steps once releases ship.

  1. Schemaagentclientprotocol/agent-client-protocol#1199 adds SetSessionTitleRequest / SetSessionTitleResponse to the protocol schema. Patched in here via agent-client-protocol-schema = { git = ..., rev = b9739d6 }.
  2. Rust SDK routingagentclientprotocol/rust-sdk#164 wires the new schema types into the agent-side dispatch tables. Patched in here via agent-client-protocol = { git = ..., rev = 34523b3 }.
  3. This PR — uses the new types to handle the request and emit the repaint notification.

Once #1199 and rust-sdk#164 merge and an agent-client-protocol release ships (likely 0.12.0 or 0.14.0), drop both lines of the [patch.crates-io] block and bump the agent-client-protocol version on line 21 — that's the entire cleanup.

Companion PRs

Draft

Drafted while waiting on the two upstream PRs above. Ready for design review on the codex-acp side; will mark ready-for-review once the dependency chain unblocks the temp patch removal.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: df61470c54

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Cargo.toml Outdated
[dependencies]
agent-client-protocol = { version = "=0.11.1", features = ["unstable"] }
# Temporary local override until `session/setTitle` is released in the Rust SDK.
agent-client-protocol = { version = "=0.11.1", path = "../rust-sdk/src/agent-client-protocol", features = ["unstable"] }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Replace local path override with a resolvable dependency

Avoid committing agent-client-protocol as a local path dependency here, because path = "../rust-sdk/src/agent-client-protocol" requires a sibling checkout that is not part of this repository. In a normal clone (including CI and downstream builds), Cargo cannot resolve that path, so cargo build --locked fails before compilation. This effectively makes the commit non-buildable outside the author’s local workspace.

Useful? React with 👍 / 👎.

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.
@daniel-agentee daniel-agentee force-pushed the acp-set-title-handler branch from df61470 to 24ce239 Compare May 15, 2026 15:25
@daniel-agentee daniel-agentee marked this pull request as draft May 15, 2026 15:30
@daniel-agentee
Copy link
Copy Markdown
Author

Thanks @chatgpt-codex-connector — addressed in 24ce239.

Replaced the path = "../rust-sdk/..." override with a proper [patch.crates-io] block at the bottom of Cargo.toml. The [dependencies] line for agent-client-protocol is now identical to main (just version = "=0.11.1"); the override lives in a clearly-marked temporary block that cleans up to a single deletion + version bump once the two upstream PRs in the chain release (linked in the PR description).

cargo build --locked and cargo test --locked --lib are now green from a fresh clone.

@chatgpt-codex-connector
Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 24ce239c69

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/codex_agent.rs
) -> Result<SetSessionTitleResponse, Error> {
info!("Setting session title for session: {}", args.session_id);

let thread = self.get_thread(&args.session_id)?;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Support renaming sessions that are not currently loaded

session/setTitle now fails fast on self.get_thread(&args.session_id), which only resolves sessions in the in-memory self.sessions map. After session/close (or before session/load), a session can still appear in session/list but is no longer in that map, so rename requests for listed historical sessions return resource_not_found instead of persisting the new title. This breaks the main rename flow for non-active sessions; the handler should allow a DB/index-only rename path when no live thread is attached.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant