From a4df9c3b01824ed75e4a854cc161cdacc8f7a412 Mon Sep 17 00:00:00 2001 From: Johannes Kresner Date: Sun, 15 Nov 2026 22:22:24 +0100 Subject: [PATCH] feat: open the session in hx with --session from the TUI Co-Authored-By: Claude Sonnet 5.5 --- README.md | 2 +- src/tui/mod.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d5d531b..4e43b33 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ command = "python3 /work/adapters/gitea.py" ## State-machine sessions and the TUI `orch` without a subcommand opens the TUI: sessions overview (`enter` on a row opens the session detail, `esc` goes -back; `t` full test output, `d` diff, `l` event transcript, `o` open the worktree in hx). It reads `.hx/orch.db` of the +back; `t` full test output, `d` diff, `l` event transcript, `o` open the session in hx, `hx --session sN` in its worktree). It reads `.hx/orch.db` of the current directory. `orch session --repo . --machine task --name NAME [--profile P]` creates a session and runs it. `orch session --repo . --resume s1` continues an unfinished session (for example after a crash or a closed terminal) from its saved state; `--machine`, `--name` and `--after` are not allowed with it. Machines are TOML files in diff --git a/src/tui/mod.rs b/src/tui/mod.rs index 58ea7d5..78b55c8 100644 --- a/src/tui/mod.rs +++ b/src/tui/mod.rs @@ -768,12 +768,18 @@ fn transcript(app: &App, id: &str) -> Pager { } } -/// Opens hx in the worktree: the TUI steps aside for the time hx runs. -fn open_in_hx(term: &mut ratatui::DefaultTerminal, worktree: &str) -> Option { +/// Opens hx on the session's conversation in the worktree: the TUI steps aside for the time hx runs. +fn open_in_hx( + term: &mut ratatui::DefaultTerminal, + worktree: &str, + session: &str, +) -> Option { let hx = crate::profile::Profile::load("default").map_or_else(|_| "hx".into(), |p| p.hx); let mut parts = hx.split_whitespace(); let mut cmd = std::process::Command::new(parts.next()?); - cmd.args(parts).current_dir(worktree); + cmd.args(parts) + .args(["--session", session]) + .current_dir(worktree); ratatui::restore(); let res = cmd.status(); *term = ratatui::init(); @@ -1002,7 +1008,7 @@ fn on_key( } KeyCode::Char('o') => { if let Some(d) = &app.detail - && let Some(err) = open_in_hx(term, &d.worktree.clone()) + && let Some(err) = open_in_hx(term, &d.worktree.clone(), &d.id.clone()) { app.pager = Some(Pager { title: "open worktree".into(),