Skip to content

feat(shell): add /title slash command to rename sessions#1543

Open
mvanhorn wants to merge 1 commit intoMoonshotAI:mainfrom
mvanhorn:osc/1536-add-title-slash-command
Open

feat(shell): add /title slash command to rename sessions#1543
mvanhorn wants to merge 1 commit intoMoonshotAI:mainfrom
mvanhorn:osc/1536-add-title-slash-command

Conversation

@mvanhorn
Copy link
Copy Markdown

@mvanhorn mvanhorn commented Mar 22, 2026

Summary

Adds a /title slash command that lets users manually set session titles instead of relying on auto-generated ones.

  • /title My Project sets the current session title
  • /title (no args) shows the current title
  • Title persists across session restarts via SessionState.custom_title

Changes

Three files, 23 lines total:

  • src/kimi_cli/session_state.py - Added custom_title: str | None = None field to SessionState
  • src/kimi_cli/session.py - Session.refresh() now checks state.custom_title before falling back to the auto-derived title from the wire file
  • src/kimi_cli/ui/shell/slash.py - Added /title command following the existing @registry.command() pattern

Testing

Verified programmatically:

  • /title is registered in the slash command registry alongside /new, /sessions, /help
  • SessionState.custom_title field initializes to None and accepts string values
  • Session.refresh() respects the custom title when set

Fixes #1536

This contribution was developed with AI assistance (Claude Code).


Open with Devin

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

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: 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".

Comment on lines +446 to +447
session.state.custom_title = new_title
session.save_state()
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 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 👍 / 👎.

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.

Feature Request: Add /title command to manually set or rename session title

1 participant