Skip to main content

tmux_botdomo/
session.rs

1use serde::{Deserialize, Serialize};
2use std::fmt;
3
4#[derive(Debug, Clone, Deserialize, Serialize)]
5pub enum Agent {
6    ClaudeCode,
7    Codex,
8    Gemini,
9}
10
11impl fmt::Display for Agent {
12    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13        match self {
14            Agent::ClaudeCode => write!(f, "Claude Code"),
15            Agent::Codex => write!(f, "Codex"),
16            Agent::Gemini => write!(f, "Gemini"),
17        }
18    }
19}
20
21#[derive(Debug, Deserialize, Serialize)]
22pub struct TmuxLocation {
23    pub session_id: String,
24    pub window_id: String,
25    pub pane_id: String,
26}
27
28impl fmt::Display for TmuxLocation {
29    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30        write!(
31            f,
32            "({}, {}, {})",
33            self.session_id, self.window_id, self.pane_id
34        )
35    }
36}
37
38impl TmuxLocation {
39    pub fn new(session_id: String, window_id: String, pane_id: String) -> Self {
40        Self {
41            session_id,
42            window_id,
43            pane_id,
44        }
45    }
46}
47
48#[derive(Debug, Deserialize, Serialize)]
49pub struct AgentSessionInfo {
50    pub agent: Agent,
51    pub cwd: String,
52    pub pane_tty: String,
53    pub pid: String,
54    pub tmux_location: TmuxLocation,
55}
56
57impl AgentSessionInfo {
58    pub fn new(
59        agent: Agent,
60        cwd: String,
61        pane_tty: String,
62        pid: String,
63        tmux_location: TmuxLocation,
64    ) -> Self {
65        Self {
66            agent,
67            cwd,
68            pane_tty,
69            pid,
70            tmux_location,
71        }
72    }
73}