Add /rename builtin slash command#662
Open
daniel-agentee wants to merge 2 commits into
Open
Conversation
Mirrors the codex-acp builtin: typing `/rename <new title>` in a Claude session calls `renameSession` from @anthropic-ai/claude-agent-sdk and appends a custom-title entry to the session JSONL. The new title shows up via listSessions() on the next refresh. The command is intercepted at the top of `prompt()` before the SDK loop starts, so it never round-trips through Claude. Empty argument prints a usage hint; SDK errors are surfaced as a chat message rather than thrown. `/rename` is also appended to the available-commands list so it appears alongside SDK-provided slash commands in the picker.
renameSession() persists the new title to the session JSONL, but the connected client only sees it on the next listSessions() refresh — usually after restart. Send a session_info_update notification with the new title (and a fresh updatedAt) so the client can repaint its session list in place.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
/rename <new title>as a builtin slash command. Typing it in any ACP client (including stock Zed.app) renames the current session:renameSession()from@anthropic-ai/claude-agent-sdkwrites acustom-titleentry to the session JSONL, and asession_info_updatenotification is emitted so the client can repaint its session list inline — no restart, nolistSessions()round-trip required.Empty argument prints a usage hint instead of being a silent no-op. SDK errors are surfaced as a chat message rather than thrown.
Why
ACP sessions can be retitled programmatically via
renameSession(), but until now there was no way for a user to trigger that from inside a session — the title was either auto-summarised or unchangeable. The slash-command path also avoids needing any client-side UI work, so it ships value immediately on stock Zed.app.What's in this PR
src/acp-agent.ts:renameSessionfrom@anthropic-ai/claude-agent-sdk.prompt(), before any SDK round-trip, intercepts/rename .... Empty →Usage:agent message; non-empty → callsrenameSession(sessionId, title, { dir }), emitssession_info_updatewith the new title and a freshupdatedAt, then sends a confirmation chunk. Returns{ stopReason: "end_turn" }immediately.getAvailableSlashCommands, appends{ name: "rename", description: "rename this session", input: { hint: "new session title" } }so the/picker surfaces it alongside SDK commands.src/tests/rename-slash-command.test.ts: 4 tests covering happy path, empty-arg usage, SDK-error surfacing, and that/renameddoesn't accidentally match.Tests
10 test files / 263 tests pass (4 new + 259 existing).
Companion notes
This PR is a single, self-contained feature: the rename machinery is provided by the SDK (
renameSession), so there's no separate "rename infrastructure" PR to split out — only the slash command + thesession_info_updateemit that goes with it.