aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-28 05:06:04 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-28 05:06:27 +0300
commit2d8b4e2db4642dede084801c03516046f205626b (patch)
tree909338388764efbaa8bc487f90e5e9f6d8a323a6 /src
parent986e4a17767a3d4838e340b92cb2db9e6012acc4 (diff)
feat: expose agent session refs in api
Diffstat (limited to 'src')
-rw-r--r--src/api/schema.rs14
-rw-r--r--src/app/agents.rs1
-rw-r--r--src/app/creation.rs26
3 files changed, 41 insertions, 0 deletions
diff --git a/src/api/schema.rs b/src/api/schema.rs
index aa7cbd3c..cd82f99f 100644
--- a/src/api/schema.rs
+++ b/src/api/schema.rs
@@ -803,6 +803,8 @@ pub struct AgentInfo {
pub custom_status: Option<String>,
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
pub state_labels: HashMap<String, String>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub agent_session: Option<AgentSessionInfo>,
pub workspace_id: String,
pub tab_id: String,
pub pane_id: String,
@@ -834,10 +836,20 @@ pub struct PaneInfo {
pub custom_status: Option<String>,
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
pub state_labels: HashMap<String, String>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub agent_session: Option<AgentSessionInfo>,
pub revision: u64,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub struct AgentSessionInfo {
+ pub source: String,
+ pub agent: String,
+ pub kind: crate::agent_resume::AgentSessionRefKind,
+ pub value: String,
+}
+
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneReadResult {
pub pane_id: String,
pub workspace_id: String,
@@ -1402,6 +1414,7 @@ mod tests {
agent_status: AgentStatus::Unknown,
custom_status: None,
state_labels: HashMap::new(),
+ agent_session: None,
revision: 0,
},
worktree: WorktreeInfo {
@@ -1451,6 +1464,7 @@ mod tests {
agent_status: AgentStatus::Unknown,
custom_status: None,
state_labels: HashMap::new(),
+ agent_session: None,
revision: 0,
},
},
diff --git a/src/app/agents.rs b/src/app/agents.rs
index 8868fb9c..55ee15df 100644
--- a/src/app/agents.rs
+++ b/src/app/agents.rs
@@ -417,6 +417,7 @@ impl App {
agent_status: pane.agent_status,
custom_status: pane.custom_status,
state_labels: pane.state_labels,
+ agent_session: pane.agent_session,
workspace_id: pane.workspace_id,
tab_id: pane.tab_id,
pane_id: pane.pane_id,
diff --git a/src/app/creation.rs b/src/app/creation.rs
index aa727dd5..d483eb1a 100644
--- a/src/app/creation.rs
+++ b/src/app/creation.rs
@@ -295,6 +295,7 @@ impl App {
agent_status: pane_agent_status(terminal.state, pane.seen),
custom_status: presentation.custom_status,
state_labels: presentation.state_labels,
+ agent_session: terminal_agent_session_info(terminal),
revision: terminal.revision,
})
}
@@ -345,3 +346,28 @@ impl App {
}
}
}
+
+fn terminal_agent_session_info(
+ terminal: &crate::terminal::TerminalState,
+) -> Option<crate::api::schema::AgentSessionInfo> {
+ if let Some(authority) = terminal.hook_authority.as_ref() {
+ if let Some(session_ref) = authority.session_ref.as_ref() {
+ return Some(crate::api::schema::AgentSessionInfo {
+ source: authority.source.clone(),
+ agent: authority.agent_label.clone(),
+ kind: session_ref.kind,
+ value: session_ref.value.clone(),
+ });
+ }
+ }
+
+ terminal
+ .persisted_agent_session
+ .as_ref()
+ .map(|session| crate::api::schema::AgentSessionInfo {
+ source: session.source.clone(),
+ agent: session.agent.clone(),
+ kind: session.session_ref.kind,
+ value: session.session_ref.value.clone(),
+ })
+}