feat: restart a failed or escalated session at the state where it stopped
Adds orch session --restart sN and R in the TUI. A restart event gives the session fresh budgets and retry counts. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0e57b04d25
commit
e50f90d299
9 files changed
+140
-10
No files matched your search
+16
-6
@@ -126,13 +126,16 @@ enum Cmd {
|
||||
#[arg(long)]
|
||||
repo: PathBuf,
|
||||
/// Machine file name, without .toml (looked up in REPO/.hx/machines, then ~/.hx/machines).
|
||||
#[arg(long, required_unless_present = "resume")]
|
||||
#[arg(long, required_unless_present_any = ["resume", "restart"])]
|
||||
machine: Option<String>,
|
||||
#[arg(long, required_unless_present = "resume")]
|
||||
#[arg(long, required_unless_present_any = ["resume", "restart"])]
|
||||
name: Option<String>,
|
||||
/// Continue this unfinished session (e.g. s1) from its saved state instead of creating one.
|
||||
#[arg(long, conflicts_with_all = ["machine", "name", "after"])]
|
||||
#[arg(long, conflicts_with_all = ["machine", "name", "after", "restart"])]
|
||||
resume: Option<String>,
|
||||
/// Continue this failed or escalated session at the state where it stopped, with fresh budgets and retries.
|
||||
#[arg(long, conflicts_with_all = ["machine", "name", "after"])]
|
||||
restart: Option<String>,
|
||||
/// Value for {{scope}} in machine commands.
|
||||
#[arg(long, default_value = "")]
|
||||
scope: String,
|
||||
@@ -258,19 +261,26 @@ fn main() -> Result<std::process::ExitCode> {
|
||||
machine,
|
||||
name,
|
||||
resume,
|
||||
restart,
|
||||
scope,
|
||||
profile,
|
||||
} => {
|
||||
let profile = profile::Profile::load(&profile)?;
|
||||
let repo = repo.canonicalize()?;
|
||||
let db = db::Db::open(&repo.join(".hx/orch.db"))?;
|
||||
let s = if let Some(id) = resume {
|
||||
if let Some(id) = &restart {
|
||||
db.reopen(id)?;
|
||||
}
|
||||
let s = if let Some(id) = resume.or(restart) {
|
||||
let s = db
|
||||
.session(&id)?
|
||||
.with_context(|| format!("no session {id}"))?;
|
||||
anyhow::ensure!(
|
||||
!db.events(Some(&id), 0)?.iter().any(|e| e.kind == "end"),
|
||||
"session {id} already ended; start a new one"
|
||||
!db.events(Some(&id), 0)?
|
||||
.iter()
|
||||
.rfind(|e| matches!(e.kind.as_str(), "end" | "restart"))
|
||||
.is_some_and(|e| e.kind == "end"),
|
||||
"session {id} already ended; --restart continues a failed or escalated one, else start a new one"
|
||||
);
|
||||
anyhow::ensure!(
|
||||
s.pid
|
||||
|
||||
Reference in new issue
Block a user