diff options
Diffstat (limited to 'crates/dinggerd/src/snapshot.rs')
| -rw-r--r-- | crates/dinggerd/src/snapshot.rs | 11 |
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 |
