feat(cli): add thread clear-name to remove a custom thread title (1600) (#1939)
Issue 1600 asks for full rename UX: set a custom title, remove it back to `(unnamed)`. The set side already shipped as `deepseek thread set-name <id> <name>`, but there was no inverse — users who wanted to drop a no-longer-relevant title had to either edit the SQLite store by hand or set a placeholder string. Add `deepseek thread clear-name <id>`, mirroring the existing `SetName` arm in `run_thread_command`: look up the thread, set `name = None`, refresh `updated_at`, upsert. Printed confirmation is `cleared name for <id>` so it stays distinguishable from the `renamed` line emitted by `set-name`. Snapshot help test and the parser-matrix test both gain the new subcommand. No state-store changes: `upsert_thread` already accepts `name: None` and `thread list` already prints `(unnamed)` when the field is empty, so the round-trip is complete with this CLI-only change. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -385,6 +385,11 @@ enum ThreadCommand {
|
||||
thread_id: String,
|
||||
name: String,
|
||||
},
|
||||
/// Remove the custom name from a thread, restoring the default
|
||||
/// `(unnamed)` rendering in `thread list`.
|
||||
ClearName {
|
||||
thread_id: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
@@ -1258,6 +1263,16 @@ fn run_thread_command(command: ThreadCommand) -> Result<()> {
|
||||
println!("renamed {thread_id}");
|
||||
Ok(())
|
||||
}
|
||||
ThreadCommand::ClearName { thread_id } => {
|
||||
let mut thread = state
|
||||
.get_thread(&thread_id)?
|
||||
.with_context(|| format!("thread not found: {thread_id}"))?;
|
||||
thread.name = None;
|
||||
thread.updated_at = chrono::Utc::now().timestamp();
|
||||
state.upsert_thread(&thread)?;
|
||||
println!("cleared name for {thread_id}");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1925,6 +1940,14 @@ mod tests {
|
||||
}
|
||||
})) if thread_id == "thread-6" && name == "My Thread"
|
||||
));
|
||||
|
||||
let cli = parse_ok(&["deepseek", "thread", "clear-name", "thread-7"]);
|
||||
assert!(matches!(
|
||||
cli.command,
|
||||
Some(Commands::Thread(ThreadArgs {
|
||||
command: ThreadCommand::ClearName { ref thread_id }
|
||||
})) if thread_id == "thread-7"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -3048,6 +3071,7 @@ mod tests {
|
||||
"archive",
|
||||
"unarchive",
|
||||
"set-name",
|
||||
"clear-name",
|
||||
],
|
||||
),
|
||||
("sandbox", vec!["check"]),
|
||||
|
||||
Reference in New Issue
Block a user