Skip to content

Add /rename builtin slash command#287

Closed
daniel-agentee wants to merge 10 commits into
zed-industries:mainfrom
daniel-agentee:acp-rename-slash
Closed

Add /rename builtin slash command#287
daniel-agentee wants to merge 10 commits into
zed-industries:mainfrom
daniel-agentee:acp-rename-slash

Conversation

@daniel-agentee

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

Copy link
Copy Markdown

Summary

Adds /rename <new title> as a builtin slash command for codex-acp. Typing /rename Foo in any ACP client (including stock Zed.app -- no client-side change required) renames the current session: the title is persisted to session_index.jsonl, the SQLite state DB is updated, and the client repaints its session list inline via the SessionInfoUpdate notification.

Empty argument prints a usage hint instead of being a silent no-op. The new builtin is added to builtin_command_names() so a same-named skill cannot shadow it.

Why

Today users can rename a session only by opening the title editor in the agent panel header, which depends on Zed having merged the title-editor wiring and on the protocol/handler PRs landing. A slash command works from any ACP client immediately because the dispatch lives entirely inside codex-acp.

What's in this PR

  • thread.rs:
    • Adds rename to builtin_command_names() and builtin_commands() with an Unstructured("new session title") input hint so the / picker shows the argument slot.
    • In handle_prompt, intercepts /rename before the Op::UserInput dispatch. Empty arg -> Usage: agent message. Non-empty -> calls self.handle_set_title(title, Some(title)), which already persists + emits SessionInfoUpdate, then sends a confirmation chunk. Returns StopReason::EndTurn immediately and never reaches the model.
  • New unit tests: rename_is_listed_in_builtin_commands, slash_rename_without_arg_shows_usage_message, slash_rename_with_arg_writes_title_to_session_index.

Tests

cargo fmt --all -- --check
cargo test --locked --lib
cargo check --locked
cargo clippy --all-targets --all-features -- -D warnings
git diff --check

37 lib tests pass.

Dependencies (drafted until merged)

This PR is intentionally split out as a separate, smaller concern from the underlying rename infrastructure. It stacks on:

I'll mark this PR ready-for-review and rebase to a clean single-commit diff once the dependencies land.

@daniel-agentee

Copy link
Copy Markdown
Author

@codex review

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

Copy link
Copy Markdown

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: 00deaa9fd3

ℹ️ 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/thread.rs Outdated
Comment on lines 2876 to 2880
self.refresh_skills().await;
self.client
.send_notification(SessionUpdate::AvailableCommandsUpdate(
AvailableCommandsUpdate::new(self.available_commands()),
));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Delay command updates until the session is visible

When session/new or session/load calls thread.load().await, this actor now sends AvailableCommandsUpdate immediately after resolving the internal oneshot, but before CodexAgent has responded to the outer ACP request with the session ID. The previous delayed task avoided this ordering problem. In clients that ignore or cannot attach updates for sessions they have not finished creating/loading yet, this notification can be dropped, leaving the slash-command palette without the builtins/skills until another update happens.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in d47615e by restacking #287 on the updated #279 tip (6bbb49f).

The available-commands update is delayed again so session/new / session/load callers can finish attaching the session before the notification arrives, but it is computed only after refresh_skills() from the current cache. That preserves the ordering behavior without reintroducing the stale pre-refresh snapshot. Local validation is green: cargo fmt --all -- --check, cargo test --locked --lib, cargo check --locked, cargo clippy --all-targets --all-features -- -D warnings, and git diff --check.

@daniel-agentee

Copy link
Copy Markdown
Author

@codex review

@daniel-agentee

Copy link
Copy Markdown
Author

@codex review

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

Copy link
Copy Markdown

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: d47615e2d7

ℹ️ 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/thread.rs
Comment thread src/thread.rs Outdated
Comment on lines +3095 to +3097
self.cached_implicit_invocation_skills
.iter()
.find(|s| s.name == name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Rewrite explicit-only skill slash commands

The advertised command list includes every enabled skill, but this lookup only matches cached_implicit_invocation_skills. For a skill with policy.allow_implicit_invocation: false, the user will still see and select /skill-name, but the prompt is not rewritten to $skill-name; it is sent to Codex as plain /skill-name text, so explicit-only skills exposed by the slash menu are not actually invoked despite the README saying selection is equivalent to $name.

Useful? React with 👍 / 👎.

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

Copy link
Copy Markdown

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: 0d31a62724

ℹ️ 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/thread.rs Outdated
Comment on lines +3470 to +3471
.handle_set_title(title.to_owned(), Some(title.to_owned()))
.await

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Sync /rename titles to the state DB

When a user invokes the new /rename slash command in a normal session with SQLite state enabled, this path only calls handle_set_title, which appends to session_index.jsonl but never updates the StateDb row. The ACP session/setTitle path explicitly calls state_db.update_thread_title(...) before appending the index, so /rename leaves state_*.sqlite with the old title; any resume/search/listing surface that reads the SQLite metadata directly can keep showing or resolving the stale name after a successful rename.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in feec0b3 as well. The slash /rename path now uses the same SQLite state DB title update that ACP session/setTitle relies on, then appends to the legacy session_index.jsonl title index and notifies the client. Local validation is green: cargo fmt --all -- --check, cargo test --locked --lib (37 tests), cargo check --locked, cargo clippy --all-targets --all-features -- -D warnings, and git diff --check.

@daniel-agentee

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

ℹ️ 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".

@daniel-agentee

Copy link
Copy Markdown
Author

Restacked this branch in bbd2042 so it now includes the refreshed #279 skill-root/duplicate-skill fixes and the refreshed #286 set-title auth/capability fixes before the /rename commit. Local validation is green: cargo fmt --all -- --check, cargo test --locked --lib (39 tests), cargo check --locked, cargo clippy --all-targets --all-features -- -D warnings, and git diff --check.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ 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".

@daniel-agentee

Copy link
Copy Markdown
Author

Restacked again in 7cf7167 to include the #279 repo-local skill loader fix (4cb94d3) on top of the refreshed #279/#286 stack, then kept /rename on top. Local validation is green: cargo fmt --all -- --check, cargo test --locked --lib (40 tests), cargo check --locked, cargo clippy --all-targets --all-features -- -D warnings, and git diff --check.

@codex review

@daniel-agentee

Copy link
Copy Markdown
Author

Restacked once more in 0ce206b to include #279’s duplicate-name slash command fix (1e212ef) along with the repo-local skill loader fix and the refreshed #286 set-title stack. Local validation is green: cargo fmt --all -- --check, cargo test --locked --lib (41 tests), cargo check --locked, cargo clippy --all-targets --all-features -- -D warnings, and git diff --check.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ 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".

@daniel-agentee
daniel-agentee marked this pull request as ready for review June 2, 2026 17:26

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

Copy link
Copy Markdown

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: 0ce206bbe9

ℹ️ 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 Outdated
Comment on lines +786 to +788
let title = match thread_titles.get(&thread_id) {
Some(Some(title)) => Some(title.clone()),
Some(None) | None => first_user_message.as_deref().and_then(format_session_title),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve cleared titles in session lists

When a title is cleared via session/setTitle with a blank value, append_thread_name records an empty thread_name, and find_latest_thread_titles_by_ids returns Some(None) for that thread. This branch treats that the same as no custom-title entry and falls back to first_user_message, so after the next session/list refresh a cleared title reappears as the generated first-message title even though the client was notified that the title was cleared.

Useful? React with 👍 / 👎.

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

Copy link
Copy Markdown

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: a78550a86b

ℹ️ 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
@daniel-agentee

Copy link
Copy Markdown
Author

This branch is supposed to be /rename-only: one commit on top of #286 (the session/setTitle + SessionInfoUpdate work), without the "Expose Codex skills as ACP slash commands" commit from #279. They're kept separate so each can be reviewed and merged on its own.

I just re-pushed it in that clean state. Flagging it because the branch has been rebased twice now with the #279 skills commit pulled back in (last on 2026-06-02), which bundles two unrelated features together and makes the diff much bigger than it needs to be. Is something automated rebasing this branch? If so, could it start from this /rename-on-#286 commit instead of the old skills-rooted stack? Happy to keep it rebased on #286 as the PR evolves.

@daniel-agentee

Copy link
Copy Markdown
Author

Restacked /rename in b57de84 on top of the updated #286 head (cd654ff) while keeping this PR /rename-only. Local validation is green: cargo fmt --all -- --check, cargo test --locked --lib (34 tests), cargo check --locked, cargo clippy --all-targets --all-features -- -D warnings, and git diff --check.

@codex review

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

Copy link
Copy Markdown

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: b57de84cac

ℹ️ 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/thread.rs
@daniel-agentee

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ 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".

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

Copy link
Copy Markdown
Author

Rebased this onto the refreshed #286 stack (fb86d53) and current origin/main (bb59050) to clear the merge conflict. The PR head is now 749e71e.

Validation after the rebase:

  • cargo fmt --all -- --check
  • git diff --check
  • CARGO_TARGET_DIR=/Users/danielstojanovic/Documents/Codex/2026-05-28/update-this-pr-and-make-it/codex-acp/target/pr286-check cargo check --locked
  • CARGO_TARGET_DIR=/Users/danielstojanovic/Documents/Codex/2026-05-28/update-this-pr-and-make-it/codex-acp/target/pr286-check cargo test --locked --lib (34 passed)

@codex review

Exposes `/rename <new title>` so users can rename the current ACP
session from the chat input without a title-editor UI in the client.
Works on stock Zed because the command resolves entirely inside
codex-acp via the existing handle_set_title path that writes to
$CODEX_HOME/session_index.jsonl and emits a SessionInfoUpdate so the
client repaints its session list inline.

The empty-arg case prints a usage hint instead of a silent no-op.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ 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".

@daniel-agentee

Copy link
Copy Markdown
Author

Restacked this on top of the updated #286 head (2c5497a) after the title-notification normalization fix. The PR head is now 9306582.

Validation:

  • cargo fmt --all -- --check
  • git diff --check
  • CARGO_TARGET_DIR=/Users/danielstojanovic/Documents/Codex/2026-05-28/update-this-pr-and-make-it/codex-acp/target/pr286-check cargo check --locked
  • CARGO_TARGET_DIR=/Users/danielstojanovic/Documents/Codex/2026-05-28/update-this-pr-and-make-it/codex-acp/target/pr286-check cargo test --locked --lib (35 passed)

@codex review

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

Copy link
Copy Markdown

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: 9306582f18

ℹ️ 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/thread.rs Outdated
.send_agent_text("Usage: /rename <new session title>\n");
} else {
match self
.handle_set_title(title.to_owned(), Some(title.to_owned()))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize /rename title notifications

When /rename is used with a title containing a newline/CR or more than 120 graphemes, this passes the raw trimmed title into SessionInfoUpdate, but session/list displays titles via stored_session_title/format_session_title in src/codex_agent.rs, which replaces newlines and truncates. That means the client repaints to a different inline title than it will show after the next list/reload, bypassing the title-notification normalization fix; use the same notification formatting here before calling handle_set_title.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in c13d0d9. /rename now formats the SessionInfoUpdate title through the same trim/newline/truncation path used for listed titles while keeping the persisted title unchanged. Added rename_notification_title_matches_session_list_formatting and extended the slash rename regression to assert the normalized SessionInfoUpdate. Validation is green: cargo fmt --all -- --check, git diff --check, CARGO_TARGET_DIR=/Users/danielstojanovic/Documents/Codex/2026-05-28/update-this-pr-and-make-it/codex-acp/target/pr286-check cargo check --locked, and CARGO_TARGET_DIR=/Users/danielstojanovic/Documents/Codex/2026-05-28/update-this-pr-and-make-it/codex-acp/target/pr286-check cargo test --locked --lib (36 passed).

@daniel-agentee

Copy link
Copy Markdown
Author

Pushed c13d0d9 to address the latest Codex review feedback on /rename title notifications.

Validation:

  • cargo fmt --all -- --check
  • git diff --check
  • CARGO_TARGET_DIR=/Users/danielstojanovic/Documents/Codex/2026-05-28/update-this-pr-and-make-it/codex-acp/target/pr286-check cargo check --locked
  • CARGO_TARGET_DIR=/Users/danielstojanovic/Documents/Codex/2026-05-28/update-this-pr-and-make-it/codex-acp/target/pr286-check cargo test --locked --lib (36 passed)

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ 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".

@benbrandt

Copy link
Copy Markdown
Member

Hi thanks for taking the time to dig in!
Development is moving to agentclientprotocol/codex-acp. The new adapter is built on the new Codex App Server, and we are pooling implementation and maintenance work across teams there. If this is still needed, please open a PR for that one. Thanks!

@benbrandt benbrandt closed this Jun 23, 2026
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.

2 participants