diff options
| author | Igor Soarez <igor@soarez.org> | 2026-10-23 14:07:15 +0300 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-10-23 14:07:15 +0300 |
| commit | a7d34521c7f874beb44e0314017ab28979550495 (patch) | |
| tree | c08f78e7e54dee869ec09f2d6d2d5522d3c9d8a1 /crates/dinggerd/src/tmux.rs | |
| parent | e05ad549b38b522fabaa8f9c1f0c4b08aa5a0869 (diff) | |
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.
Diffstat (limited to 'crates/dinggerd/src/tmux.rs')
| -rw-r--r-- | crates/dinggerd/src/tmux.rs | 19 |
1 files changed, 19 insertions, 0 deletions
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<String>)]) -> 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(|_| ()) } |
