mirror of
https://github.com/instructkr/claude-code.git
synced 2026-04-06 11:18:51 +03:00
merge: clawcode-issue-9410-cli-ux-progress-status-clear into main
This commit is contained in:
@@ -1338,12 +1338,17 @@ fn run_resume_command(
|
||||
),
|
||||
});
|
||||
}
|
||||
let backup_path = write_session_clear_backup(session, session_path)?;
|
||||
let previous_session_id = session.session_id.clone();
|
||||
let cleared = Session::new();
|
||||
let new_session_id = cleared.session_id.clone();
|
||||
cleared.save_to_path(session_path)?;
|
||||
Ok(ResumeCommandOutcome {
|
||||
session: cleared,
|
||||
message: Some(format!(
|
||||
"Cleared resumed session file {}.",
|
||||
"Session cleared\n Mode resumed session reset\n Previous session {previous_session_id}\n Backup {}\n Resume previous claw --resume {}\n New session {new_session_id}\n Session file {}",
|
||||
backup_path.display(),
|
||||
backup_path.display(),
|
||||
session_path.display()
|
||||
)),
|
||||
})
|
||||
@@ -2111,6 +2116,7 @@ impl LiveCli {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
let previous_session = self.session.clone();
|
||||
let session_state = Session::new();
|
||||
self.session = create_managed_session_handle(&session_state.session_id)?;
|
||||
let runtime = build_runtime(
|
||||
@@ -2126,10 +2132,13 @@ impl LiveCli {
|
||||
)?;
|
||||
self.replace_runtime(runtime)?;
|
||||
println!(
|
||||
"Session cleared\n Mode fresh session\n Preserved model {}\n Permission mode {}\n Session {}",
|
||||
"Session cleared\n Mode fresh session\n Previous session {}\n Resume previous /resume {}\n Preserved model {}\n Permission mode {}\n New session {}\n Session file {}",
|
||||
previous_session.id,
|
||||
previous_session.id,
|
||||
self.model,
|
||||
self.permission_mode.as_str(),
|
||||
self.session.id,
|
||||
self.session.path.display(),
|
||||
);
|
||||
Ok(true)
|
||||
}
|
||||
@@ -2665,6 +2674,27 @@ fn format_session_modified_age(modified_epoch_millis: u128) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn write_session_clear_backup(
|
||||
session: &Session,
|
||||
session_path: &Path,
|
||||
) -> Result<PathBuf, Box<dyn std::error::Error>> {
|
||||
let backup_path = session_clear_backup_path(session_path);
|
||||
session.save_to_path(&backup_path)?;
|
||||
Ok(backup_path)
|
||||
}
|
||||
|
||||
fn session_clear_backup_path(session_path: &Path) -> PathBuf {
|
||||
let timestamp = std::time::SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.ok()
|
||||
.map_or(0, |duration| duration.as_millis());
|
||||
let file_name = session_path
|
||||
.file_name()
|
||||
.and_then(|value| value.to_str())
|
||||
.unwrap_or("session.jsonl");
|
||||
session_path.with_file_name(format!("{file_name}.before-clear-{timestamp}.bak"))
|
||||
}
|
||||
|
||||
fn render_repl_help() -> String {
|
||||
[
|
||||
"REPL".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user