From 5de8fd552ee1675151f414e6ff5ce31eba9ce3e1 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Sun, 16 Aug 2026 04:56:50 +0800 Subject: [PATCH] fix(cli): check the inherited workspace before run --keep spawns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `run --keep` resolves `--ws` against the machine tree before it spawns anything, and takes `$TTY7_WS` on trust — it only parses the id. Filing the pane happens after the spawn, so a shell whose workspace has since been removed, or one opened against another machine, started the pane and then failed to file it. The pane kept running with nothing holding it. Measured against a live daemon: with a `$TTY7_WS` this machine does not have, `run --keep` exited 1 with a clear message and left a `sleep` behind, `pane ls --all` reporting `"orphans":1`. With `--ws` spelled out, the same bad id spawned nothing. Recoverable — `pane ls --all` finds it and `pane close` ends it, both documented — but nobody asked for the pane, and `$TTY7_WS` is the *documented default* for `--keep`, so this is the ordinary path rather than an exotic one. Resolving the inherited id is now the same check the explicit one gets, and only when `--keep` needs it: a plain `run` uses the workspace as an ownership stamp, where a stale id costs nothing and the round trip to find out would. The spawn still precedes the filing — `TabCreate` names the pane the daemon assigned, so it has to, and `run_keep_spawns_first_then_files_the_pane_into_the_workspace` pins that. What moved is only where the workspace is checked. --- crates/tty7-cli/src/commands.rs | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/crates/tty7-cli/src/commands.rs b/crates/tty7-cli/src/commands.rs index 1e08bb03..6d08c80c 100644 --- a/crates/tty7-cli/src/commands.rs +++ b/crates/tty7-cli/src/commands.rs @@ -405,6 +405,21 @@ fn run(args: RunArgs, ctx: &Context, backend: &mut dyn Backend) -> Result