feat(commands): add /rename command to set a custom session title (#836)

* feat(commands): add /rename command to set a custom session title

Adds a `/rename <new title>` slash command that lets users set a
human-readable name for the current session. The new title is
persisted immediately to the session JSON file so it appears in
the session picker on the next open.

- Max title length capped at 100 characters (char-count aware, handles CJK)
- Errors on missing/empty arg or no active session
- Inner `rename_with_manager` helper keeps unit tests fully isolated
  from ~/.deepseek/sessions
- Localized descriptions in en, ja, zh-Hans, pt-BR

* fix(rename): sync App state before saving to prevent data loss

Use update_session() to merge current in-memory messages and tokens
into the session before writing the renamed title, preventing stale
disk data from overwriting unsaved App state.

* style: format rename command

---------

Co-authored-by: Hunter Bown <hmbown@gmail.com>
This commit is contained in:
kitty
2026-05-06 17:13:23 +08:00
committed by GitHub
parent b86baa38ed
commit 719594636c
3 changed files with 197 additions and 0 deletions
+8
View File
@@ -18,6 +18,7 @@ mod network;
mod note;
mod provider;
mod queue;
mod rename;
mod restore;
mod review;
mod session;
@@ -248,6 +249,12 @@ pub const COMMANDS: &[CommandInfo] = &[
description_id: MessageId::CmdNetworkDescription,
},
// Session commands
CommandInfo {
name: "rename",
aliases: &[],
usage: "/rename <new title>",
description_id: MessageId::CmdRenameDescription,
},
CommandInfo {
name: "save",
aliases: &[],
@@ -503,6 +510,7 @@ pub fn execute(cmd: &str, app: &mut App) -> CommandResult {
"network" => network::network(app, arg),
// Session commands
"rename" => rename::rename(app, arg),
"save" => session::save(app, arg),
"sessions" | "resume" => session::sessions(app, arg),
"load" => session::load(app, arg),