aboutsummaryrefslogtreecommitdiff
path: root/crates/dinggerd/src/snapshot.rs
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-10-23 18:45:06 +0300
committerIgor Soarez <igor@soarez.org>2026-10-23 18:45:06 +0300
commitb4f45632debe6b8dc2f44ca6cc1b003d9093ad33 (patch)
tree550add91d02656156330f497d60fe0e6bdf2fc35 /crates/dinggerd/src/snapshot.rs
parent12ce9f3f8edc84064458b649e8615247641dad36 (diff)
session groups: list each pane once, save each group once
a pane in several sessions (a session group, `new-session -t`, or a linked window) was listed once per session: every agent of a group showed twice in the menu, panel, search, `dingger status`, and the counts. and snapshots saved each session of a group with its own copy of the windows, so restore would have rebuilt them twice and resumed each agent twice on one session file. - a pane keeps its first listing (tmux lists sessions by name) and is attended if the user looks at it through any session of the group. - snapshots keep the first session of each group; the others are not restored. e2e step 19 covers both; the previous binaries fail it. two checks (step 11's and this one) waited for idle after a turn that started from idle, which passed before the turn was even processed: they now wait for working first, and the negative control for group attendance fails as it should. step 18 now waits for the snapshot it later restores from.
Diffstat (limited to 'crates/dinggerd/src/snapshot.rs')
-rw-r--r--crates/dinggerd/src/snapshot.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/dinggerd/src/snapshot.rs b/crates/dinggerd/src/snapshot.rs
index d4ee321..715bf37 100644
--- a/crates/dinggerd/src/snapshot.rs
+++ b/crates/dinggerd/src/snapshot.rs
@@ -197,13 +197,22 @@ pub fn capture(now_ms: u64) -> Option<Snapshot> {
"#{@agent_session}",
"#{@dingger_cmd}",
"#{pane_dead}",
+ "#{?session_grouped,#{session_group},}",
]
.join("\t");
let out = tmux::run(&["list-panes", "-a", "-F", &format]).ok()?;
let lines: Vec<Vec<&str>> = out
.lines()
.map(|line| line.split('\t').collect::<Vec<_>>())
- .filter(|f| f.len() >= 21)
+ .filter(|f| f.len() >= 22)
+ .collect();
+ // One session per group: the others show the same windows, and saving
+ // them would restore every window, and resume every agent, twice. The
+ // first listed (tmux lists sessions by name) stands for its group.
+ let mut group_of_kept: std::collections::HashMap<&str, &str> = std::collections::HashMap::new();
+ let lines: Vec<Vec<&str>> = lines
+ .into_iter()
+ .filter(|f| f[21].is_empty() || *group_of_kept.entry(f[21]).or_insert(f[0]) == f[0])
.collect();
// What runs in the foreground of each pane's terminal.
let pane_pids: Vec<u32> = lines