feat: restart a failed or escalated session at the state where it stopped
build / version (push) Successful in 10s
build / build (aarch64-apple-darwin) (push) Successful in 4m5s
build / build (x86_64-unknown-linux-musl) (push) Successful in 3m34s
build / release (push) Successful in 16s

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:
johannesandClaude Sonnet 5.5 committed 2026-11-15 22:36:10 +01:00
1 parent 0e57b04d25
commit e50f90d299
9 files changed
+140 -10

No files matched your search

+16 -6
View File
@@ -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