From a7d34521c7f874beb44e0314017ab28979550495 Mon Sep 17 00:00:00 2001 From: Igor Soarez Date: Fri, 23 Oct 2026 14:07:15 +0300 Subject: write a pane's options in one tmux command list the watcher wrote @agent_state, then @dingger_hook, as separate tmux calls. a daemon stopped between them left a done display state next to a stale "working" hook state, which the restarted daemon trusted: the agent came back as working. now every changed option of a pane is one command list, which tmux applies as a unit (and one process instead of several). tests/kill-race.sh kills the daemon the instant an agent shows done: 24 of 40 kills left the options inconsistent before, 0 of 40 now. e2e step 17 runs it 20 times; the previous binary fails it. --- crates/dinggerd/src/tmux.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crates/dinggerd/src/tmux.rs') diff --git a/crates/dinggerd/src/tmux.rs b/crates/dinggerd/src/tmux.rs index b1a2d60..182d62f 100644 --- a/crates/dinggerd/src/tmux.rs +++ b/crates/dinggerd/src/tmux.rs @@ -229,6 +229,25 @@ pub fn set_pane_option(pane_id: &str, name: &str, value: &str) -> Result<(), Str run_tmux(&["set-option", "-p", "-t", pane_id, name, value]).map(|_| ()) } +/// Set (`Some`) or unset (`None`) several pane options in one tmux command +/// list, applied as a unit. +pub fn set_pane_options(pane_id: &str, changes: &[(&str, Option)]) -> Result<(), String> { + let mut args: Vec<&str> = Vec::new(); + for (name, value) in changes { + if !args.is_empty() { + args.push(";"); + } + match value { + Some(value) => args.extend(["set-option", "-p", "-t", pane_id, name, value.as_str()]), + None => args.extend(["set-option", "-p", "-u", "-t", pane_id, name]), + } + } + if args.is_empty() { + return Ok(()); + } + run_tmux(&args).map(|_| ()) +} + pub fn unset_pane_option(pane_id: &str, name: &str) -> Result<(), String> { run_tmux(&["set-option", "-p", "-u", "-t", pane_id, name]).map(|_| ()) } -- cgit v1.2.3