feat(shell): add /title slash command to rename sessions#1543
feat(shell): add /title slash command to rename sessions#1543mvanhorn wants to merge 1 commit intoMoonshotAI:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2b50e35feb
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| session.state.custom_title = new_title | ||
| session.save_state() |
There was a problem hiding this comment.
Preserve titled empty sessions before
/new cleanup
Persisting custom_title here does not make the session non-empty, but Session.is_empty() still only checks wire/context history and /new deletes empty current sessions. As a result, if a user sets /title on a fresh session and then runs /new before sending any message, the renamed session gets deleted and the saved title is lost, which undermines the new title persistence behavior.
Useful? React with 👍 / 👎.
Summary
Adds a
/titleslash command that lets users manually set session titles instead of relying on auto-generated ones./title My Projectsets the current session title/title(no args) shows the current titleSessionState.custom_titleChanges
Three files, 23 lines total:
src/kimi_cli/session_state.py- Addedcustom_title: str | None = Nonefield toSessionStatesrc/kimi_cli/session.py-Session.refresh()now checksstate.custom_titlebefore falling back to the auto-derived title from the wire filesrc/kimi_cli/ui/shell/slash.py- Added/titlecommand following the existing@registry.command()patternTesting
Verified programmatically:
/titleis registered in the slash command registry alongside/new,/sessions,/helpSessionState.custom_titlefield initializes toNoneand accepts string valuesSession.refresh()respects the custom title when setFixes #1536
This contribution was developed with AI assistance (Claude Code).