mirror of
https://github.com/instructkr/claw-code.git
synced 2026-05-18 13:31:28 +08:00
omx(team): auto-checkpoint worker-1 [1]
This commit is contained in:
@@ -3791,6 +3791,35 @@ fn run_resume_command(
|
|||||||
session: &Session,
|
session: &Session,
|
||||||
command: &SlashCommand,
|
command: &SlashCommand,
|
||||||
) -> Result<ResumeCommandOutcome, Box<dyn std::error::Error>> {
|
) -> Result<ResumeCommandOutcome, Box<dyn std::error::Error>> {
|
||||||
|
let session_list_outcome = || -> Result<ResumeCommandOutcome, Box<dyn std::error::Error>> {
|
||||||
|
let sessions = list_managed_sessions().unwrap_or_default();
|
||||||
|
let session_ids: Vec<String> = sessions.iter().map(|s| s.id.clone()).collect();
|
||||||
|
let session_details: Vec<serde_json::Value> = sessions
|
||||||
|
.iter()
|
||||||
|
.map(|session| {
|
||||||
|
serde_json::json!({
|
||||||
|
"id": session.id,
|
||||||
|
"path": session.path.display().to_string(),
|
||||||
|
"message_count": session.message_count,
|
||||||
|
"updated_at_ms": session.updated_at_ms,
|
||||||
|
"lifecycle": session.lifecycle.json_value(),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
let active_id = session.session_id.clone();
|
||||||
|
let text = render_session_list(&active_id).unwrap_or_else(|e| format!("error: {e}"));
|
||||||
|
Ok(ResumeCommandOutcome {
|
||||||
|
session: session.clone(),
|
||||||
|
message: Some(text),
|
||||||
|
json: Some(serde_json::json!({
|
||||||
|
"kind": "session_list",
|
||||||
|
"sessions": session_ids,
|
||||||
|
"session_details": session_details,
|
||||||
|
"active": active_id,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
match command {
|
match command {
|
||||||
SlashCommand::Help => Ok(ResumeCommandOutcome {
|
SlashCommand::Help => Ok(ResumeCommandOutcome {
|
||||||
session: session.clone(),
|
session: session.clone(),
|
||||||
@@ -4116,37 +4145,11 @@ fn run_resume_command(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
// /session list can be served from the sessions directory without a live session.
|
// /session list can be served from the sessions directory without a live session.
|
||||||
|
SlashCommand::Session { action: None, .. } => session_list_outcome(),
|
||||||
SlashCommand::Session {
|
SlashCommand::Session {
|
||||||
action: Some(ref act),
|
action: Some(ref act),
|
||||||
..
|
..
|
||||||
} if act == "list" => {
|
} if act == "list" => session_list_outcome(),
|
||||||
let sessions = list_managed_sessions().unwrap_or_default();
|
|
||||||
let session_ids: Vec<String> = sessions.iter().map(|s| s.id.clone()).collect();
|
|
||||||
let session_details: Vec<serde_json::Value> = sessions
|
|
||||||
.iter()
|
|
||||||
.map(|session| {
|
|
||||||
serde_json::json!({
|
|
||||||
"id": session.id,
|
|
||||||
"path": session.path.display().to_string(),
|
|
||||||
"message_count": session.message_count,
|
|
||||||
"updated_at_ms": session.updated_at_ms,
|
|
||||||
"lifecycle": session.lifecycle.json_value(),
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
let active_id = session.session_id.clone();
|
|
||||||
let text = render_session_list(&active_id).unwrap_or_else(|e| format!("error: {e}"));
|
|
||||||
Ok(ResumeCommandOutcome {
|
|
||||||
session: session.clone(),
|
|
||||||
message: Some(text),
|
|
||||||
json: Some(serde_json::json!({
|
|
||||||
"kind": "session_list",
|
|
||||||
"sessions": session_ids,
|
|
||||||
"session_details": session_details,
|
|
||||||
"active": active_id,
|
|
||||||
})),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
SlashCommand::Bughunter { .. }
|
SlashCommand::Bughunter { .. }
|
||||||
| SlashCommand::Commit { .. }
|
| SlashCommand::Commit { .. }
|
||||||
| SlashCommand::Pr { .. }
|
| SlashCommand::Pr { .. }
|
||||||
@@ -4167,6 +4170,7 @@ fn run_resume_command(
|
|||||||
| SlashCommand::Fast
|
| SlashCommand::Fast
|
||||||
| SlashCommand::Exit
|
| SlashCommand::Exit
|
||||||
| SlashCommand::Summary
|
| SlashCommand::Summary
|
||||||
|
| SlashCommand::Session { .. }
|
||||||
| SlashCommand::Desktop
|
| SlashCommand::Desktop
|
||||||
| SlashCommand::Brief
|
| SlashCommand::Brief
|
||||||
| SlashCommand::Advisor
|
| SlashCommand::Advisor
|
||||||
|
|||||||
Reference in New Issue
Block a user