From 3750e0bae21c54da3947d337584f180a21d0bc67 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Tue, 26 May 2026 17:10:28 +0300 Subject: feat: add pane metadata reporting refs #36 --- src/api/subscriptions.rs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/api/subscriptions.rs') diff --git a/src/api/subscriptions.rs b/src/api/subscriptions.rs index a6d8ff97..aaa7e5ac 100644 --- a/src/api/subscriptions.rs +++ b/src/api/subscriptions.rs @@ -50,9 +50,29 @@ pub(super) struct ActiveAgentStatusChangedSubscription { status_filter: Option, last_status: Option, emit_initial_match: bool, + last_presentation: Option, request_prefix: String, } +#[derive(Debug, Clone, PartialEq, Eq)] +struct PanePresentationSnapshot { + title: Option, + display_agent: Option, + custom_status: Option, + state_labels: std::collections::HashMap, +} + +impl PanePresentationSnapshot { + fn from(pane: &crate::api::schema::PaneInfo) -> Self { + Self { + title: pane.title.clone(), + display_agent: pane.display_agent.clone(), + custom_status: pane.custom_status.clone(), + state_labels: pane.state_labels.clone(), + } + } +} + pub(super) struct ActiveEventSubscription { event_kind: crate::api::schema::EventKind, last_sequence: u64, @@ -187,6 +207,7 @@ impl ActiveSubscription { status_filter: agent_status, last_status: Some(probe.agent_status), emit_initial_match, + last_presentation: Some(PanePresentationSnapshot::from(&probe)), request_prefix: format!("{request_id}:sub:{index}"), }, )) @@ -268,13 +289,19 @@ impl ActiveAgentStatusChangedSubscription { ) .ok()?; let current_status = pane.agent_status; + let current_presentation = PanePresentationSnapshot::from(&pane); let previous_status = self.last_status.replace(current_status); + let previous_presentation = self.last_presentation.replace(current_presentation.clone()); + let presentation_changed = previous_presentation + .as_ref() + .is_some_and(|previous| previous != ¤t_presentation); + let status_changed = previous_status.is_some_and(|previous| previous != current_status); let should_emit = if self.emit_initial_match { self.emit_initial_match = false; self.status_filter .is_some_and(|wanted| wanted == current_status) } else { - previous_status.is_some_and(|previous| previous != current_status) + (status_changed || presentation_changed) && !self .status_filter .is_some_and(|wanted| wanted != current_status) @@ -290,7 +317,10 @@ impl ActiveAgentStatusChangedSubscription { workspace_id: pane.workspace_id, agent_status: current_status, agent: pane.agent, + title: pane.title, + display_agent: pane.display_agent, custom_status: pane.custom_status, + state_labels: pane.state_labels, }), }) } -- cgit v1.2.3