From 9c6b10426bd897afe6cf6f0c022f45310c5ab3d3 Mon Sep 17 00:00:00 2001 From: Igor Soarez Date: Mon, 19 Oct 2026 16:35:40 +0300 Subject: menu bar app: live agent states from tmux pane options single-file appkit status item (menubar/main.swift, LSUIElement) polling @agent/@agent_state pane options every 2s: counts in the bar, per-pane rows with click-to-focus via switch-client. daemon now also writes an @agent label per pane so the menu bar and tmux status-right can render agent names without duplicating identification logic. --- crates/dinggerd/src/tmux.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'crates/dinggerd/src/tmux.rs') diff --git a/crates/dinggerd/src/tmux.rs b/crates/dinggerd/src/tmux.rs index e833e3c..edd44aa 100644 --- a/crates/dinggerd/src/tmux.rs +++ b/crates/dinggerd/src/tmux.rs @@ -4,7 +4,6 @@ use std::process::Command; use detect_core::manifest::agent_state_label; use detect_core::{identify_agent, Agent, AgentState}; -use tracing::debug; #[derive(Debug, Clone)] pub struct Pane { @@ -25,6 +24,8 @@ pub struct Pane { /// The `@agent_state` user option previously written for this pane, /// read straight from the pane format. pub written_state: String, + /// The `@agent` user option (agent label) previously written, if any. + pub written_agent: String, } impl Pane { @@ -68,13 +69,14 @@ pub fn list_panes() -> Result, String> { "#{session_attached}\t", "#{pane_start_command}\t", "#{pane_pid}\t", - "#{@agent_state}" + "#{@agent_state}\t", + "#{@agent}" ); let out = run_tmux(&["list-panes", "-a", "-F", format])?; let mut panes = Vec::new(); for line in out.lines() { let fields: Vec<&str> = line.split('\t').collect(); - if fields.len() < 10 { + if fields.len() < 11 { continue; } let current_command = fields[2].to_string(); @@ -101,6 +103,7 @@ pub fn list_panes() -> Result, String> { session_attached: fields[6] != "0", agent, written_state: fields[9].to_string(), + written_agent: fields[10].to_string(), }); } Ok(panes) @@ -180,3 +183,10 @@ pub fn set_agent_state(pane_id: &str, state: AgentState) -> Result<(), String> { ]) .map(|_| ()) } + +/// Label the pane with the agent running in it, for tmux status-line and +/// menu-bar rendering; clears the label when the pane stops running one. +pub fn set_agent(pane_id: &str, agent: Option) -> Result<(), String> { + let label = agent.map(detect_core::agent_label).unwrap_or(""); + run_tmux(&["set-option", "-p", "-t", pane_id, "@agent", label]).map(|_| ()) +} -- cgit v1.2.3