From dc4fa55d645a7574460085ece0253b5bf7e94671 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Fri, 10 Apr 2026 02:03:14 +0900 Subject: [PATCH] fix(cli): /status JSON emits null model and correct session_id in resume mode Two bugs in --output-format json --resume /status: 1. 'model' field emitted 'restored-session' (a run-mode label) instead of the actual model or null. Fixed: status_json_value now takes Option<&str> for model; resume path passes None; live REPL path passes Some(model). 2. 'session_id' extracted parent dir name ('sessions') instead of the file stem. Session files are session-.jsonl directly under .claw/sessions/, not in a subdirectory. Fixed: extract file_stem() instead of parent().file_name(). 159 CLI tests pass. --- rust/crates/rusty-claude-cli/src/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index 524c603..0dfd5a2 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -2741,7 +2741,7 @@ fn run_resume_command( &context, )), json: Some(status_json_value( - "restored-session", + None, StatusUsage { message_count: session.messages.len(), turns: tracker.turns(), @@ -5006,7 +5006,7 @@ fn print_status_snapshot( CliOutputFormat::Json => println!( "{}", serde_json::to_string_pretty(&status_json_value( - model, + Some(model), usage, permission_mode.as_str(), &context, @@ -5017,7 +5017,7 @@ fn print_status_snapshot( } fn status_json_value( - model: &str, + model: Option<&str>, usage: StatusUsage, permission_mode: &str, context: &StatusContext, @@ -5046,9 +5046,9 @@ fn status_json_value( "untracked_files": context.git_summary.untracked_files, "session": context.session_path.as_ref().map_or_else(|| "live-repl".to_string(), |path| path.display().to_string()), "session_id": context.session_path.as_ref().and_then(|path| { - // Session files live under .claw/sessions//.jsonl - // Extract the session-id directory component. - path.parent().and_then(|p| p.file_name()).map(|n| n.to_string_lossy().into_owned()) + // Session files are named .jsonl directly under + // .claw/sessions/. Extract the stem (drop the .jsonl extension). + path.file_stem().map(|n| n.to_string_lossy().into_owned()) }), "loaded_config_files": context.loaded_config_files, "discovered_config_files": context.discovered_config_files,