diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-26 17:10:28 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-26 17:10:28 +0300 |
| commit | 3750e0bae21c54da3947d337584f180a21d0bc67 (patch) | |
| tree | 4542d8af76b4fee0c428ca5e9378a06946ef62ca /src/api/subscriptions.rs | |
| parent | 1b980eaa9d4cbc050b6b81525e4b6b72ae853be5 (diff) | |
feat: add pane metadata reporting
refs #36
Diffstat (limited to 'src/api/subscriptions.rs')
| -rw-r--r-- | src/api/subscriptions.rs | 32 |
1 files changed, 31 insertions, 1 deletions
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<crate::api::schema::AgentStatus>, last_status: Option<crate::api::schema::AgentStatus>, emit_initial_match: bool, + last_presentation: Option<PanePresentationSnapshot>, request_prefix: String, } +#[derive(Debug, Clone, PartialEq, Eq)] +struct PanePresentationSnapshot { + title: Option<String>, + display_agent: Option<String>, + custom_status: Option<String>, + state_labels: std::collections::HashMap<String, String>, +} + +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, }), }) } |
